[svn] Set target in combat even if spell does not hit target.

Call AI function only when spell hits target.
Move combat check from dealdamge to attackerstateupdate to remove redundant check.

--HG--
branch : trunk
This commit is contained in:
megamage
2008-10-31 14:00:49 -05:00
parent 67b86d636b
commit 1c3d4c40c3
2 changed files with 39 additions and 45 deletions

View File

@@ -519,9 +519,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
return damage;
}
if(!pVictim->isInCombat() && ((Creature*)pVictim)->AI())
((Creature*)pVictim)->AI()->AttackStart(this);
}
DEBUG_LOG("DealDamageStart");
@@ -539,15 +536,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
duel_hasEnded = true;
}
//Get in CombatState
if(pVictim != this && damagetype != DOT)
{
SetInCombatWith(pVictim);
pVictim->SetInCombatWith(this);
if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself())
SetContestedPvP(attackedPlayer);
}
// Rage from Damage made (only from direct weapon damage)
if( cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE))
@@ -2151,6 +2139,15 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
if(IsNonMeleeSpellCasted(false))
return;
if(!pVictim->isInCombat() && pVictim->GetTypeId() != TYPEID_PLAYER && ((Creature*)pVictim)->AI())
((Creature*)pVictim)->AI()->AttackStart(this);
SetInCombatWith(pVictim);
pVictim->SetInCombatWith(this);
if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself())
SetContestedPvP(attackedPlayer);
uint32 hitInfo;
if (attType == BASE_ATTACK)
hitInfo = HITINFO_NORMALSWING2;