Frictional Games Forum (read-only)
2 keys script - 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: 2 keys script (/thread-13893.html)

Pages: 1 2


2 keys script - FlawlessHappiness - 03-10-2012

I'm having 2 keys in my map.

The first key you can pick up unlocks a door into another room.
On the way to the locked door, you pass another locked door. But when you unlock the door with the valid key, the other door becomes unlocked automatic... However the next key still works on the newly unlocked door...
Here is my script:

////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
RemoveItem("key1");

SetSwingDoorLocked("door2", false, true);
PlaySoundAtEntity("", "unlock_door", "door2", 0, false);
RemoveItem("key2");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

What is wrong?


RE: 2 keys script - flamez3 - 03-10-2012

////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor", true);
}

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

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
Use this one: They don't figure themselves out. If you put those veents in there, the game will do both of them, not in the order you put them in.




RE: 2 keys script - Stepper321 - 03-10-2012

Quote:////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor2", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
RemoveItem("key1");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door2", false, true);
PlaySoundAtEntity("", "unlock_door", "door2", 0, false);
RemoveItem("key2");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
No it's this one.


RE: 2 keys script - FlawlessHappiness - 03-10-2012

Yay it works!!! Big Grin

I occured another question not related to the keys...

I have a room with 2 locked doors.
In the middle is a table with a note.
Behind one of the doors is a monster.

I already set up the pathnotes (there is only 1)
and made the monster inactive.

Now i want it to go break the door (by just following the pathnote) when i pick up the note.
But i cant make it work.
Script:

////////////////////////////
// Run first time starting map
void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

void SetEntityCallbackFunc("note3", "OnPickup");
{
void OnPickup(string &in asItem, string &in asEntity)
{
SetEntityActive("PlayerCollide", true);
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("monster1", true);
AddEnemyPatrolNode("monster1", "PathNodeArea_1", 0, "");
}
}
}


RE: 2 keys script - Stepper321 - 03-10-2012

You are doing much wrong, you can't do a void in the callbacks, and there must be an } after any callbacks.
not after you did it all, i can't fix this sorry, its too messed for me Sad


RE: 2 keys script - flamez3 - 03-10-2012

(03-10-2012, 12:14 PM)Stepper321 Wrote:
Quote:////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor2", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
RemoveItem("key1");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door2", false, true);
PlaySoundAtEntity("", "unlock_door", "door2", 0, false);
RemoveItem("key2");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
No it's this one.
Correction: Both work.


(03-10-2012, 12:43 PM)Stepper321 Wrote: You are doing much wrong, you can't do a void in the callbacks, and there must be an } after any callbacks.
not after you did it all, i can't fix this sorry, its too messed for me Sad
Those are not callbacks.


RE: 2 keys script - FlawlessHappiness - 03-10-2012

Instead of editing it, could you then try doing it the right way?

On pickup - Monster spawn..


RE: 2 keys script - flamez3 - 03-10-2012


void OnStart()
{
SetEntityPlayerInteractCallback("notename", "MonsterSpawm", true);
}

void MonsterSpawn(string &in asEntity)
{
SetEntityActive("monstername", true);
}


RE: 2 keys script - FlawlessHappiness - 03-10-2012

It doesn't work... yes my FATAL ERROR messages disappear, but the monster spawn, or begin its pathnode... i tried editing after what you did, with no luck.
I tried making the area get active when i pick up the node and then the area will make the monster spawn... but i guess it is impossible to use notes to trigger anything...


RE: 2 keys script - flamez3 - 03-10-2012

No, you can trigger things with notes. Using the exact way I said. Post the scri[t of the edited version.