#include "cs_misc_function" #include "1_loot_inc_data" // Throw this switch for debugging int LOOT_INC_MAIN_DEBUGGING = TRUE; int GetPartyMemberCount (object oPC, int iMinimumLevel) { int iPartyMemberCount = 0; int iPartyMemberLevel; object oPartyMember = GetFirstFactionMember (oPC); while (GetIsObjectValid (oPartyMember)) { if (GetIsPC (oPartyMember)) { iPartyMemberCount ++; iPartyMemberLevel = GetLevelByPosition (1, oPartyMember) + GetLevelByPosition (2, oPartyMember) + GetLevelByPosition (3, oPartyMember); if (iPartyMemberLevel < iMinimumLevel) { iPartyMemberCount --; } } oPartyMember = GetNextFactionMember (oPC); } if (iPartyMemberCount < 1) { iPartyMemberCount = 1; } WriteTimestampedLogEntry ("iPartyMemberCount " + IntToString (iPartyMemberCount)); return iPartyMemberCount; } object GetRandomPartyMember (object oPC) { int iPartyMemberCount = GetPartyMemberCount (oPC, 0); int iRandNum = (Random (iPartyMemberCount)+1); if (iRandNum == 1) { return oPC; } object oPartyMember = GetFirstFactionMember (oPC); int iCounter; for (iCounter = 1; iCounter < iRandNum; iCounter ++) { if (!GetIsPC(oPartyMember)) { iCounter --; } oPartyMember = GetNextFactionMember (oPC); } return oPartyMember; } int GetIsOverMaxAllowedLevel (object oPC , object oCaller) { int iHighestPartyMemberLevel = 0; object oPartyMember = GetFirstFactionMember(oPC); while (GetIsObjectValid(oPartyMember)) { int iPartyMemberLevel = GetLevelByPosition (1, oPartyMember) + GetLevelByPosition (2, oPartyMember) + GetLevelByPosition (3, oPartyMember); if (iPartyMemberLevel > iHighestPartyMemberLevel) { iHighestPartyMemberLevel = iPartyMemberLevel; } oPartyMember = GetNextFactionMember(oPC); } int iMaxAllowedLevel = GetMaxAllowedLevel(oCaller); if (iHighestPartyMemberLevel > iMaxAllowedLevel) { return TRUE; } return FALSE; } void GenerateUniqueTreasure (object oCaller,object oPC) { int iMinimumLevel = GetMinimumLevel (oCaller); int iNumberOfItemsToGenerate = GetPartyMemberCount (oPC, iMinimumLevel); int iMinimum = GetMinimumNumberOfItemsToGenerate (oCaller); int iMaximum = GetMaximumNumberOfItemsToGenerate (oCaller); int iGoldToGive; if (iNumberOfItemsToGenerate < iMinimum) iNumberOfItemsToGenerate = iMinimum; if (iNumberOfItemsToGenerate > iMaximum) iNumberOfItemsToGenerate = iMaximum; int iNumItemsInList = GetTotalAvailableItems (oCaller); int iRandomNumber; string sItemTemplate; int iCounter; for (iCounter = 0; iCounter < iNumberOfItemsToGenerate; iCounter ++) { iRandomNumber = Random (iNumItemsInList)+1; sItemTemplate = GetUniqueItemFromList (oCaller, iRandomNumber); // // CS - This loot script will only generate an item of stack size 1. So, where we have gold200 and such, // it still only creates 1 gold. This change creates an amount of gold proportional to the level of // the player. (1st level - 100, 20th level - 2000) // if (FindSubString(sItemTemplate, "gold") != -1) { iGoldToGive = Random(FloatToInt(GetChallengeRating(oCaller)*10.0))+1; GiveGoldToCreature(oCaller, iGoldToGive); } CreateItemOnObject (sItemTemplate,oCaller,1); if (LOOT_INC_MAIN_DEBUGGING == TRUE) { WriteTimestampedLogEntry (GetTag (oCaller) + " generated " + sItemTemplate); } } }