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
unlocking a door -updated with new problem
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#1
unlocking a door -updated with new problem

Trying to unlock a door with a key, but the key isn't working for some reason. The game tells me that I can't use the item in this way.

I have it set up so that a lever needs to be pulled to progress through the story, but when it's pulled, it locks the door to the room the player is in. They have to find the key, then use it to unlock the door, etc. Easy stuff. But I can't figure out what I'm doing wrong.

Here's the entire code so far:

PHP Code: (Select All)
void OnStart()
{
    
SetEntityConnectionStateChangeCallback("lever""func_shelf");
    
AddUseItemCallback("""MasterRoomKey""MasterRoomDoor""unlock_door"true);
}

void func_shelf(string &in asEntityint alState)
{
    if (
alState == 1)
{
    
SetSwingDoorLocked("MasterRoomDoor"truetrue);
    
SetLampLit("light1room2"falsetrue);
    
SetLampLit("light2room2"falsetrue);
    
SetLampLit("light3room2"falsetrue);
    
SetLampLit("light4room2"falsetrue);
    
SetLampLit("light5room2"falsetrue);
    
SetLampLit("light6room2"falsetrue);
    
SetLampLit("light7room2"falsetrue);
    
SetLampLit("light8room2"falsetrue);
    
SetLampLit("light9room2"falsetrue);
    
SetLampLit("light1hall1"falsetrue);
    
SetLampLit("light2hall1"falsetrue);
    
SetLampLit("light3hall1"falsetrue);
    
SetLampLit("light4hall1"falsetrue);
    
SetLampLit("light5hall1"falsetrue);
    
SetLampLit("light6hall1"falsetrue);
    
SetLampLit("light7hall1"falsetrue);
    
SetLampLit("light8hall1"falsetrue);
    
SetLampLit("light1room1"falsetrue);
    
SetLampLit("light2room1"falsetrue);
    
SetLampLit("light3room1"falsetrue);
    
SetLampLit("light4room1"falsetrue);
    
SetLampLit("light5room1"falsetrue);
    
SetLampLit("light6room1"falsetrue);
    
SetLampLit("light7room1"falsetrue);
    
SetLampLit("light8room1"falsetrue);
    
SetLightVisible("point1room2"false);
    
SetLightVisible("point2room2"false);
    
SetLightVisible("point3room2"false);
    
SetLightVisible("point4room2"false);
    
SetLightVisible("point5room2"false);
    
SetLightVisible("point6room2"false);
    
SetLightVisible("point7room2"false);
    
SetLightVisible("point8room2"false);
    
SetLightVisible("point9room2"false);
    
SetLightVisible("point1hall1"false);
    
SetLightVisible("point2hall1"false);
    
SetLightVisible("point3hall1"false);
    
SetLightVisible("point4hall1"false);
    
SetLightVisible("point5hall1"false);
    
SetLightVisible("point6hall1"false);
    
SetLightVisible("point7hall1"false);
    
SetLightVisible("point8hall1"false);
    
SetLightVisible("point1room1"false);
    
SetLightVisible("point2room1"false);
    
SetLightVisible("point3room1"false);
    
SetLightVisible("point4room1"false);
    
SetLightVisible("point5room1"false);
    
SetLightVisible("point6room1"false);
    
SetLightVisible("point6room1"false);
    
SetLightVisible("point8room1"false);
    
SetMoveObjectState("shelf"1.0f);
    
SetEntityActive("hallwaypoofer"true);
    
PlaySoundAtEntity("""quest_completed.snt""rotatearea"0false);
        return;
    }
}

void FUNCTION(string &in itemstring &in door)
{
    
SetSwingDoorLocked(doorfalsetrue);
    
PlaySoundAtEntity("""unlock_door"door0false);
    
RemoveItem(item);


And here's the part for those of you who only care about stuff pertaining to the key.

PHP Code: (Select All)
void OnStart()
{
    
SetEntityConnectionStateChangeCallback("lever""func_shelf");
    
AddUseItemCallback("""MasterRoomKey""MasterRoomDoor""unlock_door"true);
}

void FUNCTION(string &in itemstring &in door)
{
    
SetSwingDoorLocked(doorfalsetrue);
    
PlaySoundAtEntity("""unlock_door"door0false);
    
RemoveItem(item);


EDIT: While looking at this again, I'm pretty sure I see what's wrong. Let me try something, will update in a second.

Yep, I fixed it. Lol. Sorry! I feel stupid...

Alright, I'm not going to create a new thread for a new issue. Just going to ask here.

I have a poofer set up, as you can see in the code above. When the player gets to a set area, the poofer appears, but just stands there. I was hoping he would run to the player, then poof.

What do I do to make it so that he runs to the player?

So you guys can see the problem I'm having, I have provided a screenshot. I was hoping that opening the door would make him run RIGHT to me, then poof. Instead, here's what happens.

[Image: zDvB]

He just spawns, then stands there. Sometimes, he's facing the other way, sometimes, that way. but I have to walk directly up to him for him to poof, or stand there for a few seconds before he sees me and starts running.
(This post was last modified: 06-08-2012, 10:10 PM by Ananaias.)
06-08-2012, 09:46 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#2
RE: unlocking a door -updated with new problem

*cough* http://wiki.frictionalgames.com/hpl2/amn...ns#enemies *cough*

"What you think is irrelevant" - A character of our time

A Christmas Hunt
06-08-2012, 11:24 PM
Find
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#3
RE: unlocking a door -updated with new problem

I have no clue what to do with any of that, though. I tried putting in

void ShowEnemyPlayerPosition(string& asName);

in my script, but I got an error. Not sure where to put it Sad
(This post was last modified: 06-09-2012, 12:57 AM by Ananaias.)
06-09-2012, 12:57 AM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#4
RE: unlocking a door -updated with new problem

void func_shelf(string &in asEntity, int alState)
{
if(alState == 1)
{
bla bla bla
SetLightVisible("point6room1", false);
SetLightVisible("point8room1", false);
SetMoveObjectState("shelf", 1.0f);
SetEntityActive("hallwaypoofer", true);
PlaySoundAtEntity("", "quest_completed.snt", "rotatearea", 0, false);
ShowEnemyPlayerPosition("hallwaypoofer");
}

simple as that

06-09-2012, 01:01 AM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#5
RE: unlocking a door -updated with new problem

Nvm i got ninjad Big Grin

(This post was last modified: 06-09-2012, 01:02 AM by Datguy5.)
06-09-2012, 01:02 AM
Find
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#6
RE: unlocking a door -updated with new problem

Alright, so, the enemy ran to me, but before it did, it was still facing the wall, and it took forever for it to run to me. Is there any way to make it run faster?

Also, I tried it with a different enemy, and he seemd to be trying to open the door before the player triggered the "area" i set for the the monster to spawn

Just tried adding in pathnodes, even then, he still seems to be walking into the wall, then coming to me when I get close enough.

Could it be because I have him getting activated when I pull the lever, and not opening the door? Therefor, when I pull the lever, he's activated, and tries running to me (from the ShowEnemyPlayerPosition command), but get's stuck at the wall? Then when I am close and can see him, he comes to me.

If that's the case, is there a way to tie him to spawning when I use the key on the door?
(This post was last modified: 06-09-2012, 01:36 AM by Ananaias.)
06-09-2012, 01:15 AM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#7
RE: unlocking a door -updated with new problem

You could make it so that you have a Script Area outside the door and then having a CollideCallback. So that when the door collides with the area the monster spawns and starts running.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
06-09-2012, 10:16 AM
Find
Ananaias Offline
Junior Member

Posts: 20
Threads: 7
Joined: Jun 2012
Reputation: 0
#8
RE: unlocking a door -updated with new problem

I got it fixed. Removing "ShowEnemyPlayerPosition("hallwaypoofer");" and adding in a few pathnodes that extend past the door way got it working.
06-10-2012, 12:23 AM
Find




Users browsing this thread: 2 Guest(s)