From 398e9fddf8c23cfd887df7401f119805afea6829 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Wed, 18 May 2022 10:04:28 -0400 Subject: [PATCH] Groundwork for new buff system --- src/Abilities.cpp | 52 ++++++++++++++++++++++++----------------------- src/Abilities.hpp | 6 ++++-- src/Groups.hpp | 2 +- src/Nanos.cpp | 18 ++++++++++------ 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/Abilities.cpp b/src/Abilities.cpp index 328b3e7..efcbab7 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -17,33 +17,35 @@ static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) { } */ -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 Abilities::matchTargets(SkillData* skill, int count, int32_t *ids) { std::vector targets; - return targets; + + for (int i = 0; i < count; i++) { + int32_t id = ids[i]; + if (skill->targetType == SkillTargetType::MOBS) { + // mob? + if (NPCManager::NPCs.find(id) != NPCManager::NPCs.end()) targets.push_back(id); + else std::cout << "[WARN] skill: id not found\n"; + } else { + // player? + CNSocket* sock = PlayerManager::getSockFromID(id); + if (sock != nullptr) targets.push_back(sock); + else std::cout << "[WARN] skill: sock not found\n"; + } + } + + return targets; +} + +void Abilities::useAbility(SkillData* skill, EntityRef src, std::vector targets) { + for (EntityRef target : targets) { + Entity* entity = target.getEntity(); + if (entity->kind != PLAYER && entity->kind != COMBAT_NPC && entity->kind != MOB) + continue; // not a combatant + + + } } void Abilities::init() { diff --git a/src/Abilities.hpp b/src/Abilities.hpp index 4f0cfd4..3179cc1 100644 --- a/src/Abilities.hpp +++ b/src/Abilities.hpp @@ -14,8 +14,8 @@ enum class SkillEffectTarget { enum class SkillTargetType { MOBS = 1, - PLAYERS = 2, - SELF = 3 // only used once by client /shrug + SELF = 2, + GROUP = 3 }; struct SkillData { @@ -37,5 +37,7 @@ namespace Abilities { extern std::map SkillTable; std::vector matchTargets(SkillData*, int, int32_t*); + void applyAbility(SkillData*, EntityRef, std::vector); + void init(); } diff --git a/src/Groups.hpp b/src/Groups.hpp index 05bf569..ac6ad57 100644 --- a/src/Groups.hpp +++ b/src/Groups.hpp @@ -12,7 +12,7 @@ enum EntityKind; struct Group { std::vector members; - int32_t conditionBitFlag; + int8_t conditionCounters[32]; std::vector filter(EntityKind kind) { std::vector filtered; diff --git a/src/Nanos.cpp b/src/Nanos.cpp index 36a682a..c37b7ea 100644 --- a/src/Nanos.cpp +++ b/src/Nanos.cpp @@ -85,15 +85,16 @@ 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]; + std::vector targetData; // passive nano unbuffing if (skillData->batteryDrainType == 2) { - // TODO ABILITIES - std::vector targetData = Abilities::matchTargets(skillData, 0, nullptr); + targetData.push_back(sock); // self + if (skillData->targetType == SkillTargetType::GROUP && plr->group != nullptr) + targetData = plr->group->members; // whole group - /*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));*/ + /* TODO ABILITIES */ + targetData.clear(); } if (nanoID >= NANO_COUNT || nanoID < 0) @@ -101,13 +102,18 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) { plr->activeNano = nanoID; skillID = plr->Nanos[nanoID].iSkillID; + skillData = &Abilities::SkillTable[skillID]; // passive nano buffing - if (Abilities::SkillTable[skillID].batteryDrainType == 2) { + if (skillData->batteryDrainType == 2) { int boost = 0; if (getNanoBoost(plr)) boost = 1; + targetData.push_back(sock); // self + if (skillData->targetType == SkillTargetType::GROUP && plr->group != nullptr) + targetData = plr->group->members; // whole group + // TODO ABILITIES //std::vector targetData = Abilities::findTargets(plr, skillID); //for (auto& pwr : Abilities::Powers) {