@@ -30,6 +30,7 @@ the player using configurable emote options.
30
30
31
31
### Version
32
32
------------------------------------------------------------------------------------------------------------------
33
+ - v2024.07.01 - Fix database script to use creature_template_model table. Updated spell list/scaling code. Added Thorns to spell list
33
34
- v2019.04.17 - Fix Cure Resurrection Sickness, works now! Courtesy of Poszer and Milestorme
34
35
- v2019.04.15 - Ported to AzerothCore by gtao725 (https://github.com/gtao725/)
35
36
- v2019.02.13 - Added phrases/emotes, config options, updated AI
@@ -69,6 +70,7 @@ This code and content is released under the [GNU AGPL v3](https://github.com/aze
69
70
#include " Player.h"
70
71
#include " ScriptedCreature.h"
71
72
#include " ScriptedGossip.h"
73
+ #include " Log.h"
72
74
73
75
static bool BFEnableModule;
74
76
static bool BFAnnounceModule;
@@ -79,6 +81,7 @@ static uint32 BuffNumWhispers;
79
81
static uint32 BuffMessageTimer;
80
82
static uint32 BuffEmoteSpell;
81
83
static uint32 BuffEmoteCommand;
84
+ static uint32 MaxLevel = 80 ;
82
85
83
86
class BufferConfig : public WorldScript
84
87
{
@@ -97,6 +100,8 @@ class BufferConfig : public WorldScript
97
100
BuffEmoteSpell = sConfigMgr ->GetOption <uint32>(" Buff.EmoteSpell" , 44940 );
98
101
BuffEmoteCommand = sConfigMgr ->GetOption <uint32>(" Buff.EmoteCommand" , 3 );
99
102
103
+ MaxLevel = sConfigMgr ->GetOption <uint32>(" Buff.MaxLevel" , 80 );
104
+
100
105
// Enforce Min/Max Time
101
106
if (BuffMessageTimer != 0 )
102
107
{
@@ -128,6 +133,53 @@ class buff_npc : public CreatureScript
128
133
public:
129
134
buff_npc () : CreatureScript(" buff_npc" ) {}
130
135
136
+ /* * Get the most level-appropriate spell from the chain,
137
+ * based on character level compared to max level (MaxLevel)
138
+ * */
139
+ static uint GetSpellForLevel (uint32 spell_id, Player *player)
140
+ {
141
+ uint32 level = player->getLevel ();
142
+
143
+ // if the character is level max level or higher, return the last spell in the chain
144
+ if (level >= MaxLevel)
145
+ {
146
+ return sSpellMgr ->GetLastSpellInChain (spell_id);
147
+ }
148
+
149
+ uint32 first_spell = sSpellMgr ->GetFirstSpellInChain (spell_id);
150
+ uint32 next_spell = first_spell;
151
+ uint32 number_of_spells_in_chain = 0 ;
152
+ for (; next_spell; next_spell = sSpellMgr ->GetNextSpellInChain (next_spell))
153
+ {
154
+ number_of_spells_in_chain++;
155
+ }
156
+
157
+ // if the chain is empty, return the first spell
158
+ if (number_of_spells_in_chain == 0 )
159
+ {
160
+ LOG_WARN (" module.buffernpc" , " Unable to find a spell chain for spell with id {}" , spell_id);
161
+ return first_spell;
162
+ }
163
+
164
+ // if the chain has only one spell, return that spell
165
+ if (number_of_spells_in_chain == 1 )
166
+ {
167
+ return first_spell;
168
+ }
169
+
170
+ // if the chain has more than one spell, calculate the level-appropriate spell
171
+ uint32 spell_index = (level * number_of_spells_in_chain) / MaxLevel;
172
+ uint32 spell = first_spell;
173
+ LOG_DEBUG (" module.buffernpc" , " {}, level {}, gets spell {} of {} from spell {}" , player->GetName (), level, (spell_index+1 ), number_of_spells_in_chain, spell_id);
174
+ for (uint32 i = 0 ; i < spell_index; i++)
175
+ {
176
+ // traverse to the level-appropriate spell
177
+ spell = sSpellMgr ->GetNextSpellInChain (spell);
178
+ }
179
+
180
+ return spell;
181
+ }
182
+
131
183
static bool replace (std::string &str, const std::string &from, const std::string &to)
132
184
{
133
185
size_t start_pos = str.find (from);
@@ -184,7 +236,6 @@ class buff_npc : public CreatureScript
184
236
// Who are we dealing with?
185
237
std::string CreatureWhisper = " Init" ;
186
238
std::string PlayerName = player->GetName ();
187
- uint32 PlayerLevel = player->getLevel ();
188
239
189
240
// Store Buff IDs
190
241
std::vector<uint32> vecBuffs = {};
@@ -206,80 +257,12 @@ class buff_npc : public CreatureScript
206
257
// Are we buffing based on level
207
258
if (BuffByLevel == true )
208
259
{
209
- // Apply (10-19, 20-29, ..., 70-79, 80)
210
- if (PlayerLevel < 10 )
211
- {
212
- // Dish out the buffs
213
- player->CastSpell (player, 21562 , true ); // Prayer of Fortitude (Rank 1)
214
- player->CastSpell (player, 1126 , true ); // Mark of the Wild (Rank 1)
215
- player->CastSpell (player, 27683 , true ); // Prayer of Shadow Protection (Rank 1)
216
- } // 1-9
217
- else if (PlayerLevel >= 10 && PlayerLevel < 20 )
218
- {
219
- player->CastSpell (player, 21562 , true ); // Prayer of Fortitude (Rank 1)
220
- player->CastSpell (player, 1126 , true ); // Mark of the Wild (Rank 1)
221
- player->CastSpell (player, 27683 , true ); // Prayer of Shadow Protection (Rank 1)
222
- } // 10-19
223
- else if (PlayerLevel >= 20 && PlayerLevel < 30 )
224
- {
225
- player->CastSpell (player, 21562 , true ); // Prayer of Fortitude (Rank 1)
226
- player->CastSpell (player, 1126 , true ); // Mark of the Wild (Rank 1)
227
- player->CastSpell (player, 27683 , true ); // Prayer of Shadow Protection (Rank 1)
228
- player->CastSpell (player, 13326 , true ); // Arcane Intellect (Rank 1)
229
- } // 20-29
230
- else if (PlayerLevel >= 30 && PlayerLevel < 40 )
231
- {
232
- player->CastSpell (player, 21562 , true ); // Prayer of Fortitude (Rank 1)
233
- player->CastSpell (player, 25898 , true ); // Greater Blessing of Kings (Rank 1)
234
- player->CastSpell (player, 1126 , true ); // Mark of the Wild (Rank 1)
235
- player->CastSpell (player, 27681 , true ); // Prayer of Spirit (Rank 1)
236
- player->CastSpell (player, 27683 , true ); // Prayer of Shadow Protection (Rank 1)
237
- player->CastSpell (player, 13326 , true ); // Arcane Intellect (Rank 1)
238
- } // 30-39
239
- else if (PlayerLevel >= 40 && PlayerLevel < 50 )
240
- {
241
- player->CastSpell (player, 21562 , true ); // Prayer of Fortitude (Rank 1)
242
- player->CastSpell (player, vecBuffs[2 ], true ); // Mark of the Wild(48469)
243
- player->CastSpell (player, 27681 , true ); // Prayer of Spirit (Rank 1)
244
- player->CastSpell (player, vecBuffs[4 ], true ); // Prayer of Shadow Protection(48170)
245
- player->CastSpell (player, 13326 , true ); // Arcane Intellect (Rank 1)
246
- } // 40-49
247
- else if (PlayerLevel >= 50 && PlayerLevel < 60 )
248
- {
249
- player->CastSpell (player, vecBuffs[0 ], true ); // Prayer of Fortitude(48162)
250
- player->CastSpell (player, vecBuffs[1 ], true ); // Greater Blessing of Kings(43223)
251
- player->CastSpell (player, vecBuffs[2 ], true ); // Mark of the Wild(48469)
252
- player->CastSpell (player, vecBuffs[3 ], true ); // Prayer of Spirit(48074)
253
- player->CastSpell (player, vecBuffs[4 ], true ); // Prayer of Shadow Protection(48170)
254
- player->CastSpell (player, vecBuffs[5 ], true ); // Arcane Intellect(42995)
255
- } // 50-59
256
- else if (PlayerLevel >= 60 && PlayerLevel < 70 )
257
- {
258
- player->CastSpell (player, vecBuffs[0 ], true ); // Prayer of Fortitude(48162)
259
- player->CastSpell (player, vecBuffs[1 ], true ); // Greater Blessing of Kings(43223)
260
- player->CastSpell (player, vecBuffs[2 ], true ); // Mark of the Wild(48469)
261
- player->CastSpell (player, vecBuffs[3 ], true ); // Prayer of Spirit(48074)
262
- player->CastSpell (player, vecBuffs[4 ], true ); // Prayer of Shadow Protection(48170)
263
- player->CastSpell (player, vecBuffs[5 ], true ); // Arcane Intellect(42995)
264
- } // 60-69
265
- else if (PlayerLevel >= 70 && PlayerLevel < 80 )
266
- {
267
- player->CastSpell (player, vecBuffs[0 ], true ); // Prayer of Fortitude(48162)
268
- player->CastSpell (player, vecBuffs[1 ], true ); // Greater Blessing of Kings(43223)
269
- player->CastSpell (player, vecBuffs[2 ], true ); // Mark of the Wild(48469)
270
- player->CastSpell (player, vecBuffs[3 ], true ); // Prayer of Spirit(48074)
271
- player->CastSpell (player, vecBuffs[4 ], true ); // Prayer of Shadow Protection(48170)
272
- player->CastSpell (player, vecBuffs[5 ], true ); // Arcane Intellect(42995)
273
- } // 70-79
274
- else
260
+ for (std::vector<uint32>::const_iterator itr = vecBuffs.begin (); itr != vecBuffs.end (); itr++)
275
261
{
276
- player->CastSpell (player, vecBuffs[0 ], true ); // Prayer of Fortitude (48162)
277
- player->CastSpell (player, vecBuffs[1 ], true ); // Greater Blessing of Kings (43223)
278
- player->CastSpell (player, vecBuffs[2 ], true ); // Mark of the Wild (48469)
279
- player->CastSpell (player, vecBuffs[3 ], true ); // Prayer of Spirit (48074)
280
- player->CastSpell (player, vecBuffs[4 ], true ); // Prayer of Shadow Protection (48170)
281
- player->CastSpell (player, vecBuffs[5 ], true ); // Arcane Intellect (42995)
282
- } // LEVEL 80
262
+ uint32 spell_id = *itr; // get the spell id from the list of spells
263
+ uint32 spell = GetSpellForLevel (spell_id, player); // get the level-appropriate spell
264
+ player->CastSpell (player, spell, true ); // cast the buff
265
+ }
283
266
}
284
267
else
285
268
{
@@ -292,7 +275,6 @@ class buff_npc : public CreatureScript
292
275
293
276
// Choose and speak a random phrase to the player
294
277
// Phrases are stored in the config file
295
-
296
278
if (BuffNumWhispers > 0 )
297
279
{
298
280
creature->Whisper (PickWhisper (PlayerName).c_str (), LANG_UNIVERSAL, player);
0 commit comments