added tracking of spell recast when player zones so we know not to re-add buffs to existing players

This commit is contained in:
Emagi 2025-08-15 18:17:33 -04:00
parent fa44363a97
commit 653d504c8d
5 changed files with 12 additions and 1 deletions

View File

@ -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,11 +6649,12 @@ 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());
}
}
}
}
if (ward && spell->caster->IsPlayer())
ClientPacketFunctions::SendMaintainedExamineUpdate(((Player*)spell->caster)->GetClient(), spell->slot_pos, ward->DamageLeft, 1);

View File

@ -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;

View File

@ -121,6 +121,7 @@ struct LuaSpell{
std::atomic<bool> has_proc;
ZoneServer* zone;
int16 initial_caster_level;
bool is_loaded_recast;
std::unordered_set<std::string> modified_fields;
mutable std::shared_mutex spell_modify_mutex;

View File

@ -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;

View File

@ -8348,6 +8348,8 @@ void WorldDatabase::LoadCharacterSpellEffects(int32 char_id, Client* client, int
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())
{
lua_spell->initial_target = player->GetPet()->GetID();