Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Needed! AddTimer Sequence problem
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#1
Help Needed! AddTimer Sequence problem

i have made a timer for a sequence to my custom story. it's the second sequence timer in the map, but this one does not want to go past case 1.
can someone please help me to fix this error/bug or mismade script? it would be a great help!
the timer is activate by a script area, and as i said it works, but just not past case 1.

it is the "WakeUp1" script that does not work

the full Script:



void OnStart()
{
SetMapDisplayNameEntry("Intro");
//User properties
SetPlayerActive(false);
SetSanityDrainDisabled(true);
SetInventoryDisabled(true);
SetPlayerCrouchDisabled(true);
SetPlayerJumpDisabled(true);
ShowPlayerCrossHairIcons(false);
SetPlayerLampOil(0.0f);

//Sound properties
PlayMusic("music/intro_bg.ogg", true, 0.5, 2, 0, true);

//Timers
AddTimer("Intro", 8, "Intro");
AddEntityCollideCallback("Player", "WakeUp_1", "WakeUp", true, 1);

//Finally start
//Finally Start
FadeOut(0);
FadeIn(4);
StartPlayerLookAt("prodlook", 2.0f, 2.0f, "");

AddTimer("Debug", 1, "Debug");

//door unlocks
SetEntityConnectionStateChangeCallback("lever", "unlockdoor");
AddUseItemCallback("", "key", "door_key", "KeyDoor", true);

//monster functions
SetEntityCallbackFunc("key", "OnPickup");
}

void Debug(string &in asTimer)
{
AddLocalVarInt("aq", 1);
AddDebugMessage(" "+ GetLocalVarInt("aq"), false);
AddTimer("Debug", 1, "Debug");
}

void Intro(string &in asTimer)
{
AddLocalVarInt("IntroInt", 1);

switch( GetLocalVarInt("IntroInt") )
{
case 1:
FadeOut(2);
break;
case 4:
FadeIn(4);
TeleportPlayer("PlayerStartArea_2");
StartPlayerLookAt("titellook", 2.0f, 2.0f, "");
break;
case 12:
FadeOut(3);
break;
case 14:
FadeIn(4);
TeleportPlayer("PlayerStartArea_3");
SetLocalVarInt("AllowPlayerPushMove",1); //Say we are allowing the player to be pushed
AddTimer("PushPlayerStart1", 0.01, "PushPlayer1"); //Timer as normal here
StartPlayerLookAt("halllook", 2.0f, 2.0f, "");
break;
case 15:
SetMessage("Messages", "Popup1", 5);
break;
case 22:
SetMessage("Messages", "Popup2", 5);
break;
case 29:
SetMessage("Messages", "Popup3", 5);
break;
case 36:
SetMessage("Messages", "Popup4", 5);
break;
case 43:
SetMessage("Messages", "Popup5", 5);
break;
case 50:
SetMessage("Messages", "Popup6", 5);
break;
case 57:
SetMessage("Messages", "Popup7", 5);
break;
case 62:
FadeOut(3);
break;
case 64:
SetMessage("Messages", "Popup8", 5);
break;
case 69:
FadeIn(4);
TeleportPlayer("PlayerStartArea_4");
SetPlayerActive(true);
SetInventoryDisabled(false);
SetPlayerCrouchDisabled(false);
SetPlayerJumpDisabled(false);
ShowPlayerCrossHairIcons(true);
StopPlayerLookAt();
StopMusic(3.0f , 0.0f);
//Say we are no longer allowing the push timer
//instead of Removing the timer
SetLocalVarInt("AllowPlayerPushMove",0);
break;
}
if( GetLocalVarInt("IntroInt") < 126)
AddTimer("blackout", 1, "Intro");
}

void PushPlayer1(string &in asTimer)
{
AddPlayerBodyForce(0, 0.0f, 435.1f, true);
//Only renew the push loop whilst we are allowing the player to be pushed.
if(GetLocalVarInt("AllowPlayerPushMove")==1)
AddTimer("PushPlayerLoop1", 0.012, "PushPlayer1");
}

void unlockdoor(string &in asEntity, int alState)
{
if(GetLeverState("lever")==1)
{
SetSwingDoorLocked("door_lever", false, true);
PlaySoundAtEntity("", "unlock_door", "door_lever", 0, false);
}
}

void KeyDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_key", false, true);
PlaySoundAtEntity("", "unlock_door", "door_key", 0, false);
RemoveItem("key");
}

void OnPickup(string &in asItem, string &in asEntity)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_1", 0, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_2", 0, "");
CheckPoint("", "PlayerStartArea_4", "", "DeathHints", "Death1");
}

void WakeUp(string &in asParent, string &in asChild, int alState)
{
AddTimer("WakeUp1", 0.5, "WakeUp1");
}

