mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-17 03:20:06 +00:00
Get rid of cbf
This commit is contained in:
parent
b6171ebdc1
commit
0f09808bc4
@ -678,7 +678,6 @@ static void whoisCommand(std::string full, std::vector<std::string>& args, CNSoc
|
|||||||
Chat::sendServerMessage(sock, "[WHOIS] ID: " + std::to_string(npc->id));
|
Chat::sendServerMessage(sock, "[WHOIS] ID: " + std::to_string(npc->id));
|
||||||
Chat::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->type));
|
Chat::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->type));
|
||||||
Chat::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->hp));
|
Chat::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->hp));
|
||||||
Chat::sendServerMessage(sock, "[WHOIS] CBF: " + std::to_string(npc->cbf));
|
|
||||||
Chat::sendServerMessage(sock, "[WHOIS] EntityType: " + std::to_string((int)npc->kind));
|
Chat::sendServerMessage(sock, "[WHOIS] EntityType: " + std::to_string((int)npc->kind));
|
||||||
Chat::sendServerMessage(sock, "[WHOIS] X: " + std::to_string(npc->x));
|
Chat::sendServerMessage(sock, "[WHOIS] X: " + std::to_string(npc->x));
|
||||||
Chat::sendServerMessage(sock, "[WHOIS] Y: " + std::to_string(npc->y));
|
Chat::sendServerMessage(sock, "[WHOIS] Y: " + std::to_string(npc->y));
|
||||||
|
@ -40,7 +40,7 @@ sNPCAppearanceData BaseNPC::getAppearanceData() {
|
|||||||
sNPCAppearanceData data = {};
|
sNPCAppearanceData data = {};
|
||||||
data.iAngle = angle;
|
data.iAngle = angle;
|
||||||
data.iBarkerType = 0; // unused?
|
data.iBarkerType = 0; // unused?
|
||||||
data.iConditionBitFlag = cbf;
|
data.iConditionBitFlag = 0;
|
||||||
data.iHP = hp;
|
data.iHP = hp;
|
||||||
data.iNPCType = type;
|
data.iNPCType = type;
|
||||||
data.iNPC_ID = id;
|
data.iNPC_ID = id;
|
||||||
@ -50,6 +50,12 @@ sNPCAppearanceData BaseNPC::getAppearanceData() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sNPCAppearanceData CombatNPC::getAppearanceData() {
|
||||||
|
sNPCAppearanceData data = BaseNPC::getAppearanceData();
|
||||||
|
data.iConditionBitFlag = getCompositeCondition();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entity coming into view.
|
* Entity coming into view.
|
||||||
*/
|
*/
|
||||||
|
@ -73,7 +73,6 @@ public:
|
|||||||
int type;
|
int type;
|
||||||
int hp;
|
int hp;
|
||||||
int angle;
|
int angle;
|
||||||
int cbf;
|
|
||||||
bool loopingPath = false;
|
bool loopingPath = false;
|
||||||
|
|
||||||
BaseNPC(int _A, uint64_t iID, int t, int _id) {
|
BaseNPC(int _A, uint64_t iID, int t, int _id) {
|
||||||
@ -81,7 +80,6 @@ public:
|
|||||||
type = t;
|
type = t;
|
||||||
hp = 400;
|
hp = 400;
|
||||||
angle = _A;
|
angle = _A;
|
||||||
cbf = 0;
|
|
||||||
id = _id;
|
id = _id;
|
||||||
instanceID = iID;
|
instanceID = iID;
|
||||||
};
|
};
|
||||||
@ -89,7 +87,7 @@ public:
|
|||||||
virtual void enterIntoViewOf(CNSocket *sock) override;
|
virtual void enterIntoViewOf(CNSocket *sock) override;
|
||||||
virtual void disappearFromViewOf(CNSocket *sock) override;
|
virtual void disappearFromViewOf(CNSocket *sock) override;
|
||||||
|
|
||||||
sNPCAppearanceData getAppearanceData();
|
virtual sNPCAppearanceData getAppearanceData();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CombatNPC : public BaseNPC, public ICombatant {
|
struct CombatNPC : public BaseNPC, public ICombatant {
|
||||||
@ -118,6 +116,8 @@ struct CombatNPC : public BaseNPC, public ICombatant {
|
|||||||
transitionHandlers[AIState::INACTIVE] = {};
|
transitionHandlers[AIState::INACTIVE] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual sNPCAppearanceData getAppearanceData() override;
|
||||||
|
|
||||||
virtual bool isExtant() override { return hp > 0; }
|
virtual bool isExtant() override { return hp > 0; }
|
||||||
|
|
||||||
virtual bool addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) override;
|
virtual bool addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) override;
|
||||||
|
@ -51,13 +51,13 @@ int Mob::takeDamage(EntityRef src, int amt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wake up sleeping monster
|
// wake up sleeping monster
|
||||||
if (cbf & CSB_BIT_MEZ) {
|
if (hasBuff(ECSB_MEZ)) {
|
||||||
cbf &= ~CSB_BIT_MEZ;
|
removeBuff(ECSB_MEZ);
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, pkt1);
|
INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, pkt1);
|
||||||
pkt1.eCT = 2;
|
pkt1.eCT = 2;
|
||||||
pkt1.iID = id;
|
pkt1.iID = id;
|
||||||
pkt1.iConditionBitFlag = cbf;
|
pkt1.iConditionBitFlag = getCompositeCondition();
|
||||||
NPCManager::sendToViewable(this, &pkt1, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
NPCManager::sendToViewable(this, &pkt1, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,13 +96,12 @@ static std::pair<int,int> lerp(int x1, int y1, int x2, int y2, int speed) {
|
|||||||
|
|
||||||
void MobAI::clearDebuff(Mob *mob) {
|
void MobAI::clearDebuff(Mob *mob) {
|
||||||
mob->skillStyle = -1;
|
mob->skillStyle = -1;
|
||||||
mob->cbf = 0;
|
mob->clearBuffs(false);
|
||||||
mob->unbuffTimes.clear();
|
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, pkt1);
|
INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, pkt1);
|
||||||
pkt1.eCT = 2;
|
pkt1.eCT = 2;
|
||||||
pkt1.iID = mob->id;
|
pkt1.iID = mob->id;
|
||||||
pkt1.iConditionBitFlag = mob->cbf;
|
pkt1.iConditionBitFlag = mob->getCompositeCondition();
|
||||||
NPCManager::sendToViewable(mob, &pkt1, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
NPCManager::sendToViewable(mob, &pkt1, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +554,7 @@ void MobAI::combatStep(CombatNPC* npc, time_t currTime) {
|
|||||||
|
|
||||||
// drain
|
// drain
|
||||||
if (self->skillStyle < 0 && (self->lastDrainTime == 0 || currTime - self->lastDrainTime >= 1000)
|
if (self->skillStyle < 0 && (self->lastDrainTime == 0 || currTime - self->lastDrainTime >= 1000)
|
||||||
&& self->cbf & CSB_BIT_BOUNDINGBALL) {
|
&& self->hasBuff(ECSB_BOUNDINGBALL)) {
|
||||||
drainMobHP(self, self->maxHealth / 20); // lose 5% every second
|
drainMobHP(self, self->maxHealth / 20); // lose 5% every second
|
||||||
self->lastDrainTime = currTime;
|
self->lastDrainTime = currTime;
|
||||||
}
|
}
|
||||||
@ -564,27 +563,13 @@ void MobAI::combatStep(CombatNPC* npc, time_t currTime) {
|
|||||||
if (self->hp <= 0)
|
if (self->hp <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// unbuffing
|
// tick buffs TODO abilities
|
||||||
std::unordered_map<int32_t, time_t>::iterator it = self->unbuffTimes.begin();
|
//for(auto buffEntry : self->buffs) {
|
||||||
while (it != self->unbuffTimes.end()) {
|
// buffEntry.second->combatTick(currTime);
|
||||||
|
//}
|
||||||
if (currTime >= it->second) {
|
|
||||||
self->cbf &= ~it->first;
|
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, pkt1);
|
|
||||||
pkt1.eCT = 2;
|
|
||||||
pkt1.iID = self->id;
|
|
||||||
pkt1.iConditionBitFlag = self->cbf;
|
|
||||||
NPCManager::sendToViewable(self, &pkt1, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
|
||||||
|
|
||||||
it = self->unbuffTimes.erase(it);
|
|
||||||
} else {
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip attack if stunned or asleep
|
// skip attack if stunned or asleep
|
||||||
if (self->cbf & (CSB_BIT_STUN|CSB_BIT_MEZ)) {
|
if (self->hasBuff(ECSB_STUN) || self->hasBuff(ECSB_MEZ)) {
|
||||||
self->skillStyle = -1; // in this case we also reset the any outlying abilities the mob might be winding up.
|
self->skillStyle = -1; // in this case we also reset the any outlying abilities the mob might be winding up.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -609,7 +594,7 @@ void MobAI::combatStep(CombatNPC* npc, time_t currTime) {
|
|||||||
self->nextAttack = 0;
|
self->nextAttack = 0;
|
||||||
|
|
||||||
// halve movement speed if snared
|
// halve movement speed if snared
|
||||||
if (self->cbf & CSB_BIT_DN_MOVE_SPEED)
|
if (self->hasBuff(ECSB_DN_MOVE_SPEED))
|
||||||
self->speed /= 2;
|
self->speed /= 2;
|
||||||
|
|
||||||
int targetX = plr->x;
|
int targetX = plr->x;
|
||||||
@ -715,7 +700,7 @@ void MobAI::roamingStep(CombatNPC* npc, time_t currTime) {
|
|||||||
farY = std::clamp(farY, yStart, yStart + self->idleRange);
|
farY = std::clamp(farY, yStart, yStart + self->idleRange);
|
||||||
|
|
||||||
// halve movement speed if snared
|
// halve movement speed if snared
|
||||||
if (self->cbf & CSB_BIT_DN_MOVE_SPEED)
|
if (self->hasBuff(ECSB_DN_MOVE_SPEED))
|
||||||
self->speed /= 2;
|
self->speed /= 2;
|
||||||
|
|
||||||
std::queue<Vec3> queue;
|
std::queue<Vec3> queue;
|
||||||
@ -788,7 +773,6 @@ void MobAI::onRoamStart(CombatNPC* npc, EntityRef src) {
|
|||||||
self->hp = self->maxHealth;
|
self->hp = self->maxHealth;
|
||||||
self->killedTime = 0;
|
self->killedTime = 0;
|
||||||
self->nextAttack = 0;
|
self->nextAttack = 0;
|
||||||
self->cbf = 0;
|
|
||||||
|
|
||||||
// cast a return home heal spell, this is the right way(tm)
|
// cast a return home heal spell, this is the right way(tm)
|
||||||
// TODO ABILITIES
|
// TODO ABILITIES
|
||||||
@ -833,9 +817,8 @@ void MobAI::onDeath(CombatNPC* npc, EntityRef src) {
|
|||||||
Mob* self = (Mob*)npc;
|
Mob* self = (Mob*)npc;
|
||||||
|
|
||||||
self->target = nullptr;
|
self->target = nullptr;
|
||||||
self->cbf = 0;
|
|
||||||
self->skillStyle = -1;
|
self->skillStyle = -1;
|
||||||
self->unbuffTimes.clear();
|
self->clearBuffs(true);
|
||||||
self->killedTime = getTime(); // XXX: maybe introduce a shard-global time for each step?
|
self->killedTime = getTime(); // XXX: maybe introduce a shard-global time for each step?
|
||||||
|
|
||||||
// check for the edge case where hitting the mob did not aggro it
|
// check for the edge case where hitting the mob did not aggro it
|
||||||
|
@ -21,8 +21,6 @@ namespace MobAI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Mob : public CombatNPC {
|
struct Mob : public CombatNPC {
|
||||||
// general
|
|
||||||
std::unordered_map<int32_t,time_t> unbuffTimes = {};
|
|
||||||
|
|
||||||
// dead
|
// dead
|
||||||
time_t killedTime = 0;
|
time_t killedTime = 0;
|
||||||
@ -71,8 +69,6 @@ struct Mob : public CombatNPC {
|
|||||||
offsetX = 0;
|
offsetX = 0;
|
||||||
offsetY = 0;
|
offsetY = 0;
|
||||||
|
|
||||||
cbf = 0;
|
|
||||||
|
|
||||||
// NOTE: there appear to be discrepancies in the dump
|
// NOTE: there appear to be discrepancies in the dump
|
||||||
hp = maxHealth;
|
hp = maxHealth;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user