From 5b580559247df9e11180c04c18f5f29b1f46fa53 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Thu, 21 Jul 2022 09:22:19 -0700 Subject: [PATCH] Passive nano powers pt 1 --- src/Abilities.cpp | 83 +++++++++++++++++++++++++---------------------- src/Abilities.hpp | 2 +- src/Buffs.cpp | 9 ++++- src/Buffs.hpp | 1 + src/Combat.cpp | 3 +- src/Items.cpp | 1 + 6 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/Abilities.cpp b/src/Abilities.cpp index f24b3a2..009c951 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -40,71 +40,71 @@ std::vector Abilities::matchTargets(SkillData* skill, int count, int3 return targets; } -/* ripped from client */ +/* ripped from client (enums emplaced) */ int Abilities::getCSTBFromST(int eSkillType) { int result = 0; switch (eSkillType) { - case 11: - result = 1; + case EST_RUN: + result = ECSB_UP_MOVE_SPEED; break; - case 10: - result = 3; + case EST_JUMP: + result = ECSB_UP_JUMP_HEIGHT; break; - case 12: - result = 4; + case EST_STEALTH: + result = ECSB_UP_STEALTH; break; - case 16: - result = 5; + case EST_PHOENIX: + result = ECSB_PHOENIX; break; - case 17: - result = 6; + case EST_PROTECTBATTERY: + result = ECSB_PROTECT_BATTERY; break; - case 18: - result = 7; + case EST_PROTECTINFECTION: + result = ECSB_PROTECT_INFECTION; break; - case 5: - result = 8; + case EST_SNARE: + result = ECSB_DN_MOVE_SPEED; break; - case 4: - result = 11; + case EST_SLEEP: + result = ECSB_MEZ; break; - case 14: - result = 13; + case EST_MINIMAPENEMY: + result = ECSB_MINIMAP_ENEMY; break; - case 15: - result = 14; + case EST_MINIMAPTRESURE: + result = ECSB_MINIMAP_TRESURE; break; - case 19: - result = 15; + case EST_REWARDBLOB: + result = ECSB_REWARD_BLOB; break; - case 20: - result = 16; + case EST_REWARDCASH: + result = ECSB_REWARD_CASH; break; - case 23: - result = 17; + case EST_INFECTIONDAMAGE: + result = ECSB_INFECTION; break; - case 25: - result = 18; + case EST_FREEDOM: + result = ECSB_FREEDOM; break; - case 31: - result = 19; + case EST_BOUNDINGBALL: + result = ECSB_BOUNDINGBALL; break; - case 32: - result = 20; + case EST_INVULNERABLE: + result = ECSB_INVULNERABLE; break; - case 35: - result = 24; + case EST_BUFFHEAL: + result = ECSB_HEAL; break; - case 33: - result = 21; + case EST_NANOSTIMPAK: + result = ECSB_STIMPAKSLOT1; break; } return result; } #pragma region Skill Handlers -void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr) { +void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr, int boost) { assert(skill->drainType == SkillDrainType::PASSIVE); EntityRef self = PlayerManager::getSockFromID(plr->iID); @@ -118,12 +118,17 @@ void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr) { std::cout << "[WARN] Passive skill with type " << skill->skillType << " has target type MOB" << std::endl; } + int timeBuffId = getCSTBFromST(skill->skillType); + int value = skill->values[0][boost]; + BuffStack passiveBuff = { 1, // passive nano buffs refreshed every tick + value, self, BuffClass::NONE, // overwritten per target [](EntityRef host, BuffStack* stack) { Buffs::timeBuffUpdate(host, stack, ETBU_ADD); + // TODO SKILLUSE/SKILLUSESUCC, sSkillResult_Buff }, nullptr, [](EntityRef host, BuffStack* stack) { @@ -138,7 +143,7 @@ void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr) { passiveBuff.buffStackClass = target == self ? BuffClass::NANO : BuffClass::GROUP_NANO; ICombatant* combatant = dynamic_cast(entity); - combatant->addBuff(getCSTBFromST(skill->skillType), &passiveBuff); + combatant->addBuff(timeBuffId, &passiveBuff); } } #pragma endregion diff --git a/src/Abilities.hpp b/src/Abilities.hpp index 03b8fa7..4600339 100644 --- a/src/Abilities.hpp +++ b/src/Abilities.hpp @@ -47,7 +47,7 @@ namespace Abilities { std::vector matchTargets(SkillData*, int, int32_t*); int getCSTBFromST(int eSkillType); - void usePassiveNanoSkill(SkillData*, Player*); + void usePassiveNanoSkill(SkillData*, Player*, int); void init(); } diff --git a/src/Buffs.cpp b/src/Buffs.cpp index a925b97..8ffdace 100644 --- a/src/Buffs.cpp +++ b/src/Buffs.cpp @@ -73,14 +73,21 @@ void Buffs::timeBuffUpdate(EntityRef self, BuffStack* stack, int status) { if(status == ETBU_DEL && plr->hasBuff(stack->buff->id)) return; // no premature status removal! + sTimeBuff payload{}; + int cbf = plr->getCompositeCondition(); - if(status == ETBU_ADD && stack->buff->id > 0) cbf |= CSB_FROM_ECSB(stack->buff->id); + if(status == ETBU_ADD) { + if(stack->buff->id > 0) cbf |= CSB_FROM_ECSB(stack->buff->id); + payload.iValue = stack->value; + //payload.iTimeLimit = stack->durationTicks * MS_PER_PLAYER_TICK; + } INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt); pkt.eCSTB = stack->buff->id; // eCharStatusTimeBuffID pkt.eTBU = status; // eTimeBuffUpdate pkt.eTBT = (int)stack->buffStackClass; pkt.iConditionBitFlag = cbf; + pkt.TimeBuff = payload; self.sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); } diff --git a/src/Buffs.hpp b/src/Buffs.hpp index dc73f6a..2fc8163 100644 --- a/src/Buffs.hpp +++ b/src/Buffs.hpp @@ -26,6 +26,7 @@ typedef std::function BuffCallback; struct BuffStack { int durationTicks; + int value; EntityRef source; BuffClass buffStackClass; diff --git a/src/Combat.cpp b/src/Combat.cpp index 94c8f66..337facf 100644 --- a/src/Combat.cpp +++ b/src/Combat.cpp @@ -351,6 +351,7 @@ static void dotDamageOnOff(CNSocket *sock, CNPacketData *data) { if (pkt->iFlag && !plr->hasBuff(ECSB_INFECTION)) { BuffStack infection = { -1, // infinite + NULL, sock, // self-inflicted BuffClass::ENVIRONMENT, [](EntityRef host, BuffStack* stack) { @@ -746,7 +747,7 @@ static void playerTick(CNServer *serv, time_t currTime) { if (skill->drainType == SkillDrainType::PASSIVE) { // apply passive buff drainRate = skill->batteryUse[boost * 3]; - Abilities::usePassiveNanoSkill(skill, plr); + Abilities::usePassiveNanoSkill(skill, plr, boost * 3); } } diff --git a/src/Items.cpp b/src/Items.cpp index 832b2f5..94b2c20 100644 --- a/src/Items.cpp +++ b/src/Items.cpp @@ -494,6 +494,7 @@ static void itemUseHandler(CNSocket* sock, CNPacketData* data) { int durationMilliseconds = Abilities::SkillTable[144].durationTime[0] * 100; BuffStack gumballBuff = { durationMilliseconds / MS_PER_PLAYER_TICK, + NULL, sock, BuffClass::CASH_ITEM, // or BuffClass::ITEM? [](EntityRef host, BuffStack* stack) {