mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-20 03:20:03 +00:00
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:
30
src/Buffs.cpp
Normal file
30
src/Buffs.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user