int Swings = 0;
void OnStart()
{
AddEntityCollideCallback("Player", "seeShadow", "See_Grunt",true, 1);
AddEntityCollideCallback("silent_grunt", "silent_grunt_gone", "Disable_Grunt",true, 1);
AddEntityCollideCallback("Player", "MapChange", "ChangeMap", false, 1);
AddUseItemCallback("", "stone_hammer_chipper", "breakstone_1", "Break_Rock", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
//GRUNT//
void See_Grunt(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
StartPlayerLookAt("silent_grunt", 2.0f, 4.0f, "See_Grunt_Walk");
}
void See_Grunt_Walk()
{
SetEntityActive("silent_grunt", true);
AddTimer("endwalkTimer", 8.0f, "End_Walk_Timer");
SetEnemyDisableTriggers("silent_grunt", true);
AddEnemyPatrolNode("silent_grunt", "silent_path_3", 0.1f, "");
AddEnemyPatrolNode("silent_grunt", "silent_path_5", 0.1f, "");
AddEnemyPatrolNode("silent_grunt", "silent_path_7", 0.1f, "");
AddEnemyPatrolNode("silent_grunt", "silent_path_8", 0.1f, "");
}
void Disable_Grunt(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("silent_grunt", false);
}
void End_Walk_Timer(string &in asTimer)
{
SetPlayerActive(true);
StopPlayerLookAt();
}
//CHANGE MAP//
void ChangeMap(string &in asParent, string &in asChild, int alState)
{
ChangeMap("014_wateroffice.map", "PlayerStartArea_1", "", "");
}
//HAMMER CHIPPER//
void Break_Rock(string &in asItem, string &in asEntity)
{
Swings = 1;
SetEntityActive("move_hammer", true);
SetEntityActive("rock_chipper", true);
StartPlayerLookAt("move_hammer", 2, 2, "");
AddTimer("hammermove", 0.1, "MoveHammerTimer");
AddTimer("hammersound", 0.27, "MoveHammerTimer");
AddTimer("hammerreset", 0.4, "MoveHammerTimer");
AddTimer("hammerrepeat", 0.6, "MoveHammerTimer");
}
void MoveHammerTimer(string &in asTimer)
{
if(asTimer == "hammermove") SetMoveObjectState("move_hammer", 0.4);
else if(asTimer == "hammersound")
{
StopPlayerLookAt();
PlaySoundAtEntity("", "impact_rock_high", "breakstone_1", 0, false);
PlaySoundAtEntity("", "15_hammer", "Player", 0, false);
}
else if(asTimer =="hammerreset") SetMoveObjectState("move_hammer", 0);
if(Swings < 3 && asTimer =="hammerrepeat")
{
AddTimer("hammermove", 0.01, "MoveHammerTimer");
AddTimer("hammersound", 0.17, "MoveHammerTimer");
AddTimer("hammerreset", 0.3, "MoveHammerTimer");
AddTimer("hammerrepeat", 0.5, "MoveHammerTimer");
Swings = Swings + 1;
}
else if(Swings == 3 && asTimer =="hammerrepeat")
{
AddTimer("hammermove", 0.2, "MoveHammerTimer");
AddTimer("hammersound", 0.37, "MoveHammerTimer");
AddTimer("hammerreset", 0.5, "MoveHammerTimer");
AddTimer("hammerrepeat", 0.8, "MoveHammerTimer");
AddTimer("Break", 0.42, "MoveHammerTimer");
Swings = Swings + 1;
}
else if(Swings == 4 && asTimer =="Break")
{
Break_Rocks_Complete();
SetEntityActive("move_hammer", false);
SetEntityActive("rock_chipper", false);
}
}
void Break_Rocks_Complete()
{
SetEntityActive("breakstone_1", false);
SetEntityActive("breakstone_2", false);
SetEntityActive("med_rock_1", true);
SetEntityActive("med_rock_2", true);
SetEntityActive("med_rock_3", true);
SetEntityActive("large_rock_1", true);
SetEntityActive("large_rock_2", true);
SetEntityActive("large_rock_3", true);
SetEntityActive("small_rock_1", true);
SetEntityActive("small_rock_2", true);
SetEntityActive("small_rock_3", true);
SetEntityActive("small_rock_4", true);
SetEntityActive("small_rock_5", true);
SetEntityActive("small_rock_6", true);
SetEntityActive("small_rock_7", true);
SetEntityActive("small_rock_8", true);
SetEntityActive("small_rock_9", true);
SetEntityActive("small_rock_10", true);
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "breakrock_dust", false);
PlaySoundAtEntity("", "25_break_rock", "Player", 0, false);
}