Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/map/entities/battleentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "ai/states/weaponskill_state.h"
#include "attack.h"
#include "attackround.h"
#include "blue_spell.h"
#include "items/item_weapon.h"
#include "job_points.h"
#include "lua/luautils.h"
Expand Down Expand Up @@ -2306,6 +2307,7 @@ void CBattleEntity::OnCastFinished(CMagicState& state, action_t& action)

for (auto* PTarget : PAI->TargetFind->m_targets)
{
// Reset the spell's message to prevent any state carryover between targets
PSpell->setMessage(initialSpellMessage);

action_target_t& actionTarget = action.addTarget(PTarget->id);
Expand Down Expand Up @@ -2361,7 +2363,7 @@ void CBattleEntity::OnCastFinished(CMagicState& state, action_t& action)

actionResult.param = damage;

// spell failed to apply
// Handle spell failed to apply
if (!PSpell->tookEffect())
{
actionResult.resolution = ActionResolution::Miss;
Expand Down Expand Up @@ -2405,6 +2407,32 @@ void CBattleEntity::OnCastFinished(CMagicState& state, action_t& action)
msg != MsgBasic::ShadowAbsorb) // If message isn't the shadow loss message, because I had to move this outside of the above check for it.
{
luautils::OnMagicHit(this, PTarget, PSpell);

// Process Blu Spell based Actions
if (PSpell->getSpellGroup() == SPELLGROUP_BLUE && PSpell->getMessage() != MsgBasic::MagicFail)
{
if (auto* PBlueSpell = dynamic_cast<CBlueSpell*>(PSpell))
{
// Physical Blue Spells trigger HitDistortion - using the existence of a Primary Skillchain element as a physical indicator
if (PBlueSpell->getPrimarySkillchain() != 0)
{
// This will set the Hit Distortion field
actionResult.recordDamage(attack_outcome_t{
.atkType = ATTACK_TYPE::PHYSICAL,
.damage = damage,
.target = PTarget,
.isCritical = false, // ToDo: Get Critical status from spell processing
});
}

// Some Physical Blue Spells present with a knockback effect - using knockback on linked Mob Skill to determine which
CMobSkill* mobSkillForBlueSpell = battleutils::GetMobSkill(PBlueSpell->getMonsterSkillId());
if (mobSkillForBlueSpell)
{
actionResult.knockback = mobSkillForBlueSpell->getKnockback();
}
}
}
}

// The entity under consideration for RoE objective credit
Expand Down
Loading