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 Intro script help and monster nodes [SOLVED]
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#11
RE: Intro script help

Here's how the case script work : >. I learnt this yesterday because timers are a bit more messy and I needed to make the intro sequence for my mod.

First of all you need something that will call the Intro sequence at the beginning of the game.
Like :


void OnStart()
{
FadeOut(0);
AddTimer("StartGame", 1, "introSequence");
}

FadeOut(0); is there to make the screen black instantly at the beginning of the game.

Then there's the sequence, it will call cases one by one, and the time between every case will be the one you choose. More on that later.

void introSequence(string &in asTimer)
{
AddLocalVarInt("iIntroPart", 1);
float partSpeed = 1.5f;
switch (GetLocalVarInt("iIntroPart"))
{
case 1:
Between the case number and the break, put anything you want to happen ! This is where the events of the sequence should be. You set the time before the next case is called by putting the line between case 1 and break; .

partSpeed = 5.0f;

(- This makes the part 5 seconds before another "case" is called. You can make it as long as you want, if you don't set it it will use the default speed that we set just above : float partSpeed=1.5f.)
break;


case 2:


There you go, the next step in your intro sequence !

break;


Now it's time to finish the function.

}

if (GetLocalVarInt("iIntroPart") <2)
{
AddTimer("tmrIntro", partSpeed, "introSequence");
}
}

What happens during the sequence, exactly, is that the function introSequence is called. It starts by calling case 1, then if there are other cases to call it calls itself again, but this time it does case 2, etc.

The if (GetLocalVarInt("iIntroPart") <2) doesn't have to be 2, it has to be the number of parts/cases you have.

Oh, last thing : you might want to add this

void OnEnter()
{
SetLocalVarInt("iIntroPart", 0);
}

at the beginning of your .hps file. Not sure if it really matters, but well it doesn't hurt.

Hopefully this was clear enough, I had quite a bit of trouble understanding how cases work so I'm glad if I can help people out with that : D. Ask questions if I didn't explain well, and have a cookie while you're here.

12-27-2013, 10:30 PM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#12
RE: Intro script help

(12-27-2013, 10:30 PM)daortir Wrote: Here's how the case script work : >. I learnt this yesterday because timers are a bit more messy and I needed to make the intro sequence for my mod.

First of all you need something that will call the Intro sequence at the beginning of the game.
Like :


void OnStart()
{
FadeOut(0);
AddTimer("StartGame", 1, "introSequence");
}

FadeOut(0); is there to make the screen black instantly at the beginning of the game.

Then there's the sequence, it will call cases one by one, and the time between every case will be the one you choose. More on that later.

void introSequence(string &in asTimer)
{
AddLocalVarInt("iIntroPart", 1);
float partSpeed = 1.5f;
switch (GetLocalVarInt("iIntroPart"))
{
case 1:
Between the case number and the break, put anything you want to happen ! This is where the events of the sequence should be. You set the time before the next case is called by putting the line between case 1 and break; .

partSpeed = 5.0f;

(- This makes the part 5 seconds before another "case" is called. You can make it as long as you want, if you don't set it it will use the default speed that we set just above : float partSpeed=1.5f.)
break;


case 2:


There you go, the next step in your intro sequence !

break;


Now it's time to finish the function.

}

if (GetLocalVarInt("iIntroPart") <2)
{
AddTimer("tmrIntro", partSpeed, "introSequence");
}
}

What happens during the sequence, exactly, is that the function introSequence is called. It starts by calling case 1, then if there are other cases to call it calls itself again, but this time it does case 2, etc.

The if (GetLocalVarInt("iIntroPart") <2) doesn't have to be 2, it has to be the number of parts/cases you have.

Oh, last thing : you might want to add this

void OnEnter()
{
SetLocalVarInt("iIntroPart", 0);
}

at the beginning of your .hps file. Not sure if it really matters, but well it doesn't hurt.

Hopefully this was clear enough, I had quite a bit of trouble understanding how cases work so I'm glad if I can help people out with that : D. Ask questions if I didn't explain well, and have a cookie while you're here.

hmm alrighty well i still cant get past the first case so i must be doing something wrong, dunno what though D:
PHP Code: (Select All)
////////////////////////////
// Run when starting game
void OnStart()
{
    if(
ScriptDebugOn())
          {
               
GiveItemFromFile("lantern""lantern.ent");
               
SetPlayerLampOil(100.0f);
 
               for(
int i 0;10;i++)
               {
                    
GiveItemFromFile("tinderbox""tinderbox.ent");
               }
          }
    
SetSanityDrainDisabled(true);
    
SetPlayerCrouching(true);
    
SetPlayerActive(false);
    
FadeOut(0);
    
AddTimer("StartGame"6.0f"IntroSequence");
}

void IntroSequence(string &in asTimer)
{
    
AddLocalVarInt("iIntroPart"1);
    
float partSpeed 0.5f;
    switch(
GetLocalVarInt("iIntroPart")) {
        case 
1:
            
PlayGuiSound(""1.0f);
            
FadeIn(6.0f);
            
StartPlayerLookAt("AreaIntroLook_2"1.0f1.0f"");
            
FadePlayerRollTo(-450.88);
            
partSpeed 1.0f;
        break;
        
        case 
2:
            
StartPlayerLookAt("AreaIntroLook_4"1.0f1.0f"");
            
partSpeed 1.0f;
        break;
        
        case 
3:
            
StartPlayerLookAt("AreaIntroLook_3"1.0f1.0f"");
            
PlayGuiSound(""0.7f);
            
FadeOut(3.0f);
            
partSpeed 1.0f;
        break;
        
        case 
4:
            
FadeIn(6.0f);
            
SetPlayerLookSpeedMul(0.06f);
            
StartPlayerLookAt("AreaIntroLook_1"1.0f1.0f"");
            
partSpeed 1.0f;
        break;
        
        case 
5:
            
StartPlayerLookAt("AreaIntroLook_2"1.0f1.0f"");
            
FadeOut(8.0f);
            
PlayGuiSound(""0.8f);
            
partSpeed 1.0f;
        break;
    }
    
    if(
GetLocalVarInt("iIntroPart") < 6)    AddTimer("tmrIntro"partSpeed"introSequence");     
}

void monster(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("engineer_1"true);
    
    
AddEnemyPatrolNode("engineer_1""PathNodeArea_1"0"");
    
AddEnemyPatrolNode("engineer_1""PathNodeArea_2"0.001"");
    
AddEnemyPatrolNode("engineer_1""PathNodeArea_3"0"");
}

////////////////////////////
// Run when entering map
void OnEnter()
{
    
SetLocalVarInt("iIntroPart"0);

12-28-2013, 02:04 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#13
RE: Intro script help

PHP Code: (Select All)
    if(GetLocalVarInt("iIntroPart") < 6)    AddTimer("tmrIntro"partSpeed"introSequence");     


I THINK this may be your problem. I never have used cases, but comparing it to daortir's this was all I could find different. Try this?

PHP Code: (Select All)
if(GetLocalVarInt("iIntroPart") < 6)    
{
AddTimer("tmrIntro"partSpeed"introSequence");     
}


Discord: Romulator#0001
[Image: 3f6f01a904.png]
12-28-2013, 02:30 AM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#14
RE: Intro script help

(12-28-2013, 02:30 AM)Romulator Wrote:
PHP Code: (Select All)
    if(GetLocalVarInt("iIntroPart") < 6)    AddTimer("tmrIntro"partSpeed"introSequence");     


I THINK this may be your problem. I never have used cases, but comparing it to daortir's this was all I could find different. Try this?

PHP Code: (Select All)
if(GetLocalVarInt("iIntroPart") < 6)    
{
AddTimer("tmrIntro"partSpeed"introSequence");     
}


that didnt work, hmm i wonder what the problem might be UndecidedHuh
12-28-2013, 03:40 AM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#15
RE: Intro script help

If you have .map_cache file in your maps, try to delete this file. Only
"yourmap.map_cache" maybe that will help
12-28-2013, 12:28 PM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#16
RE: Intro script help

(12-28-2013, 12:28 PM)Lazzer Wrote: If you have .map_cache file in your maps, try to delete this file. Only
"yourmap.map_cache" maybe that will help

nope, that didnt work either, this is a very odd problem.
12-28-2013, 05:05 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#17
RE: Intro script help

I notice in each of your cases you have the line"partSpeed = 1.0f" when it should be "float partSpeed = 1.0f". I think that is probably where your problem is; it's messing up the script before it resets. Everything else looks pretty solid, other than perhaps capitalizing "introSequence" in the last line of the timer, but I don't think it's case-sensitive.

(This post was last modified: 12-29-2013, 01:02 AM by Damascus.)
12-29-2013, 01:01 AM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#18
RE: Intro script help

(12-29-2013, 01:01 AM)Damascus Wrote: I notice in each of your cases you have the line"partSpeed = 1.0f" when it should be "float partSpeed = 1.0f". I think that is probably where your problem is; it's messing up the script before it resets. Everything else looks pretty solid, other than perhaps capitalizing "introSequence" in the last line of the timer, but I don't think it's case-sensitive.

alrighty, well i tried "float partSpeed = 1.0f", but it didnt work, instead gave me errors, so i undid that, and after very very close looking at the last line of the timer... i realized that the "i" in "introSequence" was supposed to be capitalized. thank you and to everybody that helped Big Grin i appreciate it
12-29-2013, 03:12 AM
Find
daortir Offline
Senior Member

Posts: 422
Threads: 9
Joined: Sep 2013
Reputation: 18
#19
RE: Intro script help

This is why scripting gives cancer and is the true incarnation of cosmic terror. Stay away from the things that sleep between the lines of code. Once they see you, you will never be alone again.

12-29-2013, 03:28 AM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#20
RE: Intro script help and monster nodes

alrighty, a past problem has returned, the manpig will not walk on his own until he sees the player, but i want the player to watch the pig leave the room as they are waking up, dunno why he wont move Big Grin
12-29-2013, 05:04 AM
Find




Users browsing this thread: 1 Guest(s)