/****************************************************************************** Adds a DeadBodySwarm at each instance of *SwarmTargetClass* before game starts. If *bSwarmTargetSubclassesAlso* is TRUE, DeadBodySwarms are added at instances of sub classes also. The SwarmSize, SwarmRadius can be customized. A (positive) random value ("...Spread") is added to these values. The Event *SwarmCreatedEvent* is risen every time a DeadBodySwarm was spawned successfully. The instance of DeadBodySwarm is passed as parameter to the Trigger function. If the actor is destroyed, the DeadBodySwarm will be destroyed after the given *DestroyDelay* + *DestroyDelaySpread*, too. Version 0, Released 12 Jul 2023 SeriousBarbie AT barbies DOT world ******************************************************************************/ class SBDeadBodySwarmSpawner expands Keypoint; var() int SwarmRadius; var() int SwarmRadiusSpread; var() byte SwarmSize; var() byte SwarmSizeSpread; var() name SwarmCreatedEvent; var() byte DestroyDelay; // delay in seconds var() byte DestroyDelaySpread; var() class SwarmTargetClass; var() bool bSwarmTargetSubclassesAlso; event SwarmCreated(DeadBodySwarm DBS) { local Actor A; foreach AllActors(class'Actor', A, SwarmCreatedEvent) A.Trigger(DBS, None); } auto state Ready { function bool SpawnSwarm(Actor A) { local ActorDestroyer AD; local DeadBodySwarm DBS; if (A.Event == '') A.Event = A.Name; // assign an unique event DBS = spawn(class'DeadBodySwarm', , A.Event, A.Location); if (DBS == none) { warn("could not spawn DeadBodySwarm at" @ A); return false; } DBS.SwarmRadius = SwarmRadius + rand(SwarmRadiusSpread); DBS.SwarmSize = SwarmSize + rand(SwarmSizeSpread); AD = Spawn(class'ActorDestroyer', , A.Event, A.Location); if (AD == None) { warn("could not spawn ActorDestroyer at" @ A); return false; } AD.DestroyActorsWithTag = DBS.Tag; AD.DestroyDelay = DestroyDelay + rand(DestroyDelaySpread); if (SwarmCreatedEvent != '') SwarmCreated(DBS); return true; } function BeginState() { local Actor A; if (SwarmTargetClass == None) { warn("SwarmTargetClass must not be empty"); return; } foreach AllActors(SwarmTargetClass, A) if (bSwarmTargetSubclassesAlso || A.Class == SwarmTargetClass) SpawnSwarm(A); } } defaultproperties { bStatic=False bSwarmTargetSubclassesAlso=True SwarmRadius=100 SwarmRadiusSpread=40 SwarmSize=10 SwarmSizeSpread=20 SwarmTargetClass=class'CreatureCarcass' DestroyDelay=5 DestroyDelaySpread=10 }