Fixed Archer NPCs not moving while attacking.

Author: Maneco2
This commit is contained in:
MobiusDevelopment
2021-08-11 21:27:29 +00:00
parent 74c5563623
commit aa50d9efa6
902 changed files with 3936 additions and 3998 deletions

View File

@ -29,6 +29,7 @@ import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.enums.AISkillScope;
import org.l2jmobius.gameserver.enums.AIType;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.model.AggroInfo;
@ -813,10 +814,10 @@ public class AttackableAI extends CreatureAI
}
}
}
// Dodge if its needed
if (!npc.isMovementDisabled() && (npc.getTemplate().getDodge() > 0) && (Rnd.get(100) <= npc.getTemplate().getDodge()))
// Calculate Archer movement.
if ((!npc.isMovementDisabled()) && (npc.getAiType() == AIType.ARCHER) && (Rnd.get(100) < 15))
{
// Micht: kepping this one otherwise we should do 2 sqrt
final double distance2 = npc.calculateDistanceSq2D(target);
if (Math.sqrt(distance2) <= (60 + combinedCollision))
{
@ -995,7 +996,11 @@ public class AttackableAI extends CreatureAI
}
// Check if target is within range or move.
final int range = npc.getPhysicalAttackRange() + combinedCollision;
int range = npc.getPhysicalAttackRange() + combinedCollision;
if (npc.getAiType() == AIType.ARCHER)
{
range = 850 + combinedCollision; // Base bow range for NPCs.
}
if (npc.calculateDistance2D(target) > range)
{
if (checkTarget(target))

View File

@ -21,6 +21,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_REST;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.enums.AIType;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
@ -149,8 +150,9 @@ public class FriendlyNpcAI extends AttackableAI
}
}
}
// Dodge if its needed
if (!npc.isMovementDisabled() && (npc.getTemplate().getDodge() > 0) && (Rnd.get(100) <= npc.getTemplate().getDodge()))
// Calculate Archer movement.
if ((!npc.isMovementDisabled()) && (npc.getAiType() == AIType.ARCHER) && (Rnd.get(100) < 15))
{
final double distance2 = npc.calculateDistanceSq2D(originalAttackTarget);
if (Math.sqrt(distance2) <= (60 + combinedCollision))

View File

@ -368,7 +368,6 @@ public class NpcData implements IXmlReader
set.set("aiType", parseString(attrs, "type"));
set.set("aggroRange", parseInteger(attrs, "aggroRange"));
set.set("clanHelpRange", parseInteger(attrs, "clanHelpRange"));
set.set("dodge", parseInteger(attrs, "dodge"));
set.set("isChaos", parseBoolean(attrs, "isChaos"));
set.set("isAggressive", parseBoolean(attrs, "isAggressive"));
for (Node aiNode = npcNode.getFirstChild(); aiNode != null; aiNode = aiNode.getNextSibling())

View File

@ -94,7 +94,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
private AIType _aiType;
private int _aggroRange;
private int _clanHelpRange;
private int _dodge;
private boolean _isChaos;
private boolean _isAggressive;
private int _soulShot;
@ -184,7 +183,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
_aiType = set.getEnum("aiType", AIType.class, AIType.FIGHTER);
_aggroRange = set.getInt("aggroRange", 0);
_clanHelpRange = set.getInt("clanHelpRange", 0);
_dodge = set.getInt("dodge", 0);
_isChaos = set.getBoolean("isChaos", false);
_isAggressive = set.getBoolean("isAggressive", false);
_soulShot = set.getInt("soulShot", 0);
@ -469,11 +467,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
return _clanHelpRange;
}
public int getDodge()
{
return _dodge;
}
public boolean isChaos()
{
return _isChaos;