User Tag List

Results 1 to 5 of 5

Thread: Remove X Aura if player has another Aura.

  1. #1
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove X Aura if player has another Aura.

    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.

  2. #2
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    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.

  3. #3
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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'

  4. #4
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    Quote Originally Posted by zhier View Post
    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.

  5. #5
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot. It works.

    You can close this thread now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •