void main() { object oSelf=OBJECT_SELF; ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD,FALSE),GetLocation(oSelf)); int iMapLevel = GetLocalInt(oSelf,"iChestLevel"); object oPC = GetLocalObject(oSelf,"oDiggingPC"); //Avoid PC logout exploit.. to log out to avoid spawn.. *NOT ALLOWED* if (GetIsObjectValid(oPC)==FALSE) { ExecuteScript("onclose_clear",oSelf); return; } int iMonsterMaxCount = (d4(10)/2)+iMapLevel; int iSpawnNow = d4(1)+2; iMonsterMaxCount = iMonsterMaxCount-iSpawnNow; SetLocalInt(oSelf,"iMaxMonster",iMonsterMaxCount);//Max number of monsters remaining for chest float fDelay=1.0; for (iSpawnNow; iSpawnNow>0; iSpawnNow--) { fDelay=fDelay+0.1; AssignCommand(oSelf,DelayCommand(fDelay,ExecuteScript("_map_chst_spawn2",oSelf))); } }