Skip to content

Commit

Permalink
Merge pull request #865 from Logg-y/loot-refactor
Browse files Browse the repository at this point in the history
Some loot refactoring
  • Loading branch information
Logg-y authored Dec 8, 2024
2 parents 7c4df17 + 4fa8b86 commit 4f9c792
Show file tree
Hide file tree
Showing 45 changed files with 2,052 additions and 1,965 deletions.
2 changes: 1 addition & 1 deletion seeded_database/tmapsolutions.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion seeded_database/treasures.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/nss/1testchest.nss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void main()
int i;
for (i = 0; i < 100; i++)
{
GenerateTierItem(6, 6, OBJECT_SELF, "Weapon");
// This generates random weapons for ACR 6
SelectLootItemFromACR(OBJECT_SELF, 6, LOOT_TYPE_WEAPON_MELEE);
}

SendMessageToPC(oPC, "T1: "+IntToString(GetLocalInt(GetModule(), "T1")));
Expand Down
47 changes: 18 additions & 29 deletions src/nss/ai_onspawn.nss
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ void CopyKey()
}
}

void GeneratePickpocketItem(string sType = "")
void GeneratePickpocketItem(int nAllowedLootTypes=LOOT_TYPE_MISC)
{
object oItem = GenerateTierItem(GetHitDice(OBJECT_SELF), GetLocalInt(GetArea(OBJECT_SELF), "area_cr"), OBJECT_SELF, sType);
// Avoids increasing high tier item odds on bosses/semibosses
object oItem = SelectLootItemFromACR(OBJECT_SELF, GetLocalInt(OBJECT_SELF, "area_cr"), nAllowedLootTypes);
SetDroppableFlag(oItem, FALSE);
SetPickpocketableFlag(oItem, TRUE);
SetLocalInt(OBJECT_SELF, "pickpocket_xp", 1);
Expand All @@ -42,6 +43,12 @@ void GeneratePickpocketItem(string sType = "")

void main()
{
object oArea = GetArea(OBJECT_SELF);
float fCR = GetChallengeRating(OBJECT_SELF);
int iAreaCR = GetLocalInt(oArea, "cr");
SetLocalInt(OBJECT_SELF, "cr", FloatToInt(fCR));
SetLocalInt(OBJECT_SELF, "area_cr", iAreaCR);

SignalEvent(OBJECT_SELF, EventUserDefined(GS_EV_ON_SPAWN));

NWNX_Creature_SetNoPermanentDeath(OBJECT_SELF, TRUE);
Expand Down Expand Up @@ -85,9 +92,7 @@ void main()
// SetLocalLocation(OBJECT_SELF, "GS_LOCATION", GetLocation(OBJECT_SELF));
// SetLocalInt(OBJECT_SELF, "GS_TIMEOUT", gsTIGetActualTimestamp() + GS_TIMEOUT);

object oArea = GetArea(OBJECT_SELF);

int iAreaCR = GetLocalInt(oArea, "cr");


switch (GetRacialType(OBJECT_SELF))
{
Expand All @@ -105,27 +110,27 @@ void main()
SetPickpocketableFlag(oPotion, TRUE);
}

if (d8() == 1) GeneratePickpocketItem("Misc");
if (d8() == 1) GeneratePickpocketItem();

// 1 in 20 chance of generating something that may not be a misc item
if (d20() == 1) GeneratePickpocketItem();
if (d20() == 1) GeneratePickpocketItem(LOOT_TYPE_ANY);

int nGold = d3(GetHitDice(OBJECT_SELF));

// 3x the gold on bosses
if (GetLocalInt(OBJECT_SELF, "boss") == 1)
{
nGold = nGold * 3;
GeneratePickpocketItem("Misc");
GeneratePickpocketItem("Misc");
if (d3() == 1) GeneratePickpocketItem();
GeneratePickpocketItem();
GeneratePickpocketItem();
if (d3() == 1) GeneratePickpocketItem(LOOT_TYPE_ANY);
}
// 2x the gold on semibosses or immortals (quest/unique npcs usually)
else if (GetLocalInt(OBJECT_SELF, "semiboss") == 1 || GetLocalInt(OBJECT_SELF, "rare") || GetLocalInt(OBJECT_SELF, "immortal") == 1)
{
nGold = nGold * 2;
GeneratePickpocketItem("Misc");
if (d6() == 1) GeneratePickpocketItem();
GeneratePickpocketItem();
if (d6() == 1) GeneratePickpocketItem(LOOT_TYPE_ANY);
}

object oGold = CreateItemOnObject("nw_it_gold001", OBJECT_SELF, nGold);
Expand All @@ -138,21 +143,6 @@ void main()
NWNX_Creature_SetCorpseDecayTime(OBJECT_SELF, 1200000);
NWNX_Creature_SetDisarmable(OBJECT_SELF, TRUE);

// Set cr integer on self. This is used for determining treasure.
float fCR = GetChallengeRating(OBJECT_SELF);

if (GetLocalInt(OBJECT_SELF, "boss"))
{
fCR = fCR * BOSS_CR_MULTIPLIER;
// Increased area CR means higher quality loot allowed
iAreaCR = FloatToInt(IntToFloat(iAreaCR) * BOSS_AREA_CR_MULTIPLIER);
}
else if (GetLocalInt(OBJECT_SELF, "semiboss") || GetLocalInt(OBJECT_SELF, "rare"))
{
fCR = fCR * SEMIBOSS_CR_MULTIPLIER;
iAreaCR = FloatToInt(IntToFloat(iAreaCR) * SEMIBOSS_AREA_CR_MULTIPLIER);
}

// Create random weapons before scanning, it's sensible
string sScript = GetLocalString(OBJECT_SELF, "spawn_script");
//WriteTimestampedLogEntry("ai_onspawn for " + GetName(OBJECT_SELF) + "-> spawn script = " + sScript);
Expand Down Expand Up @@ -203,8 +193,7 @@ void main()



SetLocalInt(OBJECT_SELF, "cr", FloatToInt(fCR));
SetLocalInt(OBJECT_SELF, "area_cr", iAreaCR);


DelayCommand(3.0, CopyKey());

Expand Down
11 changes: 1 addition & 10 deletions src/nss/dev_xpvalues.nss
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,7 @@ void RunOnArea(object oArea)
{
for (nLevel = 2; nLevel <= 12; nLevel++)
{
float fMultiplier = 1.0;
if (GetLocalInt(oTest, "boss") == 1)
{
fMultiplier = 3.0;
}
else if (GetLocalInt(oTest, "semiboss") == 1)
{
fMultiplier = 2.0;
}
float fThis = GetPartyXPValue(oTest, 0, IntToFloat(nLevel), 1, fMultiplier);
float fThis = GetPartyXPValue(oTest, 0, IntToFloat(nLevel), 1);
string sVar = "dev_xpvalues" + IntToString(nLevel);
SetLocalFloat(oArea, sVar, GetLocalFloat(oArea, sVar) + fThis);
}
Expand Down
2 changes: 1 addition & 1 deletion src/nss/dlg_andriel_act.nss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ void main()
else if (nRoll <= 85) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_MEDIUM); }
else if (nRoll <= 90) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_EASY); }
else { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_MASTER); }
CopyTierItemToObjectOrLocation(oMap, oPC);
CopyTierItemFromStaging(oMap, oPC);
SQLocalsPlayer_SetInt(oPC, "andriel_lastbuy", SQLite_GetTimeStamp());
}
4 changes: 2 additions & 2 deletions src/nss/enter_maker2.nss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

void MakeGroundItem(object oTest)
{
object oChestItem = SelectTierItem(12, 12, "Melee", 0, OBJECT_INVALID, d100() < 5 ? FALSE : TRUE);
object oChestItem = SelectLootItemFromACR(OBJECT_INVALID, 12, LOOT_TYPE_WEAPON_MELEE, 5);
location lLoc = GetLocation(oTest);
lLoc = Location(GetAreaFromLocation(lLoc), GetPositionFromLocation(lLoc), IntToFloat(Random(360)));
object oFloorItem = CopyTierItemToObjectOrLocation(oChestItem, OBJECT_INVALID, lLoc);
object oFloorItem = CopyTierItemFromStaging(oChestItem, OBJECT_INVALID, lLoc);
SetLocalObject(oTest, "ground_weapon", oFloorItem);
}

Expand Down
4 changes: 2 additions & 2 deletions src/nss/enter_maker4.nss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ void main()
vector vSling = vPos + Vector(IntToFloat(Random(1000))/100 - 5.0, IntToFloat(Random(1000))/100 - 5.0, 0.0);
object oChestItem = GetTieredItemOfType(BASE_ITEM_BULLET, 1, 0);
location lLoc = Location(OBJECT_SELF, vBullets, IntToFloat(Random(360)));
object oFloorItem = CopyTierItemToObjectOrLocation(oChestItem, OBJECT_INVALID, lLoc);
object oFloorItem = CopyTierItemFromStaging(oChestItem, OBJECT_INVALID, lLoc);
SetItemStackSize(oFloorItem, 10 + d4(3));
SetLocalObject(OBJECT_SELF, "puzzle_bullets", oFloorItem);

oChestItem = GetTieredItemOfType(BASE_ITEM_SLING, 1, 0);
lLoc = Location(OBJECT_SELF, vSling, IntToFloat(Random(360)));
oFloorItem = CopyTierItemToObjectOrLocation(oChestItem, OBJECT_INVALID, lLoc);
oFloorItem = CopyTierItemFromStaging(oChestItem, OBJECT_INVALID, lLoc);
SetLocalObject(OBJECT_SELF, "puzzle_sling", oFloorItem);
}
}
Loading

0 comments on commit 4f9c792

Please sign in to comment.