mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-16 19:20:05 +00:00
egg prep
This commit is contained in:
parent
704d6a2452
commit
ded7462677
@ -74,15 +74,35 @@ static void timeBuffUpdate(EntityRef self, BuffStack* buff, int type) {
|
||||
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.eTBT = (int)buff->buffClass;
|
||||
pkt.iConditionBitFlag = plr->getCompositeCondition();
|
||||
self.sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
||||
}
|
||||
|
||||
static void timeBuffTimeoutViewable(EntityRef self) {
|
||||
if(self.kind != EntityKind::PLAYER)
|
||||
return; // not implemented
|
||||
|
||||
Player* plr = (Player*)self.getEntity();
|
||||
if(plr == nullptr)
|
||||
return;
|
||||
|
||||
INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, pkt); // send a buff timeout to other players
|
||||
pkt.eCT = 1;
|
||||
pkt.iID = plr->iID;
|
||||
pkt.iConditionBitFlag = plr->getCompositeCondition();
|
||||
PlayerManager::sendToViewable(self.sock, pkt, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT);
|
||||
}
|
||||
|
||||
void Buffs::timeBuffUpdateAdd(EntityRef self, BuffStack* buff) {
|
||||
timeBuffUpdate(self, buff, ETBU_ADD);
|
||||
}
|
||||
|
||||
void Buffs::timeBuffUpdateDelete(EntityRef self, BuffStack* buff) {
|
||||
timeBuffUpdate(self, buff, ETBU_DEL);
|
||||
}
|
||||
}
|
||||
|
||||
void Buffs::timeBuffTimeout(EntityRef self, BuffStack* buff) {
|
||||
timeBuffUpdate(self, buff, ETBU_DEL);
|
||||
timeBuffTimeoutViewable(self);
|
||||
}
|
||||
|
@ -12,10 +12,13 @@ struct BuffStack;
|
||||
#define CSB_FROM_ECSB(x) (1 << (x - 1))
|
||||
|
||||
enum class BuffClass {
|
||||
NANO = 0,
|
||||
CONSUMABLE,
|
||||
EGG,
|
||||
OTHER
|
||||
NONE = ETBT_NONE,
|
||||
NANO = ETBT_NANO,
|
||||
GROUP_NANO = ETBT_GROUPNANO,
|
||||
EGG = ETBT_SHINY,
|
||||
ENVIRONMENT = ETBT_LANDEFFECT,
|
||||
ITEM = ETBT_ITEM,
|
||||
CASH_ITEM = ETBT_CASHITEM
|
||||
};
|
||||
|
||||
typedef void (*BuffCallback)(EntityRef, BuffStack*);
|
||||
@ -70,4 +73,5 @@ public:
|
||||
namespace Buffs {
|
||||
void timeBuffUpdateAdd(EntityRef self, BuffStack* buff);
|
||||
void timeBuffUpdateDelete(EntityRef self, BuffStack* buff);
|
||||
void timeBuffTimeout(EntityRef self, BuffStack* buff);
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ static void dotDamageOnOff(CNSocket *sock, CNPacketData *data) {
|
||||
ECSB_INFECTION,
|
||||
-1, // infinite
|
||||
sock, // self-inflicted
|
||||
BuffClass::OTHER,
|
||||
BuffClass::ENVIRONMENT,
|
||||
Buffs::timeBuffUpdateAdd,
|
||||
nullptr, // client ticks for us! todo anticheat lol
|
||||
Buffs::timeBuffUpdateDelete
|
||||
|
52
src/Eggs.cpp
52
src/Eggs.cpp
@ -13,16 +13,12 @@
|
||||
|
||||
using namespace Eggs;
|
||||
|
||||
/// sock, CBFlag -> until
|
||||
std::map<std::pair<CNSocket*, int32_t>, time_t> Eggs::EggBuffs;
|
||||
std::unordered_map<int, EggType> Eggs::EggTypes;
|
||||
|
||||
int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
// TODO ABILITIES
|
||||
//int bitFlag = plr->group->conditionBitFlag;
|
||||
int CBFlag = 0;// Abilities::applyBuff(sock, skillId, 1, 3, bitFlag);
|
||||
|
||||
size_t resplen;
|
||||
|
||||
@ -75,56 +71,10 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
||||
sock->sendPacket((void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||
PlayerManager::sendToViewable(sock, (void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||
|
||||
if (CBFlag == 0)
|
||||
return -1;
|
||||
|
||||
std::pair<CNSocket*, int32_t> key = std::make_pair(sock, CBFlag);
|
||||
|
||||
// save the buff serverside;
|
||||
// if you get the same buff again, new duration will override the previous one
|
||||
time_t until = getTime() + (time_t)duration * 1000;
|
||||
EggBuffs[key] = until;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void eggStep(CNServer* serv, time_t currTime) {
|
||||
// tick buffs
|
||||
time_t timeStamp = currTime;
|
||||
auto it = EggBuffs.begin();
|
||||
while (it != EggBuffs.end()) {
|
||||
// check remaining time
|
||||
if (it->second > timeStamp) {
|
||||
it++;
|
||||
} else { // if time reached 0
|
||||
CNSocket* sock = it->first.first;
|
||||
int32_t CBFlag = it->first.second;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
//int groupFlags = plr->group->conditionBitFlag;
|
||||
// TODO ABILITIES
|
||||
//for (auto& pwr : Abilities::Powers) {
|
||||
// if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
||||
// INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp);
|
||||
// resp.eCSTB = pwr.timeBuffID;
|
||||
// resp.eTBU = 2;
|
||||
// resp.eTBT = 3; // for egg buffs
|
||||
// plr->iConditionBitFlag &= ~CBFlag;
|
||||
// resp.iConditionBitFlag = plr->iConditionBitFlag |= groupFlags | plr->iSelfConditionBitFlag;
|
||||
// sock->sendPacket(resp, P_FE2CL_PC_BUFF_UPDATE);
|
||||
|
||||
// INITSTRUCT(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT, resp2); // send a buff timeout to other players
|
||||
// resp2.eCT = 1;
|
||||
// resp2.iID = plr->iID;
|
||||
// resp2.iConditionBitFlag = plr->iConditionBitFlag;
|
||||
// PlayerManager::sendToViewable(sock, resp2, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT);
|
||||
// }
|
||||
//}
|
||||
// remove buff from the map
|
||||
it = EggBuffs.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// check dead eggs and eggs in inactive chunks
|
||||
for (auto npc : NPCManager::NPCs) {
|
||||
if (npc.second->kind != EntityKind::EGG)
|
||||
@ -134,7 +84,7 @@ static void eggStep(CNServer* serv, time_t currTime) {
|
||||
if (!egg->dead || !Chunking::inPopulatedChunks(&egg->viewableChunks))
|
||||
continue;
|
||||
|
||||
if (egg->deadUntil <= timeStamp) {
|
||||
if (egg->deadUntil <= currTime) {
|
||||
// respawn it
|
||||
egg->dead = false;
|
||||
egg->deadUntil = 0;
|
||||
|
@ -10,7 +10,6 @@ struct EggType {
|
||||
};
|
||||
|
||||
namespace Eggs {
|
||||
extern std::map<std::pair<CNSocket*, int32_t>, time_t> EggBuffs;
|
||||
extern std::unordered_map<int, EggType> EggTypes;
|
||||
|
||||
void init();
|
||||
|
@ -149,7 +149,6 @@ static void joinGroup(CNSocket* sock, CNPacketData* data) {
|
||||
resp->iID_NewMember = plr->iID;
|
||||
resp->iMemberPCCnt = players.size();
|
||||
|
||||
//int bitFlag = otherPlr->group->conditionBitFlag;
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
|
||||
Player* varPlr = PlayerManager::getPlayer(players[i].sock);
|
||||
@ -173,14 +172,6 @@ static void joinGroup(CNSocket* sock, CNPacketData* data) {
|
||||
respdata[i].iY = varPlr->y;
|
||||
respdata[i].iZ = varPlr->z;
|
||||
// client doesnt read nano data here
|
||||
|
||||
if (varPlr != plr) { // apply the new member's buffs to the group and the group's buffs to the new member
|
||||
// TODO ABILITIES
|
||||
/*if (Abilities::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||
Abilities::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 1, 1, bitFlag);
|
||||
if (Abilities::SkillTable[plr->Nanos[plr->activeNano].iSkillID].targetType == 3)
|
||||
Abilities::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 1, 1, bitFlag);*/
|
||||
}
|
||||
}
|
||||
|
||||
Groups::sendToGroup(otherPlr->group, (void*)&respbuf, P_FE2CL_PC_GROUP_JOIN, resplen);
|
||||
@ -294,8 +285,6 @@ void Groups::groupKick(Player* plr) {
|
||||
resp->iID_LeaveMember = plr->iID;
|
||||
resp->iMemberPCCnt = players.size() - 1;
|
||||
|
||||
int bitFlag = 0; // TODO ABILITIES getGroupFlags(otherPlr) & ~plr->iGroupConditionBitFlag;
|
||||
|
||||
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
||||
|
||||
if (sock == nullptr)
|
||||
@ -326,13 +315,6 @@ void Groups::groupKick(Player* plr) {
|
||||
respdata[i].iY = varPlr->y;
|
||||
respdata[i].iZ = varPlr->z;
|
||||
// client doesnt read nano data here
|
||||
|
||||
// remove the leaving member's buffs from the group and remove the group buffs from the leaving member.
|
||||
// TODO ABILITIES
|
||||
/*if (Abilities::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||
Abilities::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 2, 1, 0);
|
||||
if (Abilities::SkillTable[plr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||
Abilities::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 2, 1, bitFlag);*/
|
||||
}
|
||||
|
||||
sendToGroup(group, (void*)&respbuf, P_FE2CL_PC_GROUP_LEAVE, resplen);
|
||||
|
@ -475,10 +475,8 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
resp2.PCRegenDataForOtherPC.iAngle = plr->angle;
|
||||
|
||||
if (plr->group != nullptr) {
|
||||
// TODO ABILITIES
|
||||
//int bitFlag = plr->group->conditionBitFlag;
|
||||
//resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->iConditionBitFlag = plr->iSelfConditionBitFlag | bitFlag;
|
||||
|
||||
|
||||
resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->getCompositeCondition();
|
||||
resp2.PCRegenDataForOtherPC.iPCState = plr->iPCState;
|
||||
resp2.PCRegenDataForOtherPC.iSpecialState = plr->iSpecialState;
|
||||
resp2.PCRegenDataForOtherPC.Nano = plr->Nanos[plr->activeNano];
|
||||
|
@ -122,7 +122,21 @@ enum {
|
||||
ETBU_NONE = 0,
|
||||
ETBU_ADD = 1,
|
||||
ETBU_DEL = 2,
|
||||
ETBU_CHANGE = 3
|
||||
ETBU_CHANGE = 3,
|
||||
ETBU__END = 4,
|
||||
};
|
||||
|
||||
enum {
|
||||
ETBT_NONE = 0,
|
||||
ETBT_NANO = 1,
|
||||
ETBT_GROUPNANO = 2,
|
||||
ETBT_SHINY = 3,
|
||||
ETBT_LANDEFFECT = 4,
|
||||
ETBT_ITEM = 5,
|
||||
ETBT_CASHITEM = 6,
|
||||
ETBT__END = 7,
|
||||
ETBT_SKILL = 1,
|
||||
ETBT_GROUPSKILL = 2
|
||||
};
|
||||
|
||||
enum {
|
||||
|
Loading…
Reference in New Issue
Block a user