Gah - a solution with more questions. – EntropicLqd

Difference between revisions of "UE2:Round Robin"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__TOC__
 
__TOC__
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.
+
Created due to the fact that the RoundRobin actor present in UE1 has been removed.  There are two scripts on this page, one created by [[User: DalinSeivewright | DalinSeivewright]] and the other by [[User: ElMuerte | ElMuerte]].  A round robin will cycle through a series of names and trigger the associated event.
  
 
==One-shot Script==
 
==One-shot Script==
 +
{{Infobox class
 +
| class  = myCustomRoundRobin
 +
| custom  = yes
 +
| parent1 = Actor
 +
}}
 +
 
<uscript>
 
<uscript>
 
/* A Simple Custom Round Robin Created By Dalin 'MythOpus' Seivewright.
 
/* A Simple Custom Round Robin Created By Dalin 'MythOpus' Seivewright.
Line 49: Line 55:
  
 
==Repeat-Use Script==
 
==Repeat-Use Script==
 +
{{Infobox class
 +
| class  = RoundRobinTrigger
 +
| custom  = yes
 +
| parent1 = Info
 +
}}
 
<uscript>
 
<uscript>
 
/*  
 
/*  
Line 97: Line 108:
  
 
==Related Topics==
 
==Related Topics==
*[[UE2:IncrementalTrigger | Incremental Trigger]]
+
*[[UE2:IncrementalTrigger|Incremental Trigger]]
 
+
----
+
[[Category:Custom_UT2003-specific_classes]]
+
[[Category:Custom_UT2004-specific_classes]]
+

Latest revision as of 06:19, 8 April 2008

Created due to the fact that the RoundRobin actor present in UE1 has been removed. There are two scripts on this page, one created by DalinSeivewright and the other by ElMuerte. A round robin will cycle through a series of names and trigger the associated event.

One-shot Script[edit]

UE2 Actor >> myCustomRoundRobin (custom)
/* 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[edit]

UE2 Info >> RoundRobinTrigger (custom)
/* 
	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[edit]

While these scripts can be useful for a contained and simple actor, the same effect can also be created using a scripted trigger.

Related Topics[edit]