1
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
906 B

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