Armored Cow
Member
Posts: 72
Threads: 3
Joined: Sep 2010
Reputation:
0
|
Door Open/Close Depending on Situation
When the player steps into a trigger area, I want the door that they just walked through to slam shut (if they left it open) or creak open slowly (if they closed it). I can get the door to slam shut if it's open but am not really sure how to do it this way instead.
Any help would be appreciated.
|
|
09-18-2010, 04:18 AM |
|
Liag
Junior Member
Posts: 8
Threads: 0
Joined: Sep 2010
Reputation:
1
|
RE: Door Open/Close Depending on Situation
You just need to use GetSwingDoorClosed() to check if the door is open or closed, and as for creaking it open slowly, check 00_rainy_hall.hps (beginning at line 817).
|
|
09-18-2010, 04:30 AM |
|
Armored Cow
Member
Posts: 72
Threads: 3
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
I looked at it but am still confused. For that section, the door was always closed so there was no need to check if it was closed or not.
If I tell it to check for if it is closed or not, how do I distinguish which action to take?
I know I need an "if" somewhere but am unsure what to do exactly.
|
|
09-18-2010, 05:10 AM |
|
jens
Frictional Games
Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation:
202
|
RE: Door Open/Close Depending on Situation
Assuming you have created the area and the callback for entering into the area.
GetSwingDoorClosed() will return a true or false when you use it, so if you do:
//Player enters the area, we check if door is closed or open
void ColliderPlayerInArea(CAN'T RECALL ALL THE STUFF THAT GOES HERE)
{
//Door is closed so we will creak it open
if(GetSwingDoorClosed("NameOfDoor") == true)
CreakOpen();
//Door is open so we will slam it shut, this is easy.
else
SetSwindDoorClosed("NameOfDoor", true, true);
}
//Door was closed, so we add a bunch of timers to give a small amount of force,
//creaking the door open after we disabled some stuff that would interfer
void CreakOpen()
{
SetSwingDoorDisableAutoClose("NameOfDoor", true);
SetSwingDoorClosed("NameOfDoor", false, false);
AddTimer("NameOfDoor", 0.05f, "TimerCreakDoor");
AddTimer("NameOfDoor", 0.1f, "TimerCreakDoor");
AddTimer("NameOfDoor", 0.2f, "TimerCreakDoor");
AddTimer("NameOfDoor", 0.3f, "TimerCreakDoor");
}
//The timer that gives the door a little push, notice that I do not know what a good
//force value is 1 might be too much or too little, and I am not sure of the direction
//so could be -1 or on the Z axis and not on the X axis as in this script.
void TimerCreakDoor(string &in asTimer)
{
AddPropForce(asTimer, 1, 0, 0, "World");
}
(This post was last modified: 09-18-2010, 11:01 AM by jens.)
|
|
09-18-2010, 11:00 AM |
|
Armored Cow
Member
Posts: 72
Threads: 3
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
Thank you so much Jens!
|
|
09-18-2010, 05:07 PM |
|
theDARKW0LF
Member
Posts: 150
Threads: 17
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
I followed what Jens posted, but I get an error which states, "main (81, 9): ERR : No matching signatures to 'CreakOpen()'
What gives?
EDIT: Lol, it seems I didn't notice that there was more down the code box so I had only copied the top...
Check out my custom stories(1)(2)!
|
|
09-18-2010, 09:11 PM |
|
Armored Cow
Member
Posts: 72
Threads: 3
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
Actually I'm having troubles too. It's only slamming the door, whether it's already closed or open.
Firstly, I have this in my void OnStart section:
//Callback to slam door
AddEntityCollideCallback("Player", "area_lock_door", "CollideLock", true, 1);
//Function called when player steps into area_lock_door
void CollideLock(string &in asParent, string &in asChild, int alState)
{
//Door is closed so activate CreakOpen function
if(GetSwingDoorClosed("castle_1") == true)
CreakOpen();
//Door is open so slam it shut
else
StartPlayerLookAt("castle_1", 3, 4, "");
AddTimer("", 0.5f, "TimerSlamDoor");
}
void TimerSlamDoor(string &in asTimer)
{
SetSwingDoorClosed("castle_1", true, true);
SetSwingDoorLocked("castle_1", true, true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
AddTimer("", 3.0f, "TimerStopLook");
}
void CreakOpen()
{
SetSwingDoorDisableAutoClose("castle_1", true);
SetSwingDoorClosed("castle_1", false, false);
StartPlayerLookAt("castle_1", 2, 2, "");
GiveSanityDamage(5.0f, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
AddTimer("castle_1", 0.05f, "TimerCreakDoor");
AddTimer("castle_1", 0.1f, "TimerCreakDoor");
AddTimer("castle_1", 0.2f, "TimerCreakDoor");
AddTimer("castle_1", 0.3f, "TimerCreakDoor");
AddTimer("", 3.0f, "TimerStopLook");
}
void TimerCreakDoor(string &in asTimer)
{
AddPropForce("castle_1", 1, 0, 0, "World");
}
void TimerStopLook(string &in asTimer)
{
StopPlayerLookAt();
}
|
|
09-18-2010, 09:43 PM |
|
theDARKW0LF
Member
Posts: 150
Threads: 17
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
Yeah the creaking open of the door doesn't work for me either, only it slamming does.
Check out my custom stories(1)(2)!
|
|
09-18-2010, 10:42 PM |
|
Pandemoneus
Senior Member
Posts: 328
Threads: 2
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
You have to experiment a bit with the values here.
void TimerCreakDoor(string &in asTimer)
{
AddPropForce("castle_1", 1, 0, 0, "World");
}
You might have to use -1, -2 or 2, just try it out.
[edit]
You also got a mistake in the code.
else
StartPlayerLookAt("castle_1", 3, 4, "");
AddTimer("", 0.5f, "TimerSlamDoor");
Use:
else {
StartPlayerLookAt("castle_1", 3, 4, "");
AddTimer("", 0.5f, "TimerSlamDoor");
}
You have to use { } when you use more than 1 line in if-, else-, for-clauses and so on.
|
|
09-18-2010, 10:52 PM |
|
Armored Cow
Member
Posts: 72
Threads: 3
Joined: Sep 2010
Reputation:
0
|
RE: Door Open/Close Depending on Situation
No, Pandemoneus, the problem isn't that. It's still slamming the door. It's not just that the opening won't work, but that it doesn't even attempt to open it.
|
|
09-18-2010, 11:03 PM |
|
|