Page 1 of 1

Delays

PostPosted: Fri Nov 06, 09 5:49 am
by Andrievskaya Veronika
How i can insert delays in UnrealScript? In Delphi this is Sleep() but this is not Delphi. There is same function in UScript too, but i cannot use it in events and functions.

For example i have this code:

Code: Select all
simulated event RenderTexture(ScriptedTexture Tex)
{
if (bAllowRendering)
  {
    Tex.DrawText(16, 32,"Режим работы: нормальный" , Font'DeusExUI.FontMenuHeaders');
    Tex.DrawText(16, 48,"Двойной режим включен." , Font'DeusExUI.FontMenuHeaders');
    Tex.DrawText(16, 64,"Интервал обновления текущего" , Font'DeusExUI.FontMenuHeaders');


and i want to insert a delay after each string, for example couple of seconds.

PostPosted: Fri Nov 06, 09 2:43 pm
by ~DJ~
I am not that expert in.. this.. But I think a call to state sleep will work. And then it awakes or goes back. For example:- DTR-Respawn-TNT-Crate

TNTCrateRespawn wrote:class TNTCrateRespawn extends CrateExplosiveSmall;

var() float ReSpawnTime;
var vector RespawnLocation;

state Exploding {
// ----------------------------------------------------------------------
// Exploding state
// ----------------------------------------------------------------------

ignores Explode;

function Timer() {
local Pawn apawn;
local float damageRadius;
local Vector dist;

if ( Level.NetMode != NM_Standalone ) {
damageRadius = (explosionRadius / gradualHurtSteps) * gradualHurtCounter;

for ( apawn = Level.PawnList; apawn != None; apawn = apawn.nextPawn ) {
if ( apawn.IsA('DeusExPlayer') ) {
dist = apawn.Location - Location;
if ( VSize(dist) <damageRadius>= gradualHurtSteps)
GotoState('Sleeping');
}

Begin:
// stagger the HurtRadius outward using Timer()
// do five separate blast rings increasing in size
gradualHurtCounter = 1;
gradualHurtSteps = 5;
bHidden = True;
SetCollision(False, False, False);
SetTimer(0.5/float(gradualHurtSteps), True);
}

//=============================================================================
// Sleeping state: Sitting hidden waiting to respawn.

State Sleeping
{
ignores Touch;

function BeginState() {
bHidden = true;
}

Begin:
Sleep( ReSpawnTime );
//PlaySound(RespawnSound);

// Used to be the commented out line but all PlaySpawnEffect does is return
// 0.3. Dunno!
//Sleep( Level.Game.PlaySpawnEffect(self) );

Sleep( 0.3 );

bHidden = false;
HitPoints=20;
bStasis=True;
SetCollision(True, True, True);
SetLocation(RespawnLocation);
GoToState('Active');
}

function PostBeginPlay()
{
Super.PostBeginPlay();

RespawnLocation = Location;
}


As you can see, it goes to state sleeping at function explode, rather than destroying. And it set's a sleep timer which works with RespawnTime.

I am not that sure how will you manage to do it.. but adding "goto state" sleeping after each expression might do the trick. Good luck.

PostPosted: Sat Nov 07, 09 12:13 am
by MainMan
Just use the timer function