private void PopulateArea(CLRScriptBase script)
{
List<Vector3> trapsToSpawn = new List<Vector3>();
if (!DungeonStore.DungeonSpawns.ContainsKey(SpawnType)) return;
foreach(uint wp in script.GetObjectsInArea(AreaId))
{
if(script.GetTag(wp) == "MONSTER_LOW")
{
if (DungeonStore.DungeonSpawns[SpawnType].ContainsKey(CR / 3))
{
script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, DungeonStore.DungeonSpawns[SpawnType][CR/3][rand.Next(DungeonStore.DungeonSpawns[SpawnType][CR/3].Count)], script.GetLocation(wp), CLRScriptBase.TRUE, "");
}
}
else if(script.GetTag(wp) == "MONSTER_MED")
{
if (DungeonStore.DungeonSpawns[SpawnType].ContainsKey(CR / 2))
{
script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, DungeonStore.DungeonSpawns[SpawnType][CR/2][rand.Next(DungeonStore.DungeonSpawns[SpawnType][CR/2].Count)], script.GetLocation(wp), CLRScriptBase.TRUE, "");
}
}
else if(script.GetTag(wp) == "MONSTER_HIGH")
{
if (DungeonStore.DungeonSpawns[SpawnType].ContainsKey(CR))
{
script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, DungeonStore.DungeonSpawns[SpawnType][CR][rand.Next(DungeonStore.DungeonSpawns[SpawnType][CR].Count)], script.GetLocation(wp), CLRScriptBase.TRUE, "");
}
if (!questSpawned)
{
questSpawned = true;
NWEffect AoE = script.EffectAreaOfEffect(86, "acf_trg_onenter", "acf_trg_onheartbeat", "acf_trg_onexit", "AOE"+Quest);
script.ApplyEffectAtLocation(CLRScriptBase.DURATION_TYPE_PERMANENT, script.SupernaturalEffect(AoE), script.GetLocation(wp), 0.0f);
uint spawnedAoE = script.GetObjectByTag("AOE" + Quest, 0);
script.SetLocalString(spawnedAoE, "ACR_QST_NAME", Quest);
script.SetLocalInt(spawnedAoE, "ACR_QST_LOWER_STATE", 1);
script.SetLocalInt(spawnedAoE, "ACR_QST_UPPER_STATE", 2);
script.SetLocalString(spawnedAoE, "ACR_QST_MESSAGE", "This appears to be the end of the dungeon, and your path here is scouted.");
}
}
else if (script.GetTag(wp) == "TRAP")
{
if(DungeonStore.DungeonTraps[TrapType].ContainsKey(CR))
{
trapsToSpawn.Add(script.GetPosition(wp));
}
}
}
foreach (Vector3 trap in trapsToSpawn)
{
script.ClearScriptParams();
script.AddScriptParameterInt(1);
script.AddScriptParameterFloat(trap.x);
script.AddScriptParameterFloat(trap.y);
script.AddScriptParameterFloat(trap.z);
script.AddScriptParameterObject(AreaId);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterFloat(-1.0f);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterObject(CLRScriptBase.OBJECT_INVALID);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterInt(-1);
script.AddScriptParameterString(DungeonStore.DungeonTraps[TrapType][CR][rand.Next(DungeonStore.DungeonTraps[TrapType][CR].Count)]);
script.ExecuteScriptEnhanced("ACR_Traps", script.GetModule(), CLRScriptBase.FALSE);
}
}