void OnStart()
{
AddEntityCollideCallback("Sledgehammer", "ImpactArea", "ImpactScript", false, 1);
AddEntityCollideCallback("Sledgehammer", "ImpactArea_1", "ImpactScript_1", false, 1);
AddUseItemCallback("", "rusty_key", "celler", "UsedKeyOnDoor", true);
}
// BreakableDoor_1 == Mansion_1 door
// Pieces_1/2 == custom Mansion_Broken made static and undying (-1 lifetime)
// Pieces just behind the door, the ImpactArea veeery close to BreakableDoor_1.
// Sledgehammer= Item used to destroy it.
// BreakEffect areas are on BreakableDoor_1
void ImpactScript (string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("BreakDoorInt") == 3)
{
SetEntityActive("ImpactArea", false);
SetPropStaticPhysics("Pieces_2", false);
SetPropStaticPhysics("Pieces_1", false);
AddPropImpulse("Pieces_1", 0.5, 1, 3, "world");
AddPropImpulse("Pieces_2", 0.6, 0.3, 2.5, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect", false);
PlayGuiSound("break_wood_metal.snt",2);
}
if(GetLocalVarInt("BreakDoorInt") == 2)
{
PlaySoundAtEntity("", "break_wood_metal.snt", "Pieces_1", 0, false);
SetPropHealth("BreakableDoor_1", -1);
AddPropImpulse("BreakableDoor_1", 0, 0, -0.5, "world");
}
PlaySoundAtEntity("", "break_wood.snt", "BreakableDoor_1", 0, false);
AddLocalVarInt("BreakDoorInt", 1);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect", false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect2", false);
}
void ImpactScript_1 (string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("BreakDoorInt") == 3)
{
SetEntityActive("ImpactArea_1", false);
SetPropStaticPhysics("Pieces_4", false);
SetPropStaticPhysics("Pieces_3", false);
AddPropImpulse("Pieces_3", 0.5, 1, 3, "world");
AddPropImpulse("Pieces_4", 0.6, 0.3, 2.5, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect_1", false);
PlayGuiSound("break_wood_metal.snt",2);
}
if(GetLocalVarInt("BreakDoorInt") == 2)
{
PlaySoundAtEntity("", "break_wood_metal.snt", "Pieces_3", 0, false);
SetPropHealth("BreakableDoor_2", -1);
AddPropImpulse("BreakableDoor_2", 0, 0, -0.5, "world");
}
PlaySoundAtEntity("", "break_wood.snt", "BreakableDoor_2", 0, false);
AddLocalVarInt("BreakDoorInt", 1);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect_1", false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect2", false);
}
void ImpactScript_2 (string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("BreakDoorInt") == 3)
{
SetEntityActive("ImpactArea_2", false);
SetPropStaticPhysics("Pieces_6", false);
SetPropStaticPhysics("Pieces_5", false);
AddPropImpulse("Pieces_5", 0.5, 1, 3, "world");
AddPropImpulse("Pieces_6", 0.6, 0.3, 2.5, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect_2", false);
PlayGuiSound("break_wood_metal.snt",2);
}
if(GetLocalVarInt("BreakDoorInt") == 2)
{
PlaySoundAtEntity("", "break_wood_metal.snt", "Pieces_5", 0, false);
SetPropHealth("BreakableDoor_2", -1);
AddPropImpulse("BreakableDoor_2", 0, 0, -0.5, "world");
}
PlaySoundAtEntity("", "break_wood.snt", "BreakableDoor_3", 0, false);
AddLocalVarInt("BreakDoorInt", 1);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect_2", false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect2", false);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("celler", false, true);
PlaySoundAtEntity("", "unlock_door", "celler", 0, false);
RemoveItem("rusty_key");
}