11-26-2018, 10:37 PM
So I was working on my TC mod and tried to add enemy that spawns when player enters script area
but problem is that my script does not work "unless I use F2 to reload whole map"
but problem is that my script does not work "unless I use F2 to reload whole map"
Code:
void OnStart()
{
//-- CallBacks --//
{
//-- Collide Callbacks --//
AddEntityCollideCallback("Player", "NowWillFall", "objectsfall", true, 1);
AddEntityCollideCallback("Player", "LetsSpawn", "spawnpig", true, 1);
AddEntityCollideCallback("servant_grunt_1", "DespawnPig", "despawnpig", true, 1);
}
SetMapDisplayNameEntry("Mansion - Employe District - Longue 2");
}
void OnEnter()
{
//AUTOSAVE//
{
AutoSave();
}
}
void OnLeave()
{
StopMusic(4.0f, 0);
}
//////////////////////////
////Specyfic Functions///
/////////////////////////
void objectsfall (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("buzzsaw_1", true);
SetEntityActive("vase02_2", true);
SetEntityActive("wine01_7", true);
SetEntityActive("hammer_1", true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(2, true);
}
void spawnpig (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0.001, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0.001, "");
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(2, true);
}
void despawnpig (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", false);
}