Legacy:CustomRoundRobin - Unreal Wiki

# Legacy:CustomRoundRobin

### From Unreal Wiki, The Unreal Engine Documentation Site

# Custom Round Robin

For Use In UT2004/03 Code and Maps.

UT2004 :: Actor >> MythCustomRoundRobin

## Description

Just a simple script to help mappers and coders out. A One time use 'RoundRobin' that goes down the list in it's Dynamic array and triggers off all the events during the specified timeinterval.

## The Script

    /* A Simple Custom Round Robin Created By Dalin 'MythOpus' Seivewright.
       This RoundRobin has a one time use only however but it can be set up
       to do a mass chain of triggering.  Use As Needed :D
       If you want, you could always state who wrote it... but if you'd rather not
       At least state that you got it from
       THE UNREAL WIKI! = wiki.beyondunreal.com */

    class MythCustomRoundRobin 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;
    }

## Comments

El Muerte: isn't something like the following more useful (you can use it more than once and stuff like it). It combines both the roundrobin trigger and your relationaltrigger

    /*
            RoundRobinTrigger, based on MythCustomRoundRobin by Dalin 'MythOpus' Seivewright.
            http://wiki.beyondunreal.com/wiki/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
    }

Wormbo: Did you know you could build these from ScriptedTriggers as well?

MythOpus: I realize that you can now :D But I hate scripted triggers as they take so long for me to set up. I'm lazy.

Category: Legacy Custom Class (UT2004)

##### Views

- Legacy
- Discussion
- Current revision

##### Search