Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Door set to locked, but unlocked?
Asaratha Offline
Junior Member

Posts: 14
Threads: 5
Joined: Jul 2011
Reputation: 0
#1
Door set to locked, but unlocked?

Hey, guys!

So, in my custom story I have a door set to "locked" and you must grab a key and you know, use it to unlock it.

Keys name = key_2
Doors name = keydoor_2

void OnStart()

{
AddUseItemCallback("", "key_1", "keydoor_1", "KeyOnDoor", true);
AddUseItemCallback("", "hidden_key", "hidden_door", "KeyOnHiddenDoor", true);
SetEntityPlayerInteractCallback("key_2", "Spawn_Monster", true);
AddUseItemCallback("", "key_2", "keydoor_2", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("keydoor_1", false, true);
    PlaySoundAtEntity("", "unlock_door", "keydoor_1", 0, false);
    RemoveItem("key_1");
    SetSwingDoorLocked("keydoor_2", false, true);
    PlaySoundAtEntity("", "unlock_door", "keydoor_2", 0, false);
    RemoveItem("key_2");
}
void Spawn_Monster(string &in entity)
{
    SetEntityActive("grunt", true);
    AddEnemyPatrolNode("grunt", "PathNodeArea_1", 2, "");
    AddEnemyPatrolNode("grunt", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("grunt", "PathNodeArea_3", 4, "");
}

For some reason, the door is always unlocked and I just can't get it to stay locked.

Any ideas?
08-01-2011, 04:23 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Door set to locked, but unlocked?

Where did you tell the script to lock it?

Tutorials: From Noob to Pro
08-01-2011, 04:54 PM
Website Find
Asaratha Offline
Junior Member

Posts: 14
Threads: 5
Joined: Jul 2011
Reputation: 0
#3
RE: Door set to locked, but unlocked?

I didn't, it is set to locked in the level editor.
08-01-2011, 08:23 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Door set to locked, but unlocked?

(08-01-2011, 08:23 PM)Asaratha Wrote: I didn't, it is set to locked in the level editor.

I know that, but it seems i should have checked your code for more than syntax and function parameter errors. The code logic seems to be wrong.

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

So you want both doors to open at the same time when opening either door?


Tutorials: From Noob to Pro
08-01-2011, 08:41 PM
Website Find
Asaratha Offline
Junior Member

Posts: 14
Threads: 5
Joined: Jul 2011
Reputation: 0
#5
RE: Door set to locked, but unlocked?

(08-01-2011, 08:41 PM)Your Computer Wrote:
(08-01-2011, 08:23 PM)Asaratha Wrote: I didn't, it is set to locked in the level editor.

I know that, but it seems i should have checked your code for more than syntax and function parameter errors. The code logic seems to be wrong.

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

So you want both doors to open at the same time when opening either door?

No. It worked before I added the monster if I recall correctly. Both doors are locked, you find the key near the beginning and open the first door. That room leads you to another room with 2 doors, you go through the first (unlocked) door. You get to a destroyed room and you pick up a key that opens the next one in the other room. It also sets up a monster. When you get back to the room, you use the key to unlock the door leading to a kitchen.

BUT, for some reason, the kitchen door (door2) is always unlocked.
08-01-2011, 09:00 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: Door set to locked, but unlocked?

(08-01-2011, 09:00 PM)Asaratha Wrote: No. It worked before I added the monster if I recall correctly. Both doors are locked, you find the key near the beginning and open the first door. That room leads you to another room with 2 doors, you go through the first (unlocked) door. You get to a destroyed room and you pick up a key that opens the next one in the other room. It also sets up a monster. When you get back to the room, you use the key to unlock the door leading to a kitchen.

BUT, for some reason, the kitchen door (door2) is always unlocked.
So nowhere in the code you posted is the kitchen door referenced? If so, then try not relying on the level editor and do so in the script. If not, then add conditional statements to your KeyOnDoor function. Also, for future reference, you may want to be more specific with naming your variables; that is, "key_#" and "keydoor_#" is too vague.

Tutorials: From Noob to Pro
08-01-2011, 09:19 PM
Website Find




Users browsing this thread: 1 Guest(s)