aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-04-30 09:58:34 -0500
committermegamage <none@none>2009-04-30 09:58:34 -0500
commitefd58033ea12f3380c2ff78ca1f7f0b6db368754 (patch)
tree89fcffe19d652205a3ce5c9e344c79738789b046 /src
parentb4c6a9842c36f01c2f42059bec88f0af10654074 (diff)
*Use canattack to check if canattack in pethandler and combathandler
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/CombatHandler.cpp10
-rw-r--r--src/game/PetHandler.cpp8
2 files changed, 6 insertions, 12 deletions
diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp
index fb212870822..f9fb4fd7ee0 100644
--- a/src/game/CombatHandler.cpp
+++ b/src/game/CombatHandler.cpp
@@ -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);
}
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
index 6286ba40b74..932eb593ff8 100644
--- a/src/game/PetHandler.cpp
+++ b/src/game/PetHandler.cpp
@@ -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);