Hypothetical Question: a Timer for SP games.

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Techno JF

He Who Has Powerful Words
I really think that a triggerable timer would really have its uses in SP games. Here are some scenarios I think might benefit from it:
  • The player has just killed the boss creature of the map. He now has 5 minutes to evacuate to a safe area or he will be trapped in the place he has entered.
  • The player has just been briefed on his mission, and he has bypassed the alarms. He now has 15 minutes to accomplish his mission before the alarms sound, which would suddenly make his mission a lot more difficult. (CreatureFactories suddenly double the number of enemies in the level, or something.)
  • The player has activated the auto-destruct sequence on the Skaarj vessel he infiltrated. The player has 10 minutes to fight his way to an escape pod and pilot it to a safe distance.
I'm thinking of actually trying to make a timer that broadcasts countdown messages or that has a particular place on the HUD. I really don't think that the way to make a 5 minute timer should be to create 301 SpecialEvent actors (300 seconds=5 minutes, and 1 more for 0:00 time left) and enough Dispatchers to trigger them all. Does anyone have any suggestions as to where to start?
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
46
Look outside your window!
Visit site
A tirggerable timer would be relatively easy to implement...you would have to create a timer actor, that of course can be triggered, once the actor has been triggered , begin a timer, to make things easier you should make a variable that can be modified thru the actors defaultproperties in the unrealed, this variable (could be int or a float) represents the time limit the player have once the timer has started. To send the messages to the player...of course if you want to display it in the middle of the screen (like a the countdown of a tournament game) you would have to create a localizedMessage subclass, which will be the one that will display the remaining time. You could make an variable which will represent the time at which the message will begin to broadcast, for example if you want the countdown message to begin when there are 10 seconds left in the clock, you just set this variable to 10. Hope this helps :)
 

gor

New Member
Dec 30, 2001
40
0
0
AUS
Visit site
just a note about your messages -

you wouldnt need to have 300 whatevers..

have a look at the code below - its from unrealshare.deathmatchgame, it shows how you just choose at what time you want to message poeple at by selecting the case and then you can have an array with your messages in it.

Code:
RemainingTime--;
		switch (RemainingTime)
		{
			case 300:
				BroadcastMessage(TimeMessage[0], True, 'CriticalEvent');
				break;
			case 240:
				BroadcastMessage(TimeMessage[1], True, 'CriticalEvent');
				break;
			case 180:
				BroadcastMessage(TimeMessage[2], True, 'CriticalEvent');
				break;
			case 120:
				BroadcastMessage(TimeMessage[3], True, 'CriticalEvent');
				break;
			case 60:
				BroadcastMessage(TimeMessage[4], True, 'CriticalEvent');
				break;
			case 30:
				BroadcastMessage(TimeMessage[5], True, 'CriticalEvent');
				break;
			case 10:
				BroadcastMessage(TimeMessage[6], True, 'CriticalEvent');
				break;
			case 5:
				BroadcastMessage(TimeMessage[7], True, 'CriticalEvent');
				break;
			case 4:
				BroadcastMessage(TimeMessage[8], True, 'CriticalEvent');
				break;
			case 3:
				BroadcastMessage(TimeMessage[9], True, 'CriticalEvent');
				break;
			case 2:
				BroadcastMessage(TimeMessage[10], True, 'CriticalEvent');
				break;
			case 1:
				BroadcastMessage(TimeMessage[11], True, 'CriticalEvent');
				break;
			case 0:
				BroadcastMessage(TimeMessage[12], True, 'CriticalEvent');
				break;
		}
 

Techno JF

He Who Has Powerful Words
Thanks. Actually, I thought of something similar to that. I'm going to make a rudimentary outline of it in just a little bit. I have a rough outline of the editable variables already.
Code:
var() byte Timer_Minutes;
var() byte Timer_Seconds;
   //the amount of time to put on the timer, in minutes and seconds
