Mina Darsh
Member
Posts: 227
Threads: 24
Joined: Sep 2010
Reputation:
0
RE: Curious Hio, Scripting questions. (Current: Checkpoints.)
Gah, still did not solve it, weird thing is, 'mister_moody' sometimes succesfully tries to attack the player again, and sometimes exits the door that's supposed to be deactivated until he walks into the area named 'AreaGruntCheckedRoom' before finishing his routine. It seems to happen randomly...
Here's the script as it looks now, also removed the outquoted functions to keep it clean:
Spoiler below!
void CheckPoint01(string &in asName, int alCount)
{
{
ResetProp("mansion_1"); ResetProp("rolled_up_carpet_1");
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("mister_moody", "AreaGruntCheckedRoom", "CollideAreaGruntCheckedRoom", true, -1);
AddEntityCollideCallback("mister_moody" , "ScriptArea_2" , "GoPoof" , false , 1);
SetEntityActive("ScriptArea_2", false);
}
}
////////////////////////////
// Rawr! Scary monster comin'!
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
{
SetSwingDoorClosed("mansion_1", true, false);
PlaySoundAtEntity("doorclosed", "door_mansion_close.snt", "mansion_1", 0.2f, false);
PlaySoundAtEntity("scare","react_scare.snt", "Player", 0.5f, false);
CreateParticleSystemAtEntity("breakps", "ps_hit_wood", "ScriptArea_3", false);
AddTimer("YayAnotherTimer", 2.0f, "SpawnMisterMoody");
GiveSanityDamage(20.0f, true);
}
}
////////////////////////////
//Make Mister Moody leave.
void CollideAreaGruntCheckedRoom(string &in asParent, string &in asChild, int alState)
{
{
ClearEnemyPatrolNodes("mister_moody");
AddEnemyPatrolNode("mister_moody", "PathNodeArea_3", 0, "");
SetEntityActive("ScriptArea_2", true);
}
}
void GoPoof(string &in asParent , string &in asChild , int alState)
{
{
AddTimer("YayATimer", 1.0f, "BeGone");
}
}
void SpawnMisterMoody(string &in asTimer)
{
{
SetEntityActive("mister_moody", true);
AddEnemyPatrolNode("mister_moody", "PathNodeArea_1", 3, "");
AddEnemyPatrolNode("mister_moody", "PathNodeArea_2", 0, "");
}
}
void BeGone(string &in asTimer)
{
{
SetEntityActive("mister_moody", false);
PlaySoundAtEntity("doorgruntleave","10_open_door.snt", "level_wood_1", 0.5, false);
}
}
////////////////////////////
// Run first time starting map
void OnStart()
{
{
CheckPoint("check01","PlayerStartArea_1", "CheckPoint01", "Hints", "Death_Test");
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("mister_moody", "AreaGruntCheckedRoom", "CollideAreaGruntCheckedRoom", true, -1);
AddEntityCollideCallback("mister_moody" , "ScriptArea_2" , "GoPoof" , false , 1);
SetEntityActive("ScriptArea_2", false);
}
}
////////////////////////////
// Run when entering map
void OnEnter()
{
{
PlayMusic("02_amb_safe", true, 0.7, 5, 0, true);
PreloadParticleSystem("ps_hit_wood");
PreloadSound("door_mansion_close"); PreloadSound("react_scare");
}
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Also, the door needs to be open again when the map resets, but now, with or without command the door is closed already.