PDA

View Full Version : [SOLVED] Remove X Aura if player has another Aura.



zhier
07-31-2016, 12:38 AM
Well, as the title says...

I wan't to remove X aura from the player if (s)he has another aura, for ex:

Player uses X spell and it gives the aura 12345, and then If (s)he uses the aura 22334, remove 12345 from the player.

I'm trying to do this in Spell.cpp and SpellMgr.cpp, but it doesn't work.

Thanks for your help.

Tommy
07-31-2016, 01:31 AM
You could use


void OnSpellCast(Player* /*player*/, Spell* /*spell*/, bool /*skipCheck*/) { }

via PlayerScript to do this instead of Spell source files.

For example:



class player_aura_check : public PlayerScript
{
public:
player_aura_check() : PlayerScript("player_aura_check") { }

void OnSpellCast(Player* player, Spell* spell, bool /*skipCheck*/) override
{
if (spell->GetEntry() == 22334 && player->HasAura(12345))
player->RemoveAurasDueToSpell(12345);
}
};

void SetupPlayerAuraCheck()
{
new player_aura_check;
}


I didn't use Visual Studio so I did it from memory. There might be errors, but it is the gist of what you want I hope.

zhier
07-31-2016, 01:55 AM
I got the error "spell" undeclared identifier...

Maybe because "spell" is inside /* */ ??

"GetEntry" is not a member of Spell and


Error LNK1181 cannot open input file '..\scripts\Release\scripts.lib'

Tommy
07-31-2016, 03:38 AM
I got the error "spell" undeclared identifier...

Maybe because "spell" is inside /* */ ??

"GetEntry" is not a member of Spell and


Error LNK1181 cannot open input file '..\scripts\Release\scripts.lib'

Yeah. I forgot to uncomment "spell". Since I wasn't using VS I wasn't sure what the method was. I forgot you can use "SpellInfo" to retrieve the spell Id.



class player_aura_check : public PlayerScript
{
public:
player_aura_check() : PlayerScript("player_aura_check") { }

void OnSpellCast(Player* player, Spell* spell, bool /*skipCheck*/) override
{
if ((spell->GetSpellInfo() && spell->GetSpellInfo()->Id == 22334) && player->HasAura(12345))
player->RemoveAurasDueToSpell(12345);
}
};

void SetupPlayerAuraCheck()
{
new player_aura_check;
}


Should be good to compile and test now.

zhier
07-31-2016, 03:54 AM
Thanks a lot. It works.

You can close this thread now.