Compare commits

...

4 Commits

Author SHA1 Message Date
gsemaj
6d5cea0d9a
Return home heal to new system 2023-08-14 19:49:39 -07:00
gsemaj
fdd7d53aed
Passive mob buffs to new system 2023-08-14 19:44:23 -07:00
gsemaj
57f8f3e0e1
Move mob active skills to new system 2023-08-14 19:28:45 -07:00
gsemaj
a3008cab3c
Move eruption attacks to new system 2023-08-14 18:18:06 -07:00
2 changed files with 23 additions and 35 deletions

View File

@ -6,6 +6,7 @@
#include "PlayerManager.hpp"
#include "Buffs.hpp"
#include "Nanos.hpp"
#include "MobAI.hpp"
using namespace Abilities;
@ -364,6 +365,12 @@ void Abilities::useNPCSkill(EntityRef npc, int skillID, std::vector<ICombatant*>
pkt->iSkillID = skillID;
pkt->eST = (int32_t)skill->skillType;
pkt->iTargetCnt = (int32_t)results.size();
if(npc.kind == EntityKind::MOB) {
Mob* mob = dynamic_cast<Mob*>(entity);
pkt->iValue1 = mob->hitX;
pkt->iValue2 = mob->hitY;
pkt->iValue3 = mob->hitZ;
}
attachSkillResults(results, (uint8_t*)(pkt + 1));
NPCManager::sendToViewable(entity, pkt, P_FE2CL_NPC_SKILL_HIT, resplen);

View File

@ -326,12 +326,6 @@ static void dealCorruption(Mob *mob, std::vector<int> targetData, int skillID, i
}
static void useAbilities(Mob *mob, time_t currTime) {
/*
* targetData approach
* first integer is the count
* second to fifth integers are IDs, these can be either player iID or mob's iID
* whether the skill targets players or mobs is determined by the skill packet being fired
*/
Player *plr = PlayerManager::getPlayer(mob->target);
if (mob->skillStyle >= 0) { // corruption hit
@ -346,7 +340,7 @@ static void useAbilities(Mob *mob, time_t currTime) {
if (mob->skillStyle == -2) { // eruption hit
int skillID = (int)mob->data["m_iMegaType"];
std::vector<int> targetData = {0, 0, 0, 0, 0};
std::vector<ICombatant*> targets{};
// find the players within range of eruption
for (auto it = mob->viewableChunks.begin(); it != mob->viewableChunks.end(); it++) {
@ -356,26 +350,22 @@ static void useAbilities(Mob *mob, time_t currTime) {
if (ref.kind != EntityKind::PLAYER)
continue;
CNSocket *s= ref.sock;
CNSocket *s = ref.sock;
Player *plr = PlayerManager::getPlayer(s);
if (plr->HP <= 0)
if (!plr->isAlive())
continue;
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
if (distance < Abilities::SkillTable[skillID].effectArea) {
targetData[0] += 1;
targetData[targetData[0]] = plr->iID;
if (targetData[0] > 3) // make sure not to have more than 4
targets.push_back(plr);
if (targets.size() > 3) // make sure not to have more than 4
break;
}
}
}
// TODO ABILITIES
/*for (auto& pwr : Abilities::Powers)
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
pwr.handle(mob->id, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);*/
Abilities::useNPCSkill(mob->id, skillID, targets);
mob->skillStyle = -3; // eruption cooldown
mob->nextAttack = currTime + 1000;
return;
@ -393,14 +383,11 @@ static void useAbilities(Mob *mob, time_t currTime) {
if (random < prob1) { // active skill hit
int skillID = (int)mob->data["m_iActiveSkill1"];
// TODO ABILITIES
//std::vector<int> targetData = {1, plr->iID, 0, 0, 0};
//for (auto& pwr : Abilities::Powers)
// if (pwr.skillType == Abilities::SkillTable[skillID].skillType) {
// if (pwr.bitFlag != 0 && (plr->iConditionBitFlag & pwr.bitFlag))
// return; // prevent debuffing a player twice
// pwr.handle(mob->id, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);
// }
SkillData* skill = &Abilities::SkillTable[skillID];
int debuffID = Abilities::getCSTBFromST(skill->skillType);
if(plr->hasBuff(debuffID))
return; // prevent debuffing a player twice
Abilities::useNPCSkill(mob->getRef(), skillID, { plr });
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
return;
}
@ -754,11 +741,8 @@ void MobAI::onRoamStart(CombatNPC* npc, EntityRef src) {
self->nextAttack = 0;
// cast a return home heal spell, this is the right way(tm)
// TODO ABILITIES
/*std::vector<int> targetData = { 1, 0, 0, 0, 0 };
for (auto& pwr : Abilities::Powers)
if (pwr.skillType == Abilities::SkillTable[110].skillType)
pwr.handle(self->id, targetData, 110, Abilities::SkillTable[110].durationTime[0], Abilities::SkillTable[110].powerIntensity[0]);*/
Abilities::useNPCSkill(npc->getRef(), 110, { npc });
// clear outlying debuffs
clearDebuff(self);
}
@ -775,12 +759,9 @@ void MobAI::onCombatStart(CombatNPC* npc, EntityRef src) {
self->roamY = self->y;
self->roamZ = self->z;
int skillID = (int)self->data["m_iPassiveBuff"]; // cast passive
// TODO ABILITIES
/*std::vector<int> targetData = { 1, self->id, 0, 0, 0 };
for (auto& pwr : Abilities::Powers)
if (pwr.skillType == Abilities::SkillTable[skillID].skillType)
pwr.handle(self->id, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);*/
int skillID = (int)self->data["m_iPassiveBuff"];
if(skillID != 0) // cast passive
Abilities::useNPCSkill(npc->getRef(), skillID, { npc });
}
void MobAI::onRetreat(CombatNPC* npc, EntityRef src) {