From 1800334bb75442df2bfcb406d5ceaa6a51a8016c Mon Sep 17 00:00:00 2001 From: dongresource Date: Wed, 13 Sep 2023 03:01:18 +0200 Subject: [PATCH] Fix buffs applying to non-COMBAT, non-ROAMING mobs --- src/Abilities.cpp | 4 ++-- src/Combat.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Abilities.cpp b/src/Abilities.cpp index 0859220..58bfb45 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -123,7 +123,7 @@ static SkillResult handleSkillBuff(SkillData* skill, int power, ICombatant* sour int combatLifetime = 0; if(!target->addBuff(timeBuffId, [drainType](EntityRef self, Buff* buff, int status, BuffStack* stack) { - if(buff->id == ECSB_BOUNDINGBALL) { + if(buff->id == ECSB_BOUNDINGBALL && status == ETBU_ADD) { // drain ICombatant* combatant = dynamic_cast(self.getEntity()); combatant->takeDamage(buff->getLastSource(), 0); // aggro @@ -138,7 +138,7 @@ static SkillResult handleSkillBuff(SkillData* skill, int power, ICombatant* sour Buffs::tickDrain(self, buff, COMBAT_TICKS_PER_DRAIN_PROC); // drain combatLifetime++; }, - &passiveBuff)) return SkillResult(); // no result if already buffed + &passiveBuff)) return SkillResult(); sSkillResult_Buff result{}; result.eCT = target->getCharType(); diff --git a/src/Combat.cpp b/src/Combat.cpp index 80fbab1..d204f99 100644 --- a/src/Combat.cpp +++ b/src/Combat.cpp @@ -179,6 +179,9 @@ bool CombatNPC::addBuff(int buffId, BuffCallback onUpdate, Buff if(!isAlive()) return false; + if (this->state != AIState::COMBAT && this->state != AIState::ROAMING) + return false; + if(!hasBuff(buffId)) { buffs[buffId] = new Buff(buffId, getRef(), onUpdate, onTick, stack); return true;