For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

DelayedTrigger

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
w[ch7465]-w[ch959][ch617]v[ch7431][ch628]
OldUnreal Member
Posts: 42
Joined: Tue Mar 20, 2007 10:33 am

DelayedTrigger

Post by w[ch7465]-w[ch959][ch617]v[ch7431][ch628] »

I got sick of using a nasty collection of triggers just to have a delay before something happens in my levels, so today I took my first steps in UnrealScript and wrote DelayedTimer:

Code: Select all

//-----------------------------------------------------------------------------
// DelayedTrigger: Trigger an event only after a set delay.
//-----------------------------------------------------------------------------
      class DelayedTrigger expands Triggers;
      
//-----------------------------------------------------------------------------
// Variables:
//-----------------------------------------------------------------------------
      
      // How long to delay?
      var() byte DelaySeconds;
      
      // Trigger more than once?
      var() bool bLooping;
      
      var byte OriginalSeconds;
      
//-----------------------------------------------------------------------------
//      Init for play.
//-----------------------------------------------------------------------------
      function BeginPlay() {
            OriginalSeconds = DelaySeconds;
            SetTimer(DelaySeconds, False);
      }
      
//-----------------------------------------------------------------------------
//      Time to trigger:
//-----------------------------------------------------------------------------
      function Timer() {
            local Pawn P;
            local Actor A;
            
            // Message all players:
            for (P = Level.PawnList; P != None; P = P.nextPawn) {
                  if (P.bIsPlayer) break;
            }
            
            // Trigger:
            if (Event != '') {
                  foreach AllActors(class 'Actor', A, Event) {
                        A.Trigger(Self, P);
                  }
            }
            
            // Run again?
            if (bLooping) {
                  DelaySeconds = OriginalSeconds;
                  SetTimer(DelaySeconds, False);
            }
      }
      
//-----------------------------------------------------------------------------
Please, point out any flaws, or if such a thing already exists :P

BTW, Why no UnrealScript forum?
User avatar
Pitbull
Administrator
Posts: 1225
Joined: Fri Oct 04, 2002 6:47 pm
Location: Between Venus and Mars

Re: DelayedTrigger

Post by Pitbull »


BTW, Why no UnrealScript forum?
Good idea. 8-) Done!
Upon this rock I will build my church O:-)

LOADING HATERS..████████████] 99% Complete.
User avatar
TCP_Wolf
Administrator
Posts: 1078
Joined: Sun Mar 03, 2002 12:04 pm

Re: DelayedTrigger

Post by TCP_Wolf »

Looks to me like your delayed instigator pawn is not necessarily the pawn which originally instigated the event..... man I haven't done UScript in a while .... hehe :-)
-=]HONESTY PAYS[=-
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: DelayedTrigger

Post by .:..: »

Heres how I would do it in simplier way:

Code: Select all

//-----------------------------------------------------------------------------
// DelayedTrigger: Trigger an event only after a set delay.
//-----------------------------------------------------------------------------
      class DelayedTrigger expands Triggers;
      
//-----------------------------------------------------------------------------
// Variables:
//-----------------------------------------------------------------------------
      
// How long to delay?
var() float DelaySeconds;
      
// Trigger more than once?
var() bool bLooping;

//-----------------------------------------------------------------------------
//      Init for play.
//-----------------------------------------------------------------------------
function BeginPlay()
{
      SetTimer(DelaySeconds, bLooping);
}
      
//-----------------------------------------------------------------------------
//      Time to trigger:
//-----------------------------------------------------------------------------
function Timer() 
{
      local Actor A;
            
      // Trigger:
      if (Event != '') 
      {
            foreach AllActors(class 'Actor', A, Event) 
                  A.Trigger(Self, None);
      }
}
//-----------------------------------------------------------------------------
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
StalwartUK

Re: DelayedTrigger

Post by StalwartUK »

Can't you like achieve the same effect with a trigger and a dispatcher? You can set up the event with the dispatcher to work on a delay say a couple of seconds. In any case that script simplifys the process.
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: DelayedTrigger

Post by .:..: »

Can't you like achieve the same effect with a trigger and a dispatcher? You can set up the event with the dispatcher to work on a delay say a couple of seconds. In any case that script simplifys the process.
Actually this starts triggering from START of the map, and not when its being triggered like Disaptcher.
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
sopa_de_letras

Re: DelayedTrigger

Post by sopa_de_letras »

I need to learn how to code too, I'd love to have a sort of All in one trigger with all functions from a dispatcher, trigger, timed trigger, roundrobind, stochastic, specialevent and codetrigger. Or in other words, a scriptable trigger.

Return to “UScript Board”