mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-06-24 05:10:24 +00:00
Compare commits
4 Commits
02fd17c0e7
...
6d5cea0d9a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6d5cea0d9a | ||
![]() |
fdd7d53aed | ||
![]() |
57f8f3e0e1 | ||
![]() |
a3008cab3c |
@ -6,6 +6,7 @@
|
|||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "Buffs.hpp"
|
#include "Buffs.hpp"
|
||||||
#include "Nanos.hpp"
|
#include "Nanos.hpp"
|
||||||
|
#include "MobAI.hpp"
|
||||||
|
|
||||||
using namespace Abilities;
|
using namespace Abilities;
|
||||||
|
|
||||||
@ -364,6 +365,12 @@ void Abilities::useNPCSkill(EntityRef npc, int skillID, std::vector<ICombatant*>
|
|||||||
pkt->iSkillID = skillID;
|
pkt->iSkillID = skillID;
|
||||||
pkt->eST = (int32_t)skill->skillType;
|
pkt->eST = (int32_t)skill->skillType;
|
||||||
pkt->iTargetCnt = (int32_t)results.size();
|
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));
|
attachSkillResults(results, (uint8_t*)(pkt + 1));
|
||||||
NPCManager::sendToViewable(entity, pkt, P_FE2CL_NPC_SKILL_HIT, resplen);
|
NPCManager::sendToViewable(entity, pkt, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||||
|
@ -326,12 +326,6 @@ static void dealCorruption(Mob *mob, std::vector<int> targetData, int skillID, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void useAbilities(Mob *mob, time_t currTime) {
|
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);
|
Player *plr = PlayerManager::getPlayer(mob->target);
|
||||||
|
|
||||||
if (mob->skillStyle >= 0) { // corruption hit
|
if (mob->skillStyle >= 0) { // corruption hit
|
||||||
@ -346,7 +340,7 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
|
|
||||||
if (mob->skillStyle == -2) { // eruption hit
|
if (mob->skillStyle == -2) { // eruption hit
|
||||||
int skillID = (int)mob->data["m_iMegaType"];
|
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
|
// find the players within range of eruption
|
||||||
for (auto it = mob->viewableChunks.begin(); it != mob->viewableChunks.end(); it++) {
|
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)
|
if (ref.kind != EntityKind::PLAYER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CNSocket *s= ref.sock;
|
CNSocket *s = ref.sock;
|
||||||
Player *plr = PlayerManager::getPlayer(s);
|
Player *plr = PlayerManager::getPlayer(s);
|
||||||
|
|
||||||
if (plr->HP <= 0)
|
if (!plr->isAlive())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
|
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
|
||||||
if (distance < Abilities::SkillTable[skillID].effectArea) {
|
if (distance < Abilities::SkillTable[skillID].effectArea) {
|
||||||
targetData[0] += 1;
|
targets.push_back(plr);
|
||||||
targetData[targetData[0]] = plr->iID;
|
if (targets.size() > 3) // make sure not to have more than 4
|
||||||
if (targetData[0] > 3) // make sure not to have more than 4
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO ABILITIES
|
Abilities::useNPCSkill(mob->id, skillID, targets);
|
||||||
/*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]);*/
|
|
||||||
mob->skillStyle = -3; // eruption cooldown
|
mob->skillStyle = -3; // eruption cooldown
|
||||||
mob->nextAttack = currTime + 1000;
|
mob->nextAttack = currTime + 1000;
|
||||||
return;
|
return;
|
||||||
@ -393,14 +383,11 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
|
|
||||||
if (random < prob1) { // active skill hit
|
if (random < prob1) { // active skill hit
|
||||||
int skillID = (int)mob->data["m_iActiveSkill1"];
|
int skillID = (int)mob->data["m_iActiveSkill1"];
|
||||||
// TODO ABILITIES
|
SkillData* skill = &Abilities::SkillTable[skillID];
|
||||||
//std::vector<int> targetData = {1, plr->iID, 0, 0, 0};
|
int debuffID = Abilities::getCSTBFromST(skill->skillType);
|
||||||
//for (auto& pwr : Abilities::Powers)
|
if(plr->hasBuff(debuffID))
|
||||||
// if (pwr.skillType == Abilities::SkillTable[skillID].skillType) {
|
return; // prevent debuffing a player twice
|
||||||
// if (pwr.bitFlag != 0 && (plr->iConditionBitFlag & pwr.bitFlag))
|
Abilities::useNPCSkill(mob->getRef(), skillID, { plr });
|
||||||
// return; // prevent debuffing a player twice
|
|
||||||
// pwr.handle(mob->id, targetData, skillID, Abilities::SkillTable[skillID].durationTime[0], Abilities::SkillTable[skillID].powerIntensity[0]);
|
|
||||||
// }
|
|
||||||
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -754,11 +741,8 @@ void MobAI::onRoamStart(CombatNPC* npc, EntityRef src) {
|
|||||||
self->nextAttack = 0;
|
self->nextAttack = 0;
|
||||||
|
|
||||||
// cast a return home heal spell, this is the right way(tm)
|
// cast a return home heal spell, this is the right way(tm)
|
||||||
// TODO ABILITIES
|
Abilities::useNPCSkill(npc->getRef(), 110, { npc });
|
||||||
/*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]);*/
|
|
||||||
// clear outlying debuffs
|
// clear outlying debuffs
|
||||||
clearDebuff(self);
|
clearDebuff(self);
|
||||||
}
|
}
|
||||||
@ -775,12 +759,9 @@ void MobAI::onCombatStart(CombatNPC* npc, EntityRef src) {
|
|||||||
self->roamY = self->y;
|
self->roamY = self->y;
|
||||||
self->roamZ = self->z;
|
self->roamZ = self->z;
|
||||||
|
|
||||||
int skillID = (int)self->data["m_iPassiveBuff"]; // cast passive
|
int skillID = (int)self->data["m_iPassiveBuff"];
|
||||||
// TODO ABILITIES
|
if(skillID != 0) // cast passive
|
||||||
/*std::vector<int> targetData = { 1, self->id, 0, 0, 0 };
|
Abilities::useNPCSkill(npc->getRef(), skillID, { npc });
|
||||||
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]);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MobAI::onRetreat(CombatNPC* npc, EntityRef src) {
|
void MobAI::onRetreat(CombatNPC* npc, EntityRef src) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user