From c8f5aab929f83717dd83f93fb3fe00c1f1fa7bb3 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Mon, 16 May 2022 20:28:27 -0400 Subject: [PATCH] Active power classification --- src/Abilities.cpp | 33 +++++++++++++++++++++++++++++++-- src/Abilities.hpp | 22 +++++++++++++++++++--- src/Nanos.cpp | 22 +++++++++++++++------- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/src/Abilities.cpp b/src/Abilities.cpp index f9dcc75..328b3e7 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -17,6 +17,35 @@ static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) { } */ -void Abilities::init() { - //REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EMAIL_UPDATE_CHECK, emailUpdateCheck); +std::vector Abilities::matchTargets(SkillData *skill, int count, int32_t *ids) { + + std::vector tempTargs; + switch (skill->effectTarget) + { + case SkillEffectTarget::POINT: + std::cout << "[SKILL] POINT; "; + break; + case SkillEffectTarget::SELF: + std::cout << "[SKILL] SELF; "; + break; + case SkillEffectTarget::CONE: + std::cout << "[SKILL] CONE; "; + break; + case SkillEffectTarget::AREA_SELF: + std::cout << "[SKILL] AREA_SELF; "; + break; + case SkillEffectTarget::AREA_TARGET: + std::cout << "[SKILL] AREA_TARGET; "; + break; + } + + for (int i = 0; i < count; i++) std::cout << ids[i] << " "; + std::cout << std::endl; + + std::vector targets; + return targets; +} + +void Abilities::init() { + //REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EMAIL_UPDATE_CHECK, emailUpdateCheck); } diff --git a/src/Abilities.hpp b/src/Abilities.hpp index 83cab06..4f0cfd4 100644 --- a/src/Abilities.hpp +++ b/src/Abilities.hpp @@ -3,11 +3,26 @@ #include "core/Core.hpp" #include "Combat.hpp" +enum class SkillEffectTarget { + POINT = 1, + SELF = 2, + CONE = 3, + WEAPON = 4, + AREA_SELF = 5, + AREA_TARGET = 6 +}; + +enum class SkillTargetType { + MOBS = 1, + PLAYERS = 2, + SELF = 3 // only used once by client /shrug +}; + struct SkillData { int skillType; - int effectTarget; - int effectType; - int targetType; + SkillEffectTarget effectTarget; + int effectType; // always 1? + SkillTargetType targetType; int batteryDrainType; int effectArea; @@ -21,5 +36,6 @@ struct SkillData { namespace Abilities { extern std::map SkillTable; + std::vector matchTargets(SkillData*, int, int32_t*); void init(); } diff --git a/src/Nanos.cpp b/src/Nanos.cpp index df0ae81..36a682a 100644 --- a/src/Nanos.cpp +++ b/src/Nanos.cpp @@ -84,13 +84,14 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) { plr->nanoDrainRate = 0; int16_t skillID = plr->Nanos[plr->activeNano].iSkillID; + SkillData* skillData = &Abilities::SkillTable[skillID]; // passive nano unbuffing - if (Abilities::SkillTable[skillID].batteryDrainType == 2) { + if (skillData->batteryDrainType == 2) { // TODO ABILITIES - /*std::vector targetData = Abilities::findTargets(plr, skillID); + std::vector targetData = Abilities::matchTargets(skillData, 0, nullptr); - for (auto& pwr : Abilities::Powers) + /*for (auto& pwr : Abilities::Powers) if (pwr.skillType == Abilities::SkillTable[skillID].skillType) Abilities::removeBuff(sock, targetData, pwr.bitFlag, pwr.timeBuffID, 0,(Abilities::SkillTable[skillID].targetType == 3));*/ } @@ -290,8 +291,15 @@ static void nanoSummonHandler(CNSocket* sock, CNPacketData* data) { static void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) { Player *plr = PlayerManager::getPlayer(sock); - int16_t nanoID = plr->activeNano; - int16_t skillID = plr->Nanos[nanoID].iSkillID; + // validate request check + sP_CL2FE_REQ_NANO_SKILL_USE* pkt = (sP_CL2FE_REQ_NANO_SKILL_USE*)data->buf; + if (!validInVarPacket(sizeof(sP_CL2FE_REQ_NANO_SKILL_USE), pkt->iTargetCnt, sizeof(int32_t), data->size)) { + std::cout << "[WARN] bad sP_CL2FE_REQ_NANO_SKILL_USE packet size" << std::endl; + return; + } + + int16_t skillID = plr->Nanos[plr->activeNano].iSkillID; + SkillData* skillData = &Abilities::SkillTable[skillID]; DEBUGLOG( std::cout << PlayerManager::getPlayerName(plr) << " requested to summon nano skill " << std::endl; @@ -306,8 +314,8 @@ static void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) { plr->Nanos[plr->activeNano].iStamina = 0; // TODO ABILITIES - /*std::vector targetData = Abilities::findTargets(plr, skillID, data); - for (auto& pwr : Abilities::Powers) + std::vector targetData = Abilities::matchTargets(skillData, pkt->iTargetCnt, (int32_t*)(pkt + 1)); + /*for (auto& pwr : Abilities::Powers) if (pwr.skillType == Abilities::SkillTable[skillID].skillType) pwr.handle(sock, targetData, nanoID, skillID, Abilities::SkillTable[skillID].durationTime[boost], Abilities::SkillTable[skillID].powerIntensity[boost]);*/