enderalse/source/scripts/cwcatapultstrikespawnerscript.psc

39 lines
906 B
Plaintext

Scriptname CWCatapultStrikeSpawnerScript extends ObjectReference
Sound Property AMBrCivilWarCatapultsDistantM Auto
Activator Property CWCatapultStrike Auto
{BASEOBJECT: Pointer to CWCatapultStrike activator}
int numLinkedRefs
int lastChosenLink
Event OnLoad()
lastChosenLink = 0
numLinkedRefs = countLinkedRefChain()
EndEvent
Function CallCatapultStrike()
;Call a catapult strike sfx on itself (0) or a random linkedref (n)
;note: it won't ever call a strike on the same marker more than once, unless there aren't any links
int randomLinkNum = lastChosenLink
While randomLinkNum == lastChosenLink && NumLinkedRefs != 0
randomLinkNum = Utility.RandomInt(0, numLinkedRefs)
EndWhile
lastChosenLink = randomLinkNum
ObjectReference placeAtRef = GetNthLinkedRef(randomLinkNum)
placeAtRef.placeAtMe(CWCatapultStrike)
AMBrCivilWarCatapultsDistantM.Play(placeAtRef)
EndFunction