Frictional Games Forum (read-only)
Level door - 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: Level door (/thread-7838.html)

Pages: 1 2


Level door - Karai16 - 05-06-2011

Hey guys,
I need to fix something: I've locked my level door, but I can still go through it, even though it's locked. Is there a way I can only make the shifting map code of my script work if the door is open?


RE: Level door - dragonlordsd - 05-06-2011

you mean you can still open it, or that you can walk through it?


RE: Level door - Karai16 - 05-06-2011

(05-06-2011, 11:49 PM)dragonlordsd Wrote: you mean you can still open it, or that you can walk through it?

I am able to use it, as in opening it, and go to the other map, even though it's locked.


RE: Level door - Kyle - 05-06-2011

If in the editor it says it is locked, then check your files and delete the .mapcache file for your map if it is there.


RE: Level door - Karai16 - 05-07-2011

(05-06-2011, 11:57 PM)Kyle Wrote: If in the editor it says it is locked, then check your files and delete the .mapcache file for your map if it is there.

I tried it, it doesn't work, to help you think of a solution, I'll give you the code I'm using:
Code:
void OnStart()
{
    AddUseItemCallback("", "TowerKey", "TowerDoor", "UsedKeyOnDoor", true);
SetEntityPlayerInteractCallback("TowerDoor", "TeleportFunction", true);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("TowerDoor", false, true);
    PlaySoundAtEntity("", "unlock_door", "TowerDoor", 0, false);
    RemoveItem("TowerKey");
}

void TeleportFunction(string &in asEntity)
{
ChangeMap("Custom02", "PlayerStartArea_1", "", "");
}
do I maybe have to do something with an if-statement? It does look like it, but I don't know how to use it, or if it can be used in hps language.


RE: Level door - dragonlordsd - 05-07-2011

Umm... why are you teleporting the player to change maps? Doesn't the door just automatically link to the next map?


RE: Level door - Kyle - 05-07-2011

(05-07-2011, 12:41 AM)dragonlordsd Wrote: Umm... why are you teleporting the player to change maps? Doesn't the door just automatically link to the next map?

Yeah, it does.

I see your mistake, you added a interact callback; that means that when ever the player touches the door, he teleports.
Code:
void OnStart()
{
AddUseItemCallback("", "TowerKey", "TowerDoor", "UsedKeyOnDoor", true);
SetEntityPlayerInteractCallback("TowerDoor", "TeleportFunction", true);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("TowerDoor", false, true);
    PlaySoundAtEntity("", "unlock_door", "TowerDoor", 0, false);
    RemoveItem("TowerKey");
}

void TeleportFunction(string &in asEntity)
{
if (GetSwingDoorLocked("TowerDoor") == false)
{
ChangeMap("Custom02", "PlayerStartArea_1", "", "");
}
}
This might work? But it's not a swing door. :/

Whoops... Alright, fixed that.


RE: Level door - Roenlond - 05-07-2011

I'd remove all the scripting and just go via the level editor for level doors, it's a lot easier.


RE: Level door - Karai16 - 05-07-2011

I tried doing it in the level editor, but now the key won't unlock the door... :/


RE: Level door - Russ Money - 05-07-2011

(05-07-2011, 09:37 AM)Karai16 Wrote: I tried doing it in the level editor, but now the key won't unlock the door... :/

The command you're looking for, to set the level door unlocked is this:
Code:
SetLevelDoorLocked(string& asName, bool abLocked);

Swing doors are the doors that move when push or pulled.