Skip to content

Commit ed23454

Browse files
committed
Add HitDistortion and Knockback to Blu spells
1 parent 4205a3d commit ed23454

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

src/map/entities/battleentity.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "ai/states/weaponskill_state.h"
4141
#include "attack.h"
4242
#include "attackround.h"
43+
#include "blue_spell.h"
4344
#include "items/item_weapon.h"
4445
#include "job_points.h"
4546
#include "lua/luautils.h"
@@ -2306,6 +2307,7 @@ void CBattleEntity::OnCastFinished(CMagicState& state, action_t& action)
23062307

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

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

23622364
actionResult.param = damage;
23632365

2364-
// spell failed to apply
2366+
// Handle spell failed to apply
23652367
if (!PSpell->tookEffect())
23662368
{
23672369
actionResult.resolution = ActionResolution::Miss;
@@ -2405,6 +2407,32 @@ void CBattleEntity::OnCastFinished(CMagicState& state, action_t& action)
24052407
msg != MsgBasic::ShadowAbsorb) // If message isn't the shadow loss message, because I had to move this outside of the above check for it.
24062408
{
24072409
luautils::OnMagicHit(this, PTarget, PSpell);
2410+
2411+
// Process Blu Spell based Actions
2412+
if (PSpell->getSpellGroup() == SPELLGROUP_BLUE && PSpell->getMessage() != MsgBasic::MagicFail)
2413+
{
2414+
if (auto* PBlueSpell = dynamic_cast<CBlueSpell*>(PSpell))
2415+
{
2416+
// Physical Blue Spells trigger HitDistortion - using the existence of a Primary Skillchain element as a physical indicator
2417+
if (PBlueSpell->getPrimarySkillchain() != 0)
2418+
{
2419+
// This will set the Hit Distortion field
2420+
actionResult.recordDamage(attack_outcome_t{
2421+
.atkType = ATTACK_TYPE::PHYSICAL,
2422+
.damage = damage,
2423+
.target = PTarget,
2424+
.isCritical = false, // ToDo: Get Critical status from spell processing
2425+
});
2426+
}
2427+
2428+
// Some Physical Blue Spells present with a knockback effect - using knockback on linked Mob Skill to determine which
2429+
CMobSkill* mobSkillForBlueSpell = battleutils::GetMobSkill(PBlueSpell->getMonsterSkillId());
2430+
if (mobSkillForBlueSpell)
2431+
{
2432+
actionResult.knockback = mobSkillForBlueSpell->getKnockback();
2433+
}
2434+
}
2435+
}
24082436
}
24092437

24102438
// The entity under consideration for RoE objective credit

0 commit comments

Comments
 (0)