The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall
Difference between revisions of "UE2:Round Robin"
From Unreal Wiki, The Unreal Engine Documentation Site
m (Open Source/Round Robin moved to UE2:Round Robin: Test Move.) |
m |
||
Line 98: | Line 98: | ||
==Related Topics== | ==Related Topics== | ||
*[[Open Source]] | *[[Open Source]] | ||
+ | |||
+ | ---- | ||
+ | [[Category:Open Source Scripts]] |
Revision as of 22:14, 6 April 2008
For use in either UT2003 or UT2004 maps. Created due to the fact that the RoundRobin actor present in UE1 has been removed. There are two scripts on this page, in created by User: DalinSeivewright and the other by El Muerte. A round robin will cycle through a series of names and trigger the associated event.
One-shot Script
/* A Simple Custom Round Robin Created By Dalin 'MythOpus' Seivewright. This RoundRobin has a one time use only but it can be set up to do a mass chain of triggering. Customize as needed. Found At: http://wiki.beyondunreal.com */ class myCustomRoundRobin extends Actor placeable; var() array<name> Targets; //The things you wish to trigger (it's a dynamic array) var() float TriggerSeconds; //The number of seconds between each triggering var bool bTriggered; //Internally Set Bool (Ignore It) function PostBeginPlay() { SetTimer(TriggerSeconds, TRUE); } simulated function Timer() { //If this RoundRobin has been triggered and the dynamic array's lenght is not 0 if((bTriggered) && (Targets.Length != 0) ) { TriggerEvent(Targets[0], self, None); //Always trigger the first item in the array Targets.Remove(0,1); //remove the item that has just been triggered } else if(Targets.Length == 0) { SetTimer(0.0, false); //If there is nothing left in the dynamic array.. just disable the timer. } } simulated function Trigger( Actor Other, Pawn EventInstigator ) { //When this actor is triggered, it will set bTriggered as true so the timer can //Trigger all it's targets and remove them from the array. bTriggered = true; }
Repeat-Use Script
/* RoundRobinTrigger, based on myCustomRoundRobin by Dalin 'MythOpus' Seivewright. Written by El Muerte http://wiki.beyondunreal.com/CustomRoundRobin */ class RoundRobinTrigger extends Info placeable; /** The things you wish to trigger (it's a dynamic array) */ var() array<name> Targets; /** The number of seconds between each triggering */ var() float TriggerSeconds; /** all targets will be triggered after eachother, with TriggerSeconds being the interval. Otherwise the targets will be subsequently triggered when triggered */ var() bool TimedTrigger; /** current index in the targets to trigger */ var int TriggerIndex; function Reset() { if (TimedTrigger) SetTimer(0.0, false); TriggerIndex = 0; } event Timer() { if (TriggerIndex < Targets.length) TriggerNext(); else Reset(); } function TriggerNext() { TriggerEvent(Targets[TriggerIndex++], self, None); } function Trigger( Actor Other, Pawn EventInstigator ) { if (TimedTrigger) SetTimer(TriggerSeconds, true); else Timer(); // call timer just once }
Notes
While these scripts can be useful for a contained and simple actor, the same effect can also be created using a scripted trigger.