mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
*Use canattack to check if canattack in pethandler and combathandler
--HG-- branch : trunk
This commit is contained in:
@@ -50,7 +50,7 @@ void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
|
||||
return;
|
||||
}
|
||||
|
||||
if(_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
|
||||
if(!_player->canAttack(pEnemy))
|
||||
{
|
||||
sLog.outError( "WORLD: Enemy %s %u is friendly",(IS_PLAYER_GUID(guid) ? "player" : "creature"),GUID_LOPART(guid));
|
||||
|
||||
@@ -59,14 +59,6 @@ void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
|
||||
return;
|
||||
}
|
||||
|
||||
if(!pEnemy->isAlive())
|
||||
{
|
||||
// client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options
|
||||
// stop attack state at client
|
||||
SendAttackStop(pEnemy);
|
||||
return;
|
||||
}
|
||||
|
||||
_player->Attack(pEnemy,true);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,19 +105,21 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
//TODO: Send proper error message to client
|
||||
return;
|
||||
}
|
||||
|
||||
// only place where pet can be player
|
||||
pet->clearUnitState(UNIT_STAT_FOLLOW);
|
||||
Unit *TargetUnit = ObjectAccessor::GetUnit(*_player, guid2);
|
||||
if(!TargetUnit)
|
||||
return;
|
||||
|
||||
// not let attack friendly units.
|
||||
if(GetPlayer()->IsFriendlyTo(TargetUnit))
|
||||
if(!pet->canAttack(TargetUnit))
|
||||
return;
|
||||
|
||||
// Not let attack through obstructions
|
||||
//if(!pet->IsWithinLOSInMap(TargetUnit))
|
||||
// return;
|
||||
|
||||
pet->clearUnitState(UNIT_STAT_FOLLOW);
|
||||
|
||||
if(pet->GetTypeId() != TYPEID_PLAYER && ((Creature*)pet)->IsAIEnabled)
|
||||
{
|
||||
((Creature*)pet)->AI()->AttackStart(TargetUnit);
|
||||
|
||||
Reference in New Issue
Block a user