From 2b25b17bd80c3e084869fd8cda338af1c5f88d50 Mon Sep 17 00:00:00 2001 From: Jade Date: Fri, 13 Nov 2020 23:06:18 +0000 Subject: [PATCH] Gumball Handling and Bugfixes * Gumballs now run out of timer. * Reverted a regression, (gumballs with 0 iOpt do not get emptied). * Nano matchups now work correctly. --- src/ItemManager.cpp | 16 +++++++++++++++- src/MobManager.cpp | 6 +++++- src/NPCManager.cpp | 4 ++-- src/NanoManager.cpp | 29 ++++++++++++++++++++++------- src/NanoManager.hpp | 2 +- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/ItemManager.cpp b/src/ItemManager.cpp index 9095507..648eec5 100644 --- a/src/ItemManager.cpp +++ b/src/ItemManager.cpp @@ -3,6 +3,7 @@ #include "ItemManager.hpp" #include "PlayerManager.hpp" #include "NanoManager.hpp" +#include "NPCManager.hpp" #include "Player.hpp" #include // for memset() @@ -271,6 +272,9 @@ void ItemManager::itemUseHandler(CNSocket* sock, CNPacketData* data) { return; } + if (gumball.iOpt == 0) + gumball = {}; + uint8_t respbuf[CN_PACKET_BUFFER_SIZE]; memset(respbuf, 0, resplen); @@ -282,7 +286,13 @@ void ItemManager::itemUseHandler(CNSocket* sock, CNPacketData* data) { resp->RemainItem = gumball; resp->iTargetCnt = 1; resp->eST = EST_NANOSTIMPAK; - resp->iSkillID = 144; + + if (request->iNanoSlot == 1) + resp->iSkillID = 191; + else if (request->iNanoSlot == 2) + resp->iSkillID = 197; + else + resp->iSkillID = 144; int value1 = CSB_BIT_STIMPAKSLOT1 << request->iNanoSlot; int value2 = ECSB_STIMPAKSLOT1 + request->iNanoSlot; @@ -301,6 +311,10 @@ void ItemManager::itemUseHandler(CNSocket* sock, CNPacketData* data) { sock->sendPacket((void*)&respbuf, P_FE2CL_REP_PC_ITEM_USE_SUCC, resplen); // update inventory serverside player->Inven[resp->iSlotNum] = resp->RemainItem; + + std::pair key = std::make_pair(sock, resp->iSkillID); + time_t until = getTime() + (time_t)NanoManager::SkillTable[resp->iSkillID].durationTime[0] * 10; + NPCManager::EggBuffs[key] = until; } void ItemManager::itemBankOpenHandler(CNSocket* sock, CNPacketData* data) { diff --git a/src/MobManager.cpp b/src/MobManager.cpp index 8cfdf2f..8a6f592 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -986,7 +986,11 @@ std::pair MobManager::getDamage(int attackPower, int defensePower, bool // Adaptium/Blastons/Cosmix if (attackerStyle != -1 && defenderStyle != -1 && attackerStyle != defenderStyle) { - if (attackerStyle < defenderStyle || attackerStyle - defenderStyle == 2) + if (attackerStyle - defenderStyle == 2) + defenderStyle += 3; + if (defenderStyle - attackerStyle == 2) + defenderStyle -= 3; + if (attackerStyle < defenderStyle) damage = damage * 3 / 2; else damage = damage * 2 / 3; diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index 3fda3c7..05a3abd 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -582,7 +582,7 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId) { int bitFlag = GroupManager::getGroupFlags(otherPlr); if (EggBuffs.find(key) == EggBuffs.end()) - if (!NanoManager::applyBuff(sock, skillId, 1, 3, bitFlag, true)) + if (!NanoManager::applyBuff(sock, skillId, 1, 3, bitFlag)) return -1; // save the buff serverside; @@ -719,7 +719,7 @@ void NPCManager::eggPickup(CNSocket* sock, CNPacketData* data) { sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK* pkt = (sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK*)respbuf; sSkillResult_Damage* dmg = (sSkillResult_Damage*)(respbuf + sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK)); - dmg->iDamage = PC_MAXHEALTH(plr->level) * 6 / 10; + dmg->iDamage = PC_MAXHEALTH(plr->level) * 73 / 100; plr->HP -= dmg->iDamage; diff --git a/src/NanoManager.cpp b/src/NanoManager.cpp index d656873..7c21f4a 100644 --- a/src/NanoManager.cpp +++ b/src/NanoManager.cpp @@ -469,7 +469,8 @@ void NanoManager::nanoUnbuff(CNSocket* sock, int targetData[], int32_t bitFlag, resp.eCSTB = timeBuffID; // eCharStatusTimeBuffID resp.eTBU = 2; // eTimeBuffUpdate resp.eTBT = 1; // eTimeBuffType 1 means nano - resp.iConditionBitFlag = varPlr->iConditionBitFlag = groupFlags | varPlr->iSelfConditionBitFlag; + varPlr->iConditionBitFlag &= ~bitFlag; + resp.iConditionBitFlag = varPlr->iConditionBitFlag |= groupFlags | varPlr->iSelfConditionBitFlag; if (amount > 0) resp.TimeBuff.iValue = amount; @@ -479,7 +480,7 @@ void NanoManager::nanoUnbuff(CNSocket* sock, int targetData[], int32_t bitFlag, } } -bool NanoManager::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags, bool eggBuff) { +bool NanoManager::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags) { if (SkillTable[skillID].drainType == 1) return false; @@ -494,9 +495,22 @@ bool NanoManager::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int resp.eCSTB = pwr.timeBuffID; resp.eTBU = eTBU; resp.eTBT = eTBT; - resp.iConditionBitFlag = plr->iConditionBitFlag = groupFlags | plr->iSelfConditionBitFlag; - if (eggBuff) - resp.iConditionBitFlag = plr->iConditionBitFlag |= bitFlag; + + if (skillID == 191) { // dealing with gumballs + resp.eCSTB = pwr.timeBuffID + 1; + bitFlag = bitFlag << 1; + } else if (skillID == 197) { + resp.eCSTB = pwr.timeBuffID + 2; + bitFlag = bitFlag << 2; + } + + if (eTBU == 1) + plr->iConditionBitFlag |= bitFlag; + else + plr->iConditionBitFlag &= ~bitFlag; + + resp.iConditionBitFlag = plr->iConditionBitFlag |= groupFlags | plr->iSelfConditionBitFlag; + resp.TimeBuff.iValue = SkillTable[skillID].powerIntensity[0]; sock->sendPacket((void*)&resp, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); @@ -864,7 +878,7 @@ void nanoPower(CNSocket *sock, int targetData[], // nano power dispatch table std::vector NanoPowers = { NanoPower(EST_STUN, CSB_BIT_STUN, ECSB_STUN, nanoPower), - NanoPower(EST_HEAL_HP, CSB_BIT_HEAL, ECSB_HEAL, nanoPower), + NanoPower(EST_HEAL_HP, CSB_BIT_NONE, ECSB_NONE, nanoPower), NanoPower(EST_BOUNDINGBALL, CSB_BIT_BOUNDINGBALL, ECSB_BOUNDINGBALL, nanoPower), NanoPower(EST_SNARE, CSB_BIT_DN_MOVE_SPEED, ECSB_DN_MOVE_SPEED, nanoPower), NanoPower(EST_DAMAGE, CSB_BIT_NONE, ECSB_NONE, nanoPower), @@ -884,7 +898,8 @@ std::vector NanoPowers = { NanoPower(EST_RECALL, CSB_BIT_NONE, ECSB_NONE, nanoPower), NanoPower(EST_RECALL_GROUP, CSB_BIT_NONE, ECSB_NONE, nanoPower), NanoPower(EST_RETROROCKET_SELF, CSB_BIT_NONE, ECSB_NONE, nanoPower), - NanoPower(EST_PHOENIX_GROUP, CSB_BIT_NONE, ECSB_NONE, nanoPower) + NanoPower(EST_PHOENIX_GROUP, CSB_BIT_NONE, ECSB_NONE, nanoPower), + NanoPower(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT1, ECSB_STIMPAKSLOT1, nanoPower) }; }; // namespace diff --git a/src/NanoManager.hpp b/src/NanoManager.hpp index 1a8c472..a7de27c 100644 --- a/src/NanoManager.hpp +++ b/src/NanoManager.hpp @@ -65,7 +65,7 @@ namespace NanoManager { void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill); void resetNanoSkill(CNSocket* sock, int16_t nanoID); void nanoUnbuff(CNSocket* sock, int* targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower); - bool applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags, bool eggBuff=false); + bool applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags); int nanoStyle(int nanoID); int* findTargets(Player* plr, int skillID, CNPacketData* data = nullptr); }