mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
egg prep
This commit is contained in:
parent
462ced6685
commit
daec7a33b7
@ -74,15 +74,35 @@ static void timeBuffUpdate(EntityRef self, BuffStack* buff, int type) {
|
|||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt);
|
||||||
pkt.eCSTB = buff->id; // eCharStatusTimeBuffID
|
pkt.eCSTB = buff->id; // eCharStatusTimeBuffID
|
||||||
pkt.eTBU = type; // eTimeBuffUpdate
|
pkt.eTBU = type; // eTimeBuffUpdate
|
||||||
pkt.eTBT = (buff->buffClass <= BuffClass::CONSUMABLE); // eTimeBuffType 1 means nano
|
pkt.eTBT = (int)buff->buffClass;
|
||||||
pkt.iConditionBitFlag = plr->getCompositeCondition();
|
pkt.iConditionBitFlag = plr->getCompositeCondition();
|
||||||
self.sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
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) {
|
void Buffs::timeBuffUpdateAdd(EntityRef self, BuffStack* buff) {
|
||||||
timeBuffUpdate(self, buff, ETBU_ADD);
|
timeBuffUpdate(self, buff, ETBU_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffs::timeBuffUpdateDelete(EntityRef self, BuffStack* buff) {
|
void Buffs::timeBuffUpdateDelete(EntityRef self, BuffStack* buff) {
|
||||||
timeBuffUpdate(self, buff, ETBU_DEL);
|
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))
|
#define CSB_FROM_ECSB(x) (1 << (x - 1))
|
||||||
|
|
||||||
enum class BuffClass {
|
enum class BuffClass {
|
||||||
NANO = 0,
|
NONE = ETBT_NONE,
|
||||||
CONSUMABLE,
|
NANO = ETBT_NANO,
|
||||||
EGG,
|
GROUP_NANO = ETBT_GROUPNANO,
|
||||||
OTHER
|
EGG = ETBT_SHINY,
|
||||||
|
ENVIRONMENT = ETBT_LANDEFFECT,
|
||||||
|
ITEM = ETBT_ITEM,
|
||||||
|
CASH_ITEM = ETBT_CASHITEM
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*BuffCallback)(EntityRef, BuffStack*);
|
typedef void (*BuffCallback)(EntityRef, BuffStack*);
|
||||||
@ -70,4 +73,5 @@ public:
|
|||||||
namespace Buffs {
|
namespace Buffs {
|
||||||
void timeBuffUpdateAdd(EntityRef self, BuffStack* buff);
|
void timeBuffUpdateAdd(EntityRef self, BuffStack* buff);
|
||||||
void timeBuffUpdateDelete(EntityRef self, BuffStack* buff);
|
void timeBuffUpdateDelete(EntityRef self, BuffStack* buff);
|
||||||
|
void timeBuffTimeout(EntityRef self, BuffStack* buff);
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ static void dotDamageOnOff(CNSocket *sock, CNPacketData *data) {
|
|||||||
ECSB_INFECTION,
|
ECSB_INFECTION,
|
||||||
-1, // infinite
|
-1, // infinite
|
||||||
sock, // self-inflicted
|
sock, // self-inflicted
|
||||||
BuffClass::OTHER,
|
BuffClass::ENVIRONMENT,
|
||||||
Buffs::timeBuffUpdateAdd,
|
Buffs::timeBuffUpdateAdd,
|
||||||
nullptr, // client ticks for us! todo anticheat lol
|
nullptr, // client ticks for us! todo anticheat lol
|
||||||
Buffs::timeBuffUpdateDelete
|
Buffs::timeBuffUpdateDelete
|
||||||
|
52
src/Eggs.cpp
52
src/Eggs.cpp
@ -13,16 +13,12 @@
|
|||||||
|
|
||||||
using namespace Eggs;
|
using namespace Eggs;
|
||||||
|
|
||||||
/// sock, CBFlag -> until
|
|
||||||
std::map<std::pair<CNSocket*, int32_t>, time_t> Eggs::EggBuffs;
|
|
||||||
std::unordered_map<int, EggType> Eggs::EggTypes;
|
std::unordered_map<int, EggType> Eggs::EggTypes;
|
||||||
|
|
||||||
int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// TODO ABILITIES
|
// TODO ABILITIES
|
||||||
//int bitFlag = plr->group->conditionBitFlag;
|
|
||||||
int CBFlag = 0;// Abilities::applyBuff(sock, skillId, 1, 3, bitFlag);
|
|
||||||
|
|
||||||
size_t resplen;
|
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);
|
sock->sendPacket((void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||||
PlayerManager::sendToViewable(sock, (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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eggStep(CNServer* serv, time_t currTime) {
|
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
|
// check dead eggs and eggs in inactive chunks
|
||||||
for (auto npc : NPCManager::NPCs) {
|
for (auto npc : NPCManager::NPCs) {
|
||||||
if (npc.second->kind != EntityKind::EGG)
|
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))
|
if (!egg->dead || !Chunking::inPopulatedChunks(&egg->viewableChunks))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (egg->deadUntil <= timeStamp) {
|
if (egg->deadUntil <= currTime) {
|
||||||
// respawn it
|
// respawn it
|
||||||
egg->dead = false;
|
egg->dead = false;
|
||||||
egg->deadUntil = 0;
|
egg->deadUntil = 0;
|
||||||
|
@ -10,7 +10,6 @@ struct EggType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace Eggs {
|
namespace Eggs {
|
||||||
extern std::map<std::pair<CNSocket*, int32_t>, time_t> EggBuffs;
|
|
||||||
extern std::unordered_map<int, EggType> EggTypes;
|
extern std::unordered_map<int, EggType> EggTypes;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
@ -149,7 +149,6 @@ static void joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp->iID_NewMember = plr->iID;
|
resp->iID_NewMember = plr->iID;
|
||||||
resp->iMemberPCCnt = players.size();
|
resp->iMemberPCCnt = players.size();
|
||||||
|
|
||||||
//int bitFlag = otherPlr->group->conditionBitFlag;
|
|
||||||
for (int i = 0; i < players.size(); i++) {
|
for (int i = 0; i < players.size(); i++) {
|
||||||
|
|
||||||
Player* varPlr = PlayerManager::getPlayer(players[i].sock);
|
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].iY = varPlr->y;
|
||||||
respdata[i].iZ = varPlr->z;
|
respdata[i].iZ = varPlr->z;
|
||||||
// client doesnt read nano data here
|
// 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);
|
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->iID_LeaveMember = plr->iID;
|
||||||
resp->iMemberPCCnt = players.size() - 1;
|
resp->iMemberPCCnt = players.size() - 1;
|
||||||
|
|
||||||
int bitFlag = 0; // TODO ABILITIES getGroupFlags(otherPlr) & ~plr->iGroupConditionBitFlag;
|
|
||||||
|
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->iID);
|
||||||
|
|
||||||
if (sock == nullptr)
|
if (sock == nullptr)
|
||||||
@ -326,13 +315,6 @@ void Groups::groupKick(Player* plr) {
|
|||||||
respdata[i].iY = varPlr->y;
|
respdata[i].iY = varPlr->y;
|
||||||
respdata[i].iZ = varPlr->z;
|
respdata[i].iZ = varPlr->z;
|
||||||
// client doesnt read nano data here
|
// 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);
|
sendToGroup(group, (void*)&respbuf, P_FE2CL_PC_GROUP_LEAVE, resplen);
|
||||||
|
@ -474,10 +474,8 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp2.PCRegenDataForOtherPC.iAngle = plr->angle;
|
resp2.PCRegenDataForOtherPC.iAngle = plr->angle;
|
||||||
|
|
||||||
if (plr->group != nullptr) {
|
if (plr->group != nullptr) {
|
||||||
// TODO ABILITIES
|
|
||||||
//int bitFlag = plr->group->conditionBitFlag;
|
resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->getCompositeCondition();
|
||||||
//resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->iConditionBitFlag = plr->iSelfConditionBitFlag | bitFlag;
|
|
||||||
|
|
||||||
resp2.PCRegenDataForOtherPC.iPCState = plr->iPCState;
|
resp2.PCRegenDataForOtherPC.iPCState = plr->iPCState;
|
||||||
resp2.PCRegenDataForOtherPC.iSpecialState = plr->iSpecialState;
|
resp2.PCRegenDataForOtherPC.iSpecialState = plr->iSpecialState;
|
||||||
resp2.PCRegenDataForOtherPC.Nano = plr->Nanos[plr->activeNano];
|
resp2.PCRegenDataForOtherPC.Nano = plr->Nanos[plr->activeNano];
|
||||||
|
@ -122,7 +122,21 @@ enum {
|
|||||||
ETBU_NONE = 0,
|
ETBU_NONE = 0,
|
||||||
ETBU_ADD = 1,
|
ETBU_ADD = 1,
|
||||||
ETBU_DEL = 2,
|
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 {
|
enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user