From feaaf4cab9170f330b51135f5fa94afe4fa44bed Mon Sep 17 00:00:00 2001 From: gsemaj Date: Mon, 16 May 2022 16:47:30 -0400 Subject: [PATCH] some struct reorg --- src/Abilities.cpp | 13 +++++++++++-- src/Abilities.hpp | 11 +++++++++-- src/Eggs.cpp | 4 ++-- src/MobAI.cpp | 4 ++-- src/Nanos.cpp | 4 ++-- src/TableData.cpp | 30 +++++++++++++++++++++++------- 6 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/Abilities.cpp b/src/Abilities.cpp index 8c7f84d..f9dcc75 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -8,6 +8,15 @@ std::map Abilities::SkillTable; -namespace Abilities { +/* +// New email notification +static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) { + INITSTRUCT(sP_FE2CL_REP_PC_NEW_EMAIL, resp); + resp.iNewEmailCnt = Database::getUnreadEmailCount(PlayerManager::getPlayer(sock)->iID); + sock->sendPacket(resp, P_FE2CL_REP_PC_NEW_EMAIL); +} +*/ -}; // namespace +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 022ee64..83cab06 100644 --- a/src/Abilities.hpp +++ b/src/Abilities.hpp @@ -5,14 +5,21 @@ struct SkillData { int skillType; + int effectTarget; + int effectType; int targetType; - int drainType; + int batteryDrainType; int effectArea; + int batteryUse[4]; int durationTime[4]; - int powerIntensity[4]; + + int valueTypes[3]; + int values[3][4]; }; namespace Abilities { extern std::map SkillTable; + + void init(); } diff --git a/src/Eggs.cpp b/src/Eggs.cpp index 64b1e93..5a5c903 100644 --- a/src/Eggs.cpp +++ b/src/Eggs.cpp @@ -41,7 +41,7 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) { memset(respbuf, 0, resplen); skill->eCT = 1; skill->iID = plr->iID; - skill->iDamage = PC_MAXHEALTH(plr->level) * Abilities::SkillTable[skillId].powerIntensity[0] / 1000; + skill->iDamage = PC_MAXHEALTH(plr->level) * Abilities::SkillTable[skillId].values[0][0] / 1000; plr->HP -= skill->iDamage; if (plr->HP < 0) plr->HP = 0; @@ -51,7 +51,7 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) { memset(respbuf, 0, resplen); skill->eCT = 1; skill->iID = plr->iID; - skill->iHealHP = PC_MAXHEALTH(plr->level) * Abilities::SkillTable[skillId].powerIntensity[0] / 1000; + skill->iHealHP = PC_MAXHEALTH(plr->level) * Abilities::SkillTable[skillId].values[0][0] / 1000; plr->HP += skill->iHealHP; if (plr->HP > PC_MAXHEALTH(plr->level)) plr->HP = PC_MAXHEALTH(plr->level); diff --git a/src/MobAI.cpp b/src/MobAI.cpp index 4299727..55d6747 100644 --- a/src/MobAI.cpp +++ b/src/MobAI.cpp @@ -281,7 +281,7 @@ static void dealCorruption(Mob *mob, std::vector targetData, int skillID, i int style2 = Nanos::nanoStyle(plr->activeNano); if (style2 == -1) { // no nano respdata[i].iHitFlag = HF_BIT_STYLE_TIE; - respdata[i].iDamage = Abilities::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500; + respdata[i].iDamage = Abilities::SkillTable[skillID].values[0][0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500; } else if (style == style2) { respdata[i].iHitFlag = HF_BIT_STYLE_TIE; respdata[i].iDamage = 0; @@ -300,7 +300,7 @@ static void dealCorruption(Mob *mob, std::vector targetData, int skillID, i pwr.handle(sock, targetData2, plr->activeNano, skillID, 0, 200);*/ } else { respdata[i].iHitFlag = HF_BIT_STYLE_LOSE; - respdata[i].iDamage = Abilities::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500; + respdata[i].iDamage = Abilities::SkillTable[skillID].values[0][0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500; respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina -= 90; if (plr->Nanos[plr->activeNano].iStamina < 0) { respdata[i].bNanoDeactive = 1; diff --git a/src/Nanos.cpp b/src/Nanos.cpp index dbab11a..df0ae81 100644 --- a/src/Nanos.cpp +++ b/src/Nanos.cpp @@ -86,7 +86,7 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) { int16_t skillID = plr->Nanos[plr->activeNano].iSkillID; // passive nano unbuffing - if (Abilities::SkillTable[skillID].drainType == 2) { + if (Abilities::SkillTable[skillID].batteryDrainType == 2) { // TODO ABILITIES /*std::vector targetData = Abilities::findTargets(plr, skillID); @@ -102,7 +102,7 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) { skillID = plr->Nanos[nanoID].iSkillID; // passive nano buffing - if (Abilities::SkillTable[skillID].drainType == 2) { + if (Abilities::SkillTable[skillID].batteryDrainType == 2) { int boost = 0; if (getNanoBoost(plr)) boost = 1; diff --git a/src/TableData.cpp b/src/TableData.cpp index 3bbd09d..e9e9e21 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -215,15 +215,31 @@ static void loadXDT(json& xdtData) { // load nano powers json skills = xdtData["m_pSkillTable"]["m_pSkillData"]; - for (json::iterator _skills = skills.begin(); _skills != skills.end(); _skills++) { - auto skills = _skills.value(); - SkillData skillData = { skills["m_iSkillType"], skills["m_iTargetType"], skills["m_iBatteryDrainType"], skills["m_iEffectArea"] }; + for (json::iterator _skill = skills.begin(); _skill != skills.end(); _skill++) { + auto skill = _skill.value(); + SkillData skillData = { + skill["m_iSkillType"], + skill["m_iEffectTarget"], + skill["m_iEffectType"], + skill["m_iTargetType"], + skill["m_iBatteryDrainType"], + skill["m_iEffectArea"] + }; + + skillData.valueTypes[0] = skill["m_iValueA_Type"]; + skillData.valueTypes[1] = skill["m_iValueB_Type"]; + skillData.valueTypes[2] = skill["m_iValueC_Type"]; + for (int i = 0; i < 4; i++) { - skillData.batteryUse[i] = skills["m_iBatteryDrainUse"][i]; - skillData.durationTime[i] = skills["m_iDurationTime"][i]; - skillData.powerIntensity[i] = skills["m_iValueA"][i]; + skillData.batteryUse[i] = skill["m_iBatteryDrainUse"][i]; + skillData.durationTime[i] = skill["m_iDurationTime"][i]; + + skillData.values[0][i] = skill["m_iValueA"][i]; + skillData.values[1][i] = skill["m_iValueB"][i]; + skillData.values[2][i] = skill["m_iValueC"][i]; } - Abilities::SkillTable[skills["m_iSkillNumber"]] = skillData; + + Abilities::SkillTable[skill["m_iSkillNumber"]] = skillData; } std::cout << "[INFO] Loaded " << Abilities::SkillTable.size() << " nano skills" << std::endl;