Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help How do I make a chair move?
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#12
RE: How do I make a chair move?

I tried to make a map to display the three techniques, third one is currently broken and I don't know enough about the script to fix it, second one is noisy. I know there's a way to shut off music for the enemies and disable insanity effects but heck if I can remember!

Everything's in the file attached to this post, script is below in the spoilers
Spoiler below!

PHP Code: (Select All)
// Variable declaration for chair and player position
float playerX;
float playerZ;
float chairX;
float chairZ;

/////////////////////////
// START ANNOUNCEMENTS //
void func_Announce1(string &in asParentstring &in asChildint alState)
{
    
SetMessage("Hints""BlockPath"0.0f);
}
void func_Announce2(string &in asParentstring &in asChildint alState)
{
    
SetMessage("Hints""AsEnemy"0.0f);
}
void func_Announce3(string &in asParentstring &in asChildint alState)
{
    
SetMessage("Hints""PlayerAndChair"0.0f);
}
// END ANNOUNCEMENTS //
///////////////////////

///////////////////
// CHAIR SPOOK A //
void func_ChairA(string &in asParentstring &in asChildint alState)
{
    
AddPropForce("chair_nice01_1"2000.0f0.0f0.0f"World"); // pushes chair along X axis towards door
}
// END SPOOK A //
/////////////////

///////////////////
// CHAIR SPOOK B //
void func_ChairB(string &in asParentstring &in asChildint alState)
{
    
SetEnemyDisableTriggers("chair_mean01_1"false);
    
AddEntityCollideCallback("Player""announce_playerandchair""func_DisableEnemy"false1); // stops enemy chasing when player leaves area
}
void func_DisableEnemy(string &in asParentstring &in asChildint 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"false1);
    
AddEntityCollideCallback("Player""announce_asenemy""func_Announce2"false1);
    
AddEntityCollideCallback("Player""announce_playerandchair""func_Announce3"false1);
    
    
//These start the chair events
    
AddEntityCollideCallback("Player""area_triggerchairA""func_ChairA"true1);
    
AddEntityCollideCallback("Player""area_triggerchairB""func_ChairB"true1);
    
AddEntityCollideCallback("Player""area_triggerchairC""func_ChairC"true1);
}
void OnEnter()
{

}
void OnLeave()
{





Attached Files
.zip   movingchairtest.zip (Size: 767.66 KB / Downloads: 113)

[Image: quote_by_rueppells_fox-d9ciupp.png]
12-10-2016, 08:58 PM
Find


Messages In This Thread
How do I make a chair move? - by goodcap - 12-10-2016, 06:57 AM
RE: How do I make a chair move? - by Spelos - 12-10-2016, 10:24 AM
RE: How do I make a chair move? - by Spelos - 12-11-2016, 09:00 AM
RE: How do I make a chair move? - by Mudbill - 12-10-2016, 04:03 PM
RE: How do I make a chair move? - by goodcap - 12-10-2016, 05:16 PM
RE: How do I make a chair move? - by goodcap - 12-10-2016, 07:31 PM
RE: How do I make a chair move? - by Mudbill - 12-10-2016, 07:48 PM
RE: How do I make a chair move? - by goodcap - 12-10-2016, 08:08 PM
RE: How do I make a chair move? - by CarnivorousJelly - 12-10-2016, 08:58 PM
RE: How do I make a chair move? - by goodcap - 12-10-2016, 09:17 PM
RE: How do I make a chair move? - by Spelos - 12-12-2016, 08:19 PM
RE: How do I make a chair move? - by Spelos - 12-16-2016, 09:36 AM
RE: How do I make a chair move? - by Daemian - 12-16-2016, 06:01 PM



Users browsing this thread: 3 Guest(s)