• 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 pet aura from pet?

Status
Not open for further replies.

blackmetal

Exalted Member
Hello guys, i wonder those code has problem or not but everytime it try to remove aura from pet, Server crash :megusta:

Code:
	if (GetTypeId() == TYPEID_UNIT && damage > 0 && HasAura(53257))
	{
		Player* player = this->ToPlayer();
		Pet* pet = player->GetPet();
		if (Aura* aura = GetAura(53257))
		{
			aura->DropCharge();
			if (GetOwner())
			{
				if (Aura* cobra = GetOwner()->GetAura(53257)){
					cobra->DropCharge();
					pet->RemoveAura(53257);
				}	
			}
		}
	}

Thanks :determination: :determination: :determination:
 
Last edited:

Tommy

Founder
Code:
Player* player = this->ToPlayer();
Pet* pet = player->GetPet();

You aren't checking if "player" and "pet" is null. If "this->ToPlayer()" doesn't check out it will crash and if the player has no pet it will crash without the null checks. Always make sure you run a null check before calling a class variable.


Nonetheless, fixed it up below.

Code:
	if (GetTypeId() == TYPEID_UNIT && damage > 0 && HasAura(53257))
	{
            Player* player = this->ToPlayer();
[COLOR="#00FF00"]            if (!player)
                return;[/COLOR]
            Pet* pet = player->GetPet();
[COLOR="#00FF00"]            if (!pet)
                return;[/COLOR]
            if (Aura* aura = GetAura(53257))
            {
                aura->DropCharge();
                if (GetOwner())
                {
                    if (Aura* cobra = GetOwner()->GetAura(53257))
                    {
                        cobra->DropCharge();
                        pet->RemoveAura(53257);
                    }	
                }
            }
	}
 

blackmetal

Exalted Member
Thanks for clear explains, Loved it. But some how Aura 53257 doesn't removed from Pet. Maybe i'm doing something wrong? :determination:
 

Tommy

Founder
I'm not sure what you are doing, code seems weird. Is there any specific reason you are checking if the "damage > 0"? Not sure what you want, but I'll give it a shot.

Code:
	if (GetOwner())
	{
            if (GetOwner()->GetTypeId() != TYPEID_PLAYER)
                return;

            Player* player = GetOwner()->ToPlayer();
            if (!player)
                return;

            Pet* pet = player->GetPet();
            if (!pet)
                return;

            if (Aura* cobra = player->GetAura(53257))
            {
                cobra->DropCharge(); // Might want to check and see if there's > 1 charge(s) before removing
                pet->RemoveAura(53257);
            }
	}
 

blackmetal

Exalted Member
Hi, currently i'm trying to fix this spell http://www.wowhead.com/spell=53260/cobra-strikes
it has a bug that pet can hit critical attack without losing that buff. And that buff appear both in Hunter and Pet.

Here is a Part that can remove stack from Hunter

Code:
        if (!isVictim && procSpell && isHunterPet())
        {
            switch (procSpell->Id)
            {
                case 16827: // Claw
                case 17253: // Bite
                case 49966: // Smack
                {
                    if ((procExtra & PROC_EX_CRITICAL_HIT) != 0)
                        if (Player * const petOwner = ToPet()->GetCharmerOrOwnerPlayerOrPlayerItself())
                            petOwner->RemoveAuraFromStack(53257);
                    break;
                }
            }
        }

I think i need write new script for it to check and remove those buff on both of Hunter and Pet after basics attack. :determination:
 
Last edited:

blackmetal

Exalted Member
After 1 day with 40-50 compile time i almost got this.

Code:
					Player* player = GetOwner()->ToPlayer();
					Pet* pet = player->GetPet();
					if ((procExtra & PROC_EX_CRITICAL_HIT) != 0)					
						if (Player * const petOwner = ToPet()->GetCharmerOrOwnerPlayerOrPlayerItself())
							petOwner->RemoveAuraFromStack(53257);
							pet->RemoveAuraFromStack(53257);
                    break;

You can close this thread now. Thanks Tommyfor explain code very very detailed :D
 
Status
Not open for further replies.
Top