Egg checks, fixes, and cleanup

fixed not taking egg buff flag into consideration in mob manager

fixed stamina bug and improved sanity check

Egg cleanups
This commit is contained in:
Gent 2020-11-11 23:03:08 -05:00
parent 0ecf76c5ec
commit 7135767cc4
4 changed files with 16 additions and 21 deletions

View File

@ -1,4 +1,3 @@
#define M_PI 3.14159265358979323846
#include "CNShardServer.hpp" #include "CNShardServer.hpp"
#include "CNStructs.hpp" #include "CNStructs.hpp"
#include "ChatManager.hpp" #include "ChatManager.hpp"

View File

@ -3,6 +3,7 @@
#include "CNShardServer.hpp" #include "CNShardServer.hpp"
#define CMD_PREFIX '/' #define CMD_PREFIX '/'
#define M_PI 3.14159265358979323846
typedef void (*CommandHandler)(std::string fullString, std::vector<std::string>& args, CNSocket* sock); typedef void (*CommandHandler)(std::string fullString, std::vector<std::string>& args, CNSocket* sock);

View File

@ -796,7 +796,7 @@ void MobManager::dotDamageOnOff(CNSocket *sock, CNPacketData *data) {
pkt1.eCSTB = ECSB_INFECTION; // eCharStatusTimeBuffID pkt1.eCSTB = ECSB_INFECTION; // eCharStatusTimeBuffID
pkt1.eTBU = 1; // eTimeBuffUpdate pkt1.eTBU = 1; // eTimeBuffUpdate
pkt1.eTBT = 0; // eTimeBuffType 1 means nano pkt1.eTBT = 0; // eTimeBuffType 1 means nano
pkt1.iConditionBitFlag = plr->iConditionBitFlag; pkt1.iConditionBitFlag = plr->iConditionBitFlag | plr->iGroupConditionBitFlag | plr->iEggConditionBitFlag;
sock->sendPacket((void*)&pkt1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); sock->sendPacket((void*)&pkt1, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
} }

View File

@ -692,8 +692,6 @@ BaseNPC* NPCManager::getNearestNPC(std::vector<Chunk*> chunks, int X, int Y, int
int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) { int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) {
Player* plr = PlayerManager::getPlayer(sock); Player* plr = PlayerManager::getPlayer(sock);
if (plr == nullptr)
return -1;
int32_t CBFlag = -1, iValue = 0, CSTB, EST; int32_t CBFlag = -1, iValue = 0, CSTB, EST;
@ -767,8 +765,8 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) {
skillUse->iPC_ID = plr->iID; skillUse->iPC_ID = plr->iID;
skillUse->iSkillID = skillId; skillUse->iSkillID = skillId;
skillUse->iNanoID = 0; skillUse->iNanoID = plr->activeNano;
skillUse->iNanoStamina = 150; skillUse->iNanoStamina = plr->activeNano < 1 ? 0 : plr->Nanos[plr->activeNano].iStamina;
skillUse->eST = EST; skillUse->eST = EST;
skillUse->iTargetCnt = 1; skillUse->iTargetCnt = 1;
@ -784,7 +782,7 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int duration) {
void NPCManager::eggStep(CNServer* serv, time_t currTime) { void NPCManager::eggStep(CNServer* serv, time_t currTime) {
// tick buffs // tick buffs
time_t timeStamp = getTimestamp(); time_t timeStamp = currTime / 1000;
auto it = EggBuffs.begin(); auto it = EggBuffs.begin();
while (it != EggBuffs.end()) { while (it != EggBuffs.end()) {
// check remaining time // check remaining time
@ -837,9 +835,9 @@ void NPCManager::eggStep(CNServer* serv, time_t currTime) {
} }
} }
// check dead eggs // check dead eggs and eggs in inactive chunks
for (auto egg : Eggs) { for (auto egg : Eggs) {
if (!egg.second->dead) if (!egg.second->dead || !ChunkManager::inPopulatedChunks(egg.second->appearanceData.iX, egg.second->appearanceData.iY, egg.second->instanceID))
continue; continue;
if (egg.second->deadUntil <= timeStamp) { if (egg.second->deadUntil <= timeStamp) {
// respawn it // respawn it
@ -868,9 +866,6 @@ void NPCManager::eggPickup(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_SHINY_PICKUP* pickup = (sP_CL2FE_REQ_SHINY_PICKUP*)data->buf; sP_CL2FE_REQ_SHINY_PICKUP* pickup = (sP_CL2FE_REQ_SHINY_PICKUP*)data->buf;
Player* plr = PlayerManager::getPlayer(sock); Player* plr = PlayerManager::getPlayer(sock);
if (plr == nullptr)
return;
int eggId = pickup->iShinyID; int eggId = pickup->iShinyID;
if (Eggs.find(eggId) == Eggs.end()) { if (Eggs.find(eggId) == Eggs.end()) {
@ -884,7 +879,7 @@ void NPCManager::eggPickup(CNSocket* sock, CNPacketData* data) {
return; return;
} }
if (egg->chunkPos != ChunkManager::grabChunk(plr->x, plr->y, plr->instanceID)) { if (abs(egg->appearanceData.iX - plr->x)>500 || abs(egg->appearanceData.iY - plr->y) > 500) {
std::cout << "[WARN] Player tried to open an egg from the other chunk?!" << std::endl; std::cout << "[WARN] Player tried to open an egg from the other chunk?!" << std::endl;
return; return;
} }
@ -954,22 +949,22 @@ void NPCManager::eggPickup(CNSocket* sock, CNPacketData* data) {
} }
/* /*
* SHINY_PIKUP_SUCC is only causing a GUI effect in the client * SHINY_PICKUP_SUCC is only causing a GUI effect in the client
* (buff icon pops up in the bottom of the screen) * (buff icon pops up in the bottom of the screen)
* so we don't send it for non-effect * so we don't send it for non-effect
*/ */
if (type->effectId != 0) if (type->effectId != 0)
{ {
INITSTRUCT(sP_FE2CL_REP_SHINY_PICKUP_SUCC, resp); INITSTRUCT(sP_FE2CL_REP_SHINY_PICKUP_SUCC, resp);
resp.iSkillID = type->effectId; resp.iSkillID = type->effectId;
// in general client finds correct icon on it's own, // in general client finds correct icon on it's own,
// but for damage we have to supply correct CSTB // but for damage we have to supply correct CSTB
if (resp.iSkillID == 183) if (resp.iSkillID == 183)
resp.eCSTB = ECSB_INFECTION; resp.eCSTB = ECSB_INFECTION;
sock->sendPacket((void*)&resp, P_FE2CL_REP_SHINY_PICKUP_SUCC, sizeof(sP_FE2CL_REP_SHINY_PICKUP_SUCC)); sock->sendPacket((void*)&resp, P_FE2CL_REP_SHINY_PICKUP_SUCC, sizeof(sP_FE2CL_REP_SHINY_PICKUP_SUCC));
} }
// drop // drop