From a3008cab3cebf6b780093a4665092583fc18c45a Mon Sep 17 00:00:00 2001 From: gsemaj Date: Mon, 14 Aug 2023 17:52:40 -0700 Subject: [PATCH] Move eruption attacks to new system --- src/Abilities.cpp | 7 +++++++ src/MobAI.cpp | 16 ++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Abilities.cpp b/src/Abilities.cpp index 5087a15..a3b3f86 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -6,6 +6,7 @@ #include "PlayerManager.hpp" #include "Buffs.hpp" #include "Nanos.hpp" +#include "MobAI.hpp" using namespace Abilities; @@ -364,6 +365,12 @@ void Abilities::useNPCSkill(EntityRef npc, int skillID, std::vector pkt->iSkillID = skillID; pkt->eST = (int32_t)skill->skillType; pkt->iTargetCnt = (int32_t)results.size(); + if(npc.kind == EntityKind::MOB) { + Mob* mob = dynamic_cast(entity); + pkt->iValue1 = mob->hitX; + pkt->iValue2 = mob->hitY; + pkt->iValue3 = mob->hitZ; + } attachSkillResults(results, (uint8_t*)(pkt + 1)); NPCManager::sendToViewable(entity, pkt, P_FE2CL_NPC_SKILL_HIT, resplen); diff --git a/src/MobAI.cpp b/src/MobAI.cpp index 7a31ed3..bddcf82 100644 --- a/src/MobAI.cpp +++ b/src/MobAI.cpp @@ -346,7 +346,7 @@ static void useAbilities(Mob *mob, time_t currTime) { if (mob->skillStyle == -2) { // eruption hit int skillID = (int)mob->data["m_iMegaType"]; - std::vector targetData = {0, 0, 0, 0, 0}; + std::vector targets{}; // find the players within range of eruption for (auto it = mob->viewableChunks.begin(); it != mob->viewableChunks.end(); it++) { @@ -356,26 +356,22 @@ static void useAbilities(Mob *mob, time_t currTime) { if (ref.kind != EntityKind::PLAYER) continue; - CNSocket *s= ref.sock; + CNSocket *s = ref.sock; Player *plr = PlayerManager::getPlayer(s); - if (plr->HP <= 0) + if (!plr->isAlive()) continue; int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y); if (distance < Abilities::SkillTable[skillID].effectArea) { - targetData[0] += 1; - targetData[targetData[0]] = plr->iID; - if (targetData[0] > 3) // make sure not to have more than 4 + targets.push_back(plr); + if (targets.size() > 3) // make sure not to have more than 4 break; } } } - // TODO ABILITIES - /*for (auto& pwr : Abilities::Powers) - if (pwr.skillType == Abilities::SkillTable[skillID].skillType) - pwr.handle(mob->id, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);*/ + Abilities::useNPCSkill(mob->id, skillID, targets); mob->skillStyle = -3; // eruption cooldown mob->nextAttack = currTime + 1000; return;