Frictional Games Forum (read-only)
Maps change other maps - 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: Maps change other maps (/thread-15414.html)



Maps change other maps - lllDash - 05-14-2012

I've built a puzzle that is situated in "Level_4" that is meant to make a static entity non-static in "Level_2". I've looked for some examples in custom stories and even "dark descent" script files to hopefully understand how to do it but it's hard to find an example if i don't know what it looks like. I've even gone through http://wiki.frictionalgames.com/hpl2/amnesia/script_functions#global
help please? Rolleyes


PS I know how to make an entity static. I just need an example of how to make it affect entities in other maps.


RE: Maps change other maps - Putmalk - 05-14-2012

SetGlobalVarInt function should do the trick.

Set the variable in level_4, and in level_2, do a check:

Code:
if(GetGlobalVarInt("variable") == 1)
{
//do stuff
}



RE: Maps change other maps - FragdaddyXXL - 05-15-2012

And you'll need to set up a global.hps file in your maps folder.

Here's an example of what's in mine at the moment:

Code:
////////////////////////////
// Run at the start of the game.
void OnGameStart()
{
    SetGlobalVarInt("lockdown", 0); //0: lockdown is ON  || 1: Lockdown is OFF
}

Now you can get the global variable from any .hps file in your custom story.


RE: Maps change other maps - lllDash - 05-17-2012

(05-15-2012, 12:40 AM)FragdaddyXXL Wrote: And you'll need to set up a global.hps file in your maps folder.

Here's an example of what's in mine at the moment:

Code:
////////////////////////////
// Run at the start of the game.
void OnGameStart()
{
    SetGlobalVarInt("lockdown", 0); //0: lockdown is ON  || 1: Lockdown is OFF
}

Now you can get the global variable from any .hps file in your custom story.
OH! Big Grin I get it now. thanks guys. let me guess, global.hps must be placed in the main folder of the CS, right?


RE: Maps change other maps - Putmalk - 05-17-2012

Yeah, you can just check how Frictional did it and emulate it...it should be outside the maps folder IIRC.

Do you really need the global.hps though? I don't think I used one when I made my global variables in the past....


RE: Maps change other maps - lllDash - 05-18-2012

(05-17-2012, 03:33 PM)Putmalk Wrote: Yeah, you can just check how Frictional did it and emulate it...it should be outside the maps folder IIRC.

Do you really need the global.hps though? I don't think I used one when I made my global variables in the past....
Well then...that would mean there are 2 different ways of doing it, can you show me an example of what you would put in "level1" (the level that triggers) and what you would put in "level2"? (the level that is triggered by "level1")


RE: Maps change other maps - FragdaddyXXL - 05-18-2012

Say you have a lever in level 2 that opens a door in level 1.

Level 1:
Quote: In the OnEnter() function, check your global variable with an if-else statement to see if it has changed from it's initial value.
Code:
void OnEnter()
{
    CheckPoint("WaveChpt", "PlayerStartArea_FromLevel2", "ResetWave", "", "");
    AddTimer("SanityTimer", 0.5f, "UpdateSanity"); //Set up a timer on entry.
    int temp = GetGlobalVarInt("lockdown");
    if(temp == 1)
    {        
        AddEntityCollideCallback("Player", "ScriptArea_FinalWave", "FinalWave", true, 1);
        AddTimer("TriggerBrute2", 4.0f, "SpawnBrute");        
    }
    
}

Now, in level 2, set the lever to change the global variable from 0 to 1.

Code:
void StopLockdown(string &in asEntity, int alState)
{
    
    if(alState <= -0.9)
    {
        PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);        
        StartScreenShake(0.1f, 6.0f, 1.0f, 1.4f);        
        PlaySoundAtEntity("", "21_alex_low_freq_rumble2.snt", "Player", 0, false);        
        SetMessage("Messages", "SwitchMessage", 9);
        SetGlobalVarInt("lockdown", 1);        
    }    
    
}

(Ripped this straight from one of my CSs, so sorry about the extra code Tongue)


RE: Maps change other maps - lllDash - 05-18-2012

Thanks for that. I'll give it a try.


RE: Maps change other maps - lllDash - 05-20-2012

I've only tested it now and.....IT WORKS! thanks for the help guys. [Image: biggrin.gif] And thank you FragdaddyXXL for showing me all 3 examples of your script.


RE: Maps change other maps - FragdaddyXXL - 05-20-2012

No problem! Big Grin Glad it helped.