Frictional Games Forum (read-only)

Full Version: Maps change other maps
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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/amn...ons#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.
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
}
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.
(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?
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....
(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")
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)
Thanks for that. I'll give it a try.
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.
No problem! Big Grin Glad it helped.