* Mobs should account for height when aggroing on nearby players
* We don't need to keep track of lastHealTime for each player separately
* Warp attendants no longer steal the players weapon and money
This commit is contained in:
dongresource 2020-09-27 19:58:37 +02:00
parent 2b4a1387f9
commit 6ea47ddb56
3 changed files with 13 additions and 7 deletions

View File

@ -329,7 +329,10 @@ void MobManager::roamingStep(Mob *mob, time_t currTime) {
for (Chunk *chunk : mob->currentChunks) { for (Chunk *chunk : mob->currentChunks) {
for (CNSocket *s : chunk->players) { for (CNSocket *s : chunk->players) {
Player *plr = s->plr; Player *plr = s->plr;
int distance = hypot(mob->appearanceData.iX - plr->x, mob->appearanceData.iY - plr->y);
// height is relevant for aggro distance because of platforming
int xyDistance = hypot(mob->appearanceData.iX - plr->x, mob->appearanceData.iY - plr->y);
int distance = hypot(xyDistance, mob->appearanceData.iZ - plr->z);
if (distance > mob->data["m_iSightRange"]) if (distance > mob->data["m_iSightRange"])
continue; continue;
@ -509,6 +512,8 @@ void MobManager::dealGooDamage(CNSocket *sock, int amount) {
} }
void MobManager::playerTick(CNServer *serv, time_t currTime) { void MobManager::playerTick(CNServer *serv, time_t currTime) {
static time_t lastHealTime = 0;
for (auto& pair : PlayerManager::players) { for (auto& pair : PlayerManager::players) {
CNSocket *sock = pair.first; CNSocket *sock = pair.first;
Player *plr = pair.second.plr; Player *plr = pair.second.plr;
@ -519,11 +524,9 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
dealGooDamage(sock, 150); dealGooDamage(sock, 150);
// a somewhat hacky way tick goo damage faster than heal, but eh // a somewhat hacky way tick goo damage faster than heal, but eh
if (currTime - plr->lastHealTime < 4000) if (currTime - lastHealTime < 4000)
continue; continue;
plr->lastHealTime = currTime;
// heal // heal
if (!plr->inCombat && plr->HP < PC_MAXHEALTH(plr->level)) { if (!plr->inCombat && plr->HP < PC_MAXHEALTH(plr->level)) {
plr->HP += 200; plr->HP += 200;
@ -554,8 +557,6 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
if (transmit) { if (transmit) {
INITSTRUCT(sP_FE2CL_REP_PC_TICK, pkt); INITSTRUCT(sP_FE2CL_REP_PC_TICK, pkt);
std::cout << "sending sP_FE2CL_REP_PC_TICK" << std::endl;
pkt.iHP = plr->HP; pkt.iHP = plr->HP;
pkt.iBatteryN = plr->batteryN; pkt.iBatteryN = plr->batteryN;
@ -566,4 +567,8 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
sock->sendPacket((void*)&pkt, P_FE2CL_REP_PC_TICK, sizeof(sP_FE2CL_REP_PC_TICK)); sock->sendPacket((void*)&pkt, P_FE2CL_REP_PC_TICK, sizeof(sP_FE2CL_REP_PC_TICK));
} }
} }
// if this was a heal tick, update the counter outside of the loop
if (currTime - lastHealTime < 4000)
lastHealTime = currTime;
} }

View File

@ -560,6 +560,8 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
resp.iX = Warps[warpId].x; resp.iX = Warps[warpId].x;
resp.iY = Warps[warpId].y; resp.iY = Warps[warpId].y;
resp.iZ = Warps[warpId].z; resp.iZ = Warps[warpId].z;
resp.iCandy = plrv.plr->money;
resp.eIL = 4; // do not take away any items
// force player & NPC reload // force player & NPC reload
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock); PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);

View File

@ -46,7 +46,6 @@ struct Player {
bool inCombat; bool inCombat;
bool dotDamage; bool dotDamage;
time_t lastHealTime;
int64_t aQuestFlag[16]; int64_t aQuestFlag[16];
int tasks[ACTIVE_MISSION_COUNT]; int tasks[ACTIVE_MISSION_COUNT];