From 653d504c8dd41c627d04ffcd79b511bb19dd4b50 Mon Sep 17 00:00:00 2001 From: Emagi Date: Fri, 15 Aug 2025 18:17:33 -0400 Subject: [PATCH] added tracking of spell recast when player zones so we know not to re-add buffs to existing players --- source/WorldServer/LuaFunctions.cpp | 6 +++++- source/WorldServer/LuaInterface.cpp | 2 ++ source/WorldServer/LuaInterface.h | 1 + source/WorldServer/SpellProcess.cpp | 2 ++ source/WorldServer/WorldDatabase.cpp | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/WorldServer/LuaFunctions.cpp b/source/WorldServer/LuaFunctions.cpp index b10f3f6..b1e9e74 100644 --- a/source/WorldServer/LuaFunctions.cpp +++ b/source/WorldServer/LuaFunctions.cpp @@ -6565,6 +6565,9 @@ int EQ2Emu_lua_AddWard(lua_State* state) { if (!target) continue; if (target->IsEntity()) { + if(spell->is_loaded_recast && ((Entity*)target)->GetWard(spell->spell->GetSpellID())) // recast of spell, skip readding ward if they have it + continue; + // If the ward is already active remove it if (((Entity*)target)->GetWard(spell->spell->GetSpellID())) ((Entity*)target)->RemoveWard(spell->spell->GetSpellID()); @@ -6646,8 +6649,9 @@ int EQ2Emu_lua_AddToWard(lua_State* state) { ward->DamageLeft = ward->BaseDamage; for (int32 id : spell->GetTargets()) { - if (Spawn* spawn = zone->GetSpawnByID(id)) + if (Spawn* spawn = zone->GetSpawnByID(id)) { zone->SendHealPacket(ward->Spell->caster, spawn, HEAL_PACKET_TYPE_REGEN_ABSORB, amount, ward->Spell->spell->GetName()); + } } } } diff --git a/source/WorldServer/LuaInterface.cpp b/source/WorldServer/LuaInterface.cpp index 8a88094..ad19c74 100644 --- a/source/WorldServer/LuaInterface.cpp +++ b/source/WorldServer/LuaInterface.cpp @@ -2326,6 +2326,7 @@ LuaSpell* LuaInterface::LoadSpellScript(const char* name) { spell->initial_target_char_id = 0; spell->zone = nullptr; spell->initial_caster_level = 0; + spell->is_loaded_recast = false; MSpells.lock(); current_spells[spell->state] = spell; @@ -2678,6 +2679,7 @@ LuaSpell* LuaInterface::CreateSpellScript(const char* name, lua_State* existStat new_spell->initial_target_char_id = 0; new_spell->zone = nullptr; new_spell->initial_caster_level = 0; + new_spell->is_loaded_recast = false; current_spells[new_spell->state] = new_spell; return new_spell; diff --git a/source/WorldServer/LuaInterface.h b/source/WorldServer/LuaInterface.h index e3999f9..4b5defa 100644 --- a/source/WorldServer/LuaInterface.h +++ b/source/WorldServer/LuaInterface.h @@ -121,6 +121,7 @@ struct LuaSpell{ std::atomic has_proc; ZoneServer* zone; int16 initial_caster_level; + bool is_loaded_recast; std::unordered_set modified_fields; mutable std::shared_mutex spell_modify_mutex; diff --git a/source/WorldServer/SpellProcess.cpp b/source/WorldServer/SpellProcess.cpp index fd5fac1..61d71fa 100644 --- a/source/WorldServer/SpellProcess.cpp +++ b/source/WorldServer/SpellProcess.cpp @@ -651,6 +651,7 @@ bool SpellProcess::CastInstant(Spell* spell, Entity* caster, Entity* target, boo lua_spell->spell = spell; lua_spell->initial_target = target->GetID(); lua_spell->initial_target_char_id = (target && target->IsPlayer()) ? ((Player*)target)->GetCharacterID() : 0; + lua_spell->is_loaded_recast = false; GetSpellTargets(lua_spell); PrintTargets(lua_spell, "instant"); @@ -1095,6 +1096,7 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster, lua_spell->zone = caster->GetZone(); lua_spell->initial_caster_char_id = (caster && caster->IsPlayer()) ? ((Player*)caster)->GetCharacterID() : 0; lua_spell->spell = spell; + lua_spell->is_loaded_recast = false; int32 target_id = target->GetID(); lua_spell->initial_target = target_id; diff --git a/source/WorldServer/WorldDatabase.cpp b/source/WorldServer/WorldDatabase.cpp index 6aa9064..6cb1d70 100644 --- a/source/WorldServer/WorldDatabase.cpp +++ b/source/WorldServer/WorldDatabase.cpp @@ -8347,6 +8347,8 @@ void WorldDatabase::LoadCharacterSpellEffects(int32 char_id, Client* client, int lua_spell->is_damage_spell = has_damaged; lua_spell->initial_caster_level = caster_level; } + + lua_spell->is_loaded_recast = true; if(lua_spell->initial_target == 0 && target_char_id == 0xFFFFFFFF && player->HasPet()) {