[API] Perl functions added to apply spell effects directly to NPCs without requiring buffs. (#1975)

* script functions working

* Update perl_npc.cpp

* [API] Perl functions added to apply spell effects directly to NPCs without requiring buffs.
This commit is contained in:
KayenEQ
2022-02-08 18:32:13 -05:00
committed by GitHub
parent 752e6c89f3
commit 79f250da2d
3 changed files with 62 additions and 3 deletions
+24 -2
View File
@@ -2761,9 +2761,8 @@ void NPC::ApplyAISpellEffects(StatBonuses* newbon)
}
// adds a spell to the list, taking into account priority and resorting list as needed.
void NPC::AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value)
void NPC::AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value, bool apply_bonus)
{
if(!iSpellEffectID)
return;
@@ -2775,6 +2774,29 @@ void NPC::AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base_value, int32
t.limit = limit;
t.max_value = max_value;
AIspellsEffects.push_back(t);
//we recalculate if applied from quest script.
if (apply_bonus) {
CalcBonuses();
}
}
void NPC::RemoveSpellEffectFromNPCList(uint16 iSpellEffectID, bool apply_bonus)
{
auto iter = AIspellsEffects.begin();
while (iter != AIspellsEffects.end())
{
if ((*iter).spelleffectid == iSpellEffectID)
{
iter = AIspellsEffects.erase(iter);
continue;
}
++iter;
}
if (apply_bonus) {
CalcBonuses();
}
}
bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base_value, int32 limit, int32 max_value) {