Jump to content

Random Rat Spawns


MaximumPain

Recommended Posts

I'm working on this Thieves Guild Overhaul mod. What I would like to do is have rats (small skeevers) spawn or not (say a 80% chance of not spawning) and randomly apear between 0 - 10 mins. In this way I can place rats around The Ragged Flagon that would randomly appear occasionally, not all at once. Hopefully someone will have some ideas how this can be achieved.

Edited by MaximumPain
Link to comment
Share on other sites

There are several things you will want:

 

Have some sort of random function RandomInt or RandomFloat (I lean on RandomFloat so you can use percentages like you describe, since 80% = 0.8, so you would be checking if it is above 80%, then spawn).

 

The skeever probably needs an Actor script attached to it (so it propagates to all Skeevers you insert into The Ragged Flaggon).

 

When you say 0-10 mins, are you talking about in-game time or in real time? If you want game time, you will want OnUpdateGameTime and RegisterForSingleUpdateGameTime, otherwise you will want OnUpdate and RegisterForSingleUpdate. Whichever method you choose, be sure to call the Register function both in the Update event and in the event you use to start the update.

 

When a rat is 'spawned'(enabled), I believe you don't want to Register for another update (funky behavior might happen).

 

An event you will want to attach to this script is OnDeath. Within the event you will want to Disable the rat, Resurrect the rat, and register for an update (based on how you are doing it)

 

Hope this helps you get on the right track.

Link to comment
Share on other sites

Thanks for your reply Arron.

Er on second thoughts I'll just throw some small Skeevers in The Ragged Flaggon. LOL

0-10 mins real time or what the equivalent of that is in game time.

I've not done any scripting before and so was hoping there would be some sort of standard script or something for random encounters with hostiles that I didn't know about, similar to adding critters. Anyway thanks again for your time and effort, I will be learning scripting and hopefully get to a stage where your information can be put to use.

Link to comment
Share on other sites

So an example I wrote out to show you the thought process (feel free to use the contents and experiment from there):

 

;When you are generating a new script, the name is what you call it, and when it gives you ObjectReference, replace with Actor
Scriptname AJDTestScript extends Actor

;;;;;;;;;;;;;;;;;;;;;;;;;
;So we want to start off our script, going to use a basic one assuming they have never been initialized
;;;;;;;;;;;;;;;;;;;;;;;;;
Event OnInit()
;The rat will not show up immediately
self.Disable()
;This script will check ~ every 18 in game minutes
RegisterForSingleUpdateGameTime(0.3)
EndEvent

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;The meat and potatos
;This event will be checking if the rat will be enabled or not using the RandomFloat function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Event OnUpdateGameTime()
;Give ourselves the RandomFloat value
float percentageChance = Utility.RandomFloat()

;Check for if the value is 0.8 or greater for 80% chance
if (percentageChance >= 0.8)
self.Enable()
;Re-register for the event if lower than 80%
Else
RegisterForSingleUpdateGameTime(0.3)
EndIf
EndEvent

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;What happens when the rat dies?
;We want to re-use it of course
;This event will start the process over
;Note: This event has parameters, in this case the person or NPC that killed the rat.
;Additional Note; You could play around with a special message if you killed the rat or someone else does
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Event OnDeath(Actor akKiller)
;Wait for player to loot the little bugger for 7 seconds
Utility.Wait(7)

;Remove the rat
self.Disable()
;Revive the rat
self.Resurrect()
;Re-register for the Game Time Event
RegisterForSingleUpdateGameTime(0.3)
EndEvent

 

 

Edited by Arron Dominion
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...