Gah - a solution with more questions. – EntropicLqd

Legacy:Dispatcher

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 23:03, 1 October 2016 by SeriousBarbie (Talk | contribs) (added details/corrected number of possible events)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
UT :: Actor (UT) >> Triggers (UT) >> Dispatcher (Package: Engine)

Replaced in UT2003 by the ScriptedTrigger.

A dispatcher is a Trigger meant for taking another Trigger's Event and sending out a bunch of new events. The dispatcher also has the capability to time when to send out these subsequent events. It is important to point out that the location of a dispatcher is totally irrelevant to its function: it is not affected by players touching it. However, it is generally advisable to put a dispatcher near to the trigger that it will be triggered by or the actors that it will in turn trigger just for organization's sake.

Properties[edit]

name OutEvents[8]
List of events the dispatcher will fire, in order. Note that UnrealEd will not draw a red line to the actors whose Tag matches these events. (If you're paranoid about this, type the event name in the wrong case; UnrealEd will fix the case if there's a match). If you wish to make more than 8 events, link in a second dispatcher.
Gaps in the list are ignored.
float OutDelays[8]
The time to wait before firing the corresponding event. These are sequential; ie the dispatcher works like this:
  • wait time OutDelays[0]
    • fire event OutEvents[0]
  • wait time OutDelays[1]
    • fire event OutEvents[1]

and so on.

OutDelays can be equal to zero; thus firing several events just after each other.

Examples[edit]

Simple example[edit]

An example would be if you want the dispatcher to trigger 3 events upon the event "xxx" being sent out. The 3 events you want to send out are "yyy" at the same time that "xxx" was sent out, "yyy" again 20 seconds later, and "zzz" at the same time as the second "yyy". The properties you would fill in would be this:

  • OutDelays
    • 0 - 0.0
    • 1 - 20.0
    • 2 - 0.0
  • OutEvents
    • 0 - yyy
    • 1 - yyy
    • 2 - zzz

Delaying[edit]

There is another good trick that can be done with Dispatchers. Sometimes you need to trigger something, but then you need to make it wait before the actual Event happens. This can be done by putting a Dispatcher between the two Events in the chain.

So, if you triggered the Dispatcher's tag xxx, but you needed it to wait 5 seconds before it triggered aaa, here's how it will look:

  • OutDelays
    • 0 - 5.0
  • OutEvents
    • 0 - aaa

Notice that you're not doing anything except triggering an actor that will wait 5 seconds. This is a little trick that editors will sometimes use for such things as properly timing their special effects.

Note that a dispatcher's OutDelays are cumulative. In other words, if you have:

  • OutDelay 1
  • OutDelay 3
  • OutDelay 4

Then the second event is called three seconds after the first, and four seconds after the dispatcher is triggered, and the third event four seconds after the second, and eight seconds in total from the time the dispatcher is called.

Further examples[edit]

Related Topics[edit]

  • Dynamics – main page for everything about triggers
  • Event – overview of how triggering works
  • Types of Trigger – summary of the different kinds of trigger actor

Custom Subclasses[edit]

Haltable dispatcher[edit]

Tarquin: A dispatcher which stops if triggered while dispatching. This is untested; I have no idea what happens to state label code when a function is called. see Create A Subclass for instructions.

state Dispatch
{
	function Trigger( actor Other, pawn EventInstigator )
	{
		gotostate('');
	}
 
Begin:
	for( i=0; i<ArrayCount(OutEvents); i++ )
	{
		if( OutEvents[i] != '' )
		{
			Sleep( OutDelays[i] );
			foreach AllActors( class 'Actor', Target, OutEvents[i] )
				Target.Trigger( Self, Instigator );
		}
	}
}

Elephant Dispatcher[edit]

Normal Disp breaks the chain of command. This remembers who Triggered it and passes this information on to the actors it triggers. See Event for details.

//=============================================================================
// ChainDispatcher.
//=============================================================================
class ChainDispatcher extends Dispatcher;
// Remembers who Triggered it 
// and passes this information along the chain of command
 
var actor SavedTrigger ;
 
//
// When dispatcher is triggered...
//
function Trigger( actor Other, pawn EventInstigator )
{
	SavedTrigger  = Other ;
	super.Trigger( Other, EventInstigator );
}
 
//
// Dispatch events.
//
state Dispatch
{
Begin:
	disable('Trigger');
	for( i=0; i<ArrayCount(OutEvents); i++ )
	{
		if( OutEvents[i] != '' )
		{
			Sleep( OutDelays[i] );
			foreach AllActors( class 'Actor', Target, OutEvents[i] )
				Target.Trigger( SavedTrigger, Instigator );
		}
	}
	enable('Trigger');
}

Category:Legacy Class (UT)
Category:Legacy Custom Class (UT)
Category:Legacy To Do move the custom subclasses into sub pages?