// Variable declaration for chair and player position
float playerX;
float playerZ;
float chairX;
float chairZ;
/////////////////////////
// START ANNOUNCEMENTS //
void func_Announce1(string &in asParent, string &in asChild, int alState)
{
SetMessage("Hints", "BlockPath", 0.0f);
}
void func_Announce2(string &in asParent, string &in asChild, int alState)
{
SetMessage("Hints", "AsEnemy", 0.0f);
}
void func_Announce3(string &in asParent, string &in asChild, int alState)
{
SetMessage("Hints", "PlayerAndChair", 0.0f);
}
// END ANNOUNCEMENTS //
///////////////////////
///////////////////
// CHAIR SPOOK A //
void func_ChairA(string &in asParent, string &in asChild, int alState)
{
AddPropForce("chair_nice01_1", 2000.0f, 0.0f, 0.0f, "World"); // pushes chair along X axis towards door
}
// END SPOOK A //
/////////////////
///////////////////
// CHAIR SPOOK B //
void func_ChairB(string &in asParent, string &in asChild, int alState)
{
SetEnemyDisableTriggers("chair_mean01_1", false);
AddEntityCollideCallback("Player", "announce_playerandchair", "func_DisableEnemy", false, 1); // stops enemy chasing when player leaves area
}
void func_DisableEnemy(string &in asParent, string &in asChild, int alState)
{
SetEnemyDisableTriggers("chair_mean01_1", true);
}
// END SPOOK B //
/////////////////
/*
///////////////////
// CHAIR SPOOK C //
void func_ChairC(string &in asParent, string &in asChild, int alState)
{
TimerPushLoop("timer_Chair"); // start pushing loop
AddEntityCollideCallback("Player", "area_triggerchairC", "func_StopChase", false, 1); // make a way to stop loop
}
void TimerPushLoop(string &in asTimer)
{
AddTimer(asTimer, 0.1f, "TimerPushLoop");
NudgeChairTowardsPlayer();
}
void NudgeChairTowardsPlayer()
{
chairX = GetEntityPosX("chair_nice01_3"); // Gets chair position
chairY = GetEntityPosZ("chair_nice01_3");
playerX = GetPlayerPosX(); // Gets Player Position
playerY = GetPlayerPosZ();
float playerXinRelationToChair = playerX - chairX; // Calculates distance from player to chair
float playerZinRelationToChair = playerZ - chairZ;
float forceMultiplier = 500; // may need to be higher or lower depending on how fast you want the chair to be
AddPropForce("chair_nice01_1", playerXinRelationToChair * forceMultiplier f, 0.0f, playerZinRelationToChair * forceMultiplier f, "World"); // pushes chair towards player
}
func_StopChase(string &in asParent, string &in asChild, int alState)
{
RemoveTimer("timer_Chair"); // stops chair event
}
// END SPOOOK C //
//////////////////
*/
void OnStart()
{
//These just announce which room you're in
AddEntityCollideCallback("Player", "announce_blockpath", "func_Announce1", false, 1);
AddEntityCollideCallback("Player", "announce_asenemy", "func_Announce2", false, 1);
AddEntityCollideCallback("Player", "announce_playerandchair", "func_Announce3", false, 1);
//These start the chair events
AddEntityCollideCallback("Player", "area_triggerchairA", "func_ChairA", true, 1);
AddEntityCollideCallback("Player", "area_triggerchairB", "func_ChairB", true, 1);
AddEntityCollideCallback("Player", "area_triggerchairC", "func_ChairC", true, 1);
}
void OnEnter()
{
}
void OnLeave()
{
}