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

[SOLVED] Remove X Aura if player has another Aura.

Status
Not open for further replies.

zhier

Member
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

Founder
You could use

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

via PlayerScript to do this instead of Spell source files.

For example:

Code:
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

Member
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

Founder
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.

Code:
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.
 
Status
Not open for further replies.
Top