void WakeUp1(string &in asTimer)
{
AddLocalVarInt("WakeUpInt", 1);

switch(GetLocalVarInt("WakeUpInt") )
{
case 1:
FadeOut(2);
SetEntityActive("servant_grunt_1", false);
break;
case 3:
PlayMusic("music/WakeUp.ogg", false, 1, 0.1, 1, true);
break;
case 5:
FadeIn(0.3);
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
TeleportPlayer("PlayerStartArea_5");
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true); // Simulates being on the ground
SetInventoryDisabled(true);
break;
case 23:
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
break;
}
if(GetLocalVarInt("WakeUpInt") < 126)
AddTimer("blackout", 1, "WakeUp");
}
(This post was last modified: 08-13-2012, 09:24 AM by bjaffedj.)
08-12-2012, 04:42 PM
Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
#2
RE: Help Needed! AddTimer Sequence problem

Right, don't make two posts for your issue, and please atleast post them in the right section of the forums.
08-12-2012, 05:01 PM
Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#3
RE: Help Needed! AddTimer Sequence problem

(08-12-2012, 05:01 PM)Traggey Wrote: Right, don't make two posts for your issue, and please atleast post them in the right section of the forums.
it was never my point to make 2 posts and i am sorry for that. and i actually thought i was posting in the right section. if its not the right section then where should i post it?
(This post was last modified: 08-12-2012, 05:05 PM by bjaffedj.)
08-12-2012, 05:04 PM
Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
#4
RE: Help Needed! AddTimer Sequence problem

(08-12-2012, 05:04 PM)bjaffedj Wrote:
(08-12-2012, 05:01 PM)Traggey Wrote: Right, don't make two posts for your issue, and please atleast post them in the right section of the forums.
it was never my point to make 2 posts and i am sorry for that. and i actually thought i was posting in the right section. if its not the right section then where should i post it?
I've moved it to the right section.
08-12-2012, 05:07 PM
Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#5
RE: Help Needed! AddTimer Sequence problem

thank you sir. and from now on i'll keep in might which section to post
08-12-2012, 05:10 PM
Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#6
RE: Help Needed! AddTimer Sequence problem

really? no one? Sad
08-12-2012, 07:12 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#7
RE: Help Needed! AddTimer Sequence problem

Why don't you just check against the timer name with if(-else) statements instead of incrementing a local map variable with a switch statement?

Tutorials: From Noob to Pro
08-12-2012, 07:19 PM
Website Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#8
RE: Help Needed! AddTimer Sequence problem

but will i be able to set a kind of timer through that?
08-12-2012, 07:26 PM
Find
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
#9
RE: Help Needed! AddTimer Sequence problem

Does the other switch(intro) work without problems?


By the way, your way of delaying the next case is really not as good as it can be. Look at rainy halls for example!

