Implement buffs for mobs

This commit is contained in:
gsemaj 2023-07-25 13:19:49 -04:00 committed by gsemaj
parent 8062e52c55
commit c70205a15b
2 changed files with 7 additions and 5 deletions

View File

@ -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)) {

View File

@ -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<int, Buff*> buffs = {};
// group
int groupLeader = 0;