mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
[7128] Cleanup in PetHandler.cpp and little PetAI.cpp
Fixed: pet stop attacking when casts spell by command. Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
parent
9e1b9e56fd
commit
03b7d1006a
3 changed files with 41 additions and 38 deletions
|
|
@ -139,11 +139,11 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
else
|
else
|
||||||
m_updateAlliesTimer -= diff;
|
m_updateAlliesTimer -= diff;
|
||||||
|
|
||||||
if (inCombat && i_pet.getVictim() == NULL)
|
if (inCombat && !i_pet.getVictim())
|
||||||
_stopAttack();
|
_stopAttack();
|
||||||
|
|
||||||
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
|
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
|
||||||
if( i_pet.getVictim() != NULL )
|
if( i_pet.getVictim() )
|
||||||
{
|
{
|
||||||
if( _needToStop() )
|
if( _needToStop() )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||||
break;
|
break;
|
||||||
case COMMAND_ATTACK: //spellid=1792 //ATTACK
|
case COMMAND_ATTACK: //spellid=1792 //ATTACK
|
||||||
{
|
{
|
||||||
// only place where pet can be player
|
const uint64& selguid = _player->GetSelection();
|
||||||
pet->clearUnitState(UNIT_STAT_FOLLOW);
|
|
||||||
uint64 selguid = _player->GetSelection();
|
|
||||||
Unit *TargetUnit = ObjectAccessor::GetUnit(*_player, selguid);
|
Unit *TargetUnit = ObjectAccessor::GetUnit(*_player, selguid);
|
||||||
if(!TargetUnit)
|
if(!TargetUnit)
|
||||||
return;
|
return;
|
||||||
|
|
@ -105,6 +103,9 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||||
if(!pet->IsWithinLOSInMap(TargetUnit))
|
if(!pet->IsWithinLOSInMap(TargetUnit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// This is true if pet has no target or has target but targets differs.
|
||||||
|
if(pet->getVictim() != TargetUnit)
|
||||||
|
{
|
||||||
if (pet->getVictim())
|
if (pet->getVictim())
|
||||||
pet->AttackStop();
|
pet->AttackStop();
|
||||||
|
|
||||||
|
|
@ -128,6 +129,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||||
pet->Attack(TargetUnit,true);
|
pet->Attack(TargetUnit,true);
|
||||||
pet->SendPetAIReaction(guid1);
|
pet->SendPetAIReaction(guid1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
|
case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
|
||||||
|
|
@ -161,15 +163,13 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||||
case ACT_PASSIVE: // 0x0100
|
case ACT_PASSIVE: // 0x0100
|
||||||
case ACT_ENABLED: // 0xC100 spell
|
case ACT_ENABLED: // 0xC100 spell
|
||||||
{
|
{
|
||||||
Unit* unit_target;
|
Unit* unit_target = NULL;
|
||||||
if(guid2)
|
|
||||||
unit_target = ObjectAccessor::GetUnit(*_player,guid2);
|
|
||||||
else
|
|
||||||
unit_target = NULL;
|
|
||||||
|
|
||||||
if (((Creature*)pet)->GetGlobalCooldown() > 0)
|
if (((Creature*)pet)->GetGlobalCooldown() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(guid2)
|
||||||
|
unit_target = ObjectAccessor::GetUnit(*_player,guid2);
|
||||||
|
|
||||||
// do not cast unknown spells
|
// do not cast unknown spells
|
||||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid );
|
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid );
|
||||||
if(!spellInfo)
|
if(!spellInfo)
|
||||||
|
|
@ -225,13 +225,16 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||||
|
|
||||||
if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
|
if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
|
||||||
{
|
{
|
||||||
pet->clearUnitState(UNIT_STAT_FOLLOW);
|
// This is true if pet has no target or has target but targets differs.
|
||||||
|
if (pet->getVictim() != unit_target)
|
||||||
|
{
|
||||||
if (pet->getVictim())
|
if (pet->getVictim())
|
||||||
pet->AttackStop();
|
pet->AttackStop();
|
||||||
pet->GetMotionMaster()->Clear();
|
pet->GetMotionMaster()->Clear();
|
||||||
if (((Creature*)pet)->AI())
|
if (((Creature*)pet)->AI())
|
||||||
((Creature*)pet)->AI()->AttackStart(unit_target);
|
((Creature*)pet)->AI()->AttackStart(unit_target);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
spell->prepare(&(spell->m_targets));
|
spell->prepare(&(spell->m_targets));
|
||||||
}
|
}
|
||||||
|
|
@ -575,7 +578,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
|
||||||
if(!_player->GetPet() && !_player->GetCharm())
|
if(!_player->GetPet() && !_player->GetCharm())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(ObjectAccessor::FindPlayer(guid))
|
if (GUID_HIPART(guid) == HIGHGUID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player,guid);
|
Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player,guid);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7127"
|
#define REVISION_NR "7128"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue