#include "rd_spawn" #include "rd_misc" void InitiateQuest(int iQuest, object oPC,object oGiver); string GetRandomDeliveryNPC(object oSender, int iInZone=1); string GetInZoneNPC(object oSender); object GetQuestCamp(object oPC, object oQuestNPC, int iInZone = TRUE, string sQuestCampType = ""); void GetDelivery(string sTag,object oPC, object oSender, int iInZone=1, string sNPC=""); object GetQuestCreatures(object oPC,string sCampType, int iBase, int iBaseStart, int iBaseMax, int iCampType); string GetQuestMob(object oPC, int iRaceOnly=0); object GetRandomMobs(object oPC, int iRaceOnly=0); object GetRandomQuestMobs(object oPC, int iRaceOnly=0); string GuardedDelivery(string sTag, object oPC, object oSender, int iInZone=1, string sNPC=""); void AmbushDelivery(string sTag, object oPC, object oSender); object GetDungeonCamp(object oPC, object oQuestNPC, int iInZone = TRUE); int GetMaxQuestSpots(string sZone); int GetMaxQuestCampSpots(string sZone); void SummonRndCreature(int iLevel,location lLoc); void SummonRace(object oPC,location lLoc,int iLevel); string GetQuestLocString(string sTag); void InitiateQuest(int iQuest, object oPC,object oGiver) { string sCampDescription; //CustomTokens //101 = description of camp if (iQuest == 1) { //object oPC; object oBoss; location lHostage; string sHostage; //oPC=GetPCSpeaker(); SetPartyInt(oPC,"Quest",1); SetPartyInt(oPC,"QuestStep",1); oBoss = GetQuestCamp(oPC,OBJECT_SELF,TRUE); if (GetLocalInt(oBoss,"iCampType") == 1) { if (Random(10) == 0) { lHostage = GetLocation(oBoss); sHostage = "en3_hostage" + IntToString(Random(6)+1); CreateObject(OBJECT_TYPE_CREATURE,sHostage,lHostage); if (Random(4)==0) { sHostage = "en3_hostage" + IntToString(Random(6)+1); CreateObject(OBJECT_TYPE_CREATURE,sHostage,lHostage); } } } sCampDescription = GetLocalString(oBoss,"Description"); SetCustomToken(101,sCampDescription); } } string GetRandomDeliveryNPC(object oSender, int iInZone=1) { object oNPC; string sTag; int iRandom; int iFlag; iFlag = 0; if (iInZone == 1) { sTag =GetInZoneNPC(oSender); } else { while (iFlag == 0) { iRandom = Random(7)+1; switch (iRandom) { case 1: sTag = "en3_berister"; break; case 2: sTag = "en3_erolle"; break; case 3: sTag = "en3_dorey"; break; case 4: sTag = "en3_nick"; break; case 5: sTag = "en3_marik"; break; case 6: sTag = "en3_captainellis"; break; case 7: sTag = "en3_brothertash"; break; } oNPC = GetObjectByTag(sTag); iFlag = 1; if (sTag == GetTag(oSender)) iFlag = 0; } } return sTag; } string GetInZoneNPC(object oSender) { string sTag; string sTargetTag; sTag = GetTag(oSender); if (sTag == "en3_berister") if (Random(2)==0) sTargetTag = "en3_erolle"; else sTargetTag = "en3_dorey"; if (sTag == "en3_erolle") if (Random(2)==0) sTargetTag = "en3_berister"; else sTargetTag = "en3_dorey"; if (sTag == "en3_dorey") if (Random(2)==0) sTargetTag = "en3_erolle"; else sTargetTag = "en3_berister"; if (sTag == "en3_nick") sTargetTag = "en3_marik"; if (sTag == "en3_marik") sTargetTag = "en3_nick"; if (sTag == "en3_captainellis") sTargetTag = "en3_brothertash"; if (sTag == "en3_brothertash") sTargetTag = "en3_captainellis"; return sTargetTag; } object GetQuestCamp(object oPC, object oQuestNPC, int iInZone = TRUE, string sQuestCampType = "") { object oBoss; string sZone; int iCamp; int iCamps; int iLevel; int iLeader; int iDifficulty; int iDeathAllowed; int iDeathAjust; int iAdjustedLevel; int iPCCount; iLevel = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; iAdjustedLevel = iAdjustedLevel + iDeathAjust; iAdjustedLevel = iAdjustedLevel + GetLocalInt(oPC,"Adjust"); if (GetLocalInt(oPC,"Unlucky")==1) iAdjustedLevel++; if (GetLocalInt(GetModule(),"Easy") == 1) iAdjustedLevel = iAdjustedLevel - 2; if (iAdjustedLevel < 1) iAdjustedLevel =1; if (iAdjustedLevel > 40) iAdjustedLevel =40; if (iInZone) { sZone = GetZone(oPC); iCamps = GetMaxQuestCampSpots(sZone); iCamp = Random(iCamps)+1; } else { sZone = GetRandomZone(); iCamps = GetMaxQuestCampSpots(sZone); iCamp = Random(iCamps)+1; } iLeader=1; oBoss = SpawnQuestCamp(sZone,iCamp,iAdjustedLevel,iLeader,sQuestCampType); SetPartyInt(oPC,"QuestType",1); SetPartyInt(oPC,"QuestCamp",iCamp); SetPartyString(oPC,"QuestCampzone",sZone); SetPartyString(oPC,"QuestTargetNPC",GetTag(oQuestNPC)); iDifficulty = GetLocalInt(oPC,"QuestDifficulty"); iDifficulty++; if (sZone == "SF1") iDifficulty++; SetPartyInt(oPC,"QuestDifficulty",iDifficulty); return oBoss; } void GetDelivery(string sTag,object oPC, object oSender, int iInZone=1, string sNPC="") { string sRandomNPC; object oItem; if (sNPC == "") sRandomNPC = GetRandomDeliveryNPC(oSender,iInZone); else sRandomNPC = sNPC; oItem = CreateItemOnObject(sTag,oPC); SetPartyInt(oPC,"QuestType",2); SetPartyString(oPC,"QuestTargetNPC",sRandomNPC); SetPartyString(oPC,"QuestItemTag",sTag); } int GetMaxQuestSpots(string sZone) { string sTag; int iIndex; int iFlag; object oSpawn; iIndex = 0; iFlag = 0; while (iFlag==0) { iIndex++; sTag = sZone + "_Q_" + IntToString(iIndex); oSpawn=GetObjectByTag(sTag); if (!(GetIsObjectValid(oSpawn))) iFlag = 1; } iIndex--; return iIndex; } int GetMaxQuestCampSpots(string sZone) { string sTag; int iIndex; int iFlag; object oSpawn; iIndex = 0; iFlag = 0; while (iFlag==0) { iIndex++; sTag = sZone + "_Q" + IntToString(iIndex) + "_Boss"; oSpawn=GetObjectByTag(sTag); if (!(GetIsObjectValid(oSpawn))) iFlag = 1; } iIndex--; return iIndex; } string GetQuestMob(object oPC, int iRaceOnly=0) { string sCampType; int iLevel; int iDeathAllowed; int iDeathAjust; int iAdjustedLevel; int iPCCount; iLevel = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; iAdjustedLevel = iAdjustedLevel + iDeathAjust; iAdjustedLevel = iAdjustedLevel + GetLocalInt(oPC,"Adjust"); //Setup for races and allow indoors only to be spookiness SetupCampTypes(iAdjustedLevel, 1, 1, 0, iRaceOnly); sCampType = GetCampType(); return sCampType; } object GetQuestCreatures(object oPC,string sCampType, int iBase, int iBaseStart, int iBaseMax, int iCampType) { string sZone; string sTag; int iMaxSpots; int iSpawn; int iCreatureLevel; int iCreatures; int iIndex; int iLevel; object oCreature; int iDeathAllowed; int iDeathAjust; int iAdjustedLevel; int iPCCount; sZone = GetZone(oPC); iMaxSpots = GetMaxQuestSpots(sZone); iSpawn = Random(iMaxSpots)+1; sTag = sZone + "_Q_" + IntToString(iSpawn); iLevel = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; iAdjustedLevel = iAdjustedLevel + iDeathAjust; iAdjustedLevel = iAdjustedLevel + GetLocalInt(oPC,"Adjust"); iCreatureLevel = Random(3)+1; iCreatures = Random(3)+2; iIndex = 1; while (iIndex <= iCreatures) { oCreature = GetCampMob(iCreatureLevel,sTag,sCampType,iAdjustedLevel,iBaseStart,iBase,iBaseMax,iCampType, 0); //SendMessageToPC(oPC,"Spawning " + GetName(oCreature)); iIndex++; } return oCreature; } object GetRandomMobs(object oPC, int iRaceOnly=0) { object oCreature; string sCampType; int iDifficulty; int iBase; int iBaseStart; int iBaseMax; int iCampType; object oMod; oMod = GetModule(); sCampType = GetQuestMob(oPC,iRaceOnly); 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); oCreature = GetQuestCreatures(oPC,sCampType,iBase,iBaseStart,iBaseMax,iCampType); SetLocalInt(oCreature,"iCampType",iCampType); SetLocalString(oCreature,"sCampType",sCampType); return oCreature; } object GetRandomQuestMobs(object oPC, int iRaceOnly=0) { object oCreature; string sCampType; int iDifficulty; int iBase; int iBaseStart; int iBaseMax; int iCampType; object oMod; oMod = GetModule(); sCampType = GetQuestMob(oPC,iRaceOnly); 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); oCreature = GetQuestCreatures(oPC,sCampType,iBase,iBaseStart,iBaseMax,iCampType); SetLocalInt(oCreature,"iCampType",iCampType); SetLocalString(oCreature,"sCampType",sCampType); SetPartyInt(oPC,"QuestType",3); SetPartyString(oPC,"QuestTargetNPC",GetTag(OBJECT_SELF)); SetPartyString(oPC,"QuestCreatureTag",GetTag(oCreature)); iDifficulty = GetLocalInt(oPC,"QuestDifficulty"); iDifficulty++; SetPartyInt(oPC,"QuestDifficulty",iDifficulty); return oCreature; } string GuardedDelivery(string sTag, object oPC, object oSender, int iInZone=1, string sNPC="") { string sCampType; string sGuardTag; object oGuard; object oCreature; int iBase; int iBaseStart; int iBaseMax; int iCampType; int iLevel; int iCreatureLevel; int iCreatures; int iIndex; int iDifficulty; int iDeathAllowed; int iDeathAjust; int iAdjustedLevel; int iPCCount; object oMod; oMod = GetModule(); sCampType = GetQuestMob(oPC,1); 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); if (!(sTag == "")) { GetDelivery(sTag,oPC,oSender,iInZone,sNPC); sNPC=GetLocalString(oPC,"QuestTargetNPC"); } iLevel = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; iAdjustedLevel = iAdjustedLevel + iDeathAjust; iCreatureLevel = Random(3)+1; sGuardTag = sNPC + "_g1"; oGuard = GetObjectByTag(sGuardTag); //SendMessageToPC(oPC,"Trying to spawn " + sCampType + " at " + sGuardTag); if (GetIsObjectValid(oGuard)) { //SendMessageToPC(oPC,"Spawning 1"); iCreatures = Random(3)+2; iIndex = 1; while (iIndex <= iCreatures) { oCreature = GetCampMob(iCreatureLevel,sGuardTag,sCampType,iAdjustedLevel,iBaseStart,iBase,iBaseMax,iCampType, 0); //SendMessageToPC(oPC,"Spawning " + GetName(oCreature)); iIndex++; } } sGuardTag = sNPC + "_g2"; oGuard = GetObjectByTag(sGuardTag); //SendMessageToPC(oPC,"Trying to spawn " + sCampType + " at " + sGuardTag); if (GetIsObjectValid(oGuard)) { iCreatures = Random(3)+2; iIndex = 1; while (iIndex <= iCreatures) { oCreature = GetCampMob(iCreatureLevel,sGuardTag,sCampType,iAdjustedLevel,iBaseStart,iBase,iBaseMax,iCampType, 0); //SendMessageToPC(oPC,"Spawning " + GetName(oCreature)); iIndex++; } } iDifficulty = GetLocalInt(oPC,"QuestDifficulty"); iDifficulty++; SetPartyInt(oPC,"QuestDifficulty",iDifficulty); return sCampType; } object GetDungeonCamp(object oPC, object oQuestNPC, int iInZone = TRUE) { object oBoss; object oArea; string sZone; string sDZone; int iCamp; int iCamps; int iLevel; int iLeader; int iDifficulty; int iDeathAllowed; int iDeathAjust; int iAdjustedLevel; int iPCCount; iLevel = GetLevelByPosition(1,oPC) + GetLevelByPosition(2,oPC) + GetLevelByPosition(3,oPC); iPCCount= GetPCCount(oPC); iDeathAllowed = PCDeathsLeft(oPC); iDeathAjust = (iDeathAllowed-2)/2; iAdjustedLevel = iLevel - 3 + iPCCount; iAdjustedLevel = iAdjustedLevel + iDeathAjust; iAdjustedLevel = iAdjustedLevel + GetLocalInt(oPC,"Adjust"); if (iInZone) { sZone = GetZone(oPC); sDZone = GetZoneDungeonCamp(sZone); iCamps = GetMaxQuestCampSpots(sDZone); iCamp = Random(iCamps)+1; } else { sZone = GetRandomZone(); sDZone = GetZoneDungeonCamp(sZone); iCamps = GetMaxQuestCampSpots(sDZone); iCamp = Random(iCamps)+1; } iLeader=1; oBoss = SpawnQuestCamp(sDZone,iCamp,iAdjustedLevel,iLeader); //reset spawned to force respawn on dungeon/cave/tower/thingy oArea = GetArea(oBoss); SetLocalInt(oArea,"Spawned",0); SetPartyInt(oPC,"QuestType",1); SetPartyInt(oPC,"QuestCamp",iCamp); SetPartyString(oPC,"QuestCampzone",sDZone); SetPartyString(oPC,"QuestTargetNPC",GetTag(oQuestNPC)); iDifficulty = GetLocalInt(oPC,"QuestDifficulty"); iDifficulty=iDifficulty+3; SetPartyInt(oPC,"QuestDifficulty",iDifficulty); return oBoss; } void AmbushDelivery(string sTag, object oPC, object oSender) { string sSendTag; string sAmbushTag; location lLoc; int iLevel; int iDifficulty; sSendTag = GetTag(oSender); int iAmbush = 1; if (sSendTag == "en3_berister" || sSendTag == "en3_erolle" || sSendTag == "en3_dorey") if (sTag == "en3_captainellis" || sTag == "en3_brothertash") iAmbush = 2; if (sSendTag == "en3_captainellis" || sSendTag == "en3_brothertash") if (sTag == "en3_berister" || sTag == "en3_erolle" || sTag == "en3_dorey") iAmbush = 2; if (iAmbush == 1) sAmbushTag = "WP_AMBUSH1_" + IntToString(Random(2)+1); else sAmbushTag = "WP_AMBUSH2_" + IntToString(Random(2)+1); lLoc = GetLocation(GetObjectByTag(sAmbushTag)); iLevel = GetHitDice(oPC); if (Random(2)==0) { SummonRndCreature(iLevel,lLoc); } else { SummonRace(oPC,lLoc,iLevel); } iDifficulty = GetLocalInt(oPC,"QuestDifficulty"); iDifficulty=iDifficulty++; SetPartyInt(oPC,"QuestDifficulty",iDifficulty); } void SummonRndCreature(int iLevel,location lLoc) { int iIndex; int iRandom; string sTag; sTag = GetRndCreature(iLevel); iIndex = 0; iRandom = Random(3)+2; while (iIndex < iRandom) { CreateObject(OBJECT_TYPE_CREATURE,sTag,lLoc); iIndex++; } } void SummonRace(object oPC,location lLoc,int iLevel) { object oArea; int iArea; int iRandom; int iIndex; string sCampType; if (GetLocalInt(oPC,"Evil") == 1 && Random(3) == 0) { iRandom=Random(3)+1; switch (iRandom) { case 1: sCampType="elf"; break; case 2: sCampType="dwarf"; break; case 3: sCampType="halfling"; break; } } else { oArea=GetArea(oPC); iArea=GetIsAreaInterior(oArea); if (iArea == FALSE) SetupCampTypes(iLevel, 1, 0, 1, 1); else SetupCampTypes(iLevel, 1, 1, 1, 1); sCampType = GetCampType(); } iIndex = 0; iRandom = Random(4)+1; while (iIndex < iRandom) { GetRaceCreature(sCampType,lLoc,iLevel); iIndex++; } } string GetQuestLocString(string sTag) { string sDescription; if (sTag == "NH1_Q_1_S" || sTag == "NH1_Q_2_S") sDescription = "The creatures have been spotted on the western side of Nirra Hamlett."; if (sTag == "NH1_Q_3_S") sDescription = "The creatures have been spotted near Erolle's wagon."; if (sTag == "NH1_Q_4_S") sDescription = "The creatures have been spotted near Nirra Lake."; if (sTag == "NH1_Q_5_S" || sTag == "NH1_Q_6_S") sDescription = "The creatures have been spotted near Dorey's halfling hole."; if (sTag == "MH1_Q_1_S") sDescription = "The creatures have been spotted in the graveyard."; if (sTag == "MH1_Q_2_S" || sTag == "MH1_Q_3_S" || sTag == "MH1_Q_4_S") sDescription = "The creatures have been spotted along the road."; if (sTag == "MH1_Q_5_S") sDescription = "The creatures have been spotted near the road west of the guard tower."; if (sTag == "SF1_Q_5_S") sDescription = "The creatures have been spotted along the river."; if (sTag == "SF1_Q_4_S") sDescription = "The creatures have been spotted near the Evari Forest border."; if (sTag == "SF1_Q_1_S" || sTag == "SF1_Q_2_S" || sTag == "SF1_Q_3_S") sDescription = "The creatures have been spotted near the border to Nirra Hamlett."; return sDescription; }