mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-14 18:30:05 +00:00
[WIP] Initial merge of ability namespaces & features
This commit is contained in:
parent
650f947451
commit
258ff35e20
@ -10,14 +10,14 @@
|
|||||||
* TODO: This file is in desperate need of deduplication and rewriting.
|
* TODO: This file is in desperate need of deduplication and rewriting.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::map<int32_t, SkillData> Nanos::SkillTable;
|
std::map<int32_t, SkillData> Abilities::SkillTable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* targetData approach
|
* targetData approach
|
||||||
* first integer is the count
|
* first integer is the count
|
||||||
* second to fifth integers are IDs, these can be either player iID or mob's iID
|
* second to fifth integers are IDs, these can be either player iID or mob's iID
|
||||||
*/
|
*/
|
||||||
std::vector<int> Nanos::findTargets(Player* plr, int skillID, CNPacketData* data) {
|
std::vector<int> Abilities::findTargets(Player* plr, int skillID, CNPacketData* data) {
|
||||||
std::vector<int> tD(5);
|
std::vector<int> tD(5);
|
||||||
|
|
||||||
if (SkillTable[skillID].targetType <= 2 && data != nullptr) { // client gives us the targets
|
if (SkillTable[skillID].targetType <= 2 && data != nullptr) { // client gives us the targets
|
||||||
@ -66,7 +66,7 @@ std::vector<int> Nanos::findTargets(Player* plr, int skillID, CNPacketData* data
|
|||||||
return tD;
|
return tD;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nanos::nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower) {
|
void Abilities::removeBuff(CNSocket* sock, std::vector<int> targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower) {
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
plr->iSelfConditionBitFlag &= ~bitFlag;
|
plr->iSelfConditionBitFlag &= ~bitFlag;
|
||||||
@ -101,13 +101,13 @@ void Nanos::nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_t bitF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Nanos::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags) {
|
int Abilities::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags) {
|
||||||
if (SkillTable[skillID].drainType == 1)
|
if (SkillTable[skillID].drainType == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32_t bitFlag = 0;
|
int32_t bitFlag = 0;
|
||||||
|
|
||||||
for (auto& pwr : NanoPowers) {
|
for (auto& pwr : Powers) {
|
||||||
if (pwr.skillType == SkillTable[skillID].skillType) {
|
if (pwr.skillType == SkillTable[skillID].skillType) {
|
||||||
bitFlag = pwr.bitFlag;
|
bitFlag = pwr.bitFlag;
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
@ -133,8 +133,7 @@ int Nanos::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t gr
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Nano Powers
|
namespace Abilities {
|
||||||
namespace Nanos {
|
|
||||||
|
|
||||||
bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
|
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
|
||||||
@ -406,111 +405,9 @@ bool doMove(CNSocket *sock, sSkillResult_Move *respdata, int i, int32_t targetID
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class sPAYLOAD,
|
bool doDamageNDebuff(Mob* mob, sSkillResult_Damage_N_Debuff* respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
bool (*work)(CNSocket*,sPAYLOAD*,int,int32_t,int32_t,int16_t,int16_t,int16_t)>
|
CNSocket* sock = nullptr;
|
||||||
void nanoPower(CNSocket *sock, std::vector<int> targetData,
|
Player* plr = nullptr;
|
||||||
int16_t nanoID, int16_t skillID, int16_t duration, int16_t amount,
|
|
||||||
int16_t skillType, int32_t bitFlag, int16_t timeBuffID) {
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
|
||||||
|
|
||||||
if (skillType == EST_RETROROCKET_SELF || skillType == EST_RECALL) // rocket and self recall does not need any trailing structs
|
|
||||||
targetData[0] = 0;
|
|
||||||
|
|
||||||
size_t resplen;
|
|
||||||
// special case since leech is atypically encoded
|
|
||||||
if (skillType == EST_BLOODSUCKING)
|
|
||||||
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + sizeof(sSkillResult_Heal_HP) + sizeof(sSkillResult_Damage);
|
|
||||||
else
|
|
||||||
resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + targetData[0] * sizeof(sPAYLOAD);
|
|
||||||
|
|
||||||
// validate response packet
|
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), targetData[0], sizeof(sPAYLOAD))) {
|
|
||||||
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size" << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
|
||||||
memset(respbuf, 0, resplen);
|
|
||||||
|
|
||||||
sP_FE2CL_NANO_SKILL_USE_SUCC *resp = (sP_FE2CL_NANO_SKILL_USE_SUCC*)respbuf;
|
|
||||||
sPAYLOAD *respdata = (sPAYLOAD*)(respbuf+sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC));
|
|
||||||
|
|
||||||
resp->iPC_ID = plr->iID;
|
|
||||||
resp->iSkillID = skillID;
|
|
||||||
resp->iNanoID = nanoID;
|
|
||||||
resp->iNanoStamina = plr->Nanos[plr->activeNano].iStamina;
|
|
||||||
resp->eST = skillType;
|
|
||||||
resp->iTargetCnt = targetData[0];
|
|
||||||
|
|
||||||
if (SkillTable[skillID].drainType == 2) {
|
|
||||||
if (SkillTable[skillID].targetType >= 2)
|
|
||||||
plr->iSelfConditionBitFlag |= bitFlag;
|
|
||||||
if (SkillTable[skillID].targetType == 3)
|
|
||||||
plr->iGroupConditionBitFlag |= bitFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < targetData[0]; i++)
|
|
||||||
if (!work(sock, respdata, i, targetData[i+1], bitFlag, timeBuffID, duration, amount))
|
|
||||||
return;
|
|
||||||
|
|
||||||
sock->sendPacket((void*)&respbuf, P_FE2CL_NANO_SKILL_USE_SUCC, resplen);
|
|
||||||
assert(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) == sizeof(sP_FE2CL_NANO_SKILL_USE));
|
|
||||||
if (skillType == EST_RECALL_GROUP) { // in the case of group recall, nobody but group members need the packet
|
|
||||||
for (int i = 0; i < targetData[0]; i++) {
|
|
||||||
CNSocket *sock2 = PlayerManager::getSockFromID(targetData[i+1]);
|
|
||||||
sock2->sendPacket((void*)&respbuf, P_FE2CL_NANO_SKILL_USE, resplen);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
PlayerManager::sendToViewable(sock, (void*)&respbuf, P_FE2CL_NANO_SKILL_USE, resplen);
|
|
||||||
|
|
||||||
// Warping on recall
|
|
||||||
if (skillType == EST_RECALL || skillType == EST_RECALL_GROUP) {
|
|
||||||
if ((int32_t)plr->instanceID == plr->recallInstance)
|
|
||||||
PlayerManager::sendPlayerTo(sock, plr->recallX, plr->recallY, plr->recallZ, plr->recallInstance);
|
|
||||||
else {
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_WARP_USE_RECALL_FAIL, response)
|
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_WARP_USE_RECALL_FAIL, sizeof(sP_FE2CL_REP_WARP_USE_RECALL_FAIL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// nano power dispatch table
|
|
||||||
std::vector<NanoPower> NanoPowers = {
|
|
||||||
NanoPower(EST_STUN, CSB_BIT_STUN, ECSB_STUN, nanoPower<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
|
||||||
NanoPower(EST_HEAL_HP, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Heal_HP, doHeal>),
|
|
||||||
NanoPower(EST_BOUNDINGBALL, CSB_BIT_BOUNDINGBALL, ECSB_BOUNDINGBALL, nanoPower<sSkillResult_Buff, doDebuff>),
|
|
||||||
NanoPower(EST_SNARE, CSB_BIT_DN_MOVE_SPEED, ECSB_DN_MOVE_SPEED, nanoPower<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
|
||||||
NanoPower(EST_DAMAGE, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Damage, doDamage>),
|
|
||||||
NanoPower(EST_BLOODSUCKING, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Heal_HP, doLeech>),
|
|
||||||
NanoPower(EST_SLEEP, CSB_BIT_MEZ, ECSB_MEZ, nanoPower<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
|
||||||
NanoPower(EST_REWARDBLOB, CSB_BIT_REWARD_BLOB, ECSB_REWARD_BLOB, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_RUN, CSB_BIT_UP_MOVE_SPEED, ECSB_UP_MOVE_SPEED, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_REWARDCASH, CSB_BIT_REWARD_CASH, ECSB_REWARD_CASH, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_PROTECTBATTERY, CSB_BIT_PROTECT_BATTERY, ECSB_PROTECT_BATTERY, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_MINIMAPENEMY, CSB_BIT_MINIMAP_ENEMY, ECSB_MINIMAP_ENEMY, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_PROTECTINFECTION, CSB_BIT_PROTECT_INFECTION, ECSB_PROTECT_INFECTION, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_JUMP, CSB_BIT_UP_JUMP_HEIGHT, ECSB_UP_JUMP_HEIGHT, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_FREEDOM, CSB_BIT_FREEDOM, ECSB_FREEDOM, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_PHOENIX, CSB_BIT_PHOENIX, ECSB_PHOENIX, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_STEALTH, CSB_BIT_UP_STEALTH, ECSB_UP_STEALTH, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_MINIMAPTRESURE, CSB_BIT_MINIMAP_TRESURE, ECSB_MINIMAP_TRESURE, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_RECALL, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Move, doMove>),
|
|
||||||
NanoPower(EST_RECALL_GROUP, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Move, doMove>),
|
|
||||||
NanoPower(EST_RETROROCKET_SELF, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_PHOENIX_GROUP, CSB_BIT_NONE, ECSB_NONE, nanoPower<sSkillResult_Resurrect, doResurrect>),
|
|
||||||
NanoPower(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT1, ECSB_STIMPAKSLOT1, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT2, ECSB_STIMPAKSLOT2, nanoPower<sSkillResult_Buff, doBuff>),
|
|
||||||
NanoPower(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT3, ECSB_STIMPAKSLOT3, nanoPower<sSkillResult_Buff, doBuff>)
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Mob Powers
|
|
||||||
namespace Combat {
|
|
||||||
bool doDamageNDebuff(Mob *mob, sSkillResult_Damage_N_Debuff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
|
||||||
CNSocket *sock = nullptr;
|
|
||||||
Player *plr = nullptr;
|
|
||||||
|
|
||||||
for (auto& pair : PlayerManager::players) {
|
for (auto& pair : PlayerManager::players) {
|
||||||
if (pair.second->iID == targetID) {
|
if (pair.second->iID == targetID) {
|
||||||
@ -534,7 +431,7 @@ bool doDamageNDebuff(Mob *mob, sSkillResult_Damage_N_Debuff *respdata, int i, in
|
|||||||
if (plr->iConditionBitFlag & CSB_BIT_FREEDOM)
|
if (plr->iConditionBitFlag & CSB_BIT_FREEDOM)
|
||||||
respdata[i].bProtected = 1;
|
respdata[i].bProtected = 1;
|
||||||
else {
|
else {
|
||||||
if (!(plr->iConditionBitFlag & bitFlag)) {
|
if (!(plr->iConditionBitFlag & bitFlag)) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt);
|
||||||
pkt.eCSTB = timeBuffID; // eCharStatusTimeBuffID
|
pkt.eCSTB = timeBuffID; // eCharStatusTimeBuffID
|
||||||
pkt.eTBU = 1; // eTimeBuffUpdate
|
pkt.eTBU = 1; // eTimeBuffUpdate
|
||||||
@ -564,7 +461,7 @@ bool doDamageNDebuff(Mob *mob, sSkillResult_Damage_N_Debuff *respdata, int i, in
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doHeal(Mob *mob, sSkillResult_Heal_HP *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doHeal(Mob* mob, sSkillResult_Heal_HP* respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
|
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
|
||||||
std::cout << "[WARN] doHeal: NPC ID not found" << std::endl;
|
std::cout << "[WARN] doHeal: NPC ID not found" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -591,7 +488,7 @@ bool doHeal(Mob *mob, sSkillResult_Heal_HP *respdata, int i, int32_t targetID, i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doReturnHeal(Mob *mob, sSkillResult_Heal_HP *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doReturnHeal(Mob* mob, sSkillResult_Heal_HP* respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
int healedAmount = amount * mob->maxHealth / 1000;
|
int healedAmount = amount * mob->maxHealth / 1000;
|
||||||
mob->appearanceData.iHP += healedAmount;
|
mob->appearanceData.iHP += healedAmount;
|
||||||
if (mob->appearanceData.iHP > mob->maxHealth)
|
if (mob->appearanceData.iHP > mob->maxHealth)
|
||||||
@ -605,8 +502,8 @@ bool doReturnHeal(Mob *mob, sSkillResult_Heal_HP *respdata, int i, int32_t targe
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doDamage(Mob *mob, sSkillResult_Damage *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doDamage(Mob* mob, sSkillResult_Damage* respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
Player *plr = nullptr;
|
Player* plr = nullptr;
|
||||||
|
|
||||||
for (auto& pair : PlayerManager::players) {
|
for (auto& pair : PlayerManager::players) {
|
||||||
if (pair.second->iID == targetID) {
|
if (pair.second->iID == targetID) {
|
||||||
@ -644,14 +541,14 @@ bool doDamage(Mob *mob, sSkillResult_Damage *respdata, int i, int32_t targetID,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doLeech(Mob *mob, sSkillResult_Heal_HP *healdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doLeech(Mob* mob, sSkillResult_Heal_HP* healdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
// this sanity check is VERY important
|
// this sanity check is VERY important
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
std::cout << "[WARN] Mob attempted to leech more than one player!" << std::endl;
|
std::cout << "[WARN] Mob attempted to leech more than one player!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *plr = nullptr;
|
Player* plr = nullptr;
|
||||||
|
|
||||||
for (auto& pair : PlayerManager::players) {
|
for (auto& pair : PlayerManager::players) {
|
||||||
if (pair.second->iID == targetID) {
|
if (pair.second->iID == targetID) {
|
||||||
@ -666,7 +563,7 @@ bool doLeech(Mob *mob, sSkillResult_Heal_HP *healdata, int i, int32_t targetID,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sSkillResult_Damage *damagedata = (sSkillResult_Damage*)(((uint8_t*)healdata) + sizeof(sSkillResult_Heal_HP));
|
sSkillResult_Damage* damagedata = (sSkillResult_Damage*)(((uint8_t*)healdata) + sizeof(sSkillResult_Heal_HP));
|
||||||
|
|
||||||
int healedAmount = amount * PC_MAXHEALTH(plr->level) / 1000;
|
int healedAmount = amount * PC_MAXHEALTH(plr->level) / 1000;
|
||||||
|
|
||||||
@ -702,8 +599,8 @@ bool doLeech(Mob *mob, sSkillResult_Heal_HP *healdata, int i, int32_t targetID,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doBatteryDrain(Mob *mob, sSkillResult_BatteryDrain *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doBatteryDrain(Mob* mob, sSkillResult_BatteryDrain* respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
Player *plr = nullptr;
|
Player* plr = nullptr;
|
||||||
|
|
||||||
for (auto& pair : PlayerManager::players) {
|
for (auto& pair : PlayerManager::players) {
|
||||||
if (pair.second->iID == targetID) {
|
if (pair.second->iID == targetID) {
|
||||||
@ -725,7 +622,8 @@ bool doBatteryDrain(Mob *mob, sSkillResult_BatteryDrain *respdata, int i, int32_
|
|||||||
respdata[i].bProtected = 1;
|
respdata[i].bProtected = 1;
|
||||||
respdata[i].iDrainW = 0;
|
respdata[i].iDrainW = 0;
|
||||||
respdata[i].iDrainN = 0;
|
respdata[i].iDrainN = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
respdata[i].bProtected = 0;
|
respdata[i].bProtected = 0;
|
||||||
respdata[i].iDrainW = amount * (18 + (int)mob->data["m_iNpcLevel"]) / 36;
|
respdata[i].iDrainW = amount * (18 + (int)mob->data["m_iNpcLevel"]) / 36;
|
||||||
respdata[i].iDrainN = amount * (18 + (int)mob->data["m_iNpcLevel"]) / 36;
|
respdata[i].iDrainN = amount * (18 + (int)mob->data["m_iNpcLevel"]) / 36;
|
||||||
@ -739,7 +637,7 @@ bool doBatteryDrain(Mob *mob, sSkillResult_BatteryDrain *respdata, int i, int32_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doBuff(Mob *mob, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doBuff(Mob* mob, sSkillResult_Buff* respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
respdata[i].eCT = 4;
|
respdata[i].eCT = 4;
|
||||||
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
respdata[i].iID = mob->appearanceData.iNPC_ID;
|
||||||
mob->appearanceData.iConditionBitFlag |= bitFlag;
|
mob->appearanceData.iConditionBitFlag |= bitFlag;
|
||||||
@ -749,10 +647,10 @@ bool doBuff(Mob *mob, sSkillResult_Buff *respdata, int i, int32_t targetID, int3
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class sPAYLOAD,
|
template<class sPAYLOAD,
|
||||||
bool (*work)(Mob*,sPAYLOAD*,int,int32_t,int32_t,int16_t,int16_t,int16_t)>
|
bool (*work)(EntityRef, sPAYLOAD*, int, int32_t, int32_t, int16_t, int16_t, int16_t)>
|
||||||
void mobPower(Mob *mob, std::vector<int> targetData,
|
void power(EntityRef ref, std::vector<int> targetData,
|
||||||
int16_t skillID, int16_t duration, int16_t amount,
|
int16_t nanoID, int16_t skillID, int16_t duration, int16_t amount,
|
||||||
int16_t skillType, int32_t bitFlag, int16_t timeBuffID) {
|
int16_t skillType, int32_t bitFlag, int16_t timeBuffID) {
|
||||||
size_t resplen;
|
size_t resplen;
|
||||||
// special case since leech is atypically encoded
|
// special case since leech is atypically encoded
|
||||||
if (skillType == EST_BLOODSUCKING)
|
if (skillType == EST_BLOODSUCKING)
|
||||||
@ -769,8 +667,8 @@ void mobPower(Mob *mob, std::vector<int> targetData,
|
|||||||
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
sP_FE2CL_NPC_SKILL_HIT *resp = (sP_FE2CL_NPC_SKILL_HIT*)respbuf;
|
sP_FE2CL_NPC_SKILL_HIT* resp = (sP_FE2CL_NPC_SKILL_HIT*)respbuf;
|
||||||
sPAYLOAD *respdata = (sPAYLOAD*)(respbuf+sizeof(sP_FE2CL_NPC_SKILL_HIT));
|
sPAYLOAD* respdata = (sPAYLOAD*)(respbuf + sizeof(sP_FE2CL_NPC_SKILL_HIT));
|
||||||
|
|
||||||
resp->iNPC_ID = mob->appearanceData.iNPC_ID;
|
resp->iNPC_ID = mob->appearanceData.iNPC_ID;
|
||||||
resp->iSkillID = skillID;
|
resp->iSkillID = skillID;
|
||||||
@ -781,24 +679,49 @@ void mobPower(Mob *mob, std::vector<int> targetData,
|
|||||||
resp->iTargetCnt = targetData[0];
|
resp->iTargetCnt = targetData[0];
|
||||||
|
|
||||||
for (int i = 0; i < targetData[0]; i++)
|
for (int i = 0; i < targetData[0]; i++)
|
||||||
if (!work(mob, respdata, i, targetData[i+1], bitFlag, timeBuffID, duration, amount))
|
if (!work(mob, respdata, i, targetData[i + 1], bitFlag, timeBuffID, duration, amount))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NPCManager::sendToViewable(mob, (void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
NPCManager::sendToViewable(mob, (void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// nano power dispatch table
|
// nano power dispatch table
|
||||||
std::vector<MobPower> MobPowers = {
|
std::vector<Power> Powers = {};/*
|
||||||
MobPower(EST_STUN, CSB_BIT_STUN, ECSB_STUN, mobPower<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
Power(EST_STUN, CSB_BIT_STUN, ECSB_STUN, power<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
||||||
MobPower(EST_HEAL_HP, CSB_BIT_NONE, ECSB_NONE, mobPower<sSkillResult_Heal_HP, doHeal>),
|
Power(EST_HEAL_HP, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Heal_HP, doHeal>),
|
||||||
MobPower(EST_RETURNHOMEHEAL, CSB_BIT_NONE, ECSB_NONE, mobPower<sSkillResult_Heal_HP, doReturnHeal>),
|
Power(EST_BOUNDINGBALL, CSB_BIT_BOUNDINGBALL, ECSB_BOUNDINGBALL, power<sSkillResult_Buff, doDebuff>),
|
||||||
MobPower(EST_SNARE, CSB_BIT_DN_MOVE_SPEED, ECSB_DN_MOVE_SPEED, mobPower<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
Power(EST_SNARE, CSB_BIT_DN_MOVE_SPEED, ECSB_DN_MOVE_SPEED, power<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
||||||
MobPower(EST_DAMAGE, CSB_BIT_NONE, ECSB_NONE, mobPower<sSkillResult_Damage, doDamage>),
|
Power(EST_DAMAGE, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Damage, doDamage>),
|
||||||
MobPower(EST_BATTERYDRAIN, CSB_BIT_NONE, ECSB_NONE, mobPower<sSkillResult_BatteryDrain, doBatteryDrain>),
|
Power(EST_BLOODSUCKING, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Heal_HP, doLeech>),
|
||||||
MobPower(EST_SLEEP, CSB_BIT_MEZ, ECSB_MEZ, mobPower<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
Power(EST_SLEEP, CSB_BIT_MEZ, ECSB_MEZ, power<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
||||||
MobPower(EST_BLOODSUCKING, CSB_BIT_NONE, ECSB_NONE, mobPower<sSkillResult_Heal_HP, doLeech>),
|
Power(EST_REWARDBLOB, CSB_BIT_REWARD_BLOB, ECSB_REWARD_BLOB, power<sSkillResult_Buff, doBuff>),
|
||||||
MobPower(EST_FREEDOM, CSB_BIT_FREEDOM, ECSB_FREEDOM, mobPower<sSkillResult_Buff, doBuff>)
|
Power(EST_RUN, CSB_BIT_UP_MOVE_SPEED, ECSB_UP_MOVE_SPEED, power<sSkillResult_Buff, doBuff>),
|
||||||
};
|
Power(EST_REWARDCASH, CSB_BIT_REWARD_CASH, ECSB_REWARD_CASH, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_PROTECTBATTERY, CSB_BIT_PROTECT_BATTERY, ECSB_PROTECT_BATTERY, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_MINIMAPENEMY, CSB_BIT_MINIMAP_ENEMY, ECSB_MINIMAP_ENEMY, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_PROTECTINFECTION, CSB_BIT_PROTECT_INFECTION, ECSB_PROTECT_INFECTION, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_JUMP, CSB_BIT_UP_JUMP_HEIGHT, ECSB_UP_JUMP_HEIGHT, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_FREEDOM, CSB_BIT_FREEDOM, ECSB_FREEDOM, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_PHOENIX, CSB_BIT_PHOENIX, ECSB_PHOENIX, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_STEALTH, CSB_BIT_UP_STEALTH, ECSB_UP_STEALTH, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_MINIMAPTRESURE, CSB_BIT_MINIMAP_TRESURE, ECSB_MINIMAP_TRESURE, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_RECALL, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Move, doMove>),
|
||||||
|
Power(EST_RECALL_GROUP, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Move, doMove>),
|
||||||
|
Power(EST_RETROROCKET_SELF, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_PHOENIX_GROUP, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Resurrect, doResurrect>),
|
||||||
|
Power(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT1, ECSB_STIMPAKSLOT1, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT2, ECSB_STIMPAKSLOT2, power<sSkillResult_Buff, doBuff>),
|
||||||
|
Power(EST_NANOSTIMPAK, CSB_BIT_STIMPAKSLOT3, ECSB_STIMPAKSLOT3, power<sSkillResult_Buff, doBuff>),
|
||||||
|
//
|
||||||
|
Power(EST_STUN, CSB_BIT_STUN, ECSB_STUN, power<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
||||||
|
Power(EST_HEAL_HP, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Heal_HP, doHeal>),
|
||||||
|
Power(EST_RETURNHOMEHEAL, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Heal_HP, doReturnHeal>),
|
||||||
|
Power(EST_SNARE, CSB_BIT_DN_MOVE_SPEED, ECSB_DN_MOVE_SPEED, power<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
||||||
|
Power(EST_DAMAGE, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Damage, doDamage>),
|
||||||
|
Power(EST_BATTERYDRAIN, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_BatteryDrain, doBatteryDrain>),
|
||||||
|
Power(EST_SLEEP, CSB_BIT_MEZ, ECSB_MEZ, power<sSkillResult_Damage_N_Debuff, doDamageNDebuff>),
|
||||||
|
Power(EST_BLOODSUCKING, CSB_BIT_NONE, ECSB_NONE, power<sSkillResult_Heal_HP, doLeech>),
|
||||||
|
Power(EST_FREEDOM, CSB_BIT_FREEDOM, ECSB_FREEDOM, power<sSkillResult_Buff, doBuff>)
|
||||||
|
};*/
|
||||||
|
|
||||||
}; // namespace
|
}; // namespace
|
||||||
#pragma endregion
|
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
typedef void (*PowerHandler)(CNSocket*, std::vector<int>, int16_t, int16_t, int16_t, int16_t, int16_t, int32_t, int16_t);
|
typedef void (*PowerHandler)(CNSocket*, std::vector<int>, int16_t, int16_t, int16_t, int16_t, int16_t, int32_t, int16_t);
|
||||||
|
|
||||||
struct NanoPower {
|
struct Power {
|
||||||
int16_t skillType;
|
int16_t skillType;
|
||||||
int32_t bitFlag;
|
int32_t bitFlag;
|
||||||
int16_t timeBuffID;
|
int16_t timeBuffID;
|
||||||
PowerHandler handler;
|
PowerHandler handler;
|
||||||
|
|
||||||
NanoPower(int16_t s, int32_t b, int16_t t, PowerHandler h) : skillType(s), bitFlag(b), timeBuffID(t), handler(h) {}
|
Power(int16_t s, int32_t b, int16_t t, PowerHandler h) : skillType(s), bitFlag(b), timeBuffID(t), handler(h) {}
|
||||||
|
|
||||||
void handle(CNSocket *sock, std::vector<int> targetData, int16_t nanoID, int16_t skillID, int16_t duration, int16_t amount) {
|
void handle(CNSocket *sock, std::vector<int> targetData, int16_t nanoID, int16_t skillID, int16_t duration, int16_t amount) {
|
||||||
if (handler == nullptr)
|
if (handler == nullptr)
|
||||||
@ -21,24 +21,6 @@ struct NanoPower {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*MobPowerHandler)(Mob*, std::vector<int>, int16_t, int16_t, int16_t, int16_t, int32_t, int16_t);
|
|
||||||
|
|
||||||
struct MobPower {
|
|
||||||
int16_t skillType;
|
|
||||||
int32_t bitFlag;
|
|
||||||
int16_t timeBuffID;
|
|
||||||
MobPowerHandler handler;
|
|
||||||
|
|
||||||
MobPower(int16_t s, int32_t b, int16_t t, MobPowerHandler h) : skillType(s), bitFlag(b), timeBuffID(t), handler(h) {}
|
|
||||||
|
|
||||||
void handle(Mob *mob, std::vector<int> targetData, int16_t skillID, int16_t duration, int16_t amount) {
|
|
||||||
if (handler == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
handler(mob, targetData, skillID, duration, amount, skillType, bitFlag, timeBuffID);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SkillData {
|
struct SkillData {
|
||||||
int skillType;
|
int skillType;
|
||||||
int targetType;
|
int targetType;
|
||||||
@ -49,16 +31,12 @@ struct SkillData {
|
|||||||
int powerIntensity[4];
|
int powerIntensity[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Nanos {
|
namespace Abilities {
|
||||||
extern std::vector<NanoPower> NanoPowers;
|
extern std::vector<Power> Powers;
|
||||||
extern std::map<int32_t, SkillData> SkillTable;
|
extern std::map<int32_t, SkillData> SkillTable;
|
||||||
|
|
||||||
void nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower);
|
void removeBuff(CNSocket* sock, std::vector<int> targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower);
|
||||||
int applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags);
|
int applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags);
|
||||||
|
|
||||||
std::vector<int> findTargets(Player* plr, int skillID, CNPacketData* data = nullptr);
|
std::vector<int> findTargets(Player* plr, int skillID, CNPacketData* data = nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Combat {
|
|
||||||
extern std::vector<MobPower> MobPowers;
|
|
||||||
}
|
|
||||||
|
10
src/Eggs.cpp
10
src/Eggs.cpp
@ -19,7 +19,7 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
|||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
int bitFlag = Groups::getGroupFlags(otherPlr);
|
int bitFlag = Groups::getGroupFlags(otherPlr);
|
||||||
int CBFlag = Nanos::applyBuff(sock, skillId, 1, 3, bitFlag);
|
int CBFlag = Abilities::applyBuff(sock, skillId, 1, 3, bitFlag);
|
||||||
|
|
||||||
size_t resplen;
|
size_t resplen;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
|||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
skill->eCT = 1;
|
skill->eCT = 1;
|
||||||
skill->iID = plr->iID;
|
skill->iID = plr->iID;
|
||||||
skill->iDamage = PC_MAXHEALTH(plr->level) * Nanos::SkillTable[skillId].powerIntensity[0] / 1000;
|
skill->iDamage = PC_MAXHEALTH(plr->level) * Abilities::SkillTable[skillId].powerIntensity[0] / 1000;
|
||||||
plr->HP -= skill->iDamage;
|
plr->HP -= skill->iDamage;
|
||||||
if (plr->HP < 0)
|
if (plr->HP < 0)
|
||||||
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);
|
memset(respbuf, 0, resplen);
|
||||||
skill->eCT = 1;
|
skill->eCT = 1;
|
||||||
skill->iID = plr->iID;
|
skill->iID = plr->iID;
|
||||||
skill->iHealHP = PC_MAXHEALTH(plr->level) * Nanos::SkillTable[skillId].powerIntensity[0] / 1000;
|
skill->iHealHP = PC_MAXHEALTH(plr->level) * Abilities::SkillTable[skillId].powerIntensity[0] / 1000;
|
||||||
plr->HP += skill->iHealHP;
|
plr->HP += skill->iHealHP;
|
||||||
if (plr->HP > PC_MAXHEALTH(plr->level))
|
if (plr->HP > PC_MAXHEALTH(plr->level))
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
@ -66,7 +66,7 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
|||||||
|
|
||||||
skillUse->iNPC_ID = eggId;
|
skillUse->iNPC_ID = eggId;
|
||||||
skillUse->iSkillID = skillId;
|
skillUse->iSkillID = skillId;
|
||||||
skillUse->eST = Nanos::SkillTable[skillId].skillType;
|
skillUse->eST = Abilities::SkillTable[skillId].skillType;
|
||||||
skillUse->iTargetCnt = 1;
|
skillUse->iTargetCnt = 1;
|
||||||
|
|
||||||
sock->sendPacket((void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
sock->sendPacket((void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||||
@ -100,7 +100,7 @@ static void eggStep(CNServer* serv, time_t currTime) {
|
|||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
int groupFlags = Groups::getGroupFlags(otherPlr);
|
int groupFlags = Groups::getGroupFlags(otherPlr);
|
||||||
for (auto& pwr : Nanos::NanoPowers) {
|
for (auto& pwr : Abilities::Powers) {
|
||||||
if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp);
|
||||||
resp.eCSTB = pwr.timeBuffID;
|
resp.eCSTB = pwr.timeBuffID;
|
||||||
|
@ -135,10 +135,10 @@ static void joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
// client doesnt read nano data here
|
// client doesnt read nano data here
|
||||||
|
|
||||||
if (varPlr != plr) { // apply the new member's buffs to the group and the group's buffs to the new member
|
if (varPlr != plr) { // apply the new member's buffs to the group and the group's buffs to the new member
|
||||||
if (Nanos::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
if (Abilities::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||||
Nanos::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 1, 1, bitFlag);
|
Abilities::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 1, 1, bitFlag);
|
||||||
if (Nanos::SkillTable[plr->Nanos[plr->activeNano].iSkillID].targetType == 3)
|
if (Abilities::SkillTable[plr->Nanos[plr->activeNano].iSkillID].targetType == 3)
|
||||||
Nanos::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 1, 1, bitFlag);
|
Abilities::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 1, 1, bitFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ static void groupUnbuff(Player* plr) {
|
|||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
||||||
|
|
||||||
Nanos::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
Abilities::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,10 +295,10 @@ void Groups::groupKickPlayer(Player* plr) {
|
|||||||
moveDown = 1;
|
moveDown = 1;
|
||||||
otherPlr->groupIDs[i] = 0;
|
otherPlr->groupIDs[i] = 0;
|
||||||
} else { // remove the leaving member's buffs from the group and remove the group buffs from the leaving member.
|
} else { // remove the leaving member's buffs from the group and remove the group buffs from the leaving member.
|
||||||
if (Nanos::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
if (Abilities::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||||
Nanos::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 2, 1, 0);
|
Abilities::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 2, 1, 0);
|
||||||
if (Nanos::SkillTable[plr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
if (Abilities::SkillTable[plr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||||
Nanos::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 2, 1, bitFlag);
|
Abilities::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 2, 1, bitFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ static void itemUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
player->Inven[resp->iSlotNum] = resp->RemainItem;
|
player->Inven[resp->iSlotNum] = resp->RemainItem;
|
||||||
|
|
||||||
std::pair<CNSocket*, int32_t> key = std::make_pair(sock, value1);
|
std::pair<CNSocket*, int32_t> key = std::make_pair(sock, value1);
|
||||||
time_t until = getTime() + (time_t)Nanos::SkillTable[144].durationTime[0] * 100;
|
time_t until = getTime() + (time_t)Abilities::SkillTable[144].durationTime[0] * 100;
|
||||||
Eggs::EggBuffs[key] = until;
|
Eggs::EggBuffs[key] = until;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ static void dealCorruption(Mob *mob, std::vector<int> targetData, int skillID, i
|
|||||||
int style2 = Nanos::nanoStyle(plr->activeNano);
|
int style2 = Nanos::nanoStyle(plr->activeNano);
|
||||||
if (style2 == -1) { // no nano
|
if (style2 == -1) { // no nano
|
||||||
respdata[i].iHitFlag = 8;
|
respdata[i].iHitFlag = 8;
|
||||||
respdata[i].iDamage = Nanos::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
respdata[i].iDamage = Abilities::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
||||||
} else if (style == style2) {
|
} else if (style == style2) {
|
||||||
respdata[i].iHitFlag = 8; // tie
|
respdata[i].iHitFlag = 8; // tie
|
||||||
respdata[i].iDamage = 0;
|
respdata[i].iDamage = 0;
|
||||||
@ -248,12 +248,12 @@ static void dealCorruption(Mob *mob, std::vector<int> targetData, int skillID, i
|
|||||||
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina = 150;
|
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina = 150;
|
||||||
// fire damage power disguised as a corruption attack back at the enemy
|
// fire damage power disguised as a corruption attack back at the enemy
|
||||||
std::vector<int> targetData2 = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
std::vector<int> targetData2 = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
||||||
for (auto& pwr : Nanos::NanoPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == EST_DAMAGE)
|
if (pwr.skillType == EST_DAMAGE)
|
||||||
pwr.handle(sock, targetData2, plr->activeNano, skillID, 0, 200);
|
pwr.handle(sock, targetData2, plr->activeNano, skillID, 0, 200);
|
||||||
} else {
|
} else {
|
||||||
respdata[i].iHitFlag = 16; // lose
|
respdata[i].iHitFlag = 16; // lose
|
||||||
respdata[i].iDamage = Nanos::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
respdata[i].iDamage = Abilities::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
||||||
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina -= 90;
|
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina -= 90;
|
||||||
if (plr->Nanos[plr->activeNano].iStamina < 0) {
|
if (plr->Nanos[plr->activeNano].iStamina < 0) {
|
||||||
respdata[i].bNanoDeactive = 1;
|
respdata[i].bNanoDeactive = 1;
|
||||||
@ -319,7 +319,7 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
|
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
|
||||||
if (distance < Nanos::SkillTable[skillID].effectArea) {
|
if (distance < Abilities::SkillTable[skillID].effectArea) {
|
||||||
targetData[0] += 1;
|
targetData[0] += 1;
|
||||||
targetData[targetData[0]] = plr->iID;
|
targetData[targetData[0]] = plr->iID;
|
||||||
if (targetData[0] > 3) // make sure not to have more than 4
|
if (targetData[0] > 3) // make sure not to have more than 4
|
||||||
@ -328,9 +328,9 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == Nanos::SkillTable[skillID].skillType)
|
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
|
||||||
pwr.handle(mob, targetData, skillID, Nanos::SkillTable[skillID].durationTime[0], Nanos::SkillTable[skillID].powerIntensity[0]);
|
pwr.handle(mob, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);
|
||||||
mob->skillStyle = -3; // eruption cooldown
|
mob->skillStyle = -3; // eruption cooldown
|
||||||
mob->nextAttack = currTime + 1000;
|
mob->nextAttack = currTime + 1000;
|
||||||
return;
|
return;
|
||||||
@ -349,11 +349,11 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
if (random < prob1) { // active skill hit
|
if (random < prob1) { // active skill hit
|
||||||
int skillID = (int)mob->data["m_iActiveSkill1"];
|
int skillID = (int)mob->data["m_iActiveSkill1"];
|
||||||
std::vector<int> targetData = {1, plr->iID, 0, 0, 0};
|
std::vector<int> targetData = {1, plr->iID, 0, 0, 0};
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == Nanos::SkillTable[skillID].skillType) {
|
if (pwr.skillType == Abilities::SkillTable[skillID].skillType) {
|
||||||
if (pwr.bitFlag != 0 && (plr->iConditionBitFlag & pwr.bitFlag))
|
if (pwr.bitFlag != 0 && (plr->iConditionBitFlag & pwr.bitFlag))
|
||||||
return; // prevent debuffing a player twice
|
return; // prevent debuffing a player twice
|
||||||
pwr.handle(mob, targetData, skillID, Nanos::SkillTable[skillID].durationTime[0], Nanos::SkillTable[skillID].powerIntensity[0]);
|
pwr.handle(mob, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);
|
||||||
}
|
}
|
||||||
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
||||||
return;
|
return;
|
||||||
@ -407,9 +407,9 @@ void MobAI::enterCombat(CNSocket *sock, Mob *mob) {
|
|||||||
|
|
||||||
int skillID = (int)mob->data["m_iPassiveBuff"]; // cast passive
|
int skillID = (int)mob->data["m_iPassiveBuff"]; // cast passive
|
||||||
std::vector<int> targetData = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
std::vector<int> targetData = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == Nanos::SkillTable[skillID].skillType)
|
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
|
||||||
pwr.handle(mob, targetData, skillID, Nanos::SkillTable[skillID].durationTime[0], Nanos::SkillTable[skillID].powerIntensity[0]);
|
pwr.handle(mob, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);
|
||||||
|
|
||||||
for (NPCEvent& event : NPCManager::NPCEvents) // trigger an ON_COMBAT
|
for (NPCEvent& event : NPCManager::NPCEvents) // trigger an ON_COMBAT
|
||||||
if (event.trigger == ON_COMBAT && event.npcType == mob->appearanceData.iNPCType)
|
if (event.trigger == ON_COMBAT && event.npcType == mob->appearanceData.iNPCType)
|
||||||
@ -773,9 +773,9 @@ static void retreatStep(Mob *mob, time_t currTime) {
|
|||||||
|
|
||||||
// cast a return home heal spell, this is the right way(tm)
|
// cast a return home heal spell, this is the right way(tm)
|
||||||
std::vector<int> targetData = {1, 0, 0, 0, 0};
|
std::vector<int> targetData = {1, 0, 0, 0, 0};
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == Nanos::SkillTable[110].skillType)
|
if (pwr.skillType == Abilities::SkillTable[110].skillType)
|
||||||
pwr.handle(mob, targetData, 110, Nanos::SkillTable[110].durationTime[0], Nanos::SkillTable[110].powerIntensity[0]);
|
pwr.handle(mob, targetData, 110, Abilities::SkillTable[110].durationTime[0], Abilities::SkillTable[110].powerIntensity[0]);
|
||||||
// clear outlying debuffs
|
// clear outlying debuffs
|
||||||
clearDebuff(mob);
|
clearDebuff(mob);
|
||||||
}
|
}
|
||||||
|
@ -86,12 +86,12 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
|||||||
int16_t skillID = plr->Nanos[plr->activeNano].iSkillID;
|
int16_t skillID = plr->Nanos[plr->activeNano].iSkillID;
|
||||||
|
|
||||||
// passive nano unbuffing
|
// passive nano unbuffing
|
||||||
if (SkillTable[skillID].drainType == 2) {
|
if (Abilities::SkillTable[skillID].drainType == 2) {
|
||||||
std::vector<int> targetData = findTargets(plr, skillID);
|
std::vector<int> targetData = Abilities::findTargets(plr, skillID);
|
||||||
|
|
||||||
for (auto& pwr : NanoPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == SkillTable[skillID].skillType)
|
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
|
||||||
nanoUnbuff(sock, targetData, pwr.bitFlag, pwr.timeBuffID, 0,(SkillTable[skillID].targetType == 3));
|
Abilities::removeBuff(sock, targetData, pwr.bitFlag, pwr.timeBuffID, 0,(Abilities::SkillTable[skillID].targetType == 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nanoID >= NANO_COUNT || nanoID < 0)
|
if (nanoID >= NANO_COUNT || nanoID < 0)
|
||||||
@ -101,19 +101,19 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
|||||||
skillID = plr->Nanos[nanoID].iSkillID;
|
skillID = plr->Nanos[nanoID].iSkillID;
|
||||||
|
|
||||||
// passive nano buffing
|
// passive nano buffing
|
||||||
if (SkillTable[skillID].drainType == 2) {
|
if (Abilities::SkillTable[skillID].drainType == 2) {
|
||||||
std::vector<int> targetData = findTargets(plr, skillID);
|
std::vector<int> targetData = Abilities::findTargets(plr, skillID);
|
||||||
|
|
||||||
int boost = 0;
|
int boost = 0;
|
||||||
if (getNanoBoost(plr))
|
if (getNanoBoost(plr))
|
||||||
boost = 1;
|
boost = 1;
|
||||||
|
|
||||||
for (auto& pwr : NanoPowers) {
|
for (auto& pwr : Abilities::Powers) {
|
||||||
if (pwr.skillType == SkillTable[skillID].skillType) {
|
if (pwr.skillType == Abilities::SkillTable[skillID].skillType) {
|
||||||
resp.eCSTB___Add = 1; // the part that makes nano go ZOOMAZOOM
|
resp.eCSTB___Add = 1; // the part that makes nano go ZOOMAZOOM
|
||||||
plr->nanoDrainRate = SkillTable[skillID].batteryUse[boost*3];
|
plr->nanoDrainRate = Abilities::SkillTable[skillID].batteryUse[boost*3];
|
||||||
|
|
||||||
pwr.handle(sock, targetData, nanoID, skillID, 0, SkillTable[skillID].powerIntensity[boost]);
|
pwr.handle(sock, targetData, nanoID, skillID, 0, Abilities::SkillTable[skillID].powerIntensity[boost]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,19 +296,19 @@ static void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
std::cout << PlayerManager::getPlayerName(plr) << " requested to summon nano skill " << std::endl;
|
std::cout << PlayerManager::getPlayerName(plr) << " requested to summon nano skill " << std::endl;
|
||||||
)
|
)
|
||||||
|
|
||||||
std::vector<int> targetData = findTargets(plr, skillID, data);
|
std::vector<int> targetData = Abilities::findTargets(plr, skillID, data);
|
||||||
|
|
||||||
int boost = 0;
|
int boost = 0;
|
||||||
if (getNanoBoost(plr))
|
if (getNanoBoost(plr))
|
||||||
boost = 1;
|
boost = 1;
|
||||||
|
|
||||||
plr->Nanos[plr->activeNano].iStamina -= SkillTable[skillID].batteryUse[boost*3];
|
plr->Nanos[plr->activeNano].iStamina -= Abilities::SkillTable[skillID].batteryUse[boost*3];
|
||||||
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
|
|
||||||
for (auto& pwr : NanoPowers)
|
for (auto& pwr : Abilities::Powers)
|
||||||
if (pwr.skillType == SkillTable[skillID].skillType)
|
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
|
||||||
pwr.handle(sock, targetData, nanoID, skillID, SkillTable[skillID].durationTime[boost], SkillTable[skillID].powerIntensity[boost]);
|
pwr.handle(sock, targetData, nanoID, skillID, Abilities::SkillTable[skillID].durationTime[boost], Abilities::SkillTable[skillID].powerIntensity[boost]);
|
||||||
|
|
||||||
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
if (plr->Nanos[plr->activeNano].iStamina < 0)
|
||||||
summonNano(sock, -1);
|
summonNano(sock, -1);
|
||||||
|
@ -410,7 +410,7 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
// nano revive
|
// nano revive
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
plr->HP = PC_MAXHEALTH(plr->level) / 2;
|
plr->HP = PC_MAXHEALTH(plr->level) / 2;
|
||||||
Nanos::applyBuff(sock, plr->Nanos[plr->activeNano].iSkillID, 2, 1, 0);
|
Abilities::applyBuff(sock, plr->Nanos[plr->activeNano].iSkillID, 2, 1, 0);
|
||||||
} else if (reviveData->iRegenType == 4) {
|
} else if (reviveData->iRegenType == 4) {
|
||||||
// revived by group member's nano
|
// revived by group member's nano
|
||||||
plr->HP = PC_MAXHEALTH(plr->level) / 2;
|
plr->HP = PC_MAXHEALTH(plr->level) / 2;
|
||||||
|
@ -239,10 +239,10 @@ static void loadXDT(json& xdtData) {
|
|||||||
skillData.durationTime[i] = skills["m_iDurationTime"][i];
|
skillData.durationTime[i] = skills["m_iDurationTime"][i];
|
||||||
skillData.powerIntensity[i] = skills["m_iValueA"][i];
|
skillData.powerIntensity[i] = skills["m_iValueA"][i];
|
||||||
}
|
}
|
||||||
Nanos::SkillTable[skills["m_iSkillNumber"]] = skillData;
|
Abilities::SkillTable[skills["m_iSkillNumber"]] = skillData;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << Nanos::SkillTable.size() << " nano skills" << std::endl;
|
std::cout << "[INFO] Loaded " << Abilities::SkillTable.size() << " nano skills" << std::endl;
|
||||||
|
|
||||||
// load EP data
|
// load EP data
|
||||||
json instances = xdtData["m_pInstanceTable"]["m_pInstanceData"];
|
json instances = xdtData["m_pInstanceTable"]["m_pInstanceData"];
|
||||||
|
Loading…
Reference in New Issue
Block a user