All pastes #1048654 Raw Edit

Untitled

public cpp v1 · immutable
#1048654 ·published 2008-06-16 19:00 UTC
rendered paste body
Index: Player.cpp===================================================================--- Player.cpp	(revision 6110)+++ Player.cpp	(working copy)@@ -299,6 +299,8 @@     m_restTime = 0;     m_deathTimer = 0; +	m_errorMsgSwitch = 0;+     m_DetectInvTimer = 1000;      m_bgBattleGroundID = 0;@@ -909,17 +911,27 @@             {                 if(!IsWithinDistInMap(pVictim, pldistance))                 {-                    setAttackTimer(BASE_ATTACK,1000);-                    SendAttackSwingNotInRange();+                    setAttackTimer(BASE_ATTACK,100);+					if(m_errorMsgSwitch != 1)+					{+						SendAttackSwingNotInRange();+						m_errorMsgSwitch = 1;+					}                 }                 //120 degrees of radiant range                 else if( !HasInArc( 2*M_PI/3, pVictim ))                 {-                    setAttackTimer(BASE_ATTACK,1000);-                    SendAttackSwingBadFacingAttack();+                    setAttackTimer(BASE_ATTACK,100);+					if(m_errorMsgSwitch != 2)+					{+						SendAttackSwingBadFacingAttack();+						m_errorMsgSwitch = 2;+					}                 }                 else                 {+					m_errorMsgSwitch = 0;+                     // prevent base and off attack in same time, delay attack at 0.2 sec                     if(haveOffhandWeapon())                     {@@ -936,11 +948,11 @@             {                 if(!IsWithinDistInMap(pVictim, pldistance))                 {-                    setAttackTimer(OFF_ATTACK,1000);+                    setAttackTimer(OFF_ATTACK,100);                 }                 else if( !HasInArc( 2*M_PI/3, pVictim ))                 {-                    setAttackTimer(OFF_ATTACK,1000);+                    setAttackTimer(OFF_ATTACK,100);                 }                 else                 {Index: Player.h===================================================================--- Player.h	(revision 6110)+++ Player.h	(working copy)@@ -2095,6 +2095,8 @@          uint32 m_deathTimer; +		uint8 m_errorMsgSwitch;+         uint32 m_restTime;          uint32 m_WeaponProficiency;Index: Unit.cpp===================================================================--- Unit.cpp	(revision 6110)+++ Unit.cpp	(working copy)@@ -274,10 +274,24 @@     //update combat timer only for players and pets     if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet() || ((Creature*)this)->isCharmed()))     {+		if(GetTypeId() == TYPEID_PLAYER && m_HostilRefManager.isEmpty())+		{+			// if not attacking, then always decrease combat timer. (consider the if above)+			// if we're attacking but out of range, decrease.+			// any other cases don't decrease+			if(!hasUnitState(UNIT_STAT_MELEE_ATTACKING) || (hasUnitState(UNIT_STAT_MELEE_ATTACKING) && getVictim() && !IsWithinDistInMap(getVictim(), ATTACK_DISTANCE)))+			{+			    // m_CombatTimer set at aura start and it will be freeze until aura removing+			    if ( m_CombatTimer <= p_time )+                    ClearInCombat();+                else+                    m_CombatTimer -= p_time;+			}+		}         // Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away         // targets without stopping half way there and running off.         // These flags are reset after target dies or another command is given.-        if( m_HostilRefManager.isEmpty() && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) && !(hasUnitState(UNIT_STAT_CHASE) && !hasUnitState(UNIT_STAT_FOLLOW) ) )+        else if( m_HostilRefManager.isEmpty() && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) && !(hasUnitState(UNIT_STAT_CHASE) && !hasUnitState(UNIT_STAT_FOLLOW) ) )         {             // m_CombatTimer set at aura start and it will be freeze until aura removing             if ( m_CombatTimer <= p_time )@@ -6574,33 +6588,38 @@      if(meleeAttack)         addUnitState(UNIT_STAT_MELEE_ATTACKING);-    SetInCombat();     m_attacking = victim;-    m_attacking->_addAttacker(this); -    if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI())-        ((Creature*)m_attacking)->AI()->AttackedBy(this);+	if(GetTypeId()!=TYPEID_PLAYER || IsWithinDistInMap(victim, ATTACK_DISTANCE))+	{+	    SetInCombat(); -    if(GetTypeId()==TYPEID_UNIT)-    {-        WorldPacket data(SMSG_AI_REACTION, 12);-        data << GetGUID();-        data << uint32(AI_REACTION_AGGRO);                  // Aggro sound-        ((WorldObject*)this)->SendMessageToSet(&data, true);-    }+        m_attacking->_addAttacker(this); -    if( GetTypeId()==TYPEID_UNIT && !(((Creature*)this)->isPet() || isCharmed()) )-    {-        ((Creature*)this)->CallAssistence();-    }+        if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI())+            ((Creature*)m_attacking)->AI()->AttackedBy(this); -    // delay offhand weapon attack to next attack time-    if(haveOffhandWeapon())-        resetAttackTimer(OFF_ATTACK);+        if(GetTypeId()==TYPEID_UNIT)+        {+            WorldPacket data(SMSG_AI_REACTION, 12);+            data << GetGUID();+            data << uint32(AI_REACTION_AGGRO);                  // Aggro sound+            ((WorldObject*)this)->SendMessageToSet(&data, true);+        } -    if(meleeAttack)-        SendAttackStart(victim);+        if( GetTypeId()==TYPEID_UNIT && !(((Creature*)this)->isPet() || isCharmed()) )+        {+            ((Creature*)this)->CallAssistence();+        } +        // delay offhand weapon attack to next attack time+        if(haveOffhandWeapon())+            resetAttackTimer(OFF_ATTACK);++        if(meleeAttack)+            SendAttackStart(victim);+	}+     return true; }