Groundwork for new buff system

This commit is contained in:
gsemaj 2022-05-18 10:04:28 -04:00
parent fd664c4f19
commit 398e9fddf8
4 changed files with 44 additions and 34 deletions

View File

@ -17,35 +17,37 @@ static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) {
}
*/
std::vector<EntityRef> Abilities::matchTargets(SkillData *skill, int count, int32_t *ids) {
std::vector<int> tempTargs;
switch (skill->effectTarget)
{
case SkillEffectTarget::POINT:
std::cout << "[SKILL] POINT; ";
break;
case SkillEffectTarget::SELF:
std::cout << "[SKILL] SELF; ";
break;
case SkillEffectTarget::CONE:
std::cout << "[SKILL] CONE; ";
break;
case SkillEffectTarget::AREA_SELF:
std::cout << "[SKILL] AREA_SELF; ";
break;
case SkillEffectTarget::AREA_TARGET:
std::cout << "[SKILL] AREA_TARGET; ";
break;
}
for (int i = 0; i < count; i++) std::cout << ids[i] << " ";
std::cout << std::endl;
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
}
}
void Abilities::init() {
//REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EMAIL_UPDATE_CHECK, emailUpdateCheck);
}

View File

@ -14,8 +14,8 @@ enum class SkillEffectTarget {
enum class SkillTargetType {
MOBS = 1,
PLAYERS = 2,
SELF = 3 // only used once by client /shrug
SELF = 2,
GROUP = 3
};
struct SkillData {
@ -37,5 +37,7 @@ namespace Abilities {
extern std::map<int32_t, SkillData> SkillTable;
std::vector<EntityRef> matchTargets(SkillData*, int, int32_t*);
void applyAbility(SkillData*, EntityRef, std::vector<EntityRef>);
void init();
}

View File

@ -12,7 +12,7 @@ enum EntityKind;
struct Group {
std::vector<EntityRef> members;
int32_t conditionBitFlag;
int8_t conditionCounters[32];
std::vector<EntityRef> filter(EntityKind kind) {
std::vector<EntityRef> filtered;

View File

@ -85,15 +85,16 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
plr->nanoDrainRate = 0;
int16_t skillID = plr->Nanos[plr->activeNano].iSkillID;
SkillData* skillData = &Abilities::SkillTable[skillID];
std::vector<EntityRef> targetData;
// passive nano unbuffing
if (skillData->batteryDrainType == 2) {
// TODO ABILITIES
std::vector<EntityRef> targetData = Abilities::matchTargets(skillData, 0, nullptr);
targetData.push_back(sock); // self
if (skillData->targetType == SkillTargetType::GROUP && plr->group != nullptr)
targetData = plr->group->members; // whole group
/*for (auto& pwr : Abilities::Powers)
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
Abilities::removeBuff(sock, targetData, pwr.bitFlag, pwr.timeBuffID, 0,(Abilities::SkillTable[skillID].targetType == 3));*/
/* TODO ABILITIES */
targetData.clear();
}
if (nanoID >= NANO_COUNT || nanoID < 0)
@ -101,13 +102,18 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
plr->activeNano = nanoID;
skillID = plr->Nanos[nanoID].iSkillID;
skillData = &Abilities::SkillTable[skillID];
// passive nano buffing
if (Abilities::SkillTable[skillID].batteryDrainType == 2) {
if (skillData->batteryDrainType == 2) {
int boost = 0;
if (getNanoBoost(plr))
boost = 1;
targetData.push_back(sock); // self
if (skillData->targetType == SkillTargetType::GROUP && plr->group != nullptr)
targetData = plr->group->members; // whole group
// TODO ABILITIES
//std::vector<int> targetData = Abilities::findTargets(plr, skillID);
//for (auto& pwr : Abilities::Powers) {