Frictional Games Forum (read-only)
[SCRIPT] Intro script help and monster nodes [SOLVED] - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Intro script help and monster nodes [SOLVED] (/thread-24175.html)

Pages: 1 2 3


RE: Intro script help - daortir - 12-27-2013

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.


RE: Intro script help - lothabread - 12-28-2013

(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:
////////////////////////////
// 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);




RE: Intro script help - Romulator - 12-28-2013

PHP Code:
    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:
if(GetLocalVarInt("iIntroPart") < 6)    
{
AddTimer("tmrIntro"partSpeed"introSequence");     
}




RE: Intro script help - lothabread - 12-28-2013

(12-28-2013, 02:30 AM)Romulator Wrote:
PHP Code:
    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:
if(GetLocalVarInt("iIntroPart") < 6)    
{
AddTimer("tmrIntro"partSpeed"introSequence");     
}


that didnt work, hmm i wonder what the problem might be UndecidedHuh


RE: Intro script help - Slanderous - 12-28-2013

If you have .map_cache file in your maps, try to delete this file. Only
"yourmap.map_cache" maybe that will help


RE: Intro script help - lothabread - 12-28-2013

(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.


RE: Intro script help - Damascus - 12-29-2013

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.


RE: Intro script help - lothabread - 12-29-2013

(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


RE: Intro script help - daortir - 12-29-2013

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.


RE: Intro script help and monster nodes - lothabread - 12-29-2013

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