Make sure all spell references are removed when a spell is removed from an entity
This commit is contained in:
parent
31e8f782ce
commit
c25ac12cd6
@ -872,6 +872,16 @@ lua_State* LuaInterface::LoadLuaFile(const char* name) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaInterface::RemoveSpawnFromSpell(LuaSpell* spell, Spawn* spawn) {
|
||||||
|
if(spawn->IsEntity()) {
|
||||||
|
((Entity*)spawn)->RemoveProc(0, spell);
|
||||||
|
((Entity*)spawn)->RemoveSpellEffect(spell);
|
||||||
|
((Entity*)spawn)->RemoveSpellBonus(spell);
|
||||||
|
((Entity*)spawn)->RemoveEffectsFromLuaSpell(spell);
|
||||||
|
((Entity*)spawn)->RemoveWard(spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool can_delete, string reason, bool removing_all_spells, bool return_after_call_remove, Spawn* overrideTarget) {
|
void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool can_delete, string reason, bool removing_all_spells, bool return_after_call_remove, Spawn* overrideTarget) {
|
||||||
if(call_remove_function){
|
if(call_remove_function){
|
||||||
lua_getglobal(spell->state, "remove");
|
lua_getglobal(spell->state, "remove");
|
||||||
@ -944,10 +954,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
|
|||||||
|
|
||||||
if(return_after_call_remove) {
|
if(return_after_call_remove) {
|
||||||
if(overrideTarget && overrideTarget->IsEntity()) {
|
if(overrideTarget && overrideTarget->IsEntity()) {
|
||||||
((Entity*)overrideTarget)->RemoveProc(0, spell);
|
RemoveSpawnFromSpell(spell, overrideTarget);
|
||||||
((Entity*)overrideTarget)->RemoveSpellEffect(spell);
|
|
||||||
((Entity*)overrideTarget)->RemoveSpellBonus(spell);
|
|
||||||
((Entity*)overrideTarget)->RemoveEffectsFromLuaSpell(spell);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -961,10 +968,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
|
|||||||
if (!target || !target->IsEntity())
|
if (!target || !target->IsEntity())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
((Entity*)target)->RemoveProc(0, spell);
|
RemoveSpawnFromSpell(spell, target);
|
||||||
((Entity*)target)->RemoveSpellEffect(spell);
|
|
||||||
((Entity*)target)->RemoveSpellBonus(spell);
|
|
||||||
((Entity*)target)->RemoveEffectsFromLuaSpell(spell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
multimap<int32,int8>::iterator entries;
|
multimap<int32,int8>::iterator entries;
|
||||||
@ -973,10 +977,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
|
|||||||
Client* tmpClient = zone_list.GetClientByCharID(entries->first);
|
Client* tmpClient = zone_list.GetClientByCharID(entries->first);
|
||||||
if(tmpClient && tmpClient->GetPlayer())
|
if(tmpClient && tmpClient->GetPlayer())
|
||||||
{
|
{
|
||||||
tmpClient->GetPlayer()->RemoveProc(0, spell);
|
RemoveSpawnFromSpell(spell, tmpClient->GetPlayer());
|
||||||
tmpClient->GetPlayer()->RemoveSpellEffect(spell);
|
|
||||||
tmpClient->GetPlayer()->RemoveSpellBonus(spell);
|
|
||||||
tmpClient->GetPlayer()->RemoveEffectsFromLuaSpell(spell);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spell->char_id_targets.clear(); // TODO: reach out to those clients in different
|
spell->char_id_targets.clear(); // TODO: reach out to those clients in different
|
||||||
@ -997,10 +998,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
|
|||||||
if(spell->zone && spell->zone->GetSpellProcess()) {
|
if(spell->zone && spell->zone->GetSpellProcess()) {
|
||||||
spell->zone->GetSpellProcess()->RemoveSpellScriptTimerBySpell(spell, false);
|
spell->zone->GetSpellProcess()->RemoveSpellScriptTimerBySpell(spell, false);
|
||||||
}
|
}
|
||||||
spell->caster->RemoveProc(0, spell);
|
RemoveSpawnFromSpell(spell, spell->caster);
|
||||||
spell->caster->RemoveSpellEffect(spell);
|
|
||||||
spell->caster->RemoveMaintainedSpell(spell);
|
|
||||||
spell->caster->RemoveEffectsFromLuaSpell(spell);
|
|
||||||
|
|
||||||
if(spell->spell && spell->spell->GetSpellData() && spell->caster->IsPlayer() && !removing_all_spells)
|
if(spell->spell && spell->spell->GetSpellData() && spell->caster->IsPlayer() && !removing_all_spells)
|
||||||
{
|
{
|
||||||
@ -1745,7 +1743,7 @@ void LuaInterface::DeletePendingSpells(bool all) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(target->IsEntity()) {
|
if(target->IsEntity()) {
|
||||||
((Entity*)target)->RemoveWard(spell);
|
RemoveSpawnFromSpell(spell, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
|
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
|
||||||
|
@ -237,6 +237,7 @@ public:
|
|||||||
bool LoadRegionScript(const char* name);
|
bool LoadRegionScript(const char* name);
|
||||||
LuaSpell* LoadSpellScript(string name);
|
LuaSpell* LoadSpellScript(string name);
|
||||||
LuaSpell* LoadSpellScript(const char* name);
|
LuaSpell* LoadSpellScript(const char* name);
|
||||||
|
void RemoveSpawnFromSpell(LuaSpell* spell, Spawn* spawn);
|
||||||
void RemoveSpell(LuaSpell* spell, bool call_remove_function = true, bool can_delete = true, string reason = "", bool removing_all_spells = false, bool return_after_call_remove = false, Spawn* overrideTarget = nullptr);
|
void RemoveSpell(LuaSpell* spell, bool call_remove_function = true, bool can_delete = true, string reason = "", bool removing_all_spells = false, bool return_after_call_remove = false, Spawn* overrideTarget = nullptr);
|
||||||
Spawn* GetSpawn(lua_State* state, int8 arg_num = 1);
|
Spawn* GetSpawn(lua_State* state, int8 arg_num = 1);
|
||||||
Item* GetItem(lua_State* state, int8 arg_num = 1);
|
Item* GetItem(lua_State* state, int8 arg_num = 1);
|
||||||
|
@ -1207,7 +1207,7 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
|
|||||||
((Entity*)tmpTarget)->RemoveEffectsFromLuaSpell(conflictSpell);
|
((Entity*)tmpTarget)->RemoveEffectsFromLuaSpell(conflictSpell);
|
||||||
zone->RemoveTargetFromSpell(conflictSpell, tmpTarget, false);
|
zone->RemoveTargetFromSpell(conflictSpell, tmpTarget, false);
|
||||||
CheckRemoveTargetFromSpell(conflictSpell);
|
CheckRemoveTargetFromSpell(conflictSpell);
|
||||||
((Entity*)tmpTarget)->RemoveSpellEffect(conflictSpell);
|
lua_interface->RemoveSpawnFromSpell(conflictSpell, tmpTarget);
|
||||||
if(client && IsReady(conflictSpell->spell, client->GetPlayer()))
|
if(client && IsReady(conflictSpell->spell, client->GetPlayer()))
|
||||||
UnlockSpell(client, conflictSpell->spell);
|
UnlockSpell(client, conflictSpell->spell);
|
||||||
}
|
}
|
||||||
@ -3013,7 +3013,7 @@ void SpellProcess::DeleteSpell(LuaSpell* spell)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(target->IsEntity()) {
|
if(target->IsEntity()) {
|
||||||
((Entity*)target)->RemoveWard(spell);
|
lua_interface->RemoveSpawnFromSpell(spell, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
|
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user