PDA

View Full Version : Pet Affinity Fix (maybe)


demonstar55
02-20-2009, 09:25 PM
Well, the description says it works on summoned pets, not charmed. I also asked someone on the PEQ server that played an enc on live and he said he didn't think it worked on charmed but he wasn't 100% sure because he mostly soloed. I also can't test these changes because at school I don't have access to a computer that I could host a computer on :P.

So in the file zone/groups.cpp

on line 634

change it from (lines 633-636)
#ifdef GROUP_BUFF_PETS
if(caster->GetPet() && caster->GetAA(aaPetAffinity))
caster->BardPulse(spell_id, caster->GetPet());
#endif

to

#ifdef GROUP_BUFF_PETS
if(caster->GetPet() && caster->GetAA(aaPetAffinity) && !Charmed())
caster->BardPulse(spell_id, caster->GetPet());
#endif

and on line 644

change from (lines 643-646)
#ifdef GROUP_BUFF_PETS
if(members[z]->GetPet() && members[z]->GetAA(aaPetAffinity))
members[z]->GetPet()->BardPulse(spell_id, caster);
#endif

to

#ifdef GROUP_BUFF_PETS
if(members[z]->GetPet() && members[z]->GetAA(aaPetAffinity) && !Charmed())
members[z]->GetPet()->BardPulse(spell_id, caster);
#endif

I'm not 100% if this will work :S so it would be nice if someone could check that would be great, only really thing I can think that might not be right is if Pet Affinity works on charmed pets, which I've been told is not the case, or if !Charmed() needs to do something else :S

but the main reason I'm doing this is because if an enc has Pet Affinity and a charmed pet and a bard in their group playing a resist buff song then the pet will break the charm every tick (pretty much) since it checks every tick to see if it can break the charm based on it's MR[I think])

cavedude
02-25-2009, 01:29 PM
My research agrees, charmed pets should not be effected by Pet Affinity. So, this is a good fix and I'll get it into SVN after my current batch of testing.

