wagiwombledog
Junior Member
Posts: 8
Threads: 4
Joined: Mar 2012
Reputation:
0
Crowbar/Key Script Problem
Hi,
I'm having trouble with a script for my custom story. If you could help I would greatly appreciate it + tell me what i did wrong, as i can't see anything, although i am new to scripting. It involve a crowbar, a key and 2 door's.
Crowbar=crowbar_1
Key=Waterworks_Key
Door1=Waterworks_Door
Door2=Storage
The key goes with the Waterworks door and the crowbar goes with the storage door. Here is the script:
void OnStart()
{
AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true);
AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
}
void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
void FUNCTION(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}
void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar_joint_1", true);
}
void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("Waterworks_Door", false, true);
AddPropImpulse("Waterworks_Door", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("Waterworks_Door", true);
SetSwingDoorClosed("Waterworks_Door", false, false);
SetMoveObjectState("Waterworks_Door", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}
{
AddUseItemCallback("", "Waterworks_Key", "Waterworks_Door", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("asEntity", false, true);
PlaySoundAtEntity("", "unlock_door", "asEntity", 0, false);
RemoveItem(asItem);
}
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when entering map
void OnLeave()
{
}
Thanks!
,wagiwombledog
09-12-2012, 05:42 AM
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
RE: Crowbar/Key Script Problem
I'm going to assume that the key is not working on the door, and the crowbar is not properly prying the door open.
Regardless, this should fix your problems.
Spoiler below!
void OnStart()
{
AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
AddUseItemCallback("", "Waterworks_Key", "Waterworks_Door", "UsedKeyOnDoor", true);
}
void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}
void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "Player", 0, false);
SetEntityActive("crowbar_joint_1", true);
}
void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("Storage", false, true);
AddPropImpulse("Storage", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("Storage", true);
SetSwingDoorClosed("Storage", false, false);
SetMoveObjectState("Storage", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Waterworks_Door", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
RemoveItem("Waterworks_Key");
}
RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 09-12-2012, 05:48 PM by Tomato Cat .)
09-12-2012, 04:29 PM
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
RE: Crowbar/Key Script Problem
Wait... you want the key to open a door and a crowbar to open another door? I say it because both (crowbar and key) target the same door.
THE OTHERWORLD (WIP)
Aculy iz dolan.
09-12-2012, 05:00 PM
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
RE: Crowbar/Key Script Problem
(09-12-2012, 05:00 PM) The chaser Wrote: Wait... you want the key to open a door and a crowbar to open another door? I say it because both (crowbar and key) target the same door.Yeah, using the crowbar on the "Storage" door would open the "Waterworks_Door."
RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
09-12-2012, 05:49 PM
wagiwombledog
Junior Member
Posts: 8
Threads: 4
Joined: Mar 2012
Reputation:
0
RE: Crowbar/Key Script Problem
Thank you all for your fast replies,
I'll try to be less crap with scripting in the future.
09-12-2012, 08:01 PM