mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-16 19:20:05 +00:00
c60c4dac38
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 - ???
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#include "Abilities.hpp"
|
|
|
|
#include "NPCManager.hpp"
|
|
#include "PlayerManager.hpp"
|
|
|
|
std::map<int32_t, SkillData> Abilities::SkillTable;
|
|
|
|
/*
|
|
// New email notification
|
|
static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) {
|
|
INITSTRUCT(sP_FE2CL_REP_PC_NEW_EMAIL, resp);
|
|
resp.iNewEmailCnt = Database::getUnreadEmailCount(PlayerManager::getPlayer(sock)->iID);
|
|
sock->sendPacket(resp, P_FE2CL_REP_PC_NEW_EMAIL);
|
|
}
|
|
*/
|
|
|
|
std::vector<EntityRef> Abilities::matchTargets(SkillData* skill, int count, int32_t *ids) {
|
|
|
|
std::vector<EntityRef> targets;
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
int32_t id = ids[i];
|
|
if (skill->targetType == SkillTargetType::MOBS) {
|
|
// mob?
|
|
if (NPCManager::NPCs.find(id) != NPCManager::NPCs.end()) targets.push_back(id);
|
|
else std::cout << "[WARN] skill: id not found\n";
|
|
} else {
|
|
// player?
|
|
CNSocket* sock = PlayerManager::getSockFromID(id);
|
|
if (sock != nullptr) targets.push_back(sock);
|
|
else std::cout << "[WARN] skill: sock not found\n";
|
|
}
|
|
}
|
|
|
|
return targets;
|
|
}
|
|
|
|
void Abilities::useAbility(SkillData* skill, EntityRef src, std::vector<EntityRef> targets) {
|
|
for (EntityRef target : targets) {
|
|
Entity* entity = target.getEntity();
|
|
if (entity->kind != PLAYER && entity->kind != COMBAT_NPC && entity->kind != MOB)
|
|
continue; // not a combatant
|
|
|
|
// TODO abilities
|
|
}
|
|
}
|
|
|
|
void Abilities::init() {
|
|
//REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EMAIL_UPDATE_CHECK, emailUpdateCheck);
|
|
}
|