From 5e049d41e0674674f85ba0d0b8fc8fe403c54ca5 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Sun, 18 Jul 2021 22:04:07 -0400 Subject: [PATCH] Fix for bolt spell targeting self if target zone/died while casting. Fix for bolt spell targeting self if target zone/died while casting. Despite the name being "ST_TargetOptional", this target type is reserved for projectile spells which all require a target, thus should be treated like any other targeted spell. --- common/spdat.h | 2 +- zone/spells.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common/spdat.h b/common/spdat.h index 10b079324..4dbbc7bbb 100644 --- a/common/spdat.h +++ b/common/spdat.h @@ -279,7 +279,7 @@ enum RESISTTYPE //Target Type IDs typedef enum { -/* 01 */ ST_TargetOptional = 0x01, +/* 01 */ ST_TargetOptional = 0x01, //only used for targeted projectile spells /* 02 */ ST_AEClientV1 = 0x02, /* 03 */ ST_GroupTeleport = 0x03, /* 04 */ ST_AECaster = 0x04, diff --git a/zone/spells.cpp b/zone/spells.cpp index 2962ee81f..c246c79a8 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -406,8 +406,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, spell.targettype == ST_Self || spell.targettype == ST_AECaster || spell.targettype == ST_Ring || - spell.targettype == ST_Beam || - spell.targettype == ST_TargetOptional) && target_id == 0) + spell.targettype == ST_Beam) && target_id == 0) { LogSpells("Spell [{}] auto-targeted the caster. Group? [{}], target type [{}]", spell_id, IsGroupSpell(spell_id), spell.targettype); target_id = GetID(); @@ -1585,8 +1584,12 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce case ST_TargetOptional: { - if(!spell_target) - spell_target = this; + if (!spell_target) + { + LogSpells("Spell [{}] canceled: invalid target (normal)", spell_id); + MessageString(Chat::Red, SPELL_NEED_TAR); + return false; // can't cast these unless we have a target + } CastAction = SingleTarget; break; }