From c70205a15b0daff1071e03c5888a08a2fbd8ebb7 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Tue, 25 Jul 2023 13:19:49 -0400 Subject: [PATCH] Implement buffs for mobs --- src/MobAI.cpp | 11 ++++++----- src/MobAI.hpp | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/MobAI.cpp b/src/MobAI.cpp index 42a12df..53b8e2b 100644 --- a/src/MobAI.cpp +++ b/src/MobAI.cpp @@ -441,6 +441,7 @@ static void useAbilities(Mob *mob, time_t currTime) { return; } +// TODO abiilities static void drainMobHP(Mob *mob, int amount) { size_t resplen = sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK) + sizeof(sSkillResult_Damage); assert(resplen < CN_PACKET_BUFFER_SIZE - 8); @@ -552,7 +553,7 @@ void MobAI::combatStep(CombatNPC* npc, time_t currTime) { return; } - // drain + // drain TODO abilities if (self->skillStyle < 0 && (self->lastDrainTime == 0 || currTime - self->lastDrainTime >= 1000) && self->hasBuff(ECSB_BOUNDINGBALL)) { drainMobHP(self, self->maxHealth / 20); // lose 5% every second @@ -563,10 +564,10 @@ void MobAI::combatStep(CombatNPC* npc, time_t currTime) { if (self->hp <= 0) return; - // tick buffs TODO abilities - //for(auto buffEntry : self->buffs) { - // buffEntry.second->combatTick(currTime); - //} + // tick buffs + for(auto buffEntry : self->buffs) { + buffEntry.second->combatTick(currTime); + } // skip attack if stunned or asleep if (self->hasBuff(ECSB_STUN) || self->hasBuff(ECSB_MEZ)) { diff --git a/src/MobAI.hpp b/src/MobAI.hpp index 3e74d3f..09eeefb 100644 --- a/src/MobAI.hpp +++ b/src/MobAI.hpp @@ -41,6 +41,7 @@ struct Mob : public CombatNPC { time_t lastDrainTime = 0; int skillStyle = -1; // -1 for nothing, 0-2 for corruption, -2 for eruption int hitX = 0, hitY = 0, hitZ = 0; // for use in ability targeting + std::unordered_map buffs = {}; // group int groupLeader = 0;