The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
Script Help Switch (Case/Break thingy)
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#1
Switch (Case/Break thingy)

"Noob" question time!

Sorry, this is the first time I've tried to use this, so I probably did something stupid-obvious wrong.
Spoilers for possible length issues
Spoiler below!

What should be happening: 1. The player goes through the dream 2. Answering machine ends dream 3. Player slowly opens eyes/blinks and rolls over 4. Player sits up (phone_2 starts around here) 5. Player stands up 6. Player takes a step forward 7. Player is set active so the person can control him (phone_3 starts a little while after)
What's happening: The player goes through the 'dream' sequence all well and lovely, it fades out, lucid_phone_1 and lucid_phone_2 plays, screen still hasn't faded in. The last music, lucid_phone_3, gets stuck on look and the player is in a black-out coma. If left running for more than 15 minutes on the script, the game crashes.

I removed irrelevant parts of the script. If you think it would all be useful for answering the question, let me know so I can post all 221 lines (which could probably be condensed a lot, but I'm too lazy).

PHP Code: (Select All)
void OnStart()
{
    
AddTimer("timer_wakeup"30.0f"timer_wakeup");
    
AddTimer("timer_enddream"25.0f"timer_enddream");
    
StartPlayerLookAt("area_entitylook"1.0f2.0f"");
    
SetPlayerMoveSpeedMul(0.5f);
    
SetPlayerRunSpeedMul(0.5f);
    
PlayMusic("lucid_dream"false101false);
    
SetGlobalVarInt("NightTriggered"0);
}

void Intro()
{

}

void OnEnter()
{

}

////////////////////////////////////
//////////////SCRIPTS///////////////
////////////////////////////////////
void script_standup(string &in asParentstring &in asChildint alState)
{
    
SetLocalVarInt("var_walking"1);
    
SetPlayerCrouching(false);
    
    
AddTimer("timer_setplayeractive"0.5f"timer_setplayeractive");
}

////////////////////////////////////
///////////////TIMERS///////////////
////////////////////////////////////

void timer_setplayeractive(string &in asTimer)
{
    
SetPlayerActive(true);
    
    
StopPlayerLookAt();
    
FadeImageTrailTo(0.5f0.4f);
    
FadeRadialBlurTo(0.0f0.02f);
}

void timer_enddream(string &in asTimer)
{
    
FadeOut(1.0f);
    
StopPlayerLookAt();
    
SetPlayerActive(false);
    
SetPlayerMoveSpeedMul(1.0f);
    
SetPlayerRunSpeedMul(1.0f);
    
PlayMusic("lucid_phone_1"false102false);
    
StopMusic(0,1);
}

void timer_wakeup(string &in asTimer)
{
    
AddTimer("timer_phone2"20.0f"timer_phone2"); //start next phone message
    
AddLocalVarInt("var_wakup"1);
    
float SectionSpeed 0.0f//define SectionSpeed
    
    
switch (GetLocalVarInt("var_wakeup"))
    {
        case 
1//Teleporting player and setting up sequence
            
TeleportPlayer("PlayerStartArea_2"); //Moves player from castle to bed
            
SetPlayerCrouching(true); //places the player on the bed sheeds
            
AddEntityCollideCallback("Player""area_standup""script_standup"true1); //makes player stand up
            
MovePlayerHeadPos(0.8f, -0.8f0.0f20.0f1.0f); //player's head is on the bed
            
FadePlayerRollTo(-90.0f150.0f200.0f); //player is looking at ceiling
        
            
SectionSpeed 4.0f;
        break;
        
        case 
2:    //I don't remember why I needed this since the same thing is in the last case, but I'm leaving it in to be safe
            
FadePlayerRollTo(-90.0f1.0f1.0f);
    
            
SectionSpeed 0.5f;
        break;
    
        case 
3//fade in, blurry eyes
            
FadeIn(1.3f);
            
StartScreenShake(0.02f ,0.0f0.3f1.0f);
            
FadeRadialBlurTo(0.03f1.5f);
            
FadePlayerFOVMulTo(1.3f1.7f);
            
            
SectionSpeed 1.5f;        
        break;
    
        case 
4//fade out again
            
FadeOut(2.3f);
            
FadeRadialBlurTo(0.01f0.01f);
                
            
SectionSpeed 2.75f;
        break;
        
        case 
5//fade in, still blurry
            
FadeIn(2.5f);
            
FadeRadialBlurTo(0.03f0.02f);
            
FadePlayerFOVMulTo(0.75f0.2f);
        
            
SectionSpeed 2.75f;
        break;
    
        case 
6//blinking - kind of
            
FadeOut(2.0f);
            
FadeRadialBlurTo(0.01f0.01f);
        
            
SectionSpeed 2.5f;
        break;
    
        case 
7//opening eyes, a little blurry still
            
FadeIn(2.0f);
            
FadeRadialBlurTo(0.03f0.03f);
        
            
SectionSpeed 2.5f;
        break;

        case 
8//Roll over and sit
            
FadePlayerFOVMulTo(1.0f3.4f);
            
MovePlayerHeadPos(0.0f0.0f0.0f0.4f0.1f);
            
FadePlayerRollTo(05.0f23.0f);
            
StartPlayerLookAt("area_look1"2.0f4.0f""); //Floor
            
FadeRadialBlurTo(0.01f0.01f);
        
            
PlaySoundAtEntity("sound_rustle""player_climb.snt""Player"0.0ffalse);
        
            
SectionSpeed 3.25f;
        break;

        case 
9//stand up
            
MovePlayerForward(0.075f);
            
AddTimer("timer_standup"0.5f"timer_standup");
            
PlaySoundAtEntity("sound_standing""player_stand.snt""Player"0.0ffalse);
            
StartPlayerLookAt("area_look2"1.25f3.75f""); //Wall
            
AddTimer("timer_setplayeractive"0.25"timer_setplayeractive");
        
            
SectionSpeed 0.0f;
        break;
    }
    
    if (
GetLocalVarInt("var_wakeup") <9)
    {
        
AddTimer("timer_wakeup"SectionSpeed"timer_wakeup"); 
    }
}

void timer_standup(string &in asTimer//causes player to take a step
{
    
MovePlayerForward(0.075f);
}

void timer_phone2(string &in asTimer)
{
    
StopMusic(0,2);
    
PlayMusic("lucid_phone_2"false103false);
    
AddTimer("timer_phone3"23.0f"timer_phone3");
}

void timer_phone3(string &in asTimer)
{
    
StopMusic(0,3);
    
PlayMusic("lucid_phone_3"false104false);
}

void timer_stoplook(string &in asTimer)
{
    
StopPlayerLookAt();

My apologies if the inconsistencies in my scripting are confusing. They're caused by the change in experience; this was the second map I scripted and I just came back to it after writing 4 other map scripts and starting ENGG 233 (Computing for Engineers - it's a computer software course based around C++).

I'm sorry if this question's been answered a million times, I tried searching "case break" on the forum to double-check, but I couldn't find anything that might be similar to my problem (usually, I have to actually do something to understand it :p).

Thanks for the help - in case I forget to thank you personally for some reason.

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 09-25-2013, 07:58 AM by CarnivorousJelly.)
09-25-2013, 07:55 AM
Find


Messages In This Thread
Switch (Case/Break thingy) - by CarnivorousJelly - 09-25-2013, 07:55 AM
RE: Switch (Case/Break thingy) - by Daemian - 09-25-2013, 12:00 PM
RE: Switch (Case/Break thingy) - by Kreekakon - 09-25-2013, 06:48 PM



Users browsing this thread: 1 Guest(s)