added nano potions functionality

This commit is contained in:
kamilprzyb 2020-09-25 02:39:30 +02:00
parent 86c1cbd0f2
commit d87306930d
2 changed files with 31 additions and 0 deletions

View File

@ -49,6 +49,7 @@ void NanoManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO_SKILL, nanoSkillSetGMHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO_SKILL, nanoSkillSetGMHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_WARP_USE_RECALL, nanoRecallHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_WARP_USE_RECALL, nanoRecallHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_CHARGE_NANO_STAMINA, nanoPotionHandler);
} }
void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
@ -171,6 +172,35 @@ void NanoManager::nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
// stubbed for now // stubbed for now
} }
void NanoManager::nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_CHARGE_NANO_STAMINA))
return;
Player* player = PlayerManager::getPlayer(sock);
//sanity check
if (player->activeNano == -1 || player->batteryN == 0)
return;
sNano nano = player->Nanos[player->activeNano];
int difference = 150 - nano.iStamina;
if (player->batteryN < difference)
difference = player->batteryN;
if (difference == 0)
return;
INITSTRUCT(sP_FE2CL_REP_CHARGE_NANO_STAMINA, response);
response.iNanoID = nano.iID;
response.iNanoStamina = nano.iStamina + difference;
response.iBatteryN = player->batteryN - difference;
sock->sendPacket((void*)&response, P_FE2CL_REP_CHARGE_NANO_STAMINA, sizeof(sP_FE2CL_REP_CHARGE_NANO_STAMINA));
//now update serverside
player->batteryN -= difference;
player->Nanos[nano.iID].iStamina += difference;
}
#pragma region Helper methods #pragma region Helper methods
void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) { void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
if (nanoId > 36) if (nanoId > 36)

View File

@ -52,6 +52,7 @@ namespace NanoManager {
void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data); void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data);
void nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data); void nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data);
void nanoRecallHandler(CNSocket* sock, CNPacketData* data); void nanoRecallHandler(CNSocket* sock, CNPacketData* data);
void nanoPotionHandler(CNSocket* sock, CNPacketData* data);
// Helper methods // Helper methods
void addNano(CNSocket* sock, int16_t nanoId, int16_t slot); void addNano(CNSocket* sock, int16_t nanoId, int16_t slot);