Always snap to grid

Legacy:TimedTrigger

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT2003 :: Actor >> Triggers (UT2003) >> TimedTrigger

A TimedTrigger automatically fires an event after a given amount of time has elapsed.

Since this class isn't part of the stock UT2003 code, here is a slightly extended version as an embeddable component.

See TimedTrigger (UT) for the UT version of this class.

Usage[edit]

You'll find TimedTrigger in the actor browser then. Its code will automatically be saved with your map when you save it.

See Embedding Code for more information.

Editable Properties[edit]

(Events) name Event 
Event fired by the TimedTrigger.
bool bEnabled 
Specifies whether the TimedTrigger is enabled by default. You can toggle this state in-game by triggering the TimedTrigger actor with another Trigger.
bool bRepeating 
If set to True, the TimedTrigger will fire its event over and over again. Otherwise, the event will be fired only once after the specified time has elapsed. If bRepeating is set to False and you disable and enable the TimedTrigger again after it had fired its event once, it will fire its event again.
bool bUseInstigator 
If set to True and this TimedTrigger has been enabled by another Trigger, the player who enabled the TimedTrigger will be used as the instigator of all future events fired by the TimedTrigger.
float MinDelaySeconds
float MaxDelaySeconds 
The number of seconds that have to elapse before a new event is fired. If you set MinDelaySeconds to a smaller value than MaxDelaySeconds, the TimedTrigger will randomly choose a time between those two values each time an event has been fired. If you set MinDelaySeconds to the same value as MaxDelaySeconds, the event interval is fixed.

Source[edit]

</span><div class="hidden">// ============================================================================
// TimedTrigger
// Copyright 2002 by Mychaeel <mychaeel@planetjailbreak.com>
// $Id: TimedTrigger.uc,v 1.1.1.1 2003/01/01 23:40:10 mychaeel Exp $
//
// Trigger that periodically fires a certain event. Can be activated and
// deactivated by being triggered itself. Trigger times are randomly chosen
// between a given minimum and maximum delay.
//
// Originally developed for Jailbreak mapping support.
// ============================================================================
 
 
class TimedTrigger extends Triggers
  placeable;
 
 
// ============================================================================
// Properties
// ============================================================================
 
var() bool bEnabled;          // trigger is enabled by default
var() bool bRepeating;        // event is fired repeatedly instead of just once
var() bool bUseInstigator;    // pawn enabling this trigger is event instigator
var() float MinDelaySeconds;  // minimum number of seconds between events
var() float MaxDelaySeconds;  // maximum number of seconds between events
 
 
// ============================================================================
// PostBeginPlay
//
// If the trigger is enabled, starts the timer.
// ============================================================================
 
event PostBeginPlay() {
 
  if (bEnabled)
    StartTimer();
  }
 
 
// ============================================================================
// Trigger
//
// Toggles the trigger between enabled and disabled state. If the trigger is
// being enabled, starts the timer.
// ============================================================================
 
event Trigger(Actor ActorOther, Pawn PawnInstigator) {
 
  bEnabled = !bEnabled;
 
  if (bEnabled)
    StartTimer();
  else
    SetTimer(0.0, False);
 
  if (bUseInstigator)
    Instigator = PawnInstigator;
  }
 
 
// ============================================================================
// Timer
//
// Fires the trigger's event and restarts the timer if appropriate.
// ============================================================================
 
event Timer() {
 
  TriggerEvent(Event, Self, Instigator);
 
  if (bRepeating)
    StartTimer();
  }
 
 
// ============================================================================
// StartTimer
//
// Adjusts MinDelaySeconds and MaxDelaySeconds. Starts the timer with a random
// interval between those two values.
// ============================================================================
 
function StartTimer() {
 
  if (MinDelaySeconds <= 0.0)
    MinDelaySeconds = 0.0001;  // small but non-zero
 
  if (MaxDelaySeconds < MinDelaySeconds)
    MaxDelaySeconds = MinDelaySeconds;
 
  SetTimer(MinDelaySeconds + FRand() * (MaxDelaySeconds - MinDelaySeconds), False);
  }
 
 
// ============================================================================
// Defaults
// ============================================================================
 
defaultproperties {
 
  bEnabled = True;
  bRepeating = True;
  bUseInstigator = False;
  }