New buff framework (player implementation)

Get rid of `iConditionBitFlag` in favor of a system of individual buff
objects that get composited to a bitflag on-the-fly.
Buff objects can have callbacks for application, expiration, and tick,
making them pretty flexible. Scripting languages can eventually use
these for custom behavior, too.

TODO:
- Get rid of bitflag in BaseNPC
- Apply buffs from passive nano powers
- Apply buffs from active nano powers
- Move eggs to new system
- ???
This commit is contained in:
gsemaj
2022-07-16 23:33:57 -07:00
committed by gsemaj
parent 215da0130d
commit c60c4dac38
16 changed files with 309 additions and 54 deletions

30
src/Buffs.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "Buffs.hpp"
#include "PlayerManager.hpp"
using namespace Buffs;
static void timeBuffUpdate(EntityRef self, BuffStack* buff, int type) {
if(self.kind != EntityKind::PLAYER)
return; // not implemented
Player* plr = (Player*)self.getEntity();
if(plr == nullptr)
return;
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt);
pkt.eCSTB = buff->id; // eCharStatusTimeBuffID
pkt.eTBU = type; // eTimeBuffUpdate
pkt.eTBT = (buff->buffClass <= BuffClass::CONSUMABLE); // eTimeBuffType 1 means nano
pkt.iConditionBitFlag = plr->getCompositeCondition();
self.sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
}
void Buffs::timeBuffUpdateAdd(EntityRef self, BuffStack* buff) {
timeBuffUpdate(self, buff, ETBU_ADD);
}
void Buffs::timeBuffUpdateDelete(EntityRef self, BuffStack* buff) {
timeBuffUpdate(self, buff, ETBU_DEL);
}