mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 11:50:04 +00:00
Initial tabledata implementation
This commit is contained in:
parent
75d33aff3e
commit
2acb90f2d2
@ -47,6 +47,7 @@ std::set<int> TreasureFinderPowers = {26, 40, 74};
|
||||
|
||||
std::map<int32_t, NanoData> NanoManager::NanoTable;
|
||||
std::map<int32_t, NanoTuning> NanoManager::NanoTunings;
|
||||
std::map<int32_t, SkillData> NanoManager::SkillTable;
|
||||
|
||||
void NanoManager::init() {
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler);
|
||||
@ -60,6 +61,71 @@ void NanoManager::init() {
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_CHARGE_NANO_STAMINA, nanoPotionHandler);
|
||||
}
|
||||
|
||||
void NanoManager::doNanoSkill(CNSocket* sock, int eSkillType, int eCT, int target[]) {
|
||||
size_t resplen = sizeof(sP_FE2CL_NANO_SKILL_USE);
|
||||
uint8_t respbuf[4096];
|
||||
|
||||
if (eSkillType == 1) { //damage
|
||||
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE), target.size(), sizeof(sSkillResult_Damage))) {
|
||||
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size\n";
|
||||
return;
|
||||
}
|
||||
|
||||
resplen += target.size() * sizeof(sSkillResult_Damage);
|
||||
|
||||
|
||||
} else if
|
||||
|
||||
}
|
||||
|
||||
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE), pkt->iTargetCnt, sizeof(sSkillResult_Damage_N_Debuff))) {
|
||||
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE packet size\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
memset(respbuf, 0, resplen);
|
||||
|
||||
sP_FE2CL_NANO_SKILL_USE *resp = (sP_FE2CL_NANO_SKILL_USE*)respbuf;
|
||||
sSkillResult_Damage_N_Debuff *respdata = (sSkillResult_Damage_N_Debuff*)(respbuf+sizeof(sP_FE2CL_NANO_SKILL_USE));
|
||||
|
||||
Player *plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
resp->iPC_ID = plr->iID;
|
||||
resp->iSkillID = skillId;
|
||||
resp->iNanoID = nanoId;
|
||||
resp->iNanoStamina = 150;
|
||||
resp->eST = eSkillType;
|
||||
resp->iTargetCnt = pkt->iTargetCnt;
|
||||
|
||||
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
||||
if (NPCManager::NPCs.find(pktdata[i]) == NPCManager::NPCs.end()) {
|
||||
// not sure how to best handle this
|
||||
std::cout << "[WARN] nanoDebuffEnemy: mob ID not found" << std::endl;
|
||||
return;
|
||||
}
|
||||
BaseNPC& mob = NPCManager::NPCs[pktdata[i]];
|
||||
|
||||
mob.appearanceData.iHP -= damageAmount;
|
||||
|
||||
if (mob.appearanceData.iHP <= 0)
|
||||
CombatManager::giveReward(sock);
|
||||
|
||||
respdata[i].eCT = 4;
|
||||
respdata[i].iDamage = damageAmount;
|
||||
respdata[i].iID = mob.appearanceData.iNPC_ID;
|
||||
respdata[i].iHP = mob.appearanceData.iHP;
|
||||
respdata[i].iConditionBitFlag = iCBFlag;
|
||||
std::cout << (int)mob.appearanceData.iNPC_ID << " was debuffed" << std::endl;
|
||||
}
|
||||
|
||||
sock->sendPacket((void*)&respbuf, P_FE2CL_NANO_SKILL_USE_SUCC, resplen);
|
||||
for (CNSocket* s : PlayerManager::players[sock].viewable)
|
||||
s->sendPacket((void*)&respbuf, P_FE2CL_NANO_SKILL_USE, resplen);
|
||||
}
|
||||
|
||||
void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_NANO_EQUIP))
|
||||
return; // malformed packet
|
||||
|
@ -44,11 +44,20 @@ struct NanoTuning {
|
||||
int reqItems;
|
||||
};
|
||||
|
||||
struct SkillData {
|
||||
int skillType;
|
||||
int targetType;
|
||||
int batteryUse[4];
|
||||
int durationTime[4];
|
||||
int powerIntensity[4];
|
||||
};
|
||||
|
||||
namespace NanoManager {
|
||||
extern std::vector<ActivePower> ActivePowers;
|
||||
extern std::vector<PassivePower> PassivePowers;
|
||||
extern std::map<int32_t, NanoData> NanoTable;
|
||||
extern std::map<int32_t, NanoTuning> NanoTunings;
|
||||
extern std::map<int32_t, SkillData> SkillTable;
|
||||
void init();
|
||||
|
||||
void nanoSummonHandler(CNSocket* sock, CNPacketData* data);
|
||||
|
@ -190,6 +190,22 @@ void TableData::init() {
|
||||
|
||||
std::cout << "[INFO] Loaded " << NanoManager::NanoTable.size() << " nano tunings" << std::endl;
|
||||
|
||||
// load nano powers
|
||||
nlohmann::json skills = xdtData["m_pSkillTable"]["m_pSkillData"];
|
||||
|
||||
for (nlohmann::json::iterator _skills = skills.begin(); _skills != skills.end(); _skills++) {
|
||||
auto skills = _skills.value();
|
||||
SkillData skillData = {skills["m_iSkillType"], skills["m_iTargetType"]};
|
||||
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];
|
||||
}
|
||||
NanoManager::SkillTable[skills["m_iSkillNumber"]] = skillData;
|
||||
}
|
||||
|
||||
std::cout << "[INFO] Loaded " << NanoManager::SkillTable.size() << " nano skills" << std::endl;
|
||||
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed xdt.json file! Reason:" << err.what() << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user