void TimerBlackOut(string &in asTimer)
{
    AddLocalVarInt("BlackoutStep", 1);    //What step to play in the event
    float fEventSpeed = 0.5f;                //The default time between steps in an event

    switch(GetLocalVarInt("BlackoutStep")) {
        case 1:
            StartPlayerLookAt("Arealook2", 0.1f, 0.1f, "");
            FadeIn(4);
            FadeImageTrailTo(2,1);
            AddTimer("rose", 0.5f, "TimerRose");
            SetPlayerActive(true);
            ShowPlayerCrossHairIcons(true);
            SetPlayerMoveSpeedMul(0.05f);
            SetPlayerLookSpeedMul(0.05f);
            fEventSpeed = 3.0f;    //This change here allows the choosing of time until the next case.
        break;
        case 2:
            FadePlayerRollTo(85, 1, 1);
        break;
        case 3:
            StartPlayerLookAt("Arealook3", 0.1f, 0.1f, "");
        break;
        case 4:
            FadeImageTrailTo(0,1);
            FadePlayerRollTo(65, 1, 1);
            AddTimer("thunder", 1, "TimerThunder");
        break;
        case 5:
            PlaySoundAtEntity("sigh", "react_sigh.snt", "Player", 1.0 / 2, false);
            FadeOut(2);
            fEventSpeed = 1.5f;    
        break;
        case 6:
            FadePlayerRollTo(85, 1, 4);
            StartPlayerLookAt("Arealook1", 0.1f, 0.1f, "");
        break;
        case 7:
            FadeImageTrailTo(1.8f,1.5f);
            FadePlayerFOVMulTo(1.25f, 0.01);
        break;
        case 8:
            FadePlayerRollTo(45, 1, 2);
            FadeIn(2);
            fEventSpeed = 1.5f;    
        break;
        case 9:
            StartPlayerLookAt("Arealook2", 0.1f, 0.1f, "");
        break;
        case 10:
            FadePlayerRollTo(15, 1, 2);
            FadePlayerFOVMulTo(0.75f, 0.01);
        break;
        case 11:
            PlaySoundAtEntity("sigh", "react_sigh.snt", "Player", 1.0 / 1.5f, false);
            FadeOut(1);
            StartPlayerLookAt("Arealook3", 1, 1, "");
            FadePlayerRollTo(50, 1, 2);
            fEventSpeed = 2.0f;    
        break;
        case 12:
            SetPlayerMoveSpeedMul(0.1f);
            SetPlayerLookSpeedMul(0.1f);
            StartPlayerLookAt("Arealook1", 1, 1, "");
            FadePlayerFOVMulTo(1.1f, 0.01);
            FadeImageTrailTo(0,1.5f);
            fEventSpeed = 1.5f;    
        break;
        case 13:
            SetPlayerMoveSpeedMul(0.2f);
            SetPlayerLookSpeedMul(0.2f);
            FadePlayerRollTo(-15, 1, 2);
            FadeIn(1);
            StartPlayerLookAt("Arealook4", 2, 2, "");
            fEventSpeed = 2.0f;    
        break;
        case 14:
            SetPlayerMoveSpeedMul(0.3f);
            SetPlayerLookSpeedMul(0.4f);
            FadePlayerRollTo(-30, 10, 60);     
            MovePlayerHeadPos(0, 0, 0, 1, 0.5f);    
            StartPlayerLookAt("Arealook3", 1, 1, "");
            FadePlayerFOVMulTo(0.9f, 0.01);
            FadeImageTrailTo(1.5,2);
            PlaySoundAtEntity("movement", "player_climb.snt", "Player", 0, false);
        break;
        case 15:
            SetPlayerMoveSpeedMul(0.4f);
            SetPlayerLookSpeedMul(0.6f);
            FadePlayerRollTo(10, 10, 20);     
            MovePlayerHeadPos(0, -0.5f, 0, 1, 0.5f);
        break;
        case 16:
            SetPlayerMoveSpeedMul(0.5f);
            SetPlayerLookSpeedMul(0.8f);
            FadePlayerRollTo(0, 10, 60);     
            MovePlayerHeadPos(0, 0, 0, 1, 0.5f);
            StartPlayerLookAt("Arealook4", 2, 2, "");
            FadePlayerFOVMulTo(1, 0.01f);
            PlaySoundAtEntity("movement", "player_climb.snt", "Player", 0, false);
            fEventSpeed = 2.0f;    
        break;
        case 17:
            SetPlayerJumpDisabled(false);
            SetPlayerCrouchDisabled(false);
            SetPlayerMoveSpeedMul(0.6f);
            SetPlayerLookSpeedMul(1.0f);
            FadeImageTrailTo(0,0.2f);
            StopPlayerLookAt();
            PlaySoundAtEntity("sigh", "react_sigh.snt", "Player", 1.0 / 1, false);
            AddTimer("lookloop", RandFloat(2.0f,6.0f), "TimerRandomLook");    //Activate the spinning head
            fEventSpeed = 1.0f;        
        break;
        case 18:
            SetEntityActive("AreaQuest", true);
            //AddQuest("00Trail","00Trail"); In LookAtQuest instead
        break;
    }
    
    if(GetLocalVarInt("BlackoutStep") < 19)  AddTimer("blackout", fEventSpeed, "TimerBlackOut");
}

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
08-12-2012, 07:27 PM
Website Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#10
RE: Help Needed! AddTimer Sequence problem

(08-12-2012, 07:27 PM)Theforgot3n1 Wrote: Does the other switch(intro) work without problems?


By the way, your way of delaying the next case is really not as good as it can be. Look at rainy halls for example!


yes my other "switch" script works. after the intro switch there is a gameplay sequence and then i wanted to get a new sequence going, but it do'nt want to work this time :/

(08-12-2012, 07:27 PM)Theforgot3n1 Wrote: By the way, your way of delaying the next case is really not as good as it can be. Look at rainy halls for example!

