2
0
Эх сурвалжийг харах

BETA: Reverting [4695] due this is making more issues than fixes.

MELERIX 14 жил өмнө
parent
commit
860b0b7be4

+ 17 - 35
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java

@@ -1699,32 +1699,14 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 		double dist = 0;
 		double dist2 = 0;
 		int range = 0;
-		if (_attackTarget == null && getTarget() == null && getCastTarget() == null)
-		{
-			notifyEvent(CtrlEvent.EVT_CANCEL);
-			return;
-		}
-		
 		try
 		{
-			L2Character _attackTargetCpy = _attackTarget;
-			if (npc.getTarget() == null && _attackTargetCpy != null)
-				npc.setTarget(_attackTargetCpy);
-			else if (_attackTargetCpy == null && getTarget() != null)
-			{
-				_attackTargetCpy = (L2Character) getTarget();
-				setAttackTarget(_attackTargetCpy);
-			}
-			else
-			{
-				notifyEvent(CtrlEvent.EVT_CANCEL);
-				return;
-			}
-			
-			dist = Math.sqrt(npc.getPlanDistanceSq(_attackTargetCpy.getX(), _attackTargetCpy.getY()));
+			if (npc.getTarget() == null)
+				npc.setTarget(getAttackTarget());
+			dist = Math.sqrt(npc.getPlanDistanceSq(getAttackTarget().getX(), getAttackTarget().getY()));
 			dist2 = dist - npc.getTemplate().collisionRadius;
-			range = npc.getPhysicalAttackRange() + npc.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius;
-			if (_attackTargetCpy.isMoving())
+			range = npc.getPhysicalAttackRange() + npc.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius;
+			if (getAttackTarget().isMoving())
 			{
 				dist = dist - 30;
 				if (npc.isMoving())
@@ -1737,17 +1719,17 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 				//-------------------------------------------------------------
 				//Try to stop the target or disable the target as priority
 				int random = Rnd.get(100);
-				if (_skillrender.hasImmobiliseSkill() && !_attackTargetCpy.isImmobilized() && random < 2)
+				if (_skillrender.hasImmobiliseSkill() && !getAttackTarget().isImmobilized() && random < 2)
 				{
 					for (L2Skill sk : _skillrender._immobiliseskills)
 					{
-						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
+						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
 						{
 							continue;
 						}
 						if (!GeoData.getInstance().canSeeTarget(npc, getAttackTarget()))
 							continue;
-						if (_attackTargetCpy.getFirstEffect(sk) == null)
+						if (getAttackTarget().getFirstEffect(sk) == null)
 						{
 							clientStopMoving(null);
 							//L2Object target = getAttackTarget();
@@ -1764,13 +1746,13 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 				{
 					for (L2Skill sk : _skillrender._cotskills)
 					{
-						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
+						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
 						{
 							continue;
 						}
 						if (!GeoData.getInstance().canSeeTarget(npc, getAttackTarget()))
 							continue;
-						if (_attackTargetCpy.getFirstEffect(sk) == null)
+						if (getAttackTarget().getFirstEffect(sk) == null)
 						{
 							clientStopMoving(null);
 							//L2Object target = getAttackTarget();
@@ -1786,13 +1768,13 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 				{
 					for (L2Skill sk : _skillrender._debuffskills)
 					{
-						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
+						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
 						{
 							continue;
 						}
 						if (!GeoData.getInstance().canSeeTarget(npc, getAttackTarget()))
 							continue;
-						if (_attackTargetCpy.getFirstEffect(sk) == null)
+						if (getAttackTarget().getFirstEffect(sk) == null)
 						{
 							clientStopMoving(null);
 							//L2Object target = getAttackTarget();
@@ -1809,13 +1791,13 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 				{
 					for (L2Skill sk : _skillrender._negativeskills)
 					{
-						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
+						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
 						{
 							continue;
 						}
 						if (!GeoData.getInstance().canSeeTarget(npc, getAttackTarget()))
 							continue;
-						if (_attackTargetCpy.getFirstEffect(L2EffectType.BUFF) != null)
+						if (getAttackTarget().getFirstEffect(L2EffectType.BUFF) != null)
 						{
 							clientStopMoving(null);
 							//L2Object target = getAttackTarget();
@@ -1833,7 +1815,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 				{
 					for (L2Skill sk : _skillrender._atkskills)
 					{
-						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
+						if (sk.getMpConsume() >= npc.getCurrentMp() || npc.isSkillDisabled(sk) || (sk.getCastRange() + npc.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius <= dist2 && !canAura(sk)) || (sk.isMagic() && npc.isMuted()) || (!sk.isMagic() && npc.isPhysicalMuted()))
 						{
 							continue;
 						}
@@ -1856,7 +1838,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 					{
 						if(sk.getMpConsume()>=_actor.getCurrentMp()
 								|| _actor.isSkillDisabled(sk.getId())
-								||(sk.getCastRange()+ _actor.getTemplate().collisionRadius + _attackTargetCpy.getTemplate().collisionRadius <= dist2 && !canAura(sk))
+								||(sk.getCastRange()+ _actor.getTemplate().collisionRadius + getAttackTarget().getTemplate().collisionRadius <= dist2 && !canAura(sk))
 								||(sk.isMagic()&&_actor.isMuted())
 								||(!sk.isMagic()&&_actor.isPhysicalMuted()))
 						{
@@ -1892,7 +1874,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 			
 			if (dist > range || !GeoData.getInstance().canSeeTarget(npc, getAttackTarget()))
 			{
-				if (_attackTargetCpy.isMoving())
+				if (getAttackTarget().isMoving())
 					range -= 100;
 				if (range < 5)
 					range = 5;