Skip to content

Commit 4f9c792

Browse files
authored
Merge pull request #865 from Logg-y/loot-refactor
Some loot refactoring
2 parents 7c4df17 + 4fa8b86 commit 4f9c792

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2052
-1965
lines changed

seeded_database/tmapsolutions.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

seeded_database/treasures.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/nss/1testchest.nss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ void main()
1818
int i;
1919
for (i = 0; i < 100; i++)
2020
{
21-
GenerateTierItem(6, 6, OBJECT_SELF, "Weapon");
21+
// This generates random weapons for ACR 6
22+
SelectLootItemFromACR(OBJECT_SELF, 6, LOOT_TYPE_WEAPON_MELEE);
2223
}
2324

2425
SendMessageToPC(oPC, "T1: "+IntToString(GetLocalInt(GetModule(), "T1")));

src/nss/ai_onspawn.nss

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ void CopyKey()
2929
}
3030
}
3131

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

4344
void main()
4445
{
46+
object oArea = GetArea(OBJECT_SELF);
47+
float fCR = GetChallengeRating(OBJECT_SELF);
48+
int iAreaCR = GetLocalInt(oArea, "cr");
49+
SetLocalInt(OBJECT_SELF, "cr", FloatToInt(fCR));
50+
SetLocalInt(OBJECT_SELF, "area_cr", iAreaCR);
51+
4552
SignalEvent(OBJECT_SELF, EventUserDefined(GS_EV_ON_SPAWN));
4653

4754
NWNX_Creature_SetNoPermanentDeath(OBJECT_SELF, TRUE);
@@ -85,9 +92,7 @@ void main()
8592
// SetLocalLocation(OBJECT_SELF, "GS_LOCATION", GetLocation(OBJECT_SELF));
8693
// SetLocalInt(OBJECT_SELF, "GS_TIMEOUT", gsTIGetActualTimestamp() + GS_TIMEOUT);
8794

88-
object oArea = GetArea(OBJECT_SELF);
89-
90-
int iAreaCR = GetLocalInt(oArea, "cr");
95+
9196

9297
switch (GetRacialType(OBJECT_SELF))
9398
{
@@ -105,27 +110,27 @@ void main()
105110
SetPickpocketableFlag(oPotion, TRUE);
106111
}
107112

108-
if (d8() == 1) GeneratePickpocketItem("Misc");
113+
if (d8() == 1) GeneratePickpocketItem();
109114

110115
// 1 in 20 chance of generating something that may not be a misc item
111-
if (d20() == 1) GeneratePickpocketItem();
116+
if (d20() == 1) GeneratePickpocketItem(LOOT_TYPE_ANY);
112117

113118
int nGold = d3(GetHitDice(OBJECT_SELF));
114119

115120
// 3x the gold on bosses
116121
if (GetLocalInt(OBJECT_SELF, "boss") == 1)
117122
{
118123
nGold = nGold * 3;
119-
GeneratePickpocketItem("Misc");
120-
GeneratePickpocketItem("Misc");
121-
if (d3() == 1) GeneratePickpocketItem();
124+
GeneratePickpocketItem();
125+
GeneratePickpocketItem();
126+
if (d3() == 1) GeneratePickpocketItem(LOOT_TYPE_ANY);
122127
}
123128
// 2x the gold on semibosses or immortals (quest/unique npcs usually)
124129
else if (GetLocalInt(OBJECT_SELF, "semiboss") == 1 || GetLocalInt(OBJECT_SELF, "rare") || GetLocalInt(OBJECT_SELF, "immortal") == 1)
125130
{
126131
nGold = nGold * 2;
127-
GeneratePickpocketItem("Misc");
128-
if (d6() == 1) GeneratePickpocketItem();
132+
GeneratePickpocketItem();
133+
if (d6() == 1) GeneratePickpocketItem(LOOT_TYPE_ANY);
129134
}
130135

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

141-
// Set cr integer on self. This is used for determining treasure.
142-
float fCR = GetChallengeRating(OBJECT_SELF);
143-
144-
if (GetLocalInt(OBJECT_SELF, "boss"))
145-
{
146-
fCR = fCR * BOSS_CR_MULTIPLIER;
147-
// Increased area CR means higher quality loot allowed
148-
iAreaCR = FloatToInt(IntToFloat(iAreaCR) * BOSS_AREA_CR_MULTIPLIER);
149-
}
150-
else if (GetLocalInt(OBJECT_SELF, "semiboss") || GetLocalInt(OBJECT_SELF, "rare"))
151-
{
152-
fCR = fCR * SEMIBOSS_CR_MULTIPLIER;
153-
iAreaCR = FloatToInt(IntToFloat(iAreaCR) * SEMIBOSS_AREA_CR_MULTIPLIER);
154-
}
155-
156146
// Create random weapons before scanning, it's sensible
157147
string sScript = GetLocalString(OBJECT_SELF, "spawn_script");
158148
//WriteTimestampedLogEntry("ai_onspawn for " + GetName(OBJECT_SELF) + "-> spawn script = " + sScript);
@@ -203,8 +193,7 @@ void main()
203193

204194

205195

206-
SetLocalInt(OBJECT_SELF, "cr", FloatToInt(fCR));
207-
SetLocalInt(OBJECT_SELF, "area_cr", iAreaCR);
196+
208197

209198
DelayCommand(3.0, CopyKey());
210199

src/nss/dev_xpvalues.nss

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ void RunOnArea(object oArea)
2727
{
2828
for (nLevel = 2; nLevel <= 12; nLevel++)
2929
{
30-
float fMultiplier = 1.0;
31-
if (GetLocalInt(oTest, "boss") == 1)
32-
{
33-
fMultiplier = 3.0;
34-
}
35-
else if (GetLocalInt(oTest, "semiboss") == 1)
36-
{
37-
fMultiplier = 2.0;
38-
}
39-
float fThis = GetPartyXPValue(oTest, 0, IntToFloat(nLevel), 1, fMultiplier);
30+
float fThis = GetPartyXPValue(oTest, 0, IntToFloat(nLevel), 1);
4031
string sVar = "dev_xpvalues" + IntToString(nLevel);
4132
SetLocalFloat(oArea, sVar, GetLocalFloat(oArea, sVar) + fThis);
4233
}

src/nss/dlg_andriel_act.nss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ void main()
4343
else if (nRoll <= 85) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_MEDIUM); }
4444
else if (nRoll <= 90) { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_EASY); }
4545
else { SetTreasureMapDifficulty(oMap, TREASUREMAP_DIFFICULTY_MASTER); }
46-
CopyTierItemToObjectOrLocation(oMap, oPC);
46+
CopyTierItemFromStaging(oMap, oPC);
4747
SQLocalsPlayer_SetInt(oPC, "andriel_lastbuy", SQLite_GetTimeStamp());
4848
}

src/nss/enter_maker2.nss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

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

src/nss/enter_maker4.nss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ void main()
1515
vector vSling = vPos + Vector(IntToFloat(Random(1000))/100 - 5.0, IntToFloat(Random(1000))/100 - 5.0, 0.0);
1616
object oChestItem = GetTieredItemOfType(BASE_ITEM_BULLET, 1, 0);
1717
location lLoc = Location(OBJECT_SELF, vBullets, IntToFloat(Random(360)));
18-
object oFloorItem = CopyTierItemToObjectOrLocation(oChestItem, OBJECT_INVALID, lLoc);
18+
object oFloorItem = CopyTierItemFromStaging(oChestItem, OBJECT_INVALID, lLoc);
1919
SetItemStackSize(oFloorItem, 10 + d4(3));
2020
SetLocalObject(OBJECT_SELF, "puzzle_bullets", oFloorItem);
2121

2222
oChestItem = GetTieredItemOfType(BASE_ITEM_SLING, 1, 0);
2323
lLoc = Location(OBJECT_SELF, vSling, IntToFloat(Random(360)));
24-
oFloorItem = CopyTierItemToObjectOrLocation(oChestItem, OBJECT_INVALID, lLoc);
24+
oFloorItem = CopyTierItemFromStaging(oChestItem, OBJECT_INVALID, lLoc);
2525
SetLocalObject(OBJECT_SELF, "puzzle_sling", oFloorItem);
2626
}
2727
}

0 commit comments

Comments
 (0)