void TimerBlackOut(string &in asTimer)
{
    AddLocalVarInt("BlackoutStep", 1);    //What step to play in the event
    float fEventSpeed = 0.5f;                //The default time between steps in an event

    switch(GetLocalVarInt("BlackoutStep")) {
        case 1:
            StartPlayerLookAt("Arealook2", 0.1f, 0.1f, "");
            FadeIn(4);
            FadeImageTrailTo(2,1);
            AddTimer("rose", 0.5f, "TimerRose");
            SetPlayerActive(true);
            ShowPlayerCrossHairIcons(true);
            SetPlayerMoveSpeedMul(0.05f);
            SetPlayerLookSpeedMul(0.05f);
            fEventSpeed = 3.0f;    //This change here allows the choosing of time until the next case.
        break;
        case 2:
            FadePlayerRollTo(85, 1, 1);
        break;
        case 3:
            StartPlayerLookAt("Arealook3", 0.1f, 0.1f, "");
        break;
        case 4:
            FadeImageTrailTo(0,1);
            FadePlayerRollTo(65, 1, 1);
            AddTimer("thunder", 1, "TimerThunder");
        break;
        case 5:
            PlaySoundAtEntity("sigh", "react_sigh.snt", "Player", 1.0 / 2, false);
            FadeOut(2);
            fEventSpeed = 1.5f;    
        break;
        case 6:
            FadePlayerRollTo(85, 1, 4);
            StartPlayerLookAt("Arealook1", 0.1f, 0.1f, "");
        break;
        case 7:
            FadeImageTrailTo(1.8f,1.5f);
            FadePlayerFOVMulTo(1.25f, 0.01);
        break;
        case 8:
            FadePlayerRollTo(45, 1, 2);
            FadeIn(2);
            fEventSpeed = 1.5f;    
        break;
        case 9:
            StartPlayerLookAt("Arealook2", 0.1f, 0.1f, "");
        break;
        case 10:
            FadePlayerRollTo(15, 1, 2);
            FadePlayerFOVMulTo(0.75f, 0.01);
        break;
        case 11:
            PlaySoundAtEntity("sigh", "react_sigh.snt", "Player", 1.0 / 1.5f, false);
            FadeOut(1);
            StartPlayerLookAt("Arealook3", 1, 1, "");
            FadePlayerRollTo(50, 1, 2);
            fEventSpeed = 2.0f;    
        break;
        case 12:
            SetPlayerMoveSpeedMul(0.1f);
            SetPlayerLookSpeedMul(0.1f);
            StartPlayerLookAt("Arealook1", 1, 1, "");
            FadePlayerFOVMulTo(1.1f, 0.01);
            FadeImageTrailTo(0,1.5f);
            fEventSpeed = 1.5f;    
        break;
        case 13:
            SetPlayerMoveSpeedMul(0.2f);
            SetPlayerLookSpeedMul(0.2f);
            FadePlayerRollTo(-15, 1, 2);
            FadeIn(1);
            StartPlayerLookAt("Arealook4", 2, 2, "");
            fEventSpeed = 2.0f;    
        break;
        case 14:
            SetPlayerMoveSpeedMul(0.3f);
            SetPlayerLookSpeedMul(0.4f);
            FadePlayerRollTo(-30, 10, 60);     
            MovePlayerHeadPos(0, 0, 0, 1, 0.5f);    
            StartPlayerLookAt("Arealook3", 1, 1, "");
            FadePlayerFOVMulTo(0.9f, 0.01);
            FadeImageTrailTo(1.5,2);
            PlaySoundAtEntity("movement", "player_climb.snt", "Player", 0, false);
        break;
        case 15:
            SetPlayerMoveSpeedMul(0.4f);
            SetPlayerLookSpeedMul(0.6f);
            FadePlayerRollTo(10, 10, 20);     
            MovePlayerHeadPos(0, -0.5f, 0, 1, 0.5f);
        break;
        case 16:
            SetPlayerMoveSpeedMul(0.5f);
            SetPlayerLookSpeedMul(0.8f);
            FadePlayerRollTo(0, 10, 60);     
            MovePlayerHeadPos(0, 0, 0, 1, 0.5f);
            StartPlayerLookAt("Arealook4", 2, 2, "");
            FadePlayerFOVMulTo(1, 0.01f);
            PlaySoundAtEntity("movement", "player_climb.snt", "Player", 0, false);
            fEventSpeed = 2.0f;    
        break;
        case 17:
            SetPlayerJumpDisabled(false);
            SetPlayerCrouchDisabled(false);
            SetPlayerMoveSpeedMul(0.6f);
            SetPlayerLookSpeedMul(1.0f);
            FadeImageTrailTo(0,0.2f);
            StopPlayerLookAt();
            PlaySoundAtEntity("sigh", "react_sigh.snt", "Player", 1.0 / 1, false);
            AddTimer("lookloop", RandFloat(2.0f,6.0f), "TimerRandomLook");    //Activate the spinning head
            fEventSpeed = 1.0f;        
        break;
        case 18:
            SetEntityActive("AreaQuest", true);
            //AddQuest("00Trail","00Trail"); In LookAtQuest instead
        break;
    }
    
    if(GetLocalVarInt("BlackoutStep") < 19)  AddTimer("blackout", fEventSpeed, "TimerBlackOut");
}

I actually wan't to thank you a lot! your advise really helped me and i got it to work!
(This post was last modified: 08-12-2012, 08:21 PM by bjaffedj.)
08-12-2012, 07:33 PM
Find




Users browsing this thread: 3 Guest(s)