#include "rd_treasure" //#include "x0_i0_treasure" #include "rd_level" #include "nw_i0_tool" object GetCampCreature(string sEncounter,string sCampType, int iType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iOverride = 0); object GetCampCreature2(string sEncounter,string sCampType, int iType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iOverride = 0); object GetCampCreature3(string sEncounter,string sCampType, int iType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iOverride = 0); object GetCampMob(int iType, string sEncounter, string sCampType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iCampType, int iUnique = 1, int iOverride = 0); void SpawnCampMob(int iType, string sEncounter, string sCampType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iCampType, int iUnique = 1, int iOverride = 0); object GetCreature(string sEncounter, string sCreature); object GetWanderingCreature(string sEncounter, string sCreature); int AdjustLevel(int iLevel); object GetRaceCreature(string sCampType,location lLoc, int iLevel); object GetRaceCreatures(string sCampType,location lLoc, int iLevel, int iNum=0); string BossMob(string sCreature); void FixItemComponent(object oCreature, string sTag); void FixItemComponents(object oCreature); void SpawnCampMob(int iType, string sEncounter, string sCampType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iCampType, int iUnique = 1, int iOverride = 0) { //wrapper function GetCampMob(iType, sEncounter, sCampType, iLevel, iBaseStart, iBase,iBaseMax, iCampType,iUnique,iOverride); } object GetCampMob(int iType, string sEncounter, string sCampType, int iLevel, int iBaseStart, int iBase, int iBaseMax, int iCampType, int iUnique = 1, int iOverride = 0) { string sCreature; string sCampTypeCheck; object oCreature; int iCreature; //Check for existing creature first before spawning new one. iCreature = 0; oCreature = GetObjectByTag(sEncounter + "_S"); if (GetIsObjectValid(oCreature)) { sCampTypeCheck= GetLocalString(oCreature,"CampType"); if (sCampTypeCheck == sCampType) iCreature = 1; if (iOverride > 0) iCreature = 0; } if (iCreature == 0 || iUnique == 0) { if (iCampType == 1) { oCreature = GetCampCreature(sEncounter,sCampType,iType,iLevel,iBaseStart, iBase, iBaseMax,iOverride); } else { if (iCampType == 2) oCreature = GetCampCreature2(sEncounter,sCampType,iType,iLevel,iBaseStart, iBase, iBaseMax, iOverride); else oCreature = GetCampCreature3(sEncounter,sCampType,iType,iLevel,iBaseStart, iBase, iBaseMax, iOverride); } } if (iType == 1) { if (Random(5)==0) { AssignCommand(oCreature,ActionRandomWalk()); DelayCommand(3.0f,AssignCommand(oCreature,ClearAllActions())); } if (Random(20)==0) SetActionMode(oCreature,ACTION_MODE_DETECT,TRUE); } if (iType == 2) { if (Random(10)==0) { AssignCommand(oCreature,ActionRandomWalk()); DelayCommand(3.0f,AssignCommand(oCreature,ClearAllActions())); } } return oCreature; } //GetCampCreature is for leveled up campsites object GetCampCreature(string sEncounter, string sCampType,int iType,int iLevel, int iBaseStart, int iBase, int iBaseMax, int iOverride = 0) { object oCreature; object oEncounter; location lLoc; string sType; string sCreature; string sCreatureBase; string sEncounterName; string sOriginalCreature; int iRandom; int iMobTargetLevel; int iMobLevel; int iNewLevel; int iLevels; int iMod; int iChance; int iItems; int iIndex; oEncounter=GetObjectByTag(sEncounter); lLoc = GetLocation(oEncounter); iRandom = Random(10) + 1; switch (iRandom) { case 1: case 2: case 3: sType = "f"; break; //fighter case 4: case 5: sType = "r"; break; //rogue case 6: sType = "m"; break; //mage case 7: case 8: sType = "c"; break; //cleric case 9: sType = "s"; break; //special class case 10: sType = "x"; break; //special creature } //override with leader for boss spawn if (iType==99) sType = "l"; iMobTargetLevel=iLevel; if (iMobTargetLevel < 3) { switch (iType) { case 1: iMobTargetLevel--; break; case 2: iMobTargetLevel; break; case 3: iMobTargetLevel; break; case 99: iMobTargetLevel++; break; } } else if (iMobTargetLevel < 6) { switch (iType) { case 1: iMobTargetLevel=iMobTargetLevel-2; break; case 2: iMobTargetLevel--; break; case 3: iMobTargetLevel; break; case 99: iMobTargetLevel=iMobTargetLevel+1; break; } } else if (iMobTargetLevel < 10) { switch (iType) { case 1: iMobTargetLevel=iMobTargetLevel-2; break; case 2: iMobTargetLevel; break; case 3: iMobTargetLevel+1; break; case 99: iMobTargetLevel=iMobTargetLevel+ Random(2) + 1; break; } } else if (iMobTargetLevel < 15) { switch (iType) { case 1: iMobTargetLevel=iMobTargetLevel-3; break; case 2: iMobTargetLevel; break; case 3: iMobTargetLevel+1; break; case 99: iMobTargetLevel=iMobTargetLevel + Random(2) + 2; break; } } else if (iMobTargetLevel < 25) { switch (iType) { case 1: iMobTargetLevel=iMobTargetLevel-3; break; case 2: iMobTargetLevel; break; case 3: iMobTargetLevel+2; break; case 99: iMobTargetLevel=iMobTargetLevel + Random(3) + 3; break; } } else { switch (iType) { case 1: iMobTargetLevel=iMobTargetLevel-2; break; case 2: iMobTargetLevel+1; break; case 3: iMobTargetLevel + Random(2) + 2; break; case 99: iMobTargetLevel=iMobTargetLevel + Random(3)+4; break; } } iMobTargetLevel=AdjustLevel(iMobTargetLevel); if (iMobTargetLevel>iBaseStart) { iMod = (iMobTargetLevel-iBaseStart)/iBase+1; if (iMod>iBaseMax) iMod=iBaseMax; } else { iMod=1; } if (iMod<1) iMod=1; sCreatureBase = "_" + IntToString(iMod); sCreature = "en3_" + sCampType + "_" + sType + sCreatureBase; sOriginalCreature = sCreature; sCreature = BossMob(sCreature); sEncounterName = sEncounter + "_S"; if (iOverride > 0) sEncounterName = sEncounterName + IntToString(iOverride); oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE,sEncounterName); SetLocalString(oCreature,"CampType",sCampType); //debug line //SendMessageToPC(GetFirstPC(),"Spawning " + sCreature); //Bad Tag Detection if (GetName(oCreature)=="") { string sMessage; sMessage = sCreature + " did not spawn at " + sEncounter; SendMessageToPC(GetFirstPC(),sMessage); WriteTimestampedLogEntry(sMessage); } iMobLevel = GetHitDice(oCreature); if (iMobLevel 0) { if (iType == 99) DelayCommand(0.5f,EquipMob(oCreature,1)); else DelayCommand(0.5f,EquipMob(oCreature)); } //debug line //SendMessageToPC(GetFirstPC(),"Leveled " + GetName(oCreature) + " type " + IntToString(iType) + " to " + IntToString(iNewLevel) + " based on level " + IntToString(iLevel)); } iMobLevel = GetHitDice(oCreature); if (iType == 99) { if (GetLocalInt(GetFirstPC(),"Unlucky")==1) iMobLevel=iMobLevel*2; iChance = iMobLevel/2; if (sCreature != sOriginalCreature) iChance = iChance + 25; if (Random(100) 8) iType = 1; else if (iType == 3 && iRandom > 8) iType = 2; switch (iType) { case 1: iRandom=Random(iBaseStart)+1; sCreature = "en3_" + sCampType + "_1_" + IntToString(iRandom); break; case 2: iRandom=Random(iBase)+1; sCreature = "en3_" + sCampType + "_2_" + IntToString(iRandom); break; case 3: iRandom=Random(iBaseMax)+1; sCreature = "en3_" + sCampType + "_3_" + IntToString(iRandom); break; case 99: sCreature = "en3_" + sCampType + "_Boss"; break; } oEncounter=GetObjectByTag(sEncounter); lLoc = GetLocation(oEncounter); sOriginalCreature = sCreature; sCreature = BossMob(sCreature); sEncounterName = sEncounter + "_S"; if (iOverride > 0) sEncounterName = sEncounterName + IntToString(iOverride); oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE,sEncounterName); SetLocalString(oCreature,"CampType",sCampType); //Bad Tag Detection if (GetName(oCreature)=="") { string sMessage; sMessage = sCreature + " did not spawn at " + sEncounter; SendMessageToPC(GetFirstPC(),sMessage); WriteTimestampedLogEntry(sMessage); } if (iType == 99) { iMobLevel = GetLevelByPosition(1,oCreature) + GetLevelByPosition(2,oCreature) + GetLevelByPosition(3,oCreature); if (GetLocalInt(GetFirstPC(),"Unlucky")==1) iMobLevel=iMobLevel*3; iChance = iMobLevel/2; if (sCreature != sOriginalCreature) iChance = iChance + 25; if (Random(100) 0) sEncounterName = sEncounterName + IntToString(iOverride); oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE,sEncounterName); SetLocalString(oCreature,"CampType",sCampType); //Bad Tag Detection if (GetName(oCreature)=="") SendMessageToPC(GetFirstPC(),"The dragon " + sCreature + " did not spawn at " + sEncounter); if (iType == 99) { if (sCreature != sOriginalCreature) CreateRandomItem(oCreature); if (sType == "001") { if (Random(2)==0) { GetMagicItem(oCreature); } if (Random(100)<5) CreateRandomItem(oCreature); } else if (sType == "002") { GetMagicItem(oCreature); if (Random(100)<10) CreateRandomItem(oCreature); } else if (sType == "003") { GetMagicItem(oCreature); if (Random(2)==0) { GetMagicItem(oCreature); } if (Random(100)<15) CreateRandomItem(oCreature); } } if (iType == 3) if (Random(10) == 0) { SetLocalInt(oCreature,"Wander",1); SetLocalInt(oCreature,"SpawnType",1); } if (iType == 2) { if (Random(10) == 0) { iRandom=Random(10); if (iRandom < 5) SetLocalInt(oCreature,"Wander",1); else if (iRandom == 5) SetLocalInt(oCreature,"Scout",1); else SetLocalInt(oCreature,"Wander",Random(2)+2); SetLocalInt(oCreature,"SpawnType",1); } } if (iType == 1) { if (Random(5) == 0) { iRandom=Random(10); if (iRandom < 4) SetLocalInt(oCreature,"Wander",1); else if (iRandom <6) SetLocalInt(oCreature,"Wander",Random(5)+2); else if (iRandom < 8) SetLocalInt(oCreature,"Scout",1); else SetLocalInt(oCreature,"Scout",Random(4)+2); SetLocalInt(oCreature,"SpawnType",1); } } FixItemComponents(oCreature); return oCreature; } object GetCreature(string sEncounter, string sCreature) { object oCreature; location lLoc; string sOriginalCreature; lLoc = GetLocation(GetObjectByTag(sEncounter)); sOriginalCreature = sCreature; sCreature = BossMob(sCreature); oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE,sEncounter + "_S"); FixItemComponents(oCreature); if (sCreature != sOriginalCreature) { if (Random(2) == 0) CreateRandomItem(oCreature); else GetMagicItem(oCreature); } return oCreature; } int AdjustLevel(int iLevel) { int iRandom; iRandom = Random(10)+1; if (iRandom==5 || iRandom==6) iLevel--; if (iRandom==8 || iRandom==9) iLevel++; if (iLevel<1) iLevel=1; if (iLevel>40) iLevel=40; return iLevel; } object GetWanderingCreature(string sEncounter, string sCreature) { object oCreature; location lLoc; string sOriginalCreature; lLoc = GetLocation(GetObjectByTag(sEncounter)); sOriginalCreature = sCreature; sCreature = BossMob(sCreature); oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE,sEncounter + "_W"); if (sCreature != sOriginalCreature) { if (Random(2) == 0) CreateRandomItem(oCreature); else GetMagicItem(oCreature); } return oCreature; } object GetRaceCreatures(string sCampType,location lLoc, int iLevel, int iNum=0) { int iNumber; int iCount; object oCreature; if (iNum == 0) { iNum = iLevel/4+1; if (iNum>4) iNum=4; } iNumber=Random(iNum)+1; if (iNumber > 2 && iLevel < 3) iNumber = 2; if (iNumber == 4 && iLevel < 7) iNumber = 3; iCount = 1; while (iCount <= iNumber) { oCreature = GetRaceCreature(sCampType,lLoc,iLevel); iCount++; } return oCreature; } object GetRaceCreature(string sCampType,location lLoc, int iLevel) { object oCreature; object oEncounter; string sType; string sCreature; string sCreatureBase; int iRandom; int iMobTargetLevel; int iMobLevel; int iNewLevel; int iLevels; int iMod; int iBaseStart; int iBase; int iBaseMax; iRandom = Random(10) + 1; switch (iRandom) { case 1: case 2: case 3: sType = "f"; break; //fighter case 4: case 5: sType = "r"; break; //rogue case 6: sType = "m"; break; //mage case 7: case 8: sType = "c"; break; //cleric case 9: sType = "s"; break; //special class case 10: sType = "x"; break; //special creature } if (iLevel > 15) { iMobTargetLevel=iLevel + Random(6) - 3; } else { if (iLevel > 5) { iMobTargetLevel=iLevel + Random(3) - 2; } else { iMobTargetLevel=iLevel + Random(2) - 1; } } if (iMobTargetLevel < 1) iMobTargetLevel = 1; iBaseStart = 1; iBase=1; iBaseMax=1; if (iMobTargetLevel>iBaseStart) { iMod = (iMobTargetLevel-iBaseStart)/iBase+1; if (iMod>iBaseMax) iMod=iBaseMax; } else { iMod=1; } sCreatureBase = "_" + IntToString(iMod); sCreature = "en3_" + sCampType + "_" + sType + sCreatureBase; oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE); //debug line //SendMessageToPC(GetFirstPC(),"Spawning " + sCreature); //Bad Tag Detection if (GetName(oCreature)=="") SendMessageToPC(GetFirstPC(),sCreature + " did not spawn."); iMobLevel = GetLevelByPosition(1,oCreature) + GetLevelByPosition(2,oCreature) + GetLevelByPosition(3,oCreature); if (iMobLevel 0) EquipMob(oCreature); //debug line //SendMessageToPC(GetFirstPC(),"Leveled " + GetName(oCreature) + " to " + IntToString(iNewLevel)); } return oCreature; } string BossMob(string sCreature) { string sBoss; int iRandom; int iFlag; sBoss=""; iFlag = 1; if (sCreature == "en3_undead1_boss") sBoss = "undead1_boss" + IntToString(Random(3)+1); if (sCreature == "en3_undead6_boss") sBoss = "undead6_boss" + IntToString(Random(2)+1); if (sCreature == "en3_golem1_boss") sBoss = "golem1_boss" + IntToString(Random(3)+1); if (sCreature == "en3_golem2_boss") sBoss = "golem2_boss" + IntToString(Random(3)+1); if (sCreature == "en3_summon1_boss") sBoss = "summon1_boss" + IntToString(Random(2)+1); if (sCreature == "en3_summon2_boss") sBoss = "summon2_boss" + IntToString(Random(2)+1); if (sCreature == "en3_summon3_boss") sBoss = "summon3_boss" + IntToString(Random(2)+1); if (sCreature == "en3_summon4_boss") sBoss = "summon4_boss" + IntToString(Random(2)+1); if (sCreature == "en3_summon6_boss") sBoss = "summon6_boss" + IntToString(Random(2)+1); if (sCreature == "en3_summon5_boss") sBoss = "summon5_boss" + IntToString(Random(2)+1); if (sCreature == "en3_slaad3_boss") sBoss = "slaad3_boss" + IntToString(Random(2)+1); if (sCreature == "en3_demon_boss") sBoss = "demon_boss" + IntToString(Random(2)+1); if (sCreature == "en3_slaad1_boss") sBoss = "slaad1_boss1"; if (sCreature == "en3_slaad2_boss") sBoss = "slaad2_boss1"; if (sCreature == "en3_harpy_boss") sBoss = "harpy_boss1"; if (sCreature == "en3_unkempt_boss") sBoss = "unkempt_boss1"; if (sCreature == "en3_drider1_boss") sBoss = "drider1_boss1"; if (sCreature == "en3_giant_boss") sBoss = "giant_boss1"; if (sCreature == "en3_troll_boss") sBoss = "troll_boss1"; if (sCreature == "en3_gnoll_boss") sBoss = "gnoll_boss1"; if (sCreature == "en3_medusa") sBoss = "medusa_boss1"; if (sCreature == "en3_stinger_boss") sBoss = "stinger_boss1"; if (sCreature == "en3_bugbear_boss") sBoss = "bugbear_boss1"; if (sCreature == "en3_kobold_boss") sBoss = "kobold_boss1"; if (sCreature == "en3_vampire_l_1") sBoss = "en3_vampire_" + IntToString(Random(3)+1); if (sCreature == "en3_bandit_l_1") sBoss = "bandit_1"; if (sCreature == "en3_bandit_l_2") sBoss = "bandit_2"; if (sCreature == "en3_bandit_l_3") sBoss = "bandit_3"; if (sCreature == "en3_merc_l_1") sBoss = "merc_1"; if (sCreature == "en3_merc_l_2") sBoss = "merc_2"; if (sCreature == "en3_merc_l_3") sBoss = "merc_3"; if (sCreature == "en3_shade_l_1") sBoss = "shade_1"; if (sCreature == "en3_halfling_l_1") sBoss = "halfling_1"; if (sCreature == "en3_elf_l_1") sBoss = "elf_1"; if (sCreature == "en3_drow_l_1") sBoss = "drow_1"; if (sCreature == "en3_dwarf_l_1") sBoss = "dwarf_1"; if (sCreature == "en3_duergar_l_1") sBoss = "duergar_1"; if (sCreature == "en3_angelic_l_1") sBoss = "angelic_1"; if (sCreature == "en3_fiend_l_1") sBoss = "fiend_1"; if (sCreature == "en3_orc_l_2") sBoss = "orc_2"; if (sCreature == "en3_orc_l_4") sBoss = "orc_4"; if (sCreature == "en3_minotaur_l_1") sBoss = "minotaur_1"; if (sCreature == "en3_minotaur_l_3") sBoss = "minotaur_3"; if (sCreature == "en3_lizard_l_1") sBoss = "lizard_1"; if (sCreature == "en3_lizard_l_2") sBoss = "lizard_1"; if (sCreature == "en3_goblin_l_3") sBoss = "goblin_3"; if (sCreature == "en3_giant_l_1") sBoss = "giant_1"; if (sCreature == "en3_giant_l_3") sBoss = "giant_3"; if (sCreature == "en3_ogre_l_2") sBoss = "ogre_2"; if (sCreature == "en3_beholdermage") sBoss = "en3_beholderboss"; if (sCreature == "en3_CYCLOPSA") sBoss = "en3_CYCLOPSboss"; if (sCreature == "en3_SATYR") sBoss = "en3_SATYRboss"; if (sCreature == "en3_cambion") sBoss = "en3_cambionboss"; if (sCreature == "en3_rakshasa") sBoss = "en3_rakshasaboss"; if (sCreature == "NW_WEREWOLF") sBoss = "en3_Werewolfboss"; if (sCreature == "EN3_TIEFLINGN1") sBoss = "en3_tiefboss"; if (sCreature == "NW_DRGBLACK003") sBoss = "en3_DRGBLACKboss"; if (sCreature == "NW_DRGRED003") sBoss = "en3_DRGREDboss"; if (sCreature == "en3_monkevil") sBoss = "en3_monkevil2"; if (sCreature == "en3_paladingood") sBoss = "en3_paladingood2"; if (sCreature == "en3_demilich") sBoss = "en3_azethoth"; if (sCreature == "en3_spider2_boss") sBoss = "EN3_BOSSSPIDER"; if (sCreature == "EN3_BEARDIREBOSS") sBoss = "EN3_BOSSBEARDIRE"; if (sCreature == "en3_trog_boss") sBoss = "trog_boss"; if (sCreature == "en3_stirge_boss") sBoss = "stirge_boss"; if (sCreature == "en3_blackguard") sBoss = "en3_bgboss"; if (sCreature == "en4_ctorm") sBoss = "en4_ctboss"; if (sCreature == "en3_gnome_l_1") sBoss = "en3_gnome_boss"; if (sCreature == "en3_human_l_1") sBoss = "en3_human_boss"; if (sCreature == "en3_PLANETAR1") sBoss = "en3_pboss"; if (sCreature == "en4_mindflayer") sBoss = "en4_mfboss"; if (sCreature == "en3_kobold_boss") sBoss = "kobold_boss"; if (sBoss == "") iFlag = 0; iRandom=Random(20)+1; if (GetLocalInt(GetModule(),"UniqueBoss") == 1) iRandom=1; if (iRandom < 4 && iFlag == 1) if (GetLocalInt(GetModule(),sBoss) == 0) { sCreature=sBoss; SetLocalInt(GetModule(),sBoss,1); } return sCreature; } void FixItemComponents(object oCreature) { string sTag; sTag = "en4_bargskin"; FixItemComponent(oCreature,sTag); sTag = "en4_ostinger"; FixItemComponent(oCreature,sTag); sTag = "en4_mheart"; FixItemComponent(oCreature,sTag); sTag = "en4_lichdust"; FixItemComponent(oCreature,sTag); sTag = "en3_demonhide"; FixItemComponent(oCreature,sTag); sTag = "NW_IT_MSMLMISC14"; FixItemComponent(oCreature,sTag); sTag = "NW_IT_MSMLMISC09"; FixItemComponent(oCreature,sTag); sTag = "NW_IT_MSMLMISC10"; FixItemComponent(oCreature,sTag); sTag = "en3_salskin"; FixItemComponent(oCreature,sTag); sTag = "en3_rscale"; FixItemComponent(oCreature,sTag); sTag = "en3_bbvsack"; FixItemComponent(oCreature,sTag); sTag = "NW_IT_MSMLMISC17"; FixItemComponent(oCreature,sTag); sTag = "en3_beye"; FixItemComponent(oCreature,sTag); sTag = "en3_igtongue"; FixItemComponent(oCreature,sTag); sTag = "en3_wessence"; FixItemComponent(oCreature,sTag); sTag = "en3_ceye"; FixItemComponent(oCreature,sTag); sTag = "en3_ftooth"; FixItemComponent(oCreature,sTag); sTag = "NW_IT_MSMLMISC06"; FixItemComponent(oCreature,sTag); sTag = "NW_IT_MSMLMISC19"; FixItemComponent(oCreature,sTag); sTag = "en3_seye"; FixItemComponent(oCreature,sTag); sTag = "en4_lichskull"; FixItemComponent(oCreature,sTag); sTag = "en3_igeye"; FixItemComponent(oCreature,sTag); sTag = "en4_cfeather"; FixItemComponent(oCreature,sTag); sTag = "en4_btail"; FixItemComponent(oCreature,sTag); sTag = "en4_gheart"; FixItemComponent(oCreature,sTag); sTag = "en4_mskull"; FixItemComponent(oCreature,sTag); sTag = "en4_cubeooze"; FixItemComponent(oCreature,sTag); sTag = "en4_mfstalk"; FixItemComponent(oCreature,sTag); sTag = "en4_mspike"; FixItemComponent(oCreature,sTag); sTag = "en4_ghair"; FixItemComponent(oCreature,sTag); sTag = "en4_card"; FixItemComponent(oCreature,sTag); } void FixItemComponent(object oCreature, string sTag) { object oItem; if (HasItem(oCreature,sTag)) { oItem = GetItemPossessedBy(oCreature, sTag); if (Random(3)>0) DestroyObject(oItem); } }