• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore 3.3.5 Spell_Linked_Spell creating Infinite loop on disconnect

callmephil

Respected Member
hello i've got a quite annoying bug with Spell_linked_spell

Code:
DELETE FROM `Spell_Linked_Spell` WHERE `spell_effect` BETWEEN 95000 AND 95011;
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (-95000, 95006, 0, "");
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (95006, -95000, 0, "");

INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (-95001, 95007, 0, "");
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (95007, -95001, 0, "");

INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (-95002, 95008, 0, "");
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (95008, -95002, 0, "");

INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (-95003, 95009, 0, "");
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (95009, -95003, 0, "");

INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (-95004, 95010, 0, "");
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (95010, -95004, 0, "");

INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (-95005, 95011, 0, "");
INSERT INTO `Spell_Linked_Spell` (spell_trigger, spell_effect, TYPE, COMMENT) VALUES (95011, -95005, 0, "l");

this script is applying a buff when other buff fade.
all buff are linked together.
however when i disconnect it try to remove both buff in the same time and this is creating infinite buff. i tried to fix in many way so far but i couldn't figure out a solution.

btw i need to always keep one of two linked aura.
example :
if aura 95000 is active and player go in battleground then 95000 fade and 95006 is applied
when player get out of battleground 95006 will fade and 95000 will be active

i'm using OnUpdateZone to handle zone checks.

if player disconnect and not in battleground and aura 95006 is active on login back 95006 will fade and 95000 will be applied

anyone got an idea/solution for it?

would be appreciated thanks.
 
Last edited:

MrPixelMC

Member
I don't understand, why are you using spell_linked_spell? If all you want is the player to have an aura when outside Battleground, and a different one when player Battleground, you can do this with just a PlayerScript.
Say X is the aura you want outside Battleground and Y is the aura inside Battleground.
Use OnLogin and add an if check inside, if player is in Battleground and has aura X, remove aura X and add aura Y. If player isn't in Battleground and has aura Y, remove Y and add X. Then use OnUpdateZone with a similar process.
Non working example just as a template:

Code:
void OnLogin(Player* player)
{
  if (player->InBattleground())
  {
    if (player->HasAura(X))
    {
      player->RemoveAura(X);
      player->AddAura(Y);
    }
    else if (!player->HasAura(Y))
    {
      player->AddAura(Y);
    }
  }
}

void OnUpdateZone (Player* player, uint32 oldZone, uint32 newZone)
{
  if (player->InBattleground())
  {
    if (player->HasAura(X))
    {
      player->RemoveAura(X);
      player->AddAura(Y);
    }
    else if (!player->HasAura(Y)) // Shouldn't happen but just in case it does
    {
      player->AddAura(Y);
    }
  }
}
 

callmephil

Respected Member
it's actually what i did in complementary of the sql, however it fixed itself i really don t know it happens. but thanks for the answer.
 
Top