var() byte AnnounceInterval_Minutes;
var() byte AnnounceInterval_Seconds;
   //the timer will announce itself at the interval denoted by these 
   //minute and second variables
var() byte FinalAnnounce;
   //when this many seconds are left, the timer will announce itself 
   //every second
var() sound TickSound;
   //the timer will play this sound every second it counts down
var() sound FinalSound;
   //the timer will switch to this sound after it enters its FinalAnnounce threshold
var() name BeginEvent;
   //the timer will trigger this event when it starts counting down 
   //and its main event when it reaches zero
var() name InterruptEvent;
   //if this event is called while the timer is running, then the timer 
   //will be shut down immediately
var() bool bCanBeReset;
   //if False, then after this timer either reaches zero or is interrupted,
   //it will no longer work
var() bool bConstantAnnounce;
   //if True, then the timer will announce itself every second,
   //regardless of the FinalAnnounce value
I'm also going to use the BroadcastLocalizedMessage (I think that's the right one) to put the messages on the bottom of the screen, where inventory item messages are displayed.
 
Last edited:

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
46
Look outside your window!
Visit site
You don't have to make that HUGE switch statement!! All you have to do is include the current time when you call BroadcastLocalizedMessage:

Code:
BroadcastLocalizedMessage( class<LocalMessage> Message, [color=blue]optional int Switch[/color], optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )

Put the remaining time in the optional int Switch parameter of the function when you call it.

And in the LocalMessage child class, just write:

Code:
static function string GetString(
	optional int Switch,
	optional PlayerReplicationInfo RelatedPRI_1, 
	optional PlayerReplicationInfo RelatedPRI_2,
	optional Object OptionalObject
	)
{
	return [color=blue]Switch[/color];
}

That will diplay the current time in the screen.
Oh and, IMO the best way to get your message displayed at the bottom of the screen (like pickup message's) is to derive it from CriticalEventLowPlus.
 

Techno JF

He Who Has Powerful Words
Oops! I didn't implement the sounds in that version. Oh well. The problem is now fixed, since I just added a few lines and rezipped it. This is the right one.

[edit]I had to fix yet another mistake, with the bWasInterrupted variable. Now I think that's everything.[/edit]
 
Last edited:

Techno JF

He Who Has Powerful Words
I see you already downloaded the package. Here are the lines I added. They're supposed to be at the end of the Timer function.
Code:
   //now to play the appropriate sound
   if (InternalClock>FinalAnnounce)
      CorrectTickSound=TickSound;
   else
      CorrectTickSound=FinalSound;

   for(P=Level.PawnList;P!=None;P=P.NextPawn
      if(P.bIsPlayer && P.IsA('PlayerPawn'))
         if CorrectTickSound!=None;
            PlayerPawn(P).ClientPlaySound(CorrectTickSound);
There's also a "local Pawn P;" and a "local Sound CorrectTickSound;" added to the top of the Timer function too.
 
Last edited:

Techno JF

He Who Has Powerful Words
That's an idea. Another is to make an actor that spawns a SpecialEvent, and is constantly changing its variables and triggering it.

However, I really think that my only problem with the construction I've come up with is that I've stuffed a bit too much code into the Timer() function.

This actor does it all. The timer's values are specified in terms of minutes and seconds, they can be programmed to announce at regular intervals, and they can be told to announce every second after a certain point (or announce every second, each with possible sounds). They can trigger an event when they start counting down, they obviously trigger their main event when they reach zero, and they can even be triggered so as to be interrupted and have the countdown stop.

Oh yeah, I fixed two problems that I noticed. The first one makes sure that the Timer function is stopped once the actor's countdown is interrupted. The second one rewires the Event and Tag names so that an outside actor isn't necessary. I'm pretty sure that I've finished this thing now, and I'm attaching this final copy of a single .uc to my post. I imagine I should delete the old ZIP files that still have bugs in them later.

So I'm wondering something else. Where's a good place to get a hold of custom scripts? Is there a site that hosts them?
 
Last edited: