@@ -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
4344void 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
0 commit comments