09-21-2014, 08:13 PM
All righty, so basically I'm trying to break against the traditional crowbar-breaks-after-one-use shenanigans and I have at least four doors that will require using the crowbar, three being the regular mansion door and the last being boards covering a door.
I've been able to successfully script for a single door, but now that I have to add to it, I have no idea where to really start. While I know that I can use the Variables to help condense the scripts, I'm not entirely sure how to go about it or if with also needing to script for boards, if that might makes things a little different.
____________________________________________________________
Finished Script:
-Be sure to check the names thoroughly
-I'm leaving the 4 in the script, but you do not necessarily have to leave it at 4
Thank you to the guys who contributed to this thread to get this script working![/code]
I've been able to successfully script for a single door, but now that I have to add to it, I have no idea where to really start. While I know that I can use the Variables to help condense the scripts, I'm not entirely sure how to go about it or if with also needing to script for boards, if that might makes things a little different.
____________________________________________________________
Finished Script:
-Be sure to check the names thoroughly
-I'm leaving the 4 in the script, but you do not necessarily have to leave it at 4
Thank you to the guys who contributed to this thread to get this script working![/code]
Code:
void OnStart()
{
for(int i = 1; i <= 4; i++) {
AddUseItemCallback("crowbarondoors", "crowbar", "Door_"+i, "UseCrowbarOnDoor", false);
AddEntityCollideCallback("Joint_Door_"+i, "AreaBreak_"+i, "BreakDoor", true, 1);
}
}
void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");
SetLocalVarString("CrowbarDoor", asEntity);
}
void TimerPlaceCrowbar(string &in asTimer)
{
SetEntityActive("Joint_"+asTimer, true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}
void BreakDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive(asParent, false);
SetSwingDoorLocked(GetLocalVarString("CrowbarDoor"), false, false);
SetSwingDoorClosed(GetLocalVarString("CrowbarDoor"), false, false);
SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), true);
AddPropImpulse(GetLocalVarString("CrowbarDoor"), 0, 0, 3, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect_"+asChild, false);
PlaySoundAtEntity("", "break_wood_metal", "AreaEffect_"+asChild, 0, false);
GiveSanityBoostSmall();
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
AddTimer("", 0.1, "TimerPushDoor");
GiveItem("crowbar", "Puzzle", "crowbar", "crowbar.tga", 1);
}
void TimerPushDoor(string &in asTimer)
{
AddPropImpulse(GetLocalVarString("CrowbarDoor"), -4, 2, 1, "world");
AddTimer("", 1.1, "TimerDoorCanClose");
}
void TimerDoorCanClose(string &in asTimer)
{
SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), false);
}