From 8586cdc47e29a64d485b7aa2aa9fa68ce8882889 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Wed, 8 Jun 2022 19:09:33 -0400 Subject: [PATCH] [Messages] Convert messages from Spells to FocusEffect where necessary. (#2243) * [Messages] Convert messages from Spells to FocusEffect where necessary. https://github.com/EQEmu/Server/issues/837 from 2019 notes a couple places that should use Focus Effect chat type instead of Spells chat type. * Add rule for item cast messages. --- common/ruletypes.h | 1 + zone/merc.cpp | 2 +- zone/special_attacks.cpp | 2 +- zone/spell_effects.cpp | 2 +- zone/spells.cpp | 53 ++++++++++++++++++++-------------------- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index 684d71651..248eaad5f 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -416,6 +416,7 @@ RULE_BOOL(Spells, FixBeaconHeading, false, "Beacon spells use casters heading to RULE_BOOL(Spells, UseSpellImpliedTargeting, false, "Replicates EQ2-style targeting behavior for spells. Spells will 'pass through' inappropriate targets to target's target if it is appropriate.") RULE_BOOL(Spells, BuffsFadeOnDeath, true, "Disable to keep buffs from fading on death") RULE_BOOL(Spells, IllusionsAlwaysPersist, false, "Allows Illusions to persist beyond death and zoning always.") +RULE_BOOL(Spells, UseItemCastMessage, false, "Enable to use the \"item begins to glow\" messages when casting from an item.") RULE_CATEGORY_END() RULE_CATEGORY(Combat) diff --git a/zone/merc.cpp b/zone/merc.cpp index c761818d6..ef1084aaa 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2616,7 +2616,7 @@ int64 Merc::GetFocusEffect(focusType type, uint16 spell_id, bool from_buff_tic) realTotal = CalcFocusEffect(type, UsedFocusID, spell_id); if (realTotal != 0 && UsedItem) - MessageString(Chat::Spells, BEGINS_TO_GLOW, UsedItem->Name); + MessageString(Chat::FocusEffect, BEGINS_TO_GLOW, UsedItem->Name); } //Check if spell focus effect exists for the client. diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 17f6f6e9c..42ec7658a 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -180,7 +180,7 @@ void Mob::DoSpecialAttackDamage(Mob *who, EQ::skills::SkillType skill, int32 bas auto fbash = GetFuriousBash(itm->Focus.Effect); hate = hate * (100 + fbash) / 100; if (fbash) - MessageString(Chat::Spells, GLOWS_RED, itm->Name); + MessageString(Chat::FocusEffect, GLOWS_RED, itm->Name); } } } diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 2230a8147..8382d03a1 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -6497,7 +6497,7 @@ int64 Client::GetFocusEffect(focusType type, uint16 spell_id, Mob *caster, bool default: break; } - MessageString(Chat::Spells, string_id, UsedItem->Name); + MessageString(Chat::FocusEffect, string_id, UsedItem->Name); } } diff --git a/zone/spells.cpp b/zone/spells.cpp index a7b518655..cabe198f4 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -302,8 +302,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, casting_spell_id = spell_id; casting_spell_slot = slot; casting_spell_inventory_slot = item_slot; - if(casting_spell_timer != 0xFFFFFFFF) - { + if (casting_spell_timer != 0xFFFFFFFF) { casting_spell_timer = timer; casting_spell_timer_duration = timer_duration; } @@ -352,13 +351,16 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, // if this spell doesn't require a target, or if it's an optional target // and a target wasn't provided, then it's us; unless TGB is on and this // is a TGB compatible spell. - if((IsGroupSpell(spell_id) || - spell.target_type == ST_AEClientV1 || - spell.target_type == ST_Self || - spell.target_type == ST_AECaster || - spell.target_type == ST_Ring || - spell.target_type == ST_Beam) && target_id == 0) - { + if ( + ( + IsGroupSpell(spell_id) || + spell.target_type == ST_AEClientV1 || + spell.target_type == ST_Self || + spell.target_type == ST_AECaster || + spell.target_type == ST_Ring || + spell.target_type == ST_Beam + ) && target_id == 0 + ) { LogSpells("Spell [{}] auto-targeted the caster. Group? [{}], target type [{}]", spell_id, IsGroupSpell(spell_id), spell.target_type); target_id = GetID(); } @@ -377,8 +379,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, if (cast_time) { cast_time = GetActSpellCasttime(spell_id, cast_time); } - } - else { + } else { orgcasttime = cast_time; } @@ -408,23 +409,21 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, // If you're at full mana, let it cast even if you dont have enough mana // we calculated this above, now enforce it - if(mana_cost > 0 && slot != CastingSlot::Item) { + if (mana_cost > 0 && slot != CastingSlot::Item) { int my_curmana = GetMana(); int my_maxmana = GetMaxMana(); - if(my_curmana < mana_cost) {// not enough mana + if (my_curmana < mana_cost) {// not enough mana //this is a special case for NPCs with no mana... - if(IsNPC() && my_curmana == my_maxmana){ + if (IsNPC() && my_curmana == my_maxmana){ mana_cost = 0; - } - else { + } else { //The client will prevent spell casting if insufficient mana, this is only for serverside enforcement. LogSpells("Spell Error not enough mana spell=[{}] mymana=[{}] cost=[{}]\n", spell_id, my_curmana, mana_cost); - if(IsClient()) { + if (IsClient()) { //clients produce messages... npcs should not for this case MessageString(Chat::Red, INSUFFICIENT_MANA); InterruptSpell(); - } - else { + } else { InterruptSpell(0, 0, 0); //the 0 args should cause no messages } ZeroCastingVars(); @@ -463,22 +462,24 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, // ok we know it has a cast time so we can start the timer now spellend_timer.Start(cast_time); - if (IsAIControlled()) - { + if (IsAIControlled()) { SetRunAnimSpeed(0); pMob = entity_list.GetMob(target_id); - if (pMob && this != pMob) + if (pMob && this != pMob) { FaceTarget(pMob); + } } // if we got here we didn't fizzle, and are starting our cast - if (oSpellWillFinish) + if (oSpellWillFinish) { *oSpellWillFinish = Timer::GetCurrentTime() + cast_time + 100; + } - if (IsClient() && slot == CastingSlot::Item && item_slot != 0xFFFFFFFF) { + if (RuleB(Spells, UseItemCastMessage) && IsClient() && slot == CastingSlot::Item && item_slot != 0xFFFFFFFF) { auto item = CastToClient()->GetInv().GetItem(item_slot); - if (item && item->GetItem()) - MessageString(Chat::Spells, BEGINS_TO_GLOW, item->GetItem()->Name); + if (item && item->GetItem()) { + MessageString(Chat::FocusEffect, BEGINS_TO_GLOW, item->GetItem()->Name); + } } return(true);