Grimm101
Junior Member
Posts: 12
Threads: 3
Joined: Dec 2011
Reputation:
0
|
Door open amount after being locked
Hey guys,
So I've had a monster spawn when the player walks into an area, I have also made it so that a current locked door becomes unlocked. After it being unlocked i want it to be open a certain amount so that it looks like the monster has went in there but in actual fact he has just disappeared. I am using SetMoveObjectState and it doesn't seem to want to work. Help please :-) My code is below
////////////////////////////////
// Run when starting the map
void OnStart()
////////////////////////////////
// Entities
{
SetPlayerLampOil(25.0f); //Sets player lamp oil to 25% full from start
AddUseItemCallback("", "Bedroom_Key", "Bedroom_Key_Door", "UsedKeyOnDoor", true); //Assigns the key to the door and sets the action of this as UsedKeyOnDoor
AddEntityCollideCallback("Player", "DoorCloseArea1", "DoorCloseBang", true, 1); //Declaring when a player walks into an area called "DoorCloseArea1" Deletes the possibility of it happening again so it can only happen once: Number = 1 for player enters. -1 for when player leaves. 0 for both
AddEntityCollideCallback("Player", "MonsterSpawnArea", "MonsterSpawn1", true, 1); //Sets up that if the player enters the monsterspawn area then run the mosterspawn entity meaning the monster will spawn and will continue to follow the nodes
AddEntityCollideCallback("Player", "Baby_Cry", "BabyCry", true, 1); //When the player collides with the area called Baby_Cry a sound will be played known as BabyCry
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity) //Follow code for the UsedKeyOnDoor command
{
SetSwingDoorLocked("Bedroom_Key_Door", false, true); //Sets what door the key works on and it can only be used once
PlaySoundAtEntity("", "unlock_door", "Bedroom_Key_Door", 0, false); //Plays sound when the key is used on the door
RemoveItem("Bedroom_Key"); //Removes the key after it has been used
}
void DoorCloseBang(string &in asParent, string &in asChild, int alState) //Sets up the follow code for the door close bang entity
{
SetSwingDoorClosed("Bedroom_Key_Door", true, true); //Closes a swing door: Effects indicate true to see the door close
SetSwingDoorLocked("Bedroom_Key_Door", true, true); //Locks the door once the player has entered the area after the slam
PlaySoundAtEntity("", "03_amb_library", "Bedroom_Key_Door", 0, false); //Starts the sounds of someone being in a library making some book noises and movement
PlaySoundAtEntity("", "24_bang", "Bedroom_Key_Door", 0, false); //Create banging on the door sound when the door shuts
PlaySoundAtEntity("", "react_scare", "Bedroom_Key_Door", 0, false); //Player breathes heavily after this has taken place
PlaySoundAtEntity("", "24_burn", "Bedroom_Key_Door", 0, false); //Creates a scream at the time of the door slamming and banging
SetPlayerSanity(0.0f); //Makes player sanity 3 dots to add to a blur effect
FadePlayerFOVMulTo(0.85f, 5.0f); //Zooms in the screen adding to the wobble effect
FadePlayerAspectMulTo(0.85f, 1.0f); //Stretches the screen giving wobble effect
FadeImageTrailTo(1.0f, 1.0f); //Adds blur making the wobble effect better
StartPlayerLookAt("Bedroom_Key_Door", 10.0f, 10.0f, ""); //Makes the player look at the bedroom door
AddTimer("", 2.0f, "StopLooking"); //timer to stop looking at the door after 2 seconds
SetEntityActive("slamdoortouch", true); //Sets an active entity of the door
SetEntityInteractionDisabled("Bedroom_Key_Door", true); //Makes interaction with the door disabled
}
void StopLooking(string &in asTimer) //Sets the follow code to stop the player looking
{
StopPlayerLookAt(); //Stop looking at the door
FadePlayerFOVMulTo(1.0f, 5.0f); //Sets the players FOV Multiplier back to normal = 1
FadePlayerAspectMulTo(1.0f, 5.0f); //Sets the Aspect Multiplier back to normal = 1
FadeImageTrailTo(0.0f, 1.0f); //Removes blur
SetPlayerSanity(100.0f); //Sets player sanity back to normal
}
void Locked0(string &in asEntity) //Sets the follow code so the door shows a message
{
SetMessage("DoorMessages", "Locked_Door_Message", 0); //Says the door wont budge when it is locked
}
void MonsterSpawn1(string &in asParent, string &in asChild, int alState) //Follow code for monster spawn
{
SetEntityActive("HoloGrunt1", true); //Makes the Grunt active and will be unactive/gone once the enemy has gotten to the final node unless being chased
SetSwingDoorLocked("LockedHallwayDoor1", false, true); //Unlocks the door making it look like the monster has went into that room
SetMoveObjectState("LockedHallwayDoor1", 0.7f);
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node1", 0.0f, ""); //Makes the monster move to node 1 and so on
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node2", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node3", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node4", 10.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node3", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node2", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node1", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node5", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node6", 0.0f, "");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node7", 0.0f, "");
}
void BabyCry(string &in asParent, string &in asChild, int alState) //Follow code for the sound of a baby crying
{
PlaySoundAtEntity("", "insanity_baby_cry", "Player", 0, false); //Creates a baby crying when going through into relative room
}
////////////////////////////////
// Run when entering the map
void OnEnter()
{
}
////////////////////////////////
// Run when leaving the map
void OnLeave()
{
}
(This post was last modified: 12-24-2011, 10:51 PM by Grimm101.)
|
|
12-24-2011, 10:50 PM |
|
DRedshot
Senior Member
Posts: 374
Threads: 23
Joined: Jun 2011
Reputation:
11
|
RE: Door open amount after being locked
Instead of "SetMoveObjectState" Use these two functions together
SetSwingDoorDisableAutoClose("DoorName" true);
AddPropForce("DoorName" , 0.0f , 0.0f , 3000.0f , "local");
Also, unless you want the monster to specifically go a longer path, you can get rid of all but the last
"AddEnemyPatrolNode("HoloGrunt1", "Monster1Node7", 0.0f, "");"
It will reach this last node automatically using the other nodes on the map, and wont stop at each node.
Edit: If the code appears to do nothing, raise the z (3rd) float value from 3000 to around 6-7000.0f
Also, remember to put "" around your doorname, when it says something isn't declared it can mean you have wrote a string value without the quotatation marks. I'll edit the code above because I might have mislead you by puting quotation marks around one and not the other.
(This post was last modified: 12-25-2011, 09:21 PM by DRedshot.)
|
|
12-24-2011, 11:08 PM |
|
Grimm101
Junior Member
Posts: 12
Threads: 3
Joined: Dec 2011
Reputation:
0
|
RE: Door open amount after being locked
Unfortunately it crashes when I do this is there another way to do this? Why does it crash ? :S
Monster node thing helped tho
(This post was last modified: 12-25-2011, 05:51 PM by Grimm101.)
|
|
12-25-2011, 05:50 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Door open amount after being locked
(12-25-2011, 05:50 PM)Grimm101 Wrote: Unfortunately it crashes when I do this is there another way to do this? Why does it crash ? :S
The only way to push open a swing door is the way DRedshot described. Check the hpl.log at Documents/Amnesia/Main if you're running Windows.
|
|
12-25-2011, 06:20 PM |
|
Grimm101
Junior Member
Posts: 12
Threads: 3
Joined: Dec 2011
Reputation:
0
|
RE: Door open amount after being locked
It says that my door name is not declared =S
|
|
12-25-2011, 07:48 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Door open amount after being locked
Sounds like you confused a string with a variable.
(This post was last modified: 12-25-2011, 10:10 PM by Your Computer.)
|
|
12-25-2011, 10:09 PM |
|
Grimm101
Junior Member
Posts: 12
Threads: 3
Joined: Dec 2011
Reputation:
0
|
RE: Door open amount after being locked
Okay i've been away for a while and I'm now back to continue coding. I don't understand what the problem is here but I've tried both addPropForce and AddPropImpulse and neither make the door move what so ever. Its unlocked once the player triggers everything to happen but it doesn't make the door open at all. This is what my code looks like now after messing around with it.
////////////////////////////////
// Run when starting the map
void OnStart()
////////////////////////////////
// Entities
{
SetPlayerLampOil(25.0f); //Sets player lamp oil to 25% full from start
AddUseItemCallback("", "Bedroom_Key", "Bedroom_Key_Door", "UsedKeyOnDoor", true); //Assigns the key to the door and sets the action of this as UsedKeyOnDoor
AddEntityCollideCallback("Player", "DoorCloseArea1", "DoorCloseBang", true, 1); //Declaring when a player walks into an area called "DoorCloseArea1" Deletes the possibility of it happening again so it can only happen once: Number = 1 for player enters. -1 for when player leaves. 0 for both
AddEntityCollideCallback("Player", "MonsterSpawnArea", "MonsterSpawn1", true, 1); //Sets up that if the player enters the monsterspawn area then run the mosterspawn entity meaning the monster will spawn and will continue to follow the nodes
AddEntityCollideCallback("Player", "Baby_Cry", "BabyCry", true, 1); //When the player collides with the area called Baby_Cry a sound will be played known as BabyCry
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity) //Follow code for the UsedKeyOnDoor command
{
SetSwingDoorLocked("Bedroom_Key_Door", false, true); //Sets what door the key works on and it can only be used once
PlaySoundAtEntity("", "unlock_door", "Bedroom_Key_Door", 0, false); //Plays sound when the key is used on the door
RemoveItem("Bedroom_Key"); //Removes the key after it has been used
}
void DoorCloseBang(string &in asParent, string &in asChild, int alState) //Sets up the follow code for the door close bang entity
{
SetSwingDoorClosed("Bedroom_Key_Door", true, true); //Closes a swing door: Effects indicate true to see the door close
SetSwingDoorLocked("Bedroom_Key_Door", true, true); //Locks the door once the player has entered the area after the slam
PlaySoundAtEntity("", "03_amb_library", "Bedroom_Key_Door", 0, false); //Starts the sounds of someone being in a library making some book noises and movement
PlaySoundAtEntity("", "24_bang", "Bedroom_Key_Door", 0, false); //Create banging on the door sound when the door shuts
PlaySoundAtEntity("", "react_scare", "Bedroom_Key_Door", 0, false); //Player breathes heavily after this has taken place
PlaySoundAtEntity("", "24_burn", "Bedroom_Key_Door", 0, false); //Creates a scream at the time of the door slamming and banging
SetPlayerSanity(0.0f); //Makes player sanity 3 dots to add to a blur effect
FadePlayerFOVMulTo(0.85f, 5.0f); //Zooms in the screen adding to the wobble effect
FadePlayerAspectMulTo(0.85f, 1.0f); //Stretches the screen giving wobble effect
FadeImageTrailTo(1.0f, 1.0f); //Adds blur making the wobble effect better
StartPlayerLookAt("Bedroom_Key_Door", 10.0f, 10.0f, ""); //Makes the player look at the bedroom door
AddTimer("", 2.0f, "StopLooking"); //timer to stop looking at the door after 2 seconds
SetEntityActive("slamdoortouch", true); //Sets an active entity of the door
SetEntityInteractionDisabled("Bedroom_Key_Door", true); //Makes interaction with the door disabled
}
void StopLooking(string &in asTimer) //Sets the follow code to stop the player looking
{
StopPlayerLookAt(); //Stop looking at the door
FadePlayerFOVMulTo(1.0f, 5.0f); //Sets the players FOV Multiplier back to normal = 1
FadePlayerAspectMulTo(1.0f, 5.0f); //Sets the Aspect Multiplier back to normal = 1
FadeImageTrailTo(0.0f, 1.0f); //Removes blur
SetPlayerSanity(100.0f); //Sets player sanity back to normal
}
void Locked0(string &in asEntity) //Sets the follow code so the door shows a message
{
SetMessage("DoorMessages", "Locked_Door_Message", 0); //Says the door wont budge when it is locked
}
void MonsterSpawn1(string &in asParent, string &in asChild, int alState) //Follow code for monster spawn
{
SetEntityActive("HoloGrunt1", true); //Makes the Grunt active and will be unactive/gone once the enemy has gotten to the final node unless being chased
SetSwingDoorLocked("LockedHallwayDoor1", false, true); //Unlocks the door making it look like the monster has went into that room
SetSwingDoorDisableAutoClose("LockedHallwayDoor1", true);
AddPropImpulse("LockedHallwayDoor1", 0.0f, 0.0f, 0.2f, "world");
AddPropForce("LockedHallwayDoor1", 0.0f, 0.0f, 3000.0f, "world");
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node4", 10.0f, ""); //Makes the monster move to node 1 and so on. Stops on node 4 for 10 seconds
AddEnemyPatrolNode("HoloGrunt1", "Monster1Node7", 0.0f, ""); //Final node making the monster disapear
}
void BabyCry(string &in asParent, string &in asChild, int alState) //Follow code for the sound of a baby crying
{
PlaySoundAtEntity("", "insanity_baby_cry", "Player", 0, false); //Creates a baby crying when going through into relative room
}
////////////////////////////////
// Run when entering the map
void OnEnter()
{
}
////////////////////////////////
// Run when leaving the map
void OnLeave()
{
}
(This post was last modified: 01-21-2012, 03:47 PM by Grimm101.)
|
|
01-21-2012, 03:45 PM |
|
|