demonstar55
02-25-2009, 05:29 PM
well these changes don't work right, need to do some more testing, but I don't have a server to test these on at my disposal right now :( so ignore this until I can get around to getting it to work :P, plus there are a few other lines I found that I'd need to change

cavedude
02-25-2009, 06:30 PM
The one thing I did change was !Charmed() should be !caster->GetPet()->Charmed(), substituting caster with members[z] where necessary. Haven't had time to test yet, though. I also added it to a couple of missed lines.

demonstar55
02-25-2009, 07:34 PM
The one thing I did change was !Charmed() should be !caster->GetPet()->Charmed(), substituting caster with members[z] where necessary. Haven't had time to test yet, though. I also added it to a couple of missed lines.

Alright that's what I was going to do, some how I missed the lines in spells.cpp my first time, but yeah that's what I was going to try when I went home for spring break

demonstar55
02-25-2009, 11:10 PM
even though I'm sure CD found them all, I'll just post everything fixed:

zones/groups.cpp

lines 594-597

#ifdef GROUP_BUFF_PETS
if(caster->GetPet() && caster->GetAA(aaPetAffinity))
caster->SpellOnTarget(spell_id, caster->GetPet());
#endif

change to

#ifdef GROUP_BUFF_PETS
if(caster->GetPet() && caster->GetAA(aaPetAffinity) && !caster->GetPet()->Charmed())
caster->SpellOnTarget(spell_id, caster->GetPet());
#endif

lines 604 - 607

#ifdef GROUP_BUFF_PETS
if(members[z]->GetPet() && members[z]->GetAA(aaPetAffinity))
caster->SpellOnTarget(spell_id, members[z]->GetPet());
#endif

change to

#ifdef GROUP_BUFF_PETS
if(members[z]->GetPet() && members[z]->GetAA(aaPetAffinity) && !members[z]->GetPet()->Charmed())
caster->SpellOnTarget(spell_id, members[z]->GetPet());
#endif

lines 633-636

#ifdef GROUP_BUFF_PETS
if(caster->GetPet() && caster->GetAA(aaPetAffinity))
caster->BardPulse(spell_id, caster->GetPet());
#endif

change to

#ifdef GROUP_BUFF_PETS
if(caster->GetPet() && caster->GetAA(aaPetAffinity) && !caster->GetPet()->Charmed())
caster->BardPulse(spell_id, caster->GetPet());
#endif

well I think you get the idea, but here is the rest of the line numbers

in zones/groups.cpp on line 644

in zones/raids.cpp on lines 413, 424, 592, 603

in zones/spells.cpp on lines 1561 and 1569

the rest in groups and raids are the same (it's the same two statements), for spells it's a little different, for line 1561 change

if (GetPet() && GetAA(aaPetAffinity))

to

if (GetPet() && GetAA(aaPetAffinity) && !GetPet()->Charmed())

and on 1569

if (spell_target->GetPet() && GetAA(aaPetAffinity))

to

if (spell_target->GetPet() && GetAA(aaPetAffinity) && !spell_target->GetPet()->Charmed())

these should be all correct, but I don't have a means to test them

cavedude
02-26-2009, 04:05 PM
I played with this last night and it's not working. To be truthful, I'm stumped. We're checking if the player has a pet, making sure the pet isn't charmed, and checking to make sure they have the AA. If they all check out we cast the spell on the pet... But charmed pets are still getting hit by buffs/songs. I can find no other place in the code where this AA is specified.

demonstar55
02-26-2009, 04:17 PM
I played with this last night and it's not working. To be truthful, I'm stumped. We're checking if the player has a pet, making sure the pet isn't charmed, and checking to make sure they have the AA. If they all check out we cast the spell on the pet... But charmed pets are still getting hit by buffs/songs. I can find no other place in the code where this AA is specified.

!caster->GetPet()->Charmed() must not be check if the pet is charmed :P, I guess I'd have to look into each function better, but I'd assume Charmed() would check if current thing is charmed (the caster's pet in this case), so I guess when I get home and can compile I'll mess around with this some more, unless someone beats me to it :P

cavedude
02-26-2009, 04:56 PM
Charmed() by itself is a null pointer and will create a zone crash. There is no current entity, that's why caster-> is specified. The server will basically say is what not charmed, and then crash. ;) But, caster->GetPet()->Charmed() is the correct code to find it the caster's pet has a charm spell on them. I've used it in the past, and it wouldn't compile if it wasn't valid.

cavedude
02-26-2009, 05:03 PM
I'll fiddle with GetPetType and a couple of other things.

demonstar55
02-26-2009, 05:18 PM
I'll fiddle with GetPetType and a couple of other things.

try caster->GetPetType != petCharmed

cavedude
02-26-2009, 06:12 PM
Alright, this now works with group spells just fine. The problem is bard songs still hit. Looking at spells.cpp, it looks like Bard spells hit all pets no matter what, it doesn't even check for Pet Affinity. Is this correct? If not, I'll add the check for charmed pets and Pet Affinity. This was also the trouble testing last night, !caster->GetPet()->Charmed() probably did work, since I was only testing with Bard songs not group spells. :I

demonstar55
02-26-2009, 06:51 PM
Alright, this now works with group spells just fine. The problem is bard songs still hit. Looking at spells.cpp, it looks like Bard spells hit all pets no matter what, it doesn't even check for Pet Affinity. Is this correct? If not, I'll add the check for charmed pets and Pet Affinity. This was also the trouble testing last night, !caster->GetPet()->Charmed() probably did work, since I was only testing with Bard songs not group spells. :I
Did you change the lines in zones/groups.cpp? From what I recall the comments say they have to do with bard songs, and I don't recall the songs hitting peoples pets that didn't have pet affinity, well besides the chorus ones

cavedude
02-26-2009, 06:59 PM
groups.cpp doesn't matter, the problem is in spells.cpp, that's where the final above all be all check is. The code looks like:

#ifdef GROUP_BUFF_PETS
if (GetPet())
GetPet()->BardPulse(spell_id, this);
#endif
}
}
}
else {
mlog(SPELLS__BARDS, "Bard Song Pulse: spell %d, Group target without group. Affecting caster.", spell_id);
BardPulse(spell_id, this);
#ifdef GROUP_BUFF_PETS
if (GetPet())
GetPet()->BardPulse(spell_id, this);
#endif
}
break;
}
}

Meaning all songs will land on every pet all the time. I'm going to add a check for charmed pets, but not for Pet Affinity for now. If somebody knows otherwise, please let me know.

demonstar55
02-26-2009, 07:17 PM
well I know morte could twist songs on his bard while his end had a charmed pet and then when he got pet affinity the bards resist song would cause the pet to break, so the zones/groups.cpp code would be working

cavedude
02-26-2009, 08:03 PM
Alright, we're set. KLS and I think whoever implemented Pet Affinity originally forgot to add it to that line in spells.cpp. Group spells and songs will no longer effect charmed pets, even if the caster has Pet Affinity. Of course, Bard AE songs will still hit charmed pets, as that hits all allied characters and their pets. I'll put it up on TGC tonight, and if it checks out there, I'll commit to SVN.