Ananaias
Junior Member
Posts: 20
Threads: 7
Joined: Jun 2012
Reputation:
0
|
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:
void OnStart() { SetEntityConnectionStateChangeCallback("lever", "func_shelf"); AddUseItemCallback("", "MasterRoomKey", "MasterRoomDoor", "unlock_door", true); }
void func_shelf(string &in asEntity, int alState) { if (alState == 1) { SetSwingDoorLocked("MasterRoomDoor", true, true); SetLampLit("light1room2", false, true); SetLampLit("light2room2", false, true); SetLampLit("light3room2", false, true); SetLampLit("light4room2", false, true); SetLampLit("light5room2", false, true); SetLampLit("light6room2", false, true); SetLampLit("light7room2", false, true); SetLampLit("light8room2", false, true); SetLampLit("light9room2", false, true); SetLampLit("light1hall1", false, true); SetLampLit("light2hall1", false, true); SetLampLit("light3hall1", false, true); SetLampLit("light4hall1", false, true); SetLampLit("light5hall1", false, true); SetLampLit("light6hall1", false, true); SetLampLit("light7hall1", false, true); SetLampLit("light8hall1", false, true); SetLampLit("light1room1", false, true); SetLampLit("light2room1", false, true); SetLampLit("light3room1", false, true); SetLampLit("light4room1", false, true); SetLampLit("light5room1", false, true); SetLampLit("light6room1", false, true); SetLampLit("light7room1", false, true); SetLampLit("light8room1", false, true); 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", 0, false); return; } }
void FUNCTION(string &in item, string &in door) { SetSwingDoorLocked(door, false, true); PlaySoundAtEntity("", "unlock_door", door, 0, false); RemoveItem(item); }
And here's the part for those of you who only care about stuff pertaining to the key.
void OnStart() { SetEntityConnectionStateChangeCallback("lever", "func_shelf"); AddUseItemCallback("", "MasterRoomKey", "MasterRoomDoor", "unlock_door", true); }
void FUNCTION(string &in item, string &in door) { SetSwingDoorLocked(door, false, true); PlaySoundAtEntity("", "unlock_door", door, 0, false); 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.
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 |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
RE: unlocking a door -updated with new problem
|
|
06-08-2012, 11:24 PM |
|
Ananaias
Junior Member
Posts: 20
Threads: 7
Joined: Jun 2012
Reputation:
0
|
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
(This post was last modified: 06-09-2012, 12:57 AM by Ananaias.)
|
|
06-09-2012, 12:57 AM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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 |
|
Datguy5
Senior Member
Posts: 629
Threads: 25
Joined: Dec 2011
Reputation:
12
|
RE: unlocking a door -updated with new problem
Nvm i got ninjad
(This post was last modified: 06-09-2012, 01:02 AM by Datguy5.)
|
|
06-09-2012, 01:02 AM |
|
Ananaias
Junior Member
Posts: 20
Threads: 7
Joined: Jun 2012
Reputation:
0
|
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 |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
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.
|
|
06-09-2012, 10:16 AM |
|
Ananaias
Junior Member
Posts: 20
Threads: 7
Joined: Jun 2012
Reputation:
0
|
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 |
|
|