Unlock level door?
I can use scripts to unlock a normal door, easy. But when I try with a level door, it never works. Maybe some thing in effect is the fact that the level door is always like the 2nd locked door in the level so maybe its just a matter of combining scripts, but here you go. Here is my script- (castle_1 is the level door.)
void OnStart()
{
AddUseItemCallback("", "key_study_1", "mansion_door_1", "UseKeyOnDoor", true);
AddUseItemCallback("", "key_tomb", "castle_1", "UseKeyOnDoor2", true);
AddEntityCollideCallback("Player", "SpawnEnemy", "SpawnEnemy1", true, 1);
AddEntityCollideCallback("Player", "Script_Scare", "Scare", true, 1);
}
void SpawnEnemy1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("character_infected_1", true);
SetEntityActive("deformed_man_7", true);
SetEntityActive("deformed_man_8", true);
SetEntityActive("deformed_man_9", true);
SetEntityActive("deformed_man_10", true);
SetEntityActive("deformed_man_11", true);
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_10", 0, "");
AddEnemyPatrolNode("character_infected_1", "PathNodeArea_11", 4, "");
}
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_door_1", 0, false);
RemoveItem(asItem);
}
void UseKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem(asItem);
}
void Scare(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("deformed_man_12", true);
SetEntityActive("deformed_man_13", true);
SetEntityActive("deformed_man_14", true);
SetEntityActive("deformed_man_15", true);
}
void MoveShelf(string &in asEntity, int alState)
{
if (GetLocalVarInt("Check") == 0)
{
if (alState == 1)
{
SetMoveObjectState("Shelf", 1);
PlaySoundAtEntity("", "quest_completed.snt", "Shelf", 0, false);
SetLocalVarInt("Check", 1);
return;
}
}
}
|