[Quest API] Add Caster ID Parameter to FindBuff in Perl/Lua (#3590)

* [Quest API] Add Caster ID Parameter to FindBuff in Perl/Lua

# Perl
- Add `$mob->FindBuff(spell_id, caster_id)`.

# Lua
- Add `mob:FindBuff(spell_id, caster_id)`.

# Notes
- Allows operators to check if the spell ID is cast by a specific entity ID.
- We don't use `Mob*` reference here since the mob may have died, left zone, etc.

* Formatting.
This commit is contained in:
Alex King
2023-09-29 19:38:36 -04:00
committed by GitHub
parent 79918ebaba
commit cf27f2bc88
5 changed files with 26 additions and 9 deletions
+8 -4
View File
@@ -4411,14 +4411,18 @@ std::vector<uint16> Mob::GetBuffSpellIDs()
return l;
}
bool Mob::FindBuff(uint16 spell_id)
bool Mob::FindBuff(uint16 spell_id, uint16 caster_id)
{
uint32 buff_count = GetMaxTotalSlots();
const int buff_count = GetMaxTotalSlots();
for (int buff_slot = 0; buff_slot < buff_count; buff_slot++) {
auto current_spell_id = buffs[buff_slot].spellid;
const uint16 current_spell_id = buffs[buff_slot].spellid;
if (
IsValidSpell(current_spell_id) &&
current_spell_id == spell_id
current_spell_id == spell_id &&
(
!caster_id ||
buffs[buff_slot].casterid == caster_id
)
) {
return true;
}