#include "rd_spawn" #include "rd_spawnspecial" #include "prc_class_const" #include "utl_i_sqluuid" //:: void main (){} void RespawnMobs(); void RespawnCamps(); void RespawnCampsAE(object oPC,int iDiff=0, int iSetLevel = 0, int iSpecialSpawn = 0); void RespawnMobsAE(object oPC,int iDiff=0, int iSetLevel = 0); int GetHighestPC(object oTargetPC); void ZoneRandom(); void RandomEvent(object oPC, string sZone); void GetPatrol(int iLevel,string sTag); void GetWanderingRace(int iLevel,string sTag, string sRace, int iMaxLevel=40); void GetParty(int iLevel, string sTag, int iGood=1); void LevelPartyMember(object oCreature, int iLevel); void GetGypsies(string sZone); void GetBandit(location lLoc,string sTag,int iLevel); void GetBandits(string sZone,int iLevel); string GetGoodFighter(); string GetGoodCleric(); string GetGoodRogue(); string GetGoodWizard(); string GetEvilFighter(); string GetEvilCleric(); string GetEvilRogue(); string GetEvilWizard(); void GetHero(string sZone,int iLevel); void WanderingDragon(string sZone,object oPC); void GetRandomMobsSpecial(string sZone,object oPC); string GetRaceByLevel(int iLevel); void SummonAnything(object oPC,location lLoc,int iLevel); void GetRandomCampCreatures(object oPC, string sTag); int GetAdjustedLevel(object oPC, int iDiff=0); void SetTrapsAndDoors(object oPC); void CheckZone(object oPC); int GetMaxCampSpots(string sZone); void RespawnMobs() { string sZone; object oPC; object oLastPC; int iCount; int iFlag; int iLevel; int iPCCount; int iAdjustedLevel; int iRnd; int iIndex; int iRnd2; int iDeathAllowed; int iDeathAdjust; //Try to Randomize iRnd=GetTimeSecond(); iIndex=1; while (iIndex<=iRnd) { iIndex++; iRnd2=Random(100); } oPC=GetFirstPC(); iCount = 0; iFlag = 0; while (iFlag == 0) { iCount++; oLastPC = oPC; iLevel = GetHighestPC(oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAdjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; iAdjustedLevel = iAdjustedLevel + iDeathAdjust; if (GetLocalInt(oPC,"Unlucky")==1) iAdjustedLevel++; if (GetLocalInt(GetModule(),"Easy") == 1) iAdjustedLevel = iAdjustedLevel - 2; if (iAdjustedLevel > (iLevel + 3)) iAdjustedLevel = iLevel +3; if (iAdjustedLevel < 1) iAdjustedLevel =1; if (iAdjustedLevel > 40) iAdjustedLevel =40; sZone=GetZone(oPC); if (!(sZone == "END")) SpawnMobs(sZone,iAdjustedLevel); oPC = GetNextPC(); // if (GetName(oLastPC) == GetName(oPC)) if (!GetIsObjectValid(oPC)) { iFlag = 1; } } } void RespawnCamps() { object oPC; object oLastPC; int iCount; int iFlag; oPC=GetFirstPC(); iCount = 0; iFlag = 0; while (iFlag == 0) { iCount++; oLastPC = oPC; SetLocalInt(GetArea(oPC),"Spawned",0); oPC = GetNextPC(); // if (GetName(oLastPC) == GetName(oPC)) if (!GetIsObjectValid(oPC)) { iFlag = 1; } } } void RespawnMobsAE(object oPC,int iDiff=0, int iSetLevel = 0) { string sZone; int iLevel; int iAdjustedLevel; int iRnd; int iIndex; int iRnd2; //Try to Randomize iRnd=GetTimeSecond(); iIndex=1; while (iIndex<=iRnd) { iIndex++; iRnd2=Random(100); } iAdjustedLevel = GetAdjustedLevel(oPC,iDiff); if (iSetLevel > 0) iAdjustedLevel = iSetLevel; sZone=GetZone(oPC); if (sZone != "") DelayCommand(0.5f,SpawnMobs(sZone,iAdjustedLevel)); } void RespawnCampsAE(object oPC,int iDiff=0, int iSetLevel = 0, int iSpecialSpawn = 0) { string sZone; int iLevel; int iPCCount; int iAdjustedLevel; int iRnd; int iIndex; int iRnd2; int iDeathAllowed; int iDeathAjust; //avoid respawning full camps upon a load game if (GetLocalInt(GetModule(),"ClientEnter") == 1) return; //Try to Randomize iRnd=GetTimeSecond(); iIndex=1; while (iIndex<=iRnd) { iIndex++; iRnd2=Random(100); } iAdjustedLevel = GetAdjustedLevel(oPC,iDiff); if (iSetLevel > 0) iAdjustedLevel = iSetLevel; sZone=GetZone(oPC); WriteTimestampedLogEntry("Respawn camps in " + sZone + " for level " + IntToString(iAdjustedLevel)); if (sZone != "") SpawnCamps(sZone,iAdjustedLevel, iSpecialSpawn); } int GetHighestPC(object oTargetPC) { string sZone; string sTargetZone; object oPC; object oLastPC; int iCount; int iFlag; int iLevel; int iHighLevel; oPC=GetFirstPC(); iCount = 0; iFlag = 0; sTargetZone = GetZone(oTargetPC); iHighLevel = GetLevelByPosition(1,oTargetPC) + GetLevelByPosition(2,oTargetPC) + GetLevelByPosition(3,oTargetPC); iHighLevel = iHighLevel + GetLocalInt(oTargetPC,"Adjust"); while (iFlag == 0) { iCount++; oLastPC = oPC; sZone=GetZone(oPC); if (sZone == sTargetZone) { iLevel = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC); iLevel = iLevel + GetLocalInt(oPC,"Adjust"); if (iLevel>iHighLevel) iHighLevel=iLevel; } oPC = GetNextPC(); if (GetName(oLastPC) == GetName(oPC)) { iFlag = 1; } } return iHighLevel; } void ZoneRandom() { object oPC; string sZone; oPC = GetRandomPC(); sZone = GetLocalString(GetArea(oPC),"Prefix"); if (Random(8)==0) { if (sZone != "") RandomEvent(oPC,sZone); } } void RandomEvent(object oPC, string sZone) { int iLevel; int iRandom; int iRandom2; string sTag; string sCreature; iLevel = GetHitDice(oPC); iLevel = ZoneLevel(GetArea(oPC),iLevel); iRandom = Random(20)+1; WriteTimestampedLogEntry("Random Zone Event For " + sZone + " (" + IntToString(iRandom) + ")"); switch (iRandom) { case 1: case 18: //Wandering Good Party sTag = sZone + "_W"; GetParty(iLevel,sTag,1); break; case 2: case 19: //Wandering Evil Party sTag = sZone + "_W"; GetParty(iLevel,sTag,0); break; case 3: //Patrolling Party sTag = sZone + "_P"; GetParty(iLevel,sTag,Random(2)); break; case 4: //Patrol sTag = sZone + "_P"; GetPatrol(iLevel,sTag); break; case 5: //Patrol sTag = sZone + "_P"; GetPatrol(iLevel,sTag); break; case 6: //Patrolling Bandits sTag = sZone + "_P"; GetWanderingRace(iLevel,sTag,"bandit",12); break; case 7: //Wandering Bandits sTag = sZone + "_W"; GetWanderingRace(iLevel,sTag,"bandit",12); break; case 8: case 17://Wandering Race sTag = sZone + "_W"; sCreature = GetRaceByLevel(iLevel); GetWanderingRace(iLevel,sTag,sCreature,12); break; case 9: //Party in Town GetParty(iLevel,sZone + "_Town",1); break; case 10: case 16: //Gypsies GetGypsies(sZone); break; case 11: case 20: //Gypsies GetBandits(sZone,iLevel); break; case 12: //Evil Hero GetHero(sZone,iLevel); break; case 13: WanderingDragon(sZone,oPC); break; case 14: case 15: GetRandomMobsSpecial(sZone,oPC); break; } } void GetBandits(string sZone,int iLevel) { string sTag; object oCreature; location lLoc; sTag = sZone + "_G1"; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); GetBandit(lLoc,sTag,iLevel); } sTag = sZone + "_G2"; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); GetBandit(lLoc,sTag,iLevel); } sTag = sZone + "_G3"; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); GetBandit(lLoc,sTag,iLevel); } } void GetBandit(location lLoc,string sTag,int iLevel) { int iRandom; int iNewLevel; int iLevels; string sType; string sCreature; object oCreature; 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 } sCreature = "en3_bandit_" + sType + "_1"; oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); if (iLevel < 5) iLevels = Random(5); else iLevels = Random(5) + (iLevel - 3); if (iLevels >0) iNewLevel = LevelMob(oCreature,iLevels); AssignCommand(oCreature,ActionRest()); if (iNewLevel > 0) EquipMob(oCreature); } void GetGypsies(string sZone) { string sTag; string sGypsy; object oCreature; location lLoc; sTag = sZone + "_G1"; sGypsy = "en3_gypsy1"; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); CreateObject(OBJECT_TYPE_CREATURE,sGypsy,lLoc,FALSE,sTag + "_S"); } sTag = sZone + "_G2"; sGypsy = "en3_gypsy2"; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); CreateObject(OBJECT_TYPE_CREATURE,sGypsy,lLoc,FALSE,sTag + "_S"); } sTag = sZone + "_G3"; sGypsy = "en3_gypsy3"; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); CreateObject(OBJECT_TYPE_CREATURE,sGypsy,lLoc,FALSE,sTag + "_S"); } } void GetPatrol(int iLevel,string sTag) { object oCreature; location lLoc; int iRandom; int iIndex; int iLevels; int iNewLevel; string sCreature; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { sCreature = "en3_patrol"; lLoc = GetLocation(GetObjectByTag(sTag)); iRandom = Random(3)+2; iIndex=0; while (iIndex < iRandom) { oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); iLevels = iLevel - (Random(2)+2) - 1; if (iLevels>9) iLevels = 9; iNewLevel = 0; if (iLevels >0) iNewLevel = LevelMob(oCreature,iLevels); AssignCommand(oCreature,ActionRest()); if (iNewLevel > 0) EquipMob(oCreature); iIndex++; } } } void GetWanderingRace(int iLevel,string sTag,string sRace, int iMaxLevel=40) { object oCreature; location lLoc; int iRandom; int iRandom2; int iIndex; int iLevels; int iNewLevel; string sCreature; string sType; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); iRandom = Random(3)+2; iIndex=0; while (iIndex < iRandom) { iRandom2 = Random(10) + 1; switch (iRandom2) { 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 } sCreature = "en3_" + sRace + "_" + sType + "_1"; oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); iLevels = iLevel - (Random(2)+2) - 1; if (Random(5)==0 && iLevel > 2) iLevels = iLevels + Random(5)+1; if (iLevels>(iMaxLevel-1)) iLevels = iMaxLevel-1; iNewLevel = 0; if (iLevels >0) iNewLevel = LevelMob(oCreature,iLevels); AssignCommand(oCreature,ActionRest()); if (iNewLevel > 0) EquipMob(oCreature); iIndex++; } } } void GetParty(int iLevel, string sTag, int iGood=1) { object oCreature; location lLoc; int iRandom; int iIndex; int iLevels; int iNewLevel; int iFighters; int iClerics; int iRogues; int iWizards; string sCreature; oCreature = GetObjectByTag(sTag + "_S"); if (!(GetIsObjectValid(oCreature))) { lLoc = GetLocation(GetObjectByTag(sTag)); iFighters = Random(3)+1; iWizards = Random(2); iClerics = Random(2); iRogues = Random(2); if (Random(2) == 0) iClerics++; if (Random(4) == 0) iRogues++; if (Random(6) == 0) iWizards++; iIndex=0; while (iIndex < iFighters) { if (iGood == 1) sCreature = GetGoodFighter(); else sCreature = GetEvilFighter(); oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); LevelPartyMember(oCreature,iLevel); iIndex++; } iIndex=0; while (iIndex < iClerics) { if (iGood == 1) sCreature = GetGoodCleric(); else sCreature = GetEvilCleric(); oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); LevelPartyMember(oCreature,iLevel); iIndex++; } iIndex=0; while (iIndex < iWizards) { if (iGood == 1) sCreature = GetGoodWizard(); else sCreature = GetEvilWizard(); oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); LevelPartyMember(oCreature,iLevel); iIndex++; } iIndex=0; while (iIndex < iRogues) { if (iGood == 1) sCreature = GetGoodRogue(); else sCreature = GetEvilRogue(); oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); LevelPartyMember(oCreature,iLevel); iIndex++; } } } void GetHero(string sZone,int iLevel) { string sTag; string sCreature; location lLoc; object oCreature; int iRandom; int iIndex; if (Random(2)==0) sTag = sZone + "_P"; else sTag = sZone + "_W"; lLoc = GetLocation(GetObjectByTag(sTag)); iRandom = Random(11)+1; sCreature = "en3_class" + IntToString(iRandom); oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); //if (!(GetIsObjectValid(oCreature))) // SendMessageToPC(GetFirstPC(),sCreature + " did not spawn as a hero."); iLevel = iLevel + Random(4) + 1; if (iLevel > 40) iLevel = 40; LevelPartyMember(oCreature,iLevel); if (iLevel < 6) iRandom = Random(2); else if (iLevel < 10) iRandom = Random(2)+1; else iRandom = Random(3)+1; iIndex = 0; if (Random(3)==0) { GetArtifact(oCreature); } else { while (iIndex < iRandom) { GetMagicItem(oCreature); iIndex++; } } } void LevelPartyMember(object oCreature, int iLevel) { int iLevels; int iNewLevel; iLevels = iLevel - (Random(2)+2) - 1; if (Random(5)==0) iLevels = iLevels + Random(5) + 1; if (iLevels>40) iLevels = 9; iNewLevel = 0; if (iLevels >0) iNewLevel = LevelMob(oCreature,iLevels); AssignCommand(oCreature,ActionRest()); if (iNewLevel > 0) EquipMob(oCreature); if (Random(100)<((iNewLevel+1)/2)) GetMagicItem(oCreature); } string GetGoodFighter() { int iRandom; string sTag; iRandom = Random(9)+1; switch (iRandom) { case 1: sTag = "en3_fightergood"; break; case 2: sTag = "en3_paladingood"; break; case 3: sTag = "en3_rangergood"; break; case 4: sTag = "en3_hlffightergood"; break; case 5: sTag = "en3_dwarf_x_1"; break; case 6: sTag = "en3_dwarf_s_1"; break; case 7: sTag = "en3_dwarf_f_1"; break; case 8: sTag = "en3_elf_f_1"; break; case 9: sTag = "en3_elf_r_1"; break; } return sTag; } string GetGoodCleric() { int iRandom; string sTag; iRandom = Random(4)+1; switch (iRandom) { case 1: sTag = "en3_clericgood"; break; case 2: sTag = "en3_dwarf_c_1"; break; case 3: sTag = "en3_elf_x_1"; break; case 4: sTag = "en3_elf_c_1"; break; } return sTag; } string GetGoodRogue() { int iRandom; string sTag; iRandom = Random(4)+1; switch (iRandom) { case 1: sTag = "en3_roguegood"; break; case 2: sTag = "en3_monkgood"; break; case 3: sTag = "en3_hflroguegood"; break; case 4: sTag = "en3_hflroguegood"; break; } return sTag; } string GetGoodWizard() { int iRandom; string sTag; iRandom = Random(5)+1; switch (iRandom) { case 1: sTag = "en3_bardgood"; break; case 2: sTag = "en3_wizardgood"; break; case 3: sTag = "en3_dwarf_m_1"; break; case 4: sTag = "en3_elf_m_1"; break; case 5: sTag = "en3_elf_s_1"; break; } return sTag; } string GetEvilCleric() { int iRandom; string sTag; iRandom = Random(6)+1; switch (iRandom) { case 1: sTag = "en3_clericevil"; break; case 2: sTag = "en3_duergar_c_1"; break; case 3: sTag = "en3_drow_c_1"; break; case 4: sTag = "en3_dpevil"; break; case 5: sTag = "en3_clericevil"; break; case 6: sTag = "en3_clericevil"; break; } return sTag; } string GetEvilFighter() { int iRandom; string sTag; iRandom = Random(7)+1; switch (iRandom) { case 1: sTag = "en3_fighterevil"; break; case 2: sTag = "en3_hobarbarian"; break; case 3: sTag = "en3_duergar_f_1"; break; case 4: sTag = "en3_dfevil"; break; case 5: sTag = "en3_drow_f_1"; break; case 6: sTag = "en3_fighterevil"; break; case 7: sTag = "en3_hobarbarian"; break; } return sTag; } string GetEvilRogue() { int iRandom; string sTag; iRandom = Random(4)+1; switch (iRandom) { case 1: sTag = "en3_monkevil"; break; case 2: sTag = "en3_rogueevil"; break; case 3: sTag = "en3_hflrogueevil"; break; case 4: sTag = "en3_drow_r_1"; break; } return sTag; } string GetEvilWizard() { int iRandom; string sTag; iRandom = Random(6)+1; switch (iRandom) { case 1: sTag = "en3_wizardevil"; break; case 2: sTag = "en3_wizardevil"; break; case 3: sTag = "en3_wizardevil"; break; case 4: sTag = "en3_gsevil"; break; case 5: sTag = "en3_drow_m_1"; break; case 6: sTag = "en3_drow_s_1"; break; } return sTag; } void WanderingDragon(string sZone,object oPC) { int iRandom; int iAdjust; int iLevelTest; int iLevel; int iDeathAllowed; int iDeathAdjust; string sColor; string sTag; string sCreature; string sType; object oCreature; location lLoc; sTag = sZone + "_W"; iLevel = GetHitDice(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAdjust = (iDeathAllowed-2)/2; iLevel = iLevel + iDeathAdjust; iLevel = ZoneLevel(GetArea(oPC),iLevel); iAdjust = Random(10)+1; if (iAdjust < 2) iLevelTest=iLevel-2; else if (iAdjust < 4) iLevelTest=iLevel-1; else if (iAdjust < 8) iLevelTest=iLevel; else if (iAdjust < 10) iLevelTest=iLevel+1; else iLevelTest=iLevel+2; if (iLevelTest<15) sType = "001"; else if (iLevelTest < 19) sType = "002"; else sType = "003"; iRandom = 1; if (sType=="001") { if (iLevel <11) iRandom = 1; if (iLevel <13) iRandom = Random(3)+1; else iRandom=Random(4)+2; } else if (sType=="002") { if (iLevel <15) iRandom = 1; else iRandom=Random(5)+1; } else iRandom=Random(6)+1; switch (iRandom) { case 1: sColor = "WHITE"; break; case 2: sColor = "BLACK"; break; case 3: sColor = "BLUE"; break; case 4: sColor = "GREEN"; break; case 5: sColor = "RED"; break; case 6: sColor = "SHADOW"; break; } sCreature = "NW_DRG" + sColor + sType; if (sColor == "SHADOW") sCreature = "X2_DRAGONSHAD001"; if (iLevel < 4) sCreature = "en3_dragon0_1_1"; else if (iLevel < 9) { iRandom = Random(6)+1; switch (iRandom) { case 1: sCreature = "x0_wyrmling_blk"; break; case 2: sCreature = "x0_wyrmling_wht"; break; case 3: sCreature = "x0_wyrmling_grn"; break; case 4: sCreature = "x0_wyrmling_blu"; break; case 5: sCreature = "x0_wyrmling_red"; break; case 6: sCreature = "en3_dragon2_1_1"; break; } } if (iLevel>30) if (Random(2)==0) sCreature = "X2_DRACOLICH001"; else sCreature = "en3_dragon4_boss"; lLoc = GetLocation(GetObjectByTag(sTag)); oCreature=CreateObject(OBJECT_TYPE_CREATURE,sCreature,lLoc,FALSE,sTag + "_S"); } string GetRaceByLevel(int iLevel) { int iRandom2; string sCreature; sCreature="orc"; if (iLevel<11) { iRandom2 = Random(4) +1; switch (iRandom2) { case 1: sCreature = "orc"; break; case 2: sCreature = "goblin"; break; case 3: sCreature = "lizardman"; break; case 4: sCreature = "elf"; break; } } else if (iLevel<21) { iRandom2 = Random(4) +1; switch (iRandom2) { case 1: sCreature = "ogre"; break; case 2: sCreature = "minotaur"; break; case 3: sCreature = "merc"; break; case 4: sCreature = "elf"; break; } } else if (iLevel<31) { iRandom2 = Random(5) +1; switch (iRandom2) { case 1: sCreature = "giant"; break; case 2: sCreature = "minotaur"; break; case 3: sCreature = "drow"; break; case 4: sCreature = "duergar"; break; case 5: sCreature = "vampire"; break; } } else { iRandom2 = Random(5) +1; switch (iRandom2) { case 1: sCreature = "vampire"; break; case 2: sCreature = "fiend"; break; case 3: sCreature = "drow"; break; case 4: sCreature = "duergar"; break; case 5: sCreature = "angelic"; break; } } return sCreature; } void GetRandomMobsSpecial(string sZone,object oPC) { string sTag; string sCreature; int iX; int iFlag; int iSpot; int iRandom; int iLevel; int iDeathAllowed; int iDeathAdjust; object oSpawn; location lLoc; iLevel = GetHitDice(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAdjust = (iDeathAllowed-2)/2; iLevel = iLevel + iDeathAdjust; iLevel = ZoneLevel(GetArea(oPC),iLevel); iX = GetXSpot(sZone); iSpot = Random(iX)+1; sTag = sZone + "_X_" + IntToString(iSpot); lLoc = GetLocation(GetObjectByTag(sTag)); iRandom = Random(4)+1; switch (iRandom) { case 1: sCreature = GetRaceByLevel(iLevel); GetRaceCreatures(sCreature,lLoc,iLevel); break; case 2: SummonAnything(oPC,lLoc,iLevel); break; case 3: GetRandomCampCreatures(oPC,sTag); break; case 4: GetParty(iLevel,sTag,Random(1)); break; } } void SummonAnything(object oPC,location lLoc,int iLevel) { object oArea; int iArea; string sCreature; oArea=GetArea(oPC); iArea=GetIsAreaInterior(oArea); if (iArea == FALSE) SetCreatureTags(iLevel,0); else SetCreatureTags(iLevel,1); sCreature=GetCreatureTag(); CreateObject(OBJECT_TYPE_CREATURE, sCreature,lLoc,FALSE); } void GetRandomCampCreatures(object oPC, string sTag) { object oCreature; object oMod; string sCampType; int iDifficulty; int iBase; int iBaseStart; int iBaseMax; int iCampType; int iLevel; int iDeathAllowed; int iDeathAjust; int iAdjustedLevel; int iPCCount; int iCreatureLevel; iLevel = GetHitDice(oPC); iAdjustedLevel = iAdjustedLevel + GetLocalInt(oPC,"Adjust"); iAdjustedLevel = ZoneLevel(GetArea(oPC),iLevel); //Setup for races and allow indoors only to be spookiness SetupCampTypes(iAdjustedLevel, 1, 1, 0, 0); sCampType = GetCampType(); oMod = GetModule(); iBase = GetLocalInt(oMod,"iBase"); iBaseStart = GetLocalInt(oMod,"iBaseStart"); iBaseMax = GetLocalInt(oMod,"iBaseMax"); iCampType = GetLocalInt(oMod,"iCampType"); SetLocalInt(oMod,"iBase",0); SetLocalInt(oMod,"iBaseStart",0); SetLocalInt(oMod,"iBaseMax",0); SetLocalInt(oMod,"iCampType",0); iCreatureLevel = Random(5) - 2 + iAdjustedLevel; if (iCreatureLevel < 1) iCreatureLevel = 1; if (iCreatureLevel >40) iCreatureLevel = 40; //SendMessageToPC(oPC,"Tag = " + sTag + " CampType = " + sCampType); oCreature = GetCampMob(iCreatureLevel,sTag,sCampType,iAdjustedLevel,iBaseStart,iBase,iBaseMax,iCampType, 0); //SendMessageToPC(oPC,"Creature = " + GetTag(oCreature)); } int GetAdjustedLevel(object oPC, int iDiff=0) { int iPCCount; int iAdjustedLevel; int iDeathAllowed; int iDeathAjust; int iLevel; iLevel = GetHighestPC(oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; if (iAdjustedLevel > (iLevel + 3) && iLevel < 13) iAdjustedLevel = iLevel +3; if (iAdjustedLevel > (iLevel + 5) && iLevel > 12) iAdjustedLevel = iLevel +5; if (GetLocalInt(oPC,"PCHardcore") == 0 && GetLocalInt(oPC,"PCHardCorePNP") == 0 && GetLocalInt(oPC,"PCHardCoreSpecial") == 0) iAdjustedLevel = iAdjustedLevel + iDeathAjust; else iAdjustedLevel = iLevel; if (GetLocalInt(oPC,"Unlucky")==1) iAdjustedLevel++; if (GetLocalInt(GetModule(),"Easy") == 1) iAdjustedLevel = iAdjustedLevel - 2; iAdjustedLevel=iAdjustedLevel+iDiff; if (iAdjustedLevel < 1) iAdjustedLevel =1; if (iAdjustedLevel > 40) iAdjustedLevel =40; return iAdjustedLevel; } void SetTrapsAndDoors(object oPC) { string sPrefix; string sTag; int iIndex; int iFlag; int iRandom; int iChance; int iChanceMod; object oTrap; object oDoor; object oChest; sPrefix = GetZone(oPC); iChanceMod = 0; if (GetLevelByClass(CLASS_TYPE_ROGUE,oPC) +GetLevelByClass(CLASS_TYPE_NINJA, oPC) +GetLevelByClass(CLASS_TYPE_SCOUT, oPC) +GetLevelByClass(CLASS_TYPE_FACTOTUM, oPC) +GetLevelByClass(CLASS_TYPE_PSYCHIC_ROGUE, oPC) > 0) iChanceMod = 5; iFlag = 0; iIndex = 0; while (iFlag == 0) { iIndex++; sTag = sPrefix + "_Trap" + IntToString(iIndex); oTrap = GetObjectByTag(sTag); if (GetIsObjectValid(oTrap)) { iRandom = Random(100); iChance = GetLocalInt(oTrap,"Chance"); if (iChance == 0) iChance = 10; iChance = iChance + iChanceMod; if (iRandom >= iChance && GetLocalInt(oTrap,"TrapCheck") == 0) { SetTrapDisabled(oTrap); SetLocalInt(oTrap,"TrapCheck",1); } } else { iFlag = 1; } } iFlag = 0; iIndex = 0; while (iFlag == 0) { iIndex++; sTag = sPrefix + "_Door" + IntToString(iIndex); oDoor = GetObjectByTag(sTag); if (GetIsObjectValid(oDoor)) { iRandom = Random(100); iChance = GetLocalInt(oDoor,"TrapChance"); if (iChance == 0) iChance = 5; iChance = iChance + iChanceMod; if (iRandom >= iChance && GetLocalInt(oDoor,"TrapCheck") == 0) { SetTrapDisabled(oDoor); SetLocalInt(oDoor,"TrapCheck",1); } iRandom = Random(100); iChance = GetLocalInt(oTrap,"LockedChance"); iChance = iChance + iChanceMod; if (iChance == 0) iChance = 10; if (iRandom >= iChance && GetLocalInt(oDoor,"LockedCheck") == 0) { SetTrapDisabled(oDoor); SetLocalInt(oDoor,"LockedCheck",1); } } else { iFlag = 1; } } iFlag = 0; iIndex = 0; while (iFlag == 0) { iIndex++; sTag = sPrefix + "_C" + IntToString(iIndex) + "_Boss"; if (GetIsObjectValid(GetObjectByTag(sTag))) { oChest = GetObjectByTag(sPrefix + "_C" + IntToString(iIndex) + "_Treasure"); if (GetIsObjectValid(oChest)) { iRandom = Random(100); iChance = GetLocalInt(oChest,"TrapChance"); if (iChance == 0) iChance = 5; iChance = iChance + iChanceMod; if (iRandom >= iChance && GetLocalInt(oChest,"TrapCheck") == 0) { SetTrapDisabled(oChest); SetLocalInt(oChest,"TrapCheck",1); } iRandom = Random(100); iChance = GetLocalInt(oChest,"LockedChance"); if (iChance == 0) iChance = 2; iChance = iChance + iChanceMod; if (iRandom >= iChance && GetLocalInt(oChest,"LockedCheck") == 0) { SetTrapDisabled(oChest); SetLocalInt(oChest,"LockedCheck",1); } } } else { iFlag = 1; } } } void CheckZone(object oPC) { object oSpawn; string sTag; string sZone; int iLevel; int iMaxLevel; int iIndex; int iFlag; int iCamps; iLevel = GetHitDice(oPC); iMaxLevel=GetLocalInt(GetArea(oPC),"MaximumLevel"); sZone = GetZone(oPC); if (iLevel < iMaxLevel) { iCamps = GetMaxCampSpots(sZone); iIndex = 0; iFlag = 0; while (iIndex < iCamps) { iIndex++; sTag = sZone + "_C" + IntToString(iIndex) + "_Boss_S"; oSpawn = GetObjectByTag(sTag); if (GetIsObjectValid(oSpawn)) iFlag = 1; } if (iFlag == 1) SetLocalInt(GetArea(oPC),"Spawned",0); } //Check for special powers for PrC if (SQLocalsUUID_GetInt(oPC,"SpecialPowers") > 0) CreateSpecialPowers(oPC); } int GetMaxCampSpots(string sZone) { string sTag; int iIndex; int iFlag; object oSpawn; iIndex = 0; iFlag = 0; while (iFlag==0) { iIndex++; sTag = sZone + "_C" + IntToString(iIndex) + "_Boss"; oSpawn=GetObjectByTag(sTag); if (!(GetIsObjectValid(oSpawn))) iFlag = 1; } iIndex--; return iIndex; }