void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

object oWP;
location lWP;
object oSpawn;
int nInt;

int nRND = d6();

int nMS1 = GetLocalInt(oPC, "MonsterSquare1");
int nMS2 = GetLocalInt(oPC, "MonsterSquare2");
int nMS3 = GetLocalInt(oPC, "MonsterSquare3");
int nMS4 = GetLocalInt(oPC, "MonsterSquare4");
int nMS5 = GetLocalInt(oPC, "MonsterSquare5");
int nMS6 = GetLocalInt(oPC, "MonsterSquare6");

if ((nRND == 1)&&(nMS1 != 1))
 {
 oWP = GetWaypointByTag("WP_MS1");
 lWP = GetLocation(oWP);
 oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ms_hellhound", lWP);
 AssignCommand(oSpawn, ActionAttack(oPC));
 nInt = GetObjectType(oSpawn);
 if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), oSpawn));
 else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), GetLocation(oSpawn)));
 SetLocalInt(oPC, "MonsterSquare1", 1);
 }

else if ((nRND == 2)&&(nMS2 != 1))
 {
 oWP = GetWaypointByTag("WP_MS2");
 lWP = GetLocation(oWP);
 oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ms_giantlizard", lWP);
 AssignCommand(oSpawn, ActionAttack(oPC));
 nInt = GetObjectType(oSpawn);
 if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), oSpawn));
 else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), GetLocation(oSpawn)));
 SetLocalInt(oPC, "MonsterSquare2", 1);
 }

else if ((nRND == 3)&&(nMS3 != 1))
 {
 oWP = GetWaypointByTag("WP_MS3");
 lWP = GetLocation(oWP);
 oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ms_giantspider", lWP);
 AssignCommand(oSpawn, ActionAttack(oPC));
 nInt = GetObjectType(oSpawn);
 if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), oSpawn));
 else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), GetLocation(oSpawn)));
 SetLocalInt(oPC, "MonsterSquare3", 1);
 }

else if ((nRND == 4)&&(nMS4 != 1))
 {
 oWP = GetWaypointByTag("WP_MS4");
 lWP = GetLocation(oWP);
 oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ms_leucrotta", lWP);
 AssignCommand(oSpawn, ActionAttack(oPC));
 nInt = GetObjectType(oSpawn);
 if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), oSpawn));
 else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), GetLocation(oSpawn)));
 SetLocalInt(oPC, "MonsterSquare4", 1);
 }

else if ((nRND == 5)&&(nMS5 != 1))
 {
 oWP = GetWaypointByTag("WP_MS5");
 lWP = GetLocation(oWP);
 oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ms_rustmonster", lWP);
 AssignCommand(oSpawn, ActionAttack(oPC));
 nInt = GetObjectType(oSpawn);
 if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), oSpawn));
 else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), GetLocation(oSpawn)));
 SetLocalInt(oPC, "MonsterSquare5", 1);
 }

else if ((nRND == 6)&&(nMS6 != 1))
 {
 oWP = GetWaypointByTag("WP_MS6");
 lWP = GetLocation(oWP);
 oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ms_giantviper", lWP);
 AssignCommand(oSpawn, ActionAttack(oPC));
 nInt = GetObjectType(oSpawn);
 if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), oSpawn));
 else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2), GetLocation(oSpawn)));
 SetLocalInt(oPC, "MonsterSquare6", 1);
 }
else return;
}

