Monster Script won't work
Hi
I scripted a Brute in my map, but I have a big problem.
He should Dissapear in an Area, but he don't.
I did it like this, the monster follows path nodes. I placed two Areas, one is active and one isn't Active. The path nodes leads him to both Areas, the first Area he collides makes the second Area active and when he collides the second Area he should Dissapear if the player is in another Area I placed.
My Script:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_11", "No", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_12", "Whoa", true, 1);
SetLightVisible("SpotLight_11", false);
SetEntityPlayerInteractCallback("castle_1", "insanity", true);
AddEntityCollideCallback("Player", "ScriptArea_35", "Insanity", true, 1);
SetEntityConnectionStateChangeCallback("Lever_3", "Lever");
AddUseItemCallback("", "ItemLever_1", "Block", "UseLever", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "End", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_11", "Wind", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "Noise", true, 1);
AddEntityCollideCallback("castle_1", "ScriptArea_18", "In", true, 1);
AddEntityCollideCallback("enemy_suitor_2", "ScriptArea_31", "Var", true, 1);
AddEntityCollideCallback("enemy_suitor_2", "ScriptArea_43", "Activemaka", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "Noisetwo", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_4", "Noisethree", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_5", "Suitor", true, 1);
AddEntityCollideCallback("enemy_suitor_1", "ScriptArea_6", "diss", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_6", "door", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_8", "Noisefour", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_9", "Noisefive", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_10", "Noisesix", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_29", "MonsterArea", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_30", "Monster", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_17", "book", true, 1);
AddEntityCollideCallback("book_bible_1", "ScriptArea_34", "damagebook", true, 1);
AddEntityCollideCallback("chair_nice01_9", "ScriptArea_42", "chairdamage", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_15", "chair", true, 1);
}
void Lever(string &in asEntity, int alState)
{
if (alState == 1)
{
CreateParticleSystemAtEntity("", "ps_dust_falling.ps", "ScriptArea_24", false);
ConnectEntities("door_connection", "Lever_3", "Secret", false, 1, "CreateDust");
CreateParticleSystemAtEntity("", "ps_dust_falling.ps", "ScriptArea_25", false);
CreateParticleSystemAtEntity("", "ps_dust_falling.ps", "ScriptArea_26", false);
CreateParticleSystemAtEntity("", "ps_dust_falling.ps", "ScriptArea_27", false);
CreateParticleSystemAtEntity("", "ps_dust_falling.ps", "ScriptArea_28", false);
}
}
void UseLever(string &in asItem, string &in asEntity)
{
SetEntityActive("Lever_1", true);
SetEntityActive("Lever", false);
SetEntityActive("Block", false);
PlaySoundAtEntity("wind", "01_whirl.snt", "ScriptArea_19", 0, false);
}
void End(string &in asParent, string &in asChild, int alState)
{
StartCredits("Endcredits.ogg", false, "Ending", "MainCredits", 1);
}
void chairdamage(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(1.0f, true);
}
void chair(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "enabled.snt", "chair_nice01_09", 0, false);
SetEntityActive("chair_nice01_9", true);
}
void No(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "Windig.snt", "ScriptArea_39", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_push_15.ps", "ScriptArea_38", false);
}
void Noise(string &in asParent, string &in asChild, int alState)
{
CreateParticleSystemAtEntity("", "ps_dust_whirl.ps", "ScriptArea_21", false);
CreateParticleSystemAtEntity("", "ps_dust_whirl_large.ps", "ScriptArea_20", false);
AddTimer("", 7, "stop");
FadeInSound("wind", 2.0f, false);
PlaySoundAtEntity("wind", "01_whirl.snt", "ScriptArea_19", 0, false);
}
void stop(string &in asTimer)
{
StopSound("wind", 2.0f);
}
void Noisetwo(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "Timid.snt", "ScriptArea_22", 0, false);
}
void Noisethree(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(1.0f, true);
PlaySoundAtEntity("", "Bahro.snt", "ScriptArea_23", 0, false);
}
void Suitor(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(1.0f, true);
SetEntityActive("enemy_suitor_1", true);
AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_5", 0, "");
}
void diss(string &in asParent, string &in asChild, int alState)
{
PlayMusic("Church.ogg", true, 0.7, 3, 0, true);
SetEntityActive("enemy_suitor_1", false);
}
void door(string &in asParent, string &in asChild, int alState)
{
PlayMusic("stayout.ogg", false, 70, 0, 0, true);
SetSwingDoorDisableAutoClose("Door_1", true);
SetSwingDoorClosed("Door_1",false, true);
AddPropForce("Door_1", 0, 0, -5220, "world");
CreateParticleSystemAtEntity("", "ps_dust_paper_blow.ps", "particle", false);
PlaySoundAtEntity("", "scare_wind.snt", "Player", 0, false);
PlaySoundAtEntity("", "scare_tingeling.snt", "Player", 0, false);
}
void Noisefour(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "Page.snt", "Player", 0, false);
}
void Noisefive(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "Timid.snt", "Player", 0, false);
}
void MonsterArea(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("ScriptArea_30", true);
}
void Monster(string &in asParent, string &in asChild, int alState)
{
AddTimer("", 1, "Monsta");
}
void Monsta(string &in asTimer)
{
SetPropHealth("castle_2", 0.0f);
AddEntityCollideCallback("Player", "ScriptArea_33", "Hide", false, 1);
AddEntityCollideCallback("Player", "ScriptArea_32", "Hide", false, 1);
SetLocalVarInt("Var02", 0);
SetEntityActive("enemy_suitor_2", true);
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_8", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_9", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_10", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_11", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_12", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_13", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_14", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_15", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_16", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_17", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_18", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_19", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_20", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_21", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_22", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_23", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_24", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_25", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_26", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_27", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_28", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_29", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_30", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_31", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_32", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_33", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_34", 0, "");
AddEnemyPatrolNode("enemy_suitor_2", "PathNodeArea_35", 0, "");
}
void Activemaka(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("ScriptArea_31", true);
}
void Var(string &in asParent, string &in asChild, int alState)
{
AddEntityCollideCallback("Player", "ScriptArea_33", "Hide", false, 1);
AddEntityCollideCallback("Player", "ScriptArea_32", "Hide", false, 1);
SetEntityActive("ScriptArea_32", true);
SetEntityActive("ScriptArea_33", true);
AddLocalVarInt("Var02", 1);
EnemyDissapea();
}
void Hide(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("ScriptArea_32", false);
SetEntityActive("ScriptArea_33", false);
AddLocalVarInt("Var02", 1);
EnemyDissapea();
}
void EnemyDissapea()
{
if(GetLocalVarInt("Var02") == 2)
{
FadeEnemyToSmoke("enemy_suitor_2", true);
}
else
{
AddTimer("", 2, "Monsta");
}
}
void In(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(10.0f, true);
PlaySoundAtEntity("", "Horror.snt", "Player", 0, false);
}
void book(string &in asParent, string &in asChild, int alState)
{
SetPropStaticPhysics("book_bible_1", false);
}
void damagebook(string &in asParent, string &in asChild, int alState)
{
GiveSanityDamage(1.0f, true);
}
void Whoa(string &in asParent, string &in asChild, int alState)
{
SetLightVisible("SpotLight_11", true);
PlaySoundAtEntity("", "Glow.snt", "Player", 0, false);
AddTimer("", 4, "Glow");
AddTimer("", 2, "Damage");
}
void Damage(string &in asTimer)
{
GiveSanityDamage(1.0f, true);
}
void Glow(string &in asTimer)
{
PlaySoundAtEntity("", "wholeGlow.snt", "Player", 0, false);
AddTimer("", 2, "Stopp");
}
void Stopp(string &in asTimer)
{
SetLightVisible("SpotLight_11", false);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("23_amb.ogg", true, 0.7, 3, 0, true);
FadeOut(0);
FadeIn(8);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
|