mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11825] Implement creature offhand attack. based on patch from maxxx2021
also drop some archaic Unit's code
This commit is contained in:
parent
4bd3976e30
commit
70a6a1ce76
9 changed files with 104 additions and 102 deletions
|
|
@ -1230,71 +1230,11 @@ void Player::Update( uint32 update_diff, uint32 p_time )
|
|||
|
||||
if (hasUnitState(UNIT_STAT_MELEE_ATTACKING))
|
||||
{
|
||||
UpdateMeleeAttackingState();
|
||||
|
||||
Unit *pVictim = getVictim();
|
||||
if (pVictim && !IsNonMeleeSpellCasted(false))
|
||||
{
|
||||
// default combat reach 10
|
||||
// TODO add weapon,skill check
|
||||
|
||||
if (isAttackReady(BASE_ATTACK))
|
||||
{
|
||||
if (!CanReachWithMeleeAttack(pVictim))
|
||||
{
|
||||
setAttackTimer(BASE_ATTACK,100);
|
||||
if (m_swingErrorMsg != 1) // send single time (client auto repeat)
|
||||
{
|
||||
SendAttackSwingNotInRange();
|
||||
m_swingErrorMsg = 1;
|
||||
}
|
||||
}
|
||||
//120 degrees of radiant range
|
||||
else if (!HasInArc(2*M_PI_F/3, pVictim))
|
||||
{
|
||||
setAttackTimer(BASE_ATTACK,100);
|
||||
if (m_swingErrorMsg != 2) // send single time (client auto repeat)
|
||||
{
|
||||
SendAttackSwingBadFacingAttack();
|
||||
m_swingErrorMsg = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_swingErrorMsg = 0; // reset swing error state
|
||||
|
||||
// prevent base and off attack in same time, delay attack at 0.2 sec
|
||||
if (haveOffhandWeapon())
|
||||
{
|
||||
uint32 off_att = getAttackTimer(OFF_ATTACK);
|
||||
if(off_att < ATTACK_DISPLAY_DELAY)
|
||||
setAttackTimer(OFF_ATTACK,ATTACK_DISPLAY_DELAY);
|
||||
}
|
||||
AttackerStateUpdate(pVictim, BASE_ATTACK);
|
||||
resetAttackTimer(BASE_ATTACK);
|
||||
}
|
||||
}
|
||||
|
||||
if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK))
|
||||
{
|
||||
if (!CanReachWithMeleeAttack(pVictim))
|
||||
{
|
||||
setAttackTimer(OFF_ATTACK,100);
|
||||
}
|
||||
else if (!HasInArc(2*M_PI_F/3, pVictim))
|
||||
{
|
||||
setAttackTimer(OFF_ATTACK,100);
|
||||
}
|
||||
else
|
||||
{
|
||||
// prevent base and off attack in same time, delay attack at 0.2 sec
|
||||
uint32 base_att = getAttackTimer(BASE_ATTACK);
|
||||
if(base_att < ATTACK_DISPLAY_DELAY)
|
||||
setAttackTimer(BASE_ATTACK,ATTACK_DISPLAY_DELAY);
|
||||
// do attack
|
||||
AttackerStateUpdate(pVictim, OFF_ATTACK);
|
||||
resetAttackTimer(OFF_ATTACK);
|
||||
}
|
||||
}
|
||||
|
||||
Player *vOwner = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
if (vOwner && vOwner->IsPvP() && !IsInDuelWith(vOwner))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue