Frictional Games Forum (read-only)
[SCRIPT] How to unluck a door from another map? - 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] How to unluck a door from another map? (/thread-15192.html)

Pages: 1 2


How to unluck a door from another map? - z3akx - 04-30-2012

Hi. So i have one map where the front door is blocked from the inside, but there is a back entrence and in the house you can destroy the blockade and use the front door to get back out
But i can't find a way to make the outside door unlucked after the blockade is broken

Please help Big Grin



RE: How to unluck a door from another map? - SilentStriker - 04-30-2012

Use SetSwingDoorLocked to unlock the door.



RE: How to unluck a door from another map? - FragdaddyXXL - 04-30-2012

Perhaps you could use global variables. Here's a snippet of code where I'm almost doing the same exact thing:
Code:
void OnEnter()
{
    AddTimer("SanityTimer", 0.5f, "UpdateSanity"); //Set up a timer on entry.
    if(GetGlobalVarInt("lockdown") == 1)
    {
        SetSwingDoorLocked("metal_1", false, false);
        AddEntityCollideCallback("Player", "ScriptArea_FinalWave", "FinalWave", true, 1);        
    }
}

Just need to set up a global variable that changes when the user removes the blockade. Upon entering the level with the exit, check and see if the global variable has changed. If it has, unlock the door.



RE: How to unluck a door from another map? - SilentStriker - 04-30-2012

What kind of blockade is it btw? since you can always use the built in PlayerInteractionCallback in the entity and then call SetSwingDoorLocked from there Smile



RE: How to unluck a door from another map? - z3akx - 04-30-2012

(04-30-2012, 04:58 PM)FragdaddyXXL Wrote: Perhaps you could use global variables. Here's a snippet of code where I'm almost doing the same exact thing:
Code:
void OnEnter()
{
    AddTimer("SanityTimer", 0.5f, "UpdateSanity"); //Set up a timer on entry.
    if(GetGlobalVarInt("lockdown") == 1)
    {
        SetSwingDoorLocked("metal_1", false, false);
        AddEntityCollideCallback("Player", "ScriptArea_FinalWave", "FinalWave", true, 1);        
    }
}

Just need to set up a global variable that changes when the user removes the blockade. Upon entering the level with the exit, check and see if the global variable has changed. If it has, unlock the door.
I wouldn't say right off that that wouldn't work cause im not good with the global variable thing infact i dont know what it actual do Smile


But its 2 diffrent maps

that that in "Forest.map" the door is locked ((blocked from the inside) which is in AbandonedHouse.map)

And in AbandonedHouse.map the door is blocked so when the blockade is removed you can go outside into Forest.map but you can't go inside since the door is still locked :-)
(04-30-2012, 05:01 PM)SilentStriker Wrote: What kind of blockade is it btw? since you can always use the built in PlayerInteractionCallback in the entity and then call SetSwingDoorLocked from there Smile
In the map editor Entities\gameplay\wooden_boards_block (the second last) :-)


RE: How to unluck a door from another map? - SilentStriker - 04-30-2012

Ok so then use the
SetLevelDoorLocked(string& asName, bool abLocked);

to unlock the level door. And if you press the blockade and in the entity tab you find PlayerInteractCallback use that to call a function when removing the blockade and then use the SetLevelDoorLocked code to unlock it Smile

unless you use a hammer or something to remove the blockade then you just use the SetLevelDoorLocked inside the script you have to remove the blockade Smile





RE: How to unluck a door from another map? - z3akx - 04-30-2012

(04-30-2012, 05:18 PM)SilentStriker Wrote: Ok so then use the
SetLevelDoorLocked(string& asName, bool abLocked);

to unlock the level door. And if you press the blockade and in the entity tab you find PlayerInteractCallback use that to call a function when removing the blockade and then use the SetLevelDoorLocked code to unlock it Smile

unless you use a hammer or something to remove the blockade then you just use the SetLevelDoorLocked inside the script you have to remove the blockade Smile
Okay so a script in AbandonedHouse.hps can CallBack something in Forest.hps? Big Grin




RE: How to unluck a door from another map? - SilentStriker - 04-30-2012

hmm forgot about that the door in forest.hps have to be unlocked too.... hmm then you have to use a global variable. I can teach you how to use a global variable if you want Smile



RE: How to unluck a door from another map? - z3akx - 04-30-2012

hah oh yeah please teach me Big Grin!

The door in the house is the not problem it's the one in the Forest :-)


RE: How to unluck a door from another map? - SilentStriker - 04-30-2012

Yes I realized that xD

ok so to make a global variable to work you need to make a global.hps file that you put inside your maps folder.

then inside the global.hps you write this

Code:
////////////////////////////
// Run at the start of the game.
void OnGameStart()
{
SetGlobalVarInt("NAMEOFVARIABLE", 0);}

then open your forest.hps and inside OnEnter() you write this:

Code:
void OnEnter()
{
if(GetGlobalVarInt("NAMETHEGLOBALVARIABLE") == 1)
{
SetLevelDoorLocked("NAMEOFLEVELDOOR", false);
}

else return;
}

then to make the global variable 1 since it was 0, you add this in the same function in AbandonedHouse.hps as the SetLevelDoorLocked code.

Code:
AddGlobalVarInt("NAMEOFTHEGLOBALVAR", 1);

I think I got everything ^^