#include "nw_i0_tool" #include "rd_treasure" #include "rd_misc" #include "utl_i_sqluuid" void SetPartyVariables(object oPC); void GivePartyMagicItem(object oPC); void GivePartyQuestPoints(object oPC, int iQuestPoints); void GivePartyMinorMagicItem(object oPC); void GivePartyCharSpecific(object oPC); void GivePartyQuestCredit(object oPC); void SetPartyQuestType(object oPC); void main() { int iDifficulty; int iGold; int iXP; int iChance; int iRandom; int iMod; int iLevel; int iQuestPoints; int iMaxLevel; int iQuests; object oPC; oPC = GetPCSpeaker(); if (GetLocalInt(oPC,"QuestType") == 1) AddJournalQuestEntry("jCamp",12,oPC); else if (GetLocalInt(oPC,"QuestType") == 2) AddJournalQuestEntry("jDelivery",2,oPC); else if (GetLocalInt(oPC,"QuestType") == 3) AddJournalQuestEntry("jSpecial",2,oPC); if (GetLocalInt(oPC,"QuestAdventureZone") > 0) { SetLocalInt(GetModule(),"AdventureZone",0); SetLocalInt(GetModule(),"AdvZones",0); } if (GetLocalInt(oPC,"HTCAbandonedHouse1") == 1) { SetLocalInt(GetModule(),"HTCAbandonedHouse1",0); SetPartyInt(oPC,"HTCAbandonedHouse1",0); } if (GetLocalInt(oPC,"HTCAbandonedHouse1") == 1) { SetLocalInt(GetModule(),"HTCAbandonedHouse2",0); SetPartyInt(oPC,"HTCAbandonedHouse2",0); } iDifficulty = GetLocalInt(oPC,"QuestDifficulty"); iLevel = GetHitDice(oPC); iLevel = ZoneLevel(GetArea(oPC),iLevel); if (iLevel < 20) iMod = iLevel/5 + 1; else iMod = (iLevel-20)/8 + 5; iGold = 100 * iDifficulty * iMod; iXP = 150 * iDifficulty * iMod; iChance = iDifficulty + iLevel/3 + 1; if (iGold == 0) iGold = 25; if (iXP == 0) iXP = 50; if (GetLocalInt(oPC,"QuestGold") > 0) { iGold = 0; TakeGoldFromCreature(GetLocalInt(oPC,"QuestGold"),oPC); } SetPartyVariables(oPC); iRandom = Random(100); if (GetSkillRank(SKILL_PERSUADE,oPC)>4) { if (GetIsSkillSuccessful(oPC,SKILL_PERSUADE,25)) { SendMessageToPC(oPC,"You are very persuading..."); iGold=iGold*3/2; iChance = iChance + 3; } } if (GetSkillRank(SKILL_INTIMIDATE,oPC)>4) { if (GetIsSkillSuccessful(oPC,SKILL_INTIMIDATE,25)) { SendMessageToPC(oPC,"You are very intimidating..."); iGold=iGold*3/2; iChance = iChance + 3; } } if (GetSkillRank(SKILL_BLUFF,oPC)>4) { if (GetIsSkillSuccessful(oPC,SKILL_BLUFF,25)) { SendMessageToPC(oPC,"You have successfully blown your exploits out of proportion..."); iGold=iGold*3/2; iChance = iChance + 3; } } if (GetLocalInt(oPC,"Lucky") == 1) iChance = iChance + 4; if (GetLocalInt(oPC,"Charming") == 1 && iDifficulty>0) iChance = iChance + 2; if (iDifficulty < 1) iChance = 0; RewardPartyXP(iXP, GetPCSpeaker()); RewardPartyGP(iGold, GetPCSpeaker()); iRandom = Random(100); if (iRandom < iChance) { if (iLevel < 4) GivePartyMinorMagicItem(oPC); else if (iRandom < iChance/2) GivePartyMagicItem(oPC); else GivePartyMinorMagicItem(oPC); } else if (iRandom < (iChance + iLevel/5 + 1) && iLevel < 20) GivePartyCharSpecific(oPC); else if (iRandom < (iChance + 5) && iLevel > 19) GivePartyCharSpecific(oPC); iQuests = SQLocalsUUID_GetInt(oPC,"GuildQuests"); if (SQLocalsUUID_GetInt(oPC,"PCHardCorePNP") == 0) { if (iQuests < 5 && iLevel < 7) iQuestPoints = iDifficulty; else if (iQuests > 4 && iQuests < 10 && iLevel < 14) iQuestPoints = iDifficulty; else if (iQuests > 9 && iQuests < 15 && iLevel < 21) iQuestPoints = iDifficulty; else iQuestPoints = iDifficulty/2; } else { if (iQuests < 5 && iLevel < 10) iQuestPoints = iDifficulty; else if (iQuests > 4 && iQuests < 10 && iLevel < 20) iQuestPoints = iDifficulty; else if (iQuests > 9 && iQuests < 15 && iLevel < 30) iQuestPoints = iDifficulty; else iQuestPoints = iDifficulty/2; } if (iQuestPoints > 0) GivePartyQuestPoints(oPC,iQuestPoints); GivePartyQuestCredit(oPC); //This is a fix for the infinite quest loop -- more of a bandaid since can't find logical reason for bug. SetPartyQuestType(oPC); SetLocalInt(oPC,"Quest",0); SetLocalInt(oPC,"QuestType",0); } void GivePartyQuestCredit(object oPC) { int iQuest; object oItem; itemproperty ip; object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { if (SQLocalsUUID_GetInt(oPartyMember,"PCGuild") == 3) { iQuest = SQLocalsUUID_GetInt(oPartyMember,"GuildQuests"); iQuest++; //iQuest=iQuest+4; SQLocalsUUID_SetInt(oPartyMember,"GuildQuests",iQuest); if (iQuest == 5) { SendMessageToPC(oPartyMember,"You have risen to the rank of Theurgist and been given a magical ring as a sign of your growing reputation within the guild."); CreateItemOnObject("en4_mgring",oPartyMember); } if (iQuest == 10) { SendMessageToPC(oPartyMember,"You have risen to the rank of Magician. The Ring of the Magi grows more powerful."); oItem = GetItemPossessedBy(oPartyMember,"en4_mgring"); ip = ItemPropertyAbilityBonus(IP_CONST_ABILITY_INT,3); IPSafeAddItemProperty(oItem,ip); ip = ItemPropertyAbilityBonus(IP_CONST_ABILITY_CHA,3); IPSafeAddItemProperty(oItem,ip); ip = ItemPropertyDamageReduction(IP_CONST_DAMAGEREDUCTION_1,IP_CONST_DAMAGESOAK_10_HP); IPSafeAddItemProperty(oItem,ip); } if (iQuest == 15) { SendMessageToPC(oPartyMember,"You have risen to the rank of Arch Mage. The Ring of the Magi grows more powerful."); oItem = GetItemPossessedBy(oPartyMember,"en4_mgring"); ip = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_18); IPSafeAddItemProperty(oItem,ip); ip = ItemPropertyAbilityBonus(IP_CONST_ABILITY_INT,5); IPSafeAddItemProperty(oItem,ip); ip = ItemPropertyAbilityBonus(IP_CONST_ABILITY_CHA,5); IPSafeAddItemProperty(oItem,ip); ip = ItemPropertyDamageReduction(IP_CONST_DAMAGEREDUCTION_2,IP_CONST_DAMAGESOAK_10_HP); IPSafeAddItemProperty(oItem,ip); } } oPartyMember = GetNextFactionMember(oPC, TRUE); } } void GivePartyQuestPoints(object oPC, int iQuestPoints) { int iQuest; int iPCLevelMod; object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { iPCLevelMod = SQLocalsUUID_GetInt(oPartyMember,"PCLevelMod"); if (iPCLevelMod>1) iQuestPoints = iQuestPoints - 1; if (iPCLevelMod == 2 && iQuestPoints == 0) iQuestPoints = 1; iQuest = SQLocalsUUID_GetInt(oPartyMember,"QuestPoints"); iQuest = iQuest + iQuestPoints; SQLocalsUUID_SetInt(oPartyMember,"QuestPoints",iQuest); SendMessageToPC(oPartyMember,"You have been given " + IntToString(iQuestPoints) + " quest points. You now have " + IntToString(iQuest) + "."); oPartyMember = GetNextFactionMember(oPC, TRUE); } } void GivePartyMagicItem(object oPC) { object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { GetMagicItem(oPartyMember,TRUE,TRUE); oPartyMember = GetNextFactionMember(oPC, TRUE); } } void GivePartyMinorMagicItem(object oPC) { object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { GetMinorMagicItem(oPartyMember); oPartyMember = GetNextFactionMember(oPC, TRUE); } } void GivePartyCharSpecific(object oPC) { object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { if (Random(2)==0) GetEnchantedItem(oPartyMember); else DTSGenerateCharSpecificTreasure(oPartyMember,oPartyMember); oPartyMember = GetNextFactionMember(oPC, TRUE); } } void SetPartyQuestType(object oPC) { object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { SetLocalInt(oPartyMember,"Quest",0); SetLocalInt(oPartyMember,"QuestType",0); oPartyMember = GetNextFactionMember(oPC, TRUE); } } void SetPartyVariables(object oPC) { int iLastQuest; int iNPCQuests; int iIndex; int iCount; int iQuests; string sZone; string sQuestStep; object oGiver; object oModule; oModule = GetModule(); oGiver = GetObjectByTag(GetLocalString(oPC,"QuestGiver")); iLastQuest =GetLocalInt(oPC,"Quest"); SetPartyInt(oPC,"LastQuest",iLastQuest); iQuests = GetLocalInt(oPC,GetTag(oGiver)); SetPartyInt(oPC,GetTag(oGiver),iQuests+1); SetPartyInt(oPC,"Quest",0); SetPartyInt(oPC,"QuestStep",0); SetPartyInt(oPC,"QuestType",0); SetPartyInt(oPC,"QuestDifficulty",0); SetPartyInt(oPC,"QuestDone",0); SetPartyInt(oPC,"QuestItemUnknown",0); SetPartyInt(oPC,"SpecialQuestType",0); SetPartyInt(oPC,"QuestLevel",0); SetPartyInt(oPC,"QuestAdventureZone",0); SetPartyInt(oPC,"QuestGold",0); SetPartyInt(oPC,"QuestHouses",0); SetPartyInt(oPC,"QuestFights",0); iCount = GetLocalInt(oPC,"QuestSteps"); iIndex = 1; while (iIndex <= iCount) { sQuestStep = "QuestStep" + IntToString(iIndex); SetPartyInt(oPC,sQuestStep,0); SetPartyString(oPC,sQuestStep + "Mob",""); SetPartyString(oPC,sQuestStep + "Item",""); SetPartyString(oPC,sQuestStep + "Token111",""); SetPartyString(oPC,sQuestStep + "Token112",""); SetPartyString(oPC,sQuestStep + "Token113",""); SetPartyString(oPC,sQuestStep + "Response",""); SetPartyString(oPC,sQuestStep + "Reply",""); SetPartyString(oPC,sQuestStep + "Escort",""); SetPartyInt(oPC,sQuestStep + "ItemUnknown",0); iIndex++; } SetPartyInt(oPC,"QuestSteps",0); SetPartyString(oPC,"QuestTargetNPC",""); SetPartyString(oPC,"QuestItemTag",""); SetPartyString(oPC,"QuestAttackers",""); SetPartyString(oPC,"QuestGiver",""); SetPartyString(oPC,"QuestTargetMob",""); SetPartyString(oPC,"QuestCampType",""); SetPartyString(oPC,"QuestEscort",""); sZone = GetLocalString(oPC,"QuestZone"); SetPartyInt(oModule,sZone,0); SetPartyString(oPC,"QuestZone",""); iNPCQuests = GetLocalInt(oGiver,"QuestsCompleted"); iNPCQuests++; SetPartyInt(oGiver,"QuestsCompleted",iNPCQuests); SetPartyString(oGiver,"QUEST_PC" + IntToString(iNPCQuests),GetName(oPC)); } void zSetPartyVariables(object oPC) { int iLastQuest; int iNPCQuests; int iIndex; int iCount; int iQuests; string sZone; string sQuestStep; object oGiver; object oModule; oModule = GetModule(); object oPartyMember = GetFirstFactionMember(oPC, TRUE); while (GetIsObjectValid(oPartyMember) == TRUE) { oGiver = GetObjectByTag(GetLocalString(oPartyMember,"QuestGiver")); iLastQuest =GetLocalInt(oPartyMember,"Quest"); SetLocalInt(oPartyMember,"LastQuest",iLastQuest); iQuests = GetLocalInt(oPartyMember,GetTag(oGiver)); SetLocalInt(oPartyMember,GetTag(oGiver),iQuests+1); SetLocalInt(oPartyMember,"Quest",0); SetLocalInt(oPartyMember,"QuestStep",0); SetLocalInt(oPartyMember,"QuestType",0); SetLocalInt(oPartyMember,"QuestDifficulty",0); SetLocalInt(oPartyMember,"QuestDone",0); SetLocalInt(oPartyMember,"QuestItemUnknown",0); SetLocalInt(oPartyMember,"SpecialQuestType",0); SetLocalInt(oPartyMember,"QuestLevel",0); SetLocalInt(oPartyMember,"QuestAdventureZone",0); SetPartyInt(oPartyMember,"QuestGold",0); SetPartyInt(oPartyMember,"QuestHouses",0); SetPartyInt(oPartyMember,"QuestFights",0); iCount = GetLocalInt(oPartyMember,"QuestSteps"); iIndex = 1; while (iIndex <= iCount) { sQuestStep = "QuestStep" + IntToString(iIndex); SetLocalInt(oPartyMember,sQuestStep,0); SetLocalString(oPartyMember,sQuestStep + "Mob",""); SetLocalString(oPartyMember,sQuestStep + "Item",""); SetLocalString(oPartyMember,sQuestStep + "Token111",""); SetLocalString(oPartyMember,sQuestStep + "Token112",""); SetLocalString(oPartyMember,sQuestStep + "Token113",""); SetLocalString(oPartyMember,sQuestStep + "Response",""); SetLocalString(oPartyMember,sQuestStep + "Reply",""); SetLocalString(oPartyMember,sQuestStep + "Escort",""); SetLocalInt(oPartyMember,sQuestStep + "ItemUnknown",0); iIndex++; } SetLocalInt(oPartyMember,"QuestSteps",0); SetLocalString(oPartyMember,"QuestTargetNPC",""); SetLocalString(oPartyMember,"QuestItemTag",""); SetLocalString(oPartyMember,"QuestAttackers",""); SetLocalString(oPartyMember,"QuestGiver",""); SetLocalString(oPartyMember,"QuestTargetMob",""); SetLocalString(oPartyMember,"QuestCampType",""); SetLocalString(oPartyMember,"QuestEscort",""); sZone = GetLocalString(oPartyMember,"QuestZone"); SetLocalInt(oModule,sZone,0); SetLocalString(oPartyMember,"QuestZone",""); iNPCQuests = GetLocalInt(oGiver,"QuestsCompleted"); iNPCQuests++; SetLocalInt(oGiver,"QuestsCompleted",iNPCQuests); SetLocalString(oGiver,"QUEST_PC" + IntToString(iNPCQuests),GetName(oPartyMember)); oPartyMember = GetNextFactionMember(oPC, TRUE); } }