diff --git a/trunk/dist/game/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java b/trunk/dist/game/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java index b3d0e53f04..1144640612 100644 --- a/trunk/dist/game/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java +++ b/trunk/dist/game/data/scripts/handlers/actionhandlers/L2PcInstanceAction.java @@ -24,6 +24,7 @@ import com.l2jserver.gameserver.enums.InstanceType; import com.l2jserver.gameserver.enums.PrivateStoreType; import com.l2jserver.gameserver.handler.IActionHandler; import com.l2jserver.gameserver.model.L2Object; +import com.l2jserver.gameserver.model.Location; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.entity.TvTEvent; @@ -105,6 +106,12 @@ public class L2PcInstanceAction implements IActionHandler activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); activeChar.onActionRequest(); } + else + { + final Location destination = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId()); + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); + activeChar.onActionRequest(); + } } } else @@ -115,6 +122,12 @@ public class L2PcInstanceAction implements IActionHandler { activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target); } + else + { + final Location destination = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId()); + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); + activeChar.onActionRequest(); + } } } } diff --git a/trunk/dist/game/data/scripts/handlers/effecthandlers/Fear.java b/trunk/dist/game/data/scripts/handlers/effecthandlers/Fear.java index 1c07b35c01..326af2db9f 100644 --- a/trunk/dist/game/data/scripts/handlers/effecthandlers/Fear.java +++ b/trunk/dist/game/data/scripts/handlers/effecthandlers/Fear.java @@ -18,6 +18,7 @@ */ package handlers.effecthandlers; +import com.l2jserver.Config; import com.l2jserver.gameserver.GeoData; import com.l2jserver.gameserver.ai.CtrlEvent; import com.l2jserver.gameserver.ai.CtrlIntention; @@ -105,7 +106,17 @@ public final class Fear extends AbstractEffect info.getEffected().setRunning(); } - final Location destination = GeoData.getInstance().moveCheck(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), posX, posY, posZ, info.getEffected().getInstanceId()); + // If pathfinding enabled the creature will go to the defined destination (retail like). + // Otherwise it will go to the nearest obstacle. + final Location destination; + if (Config.PATHFINDING > 0) + { + destination = new Location(posX, posY, posZ, info.getEffected().getInstanceId()); + } + else + { + destination = GeoData.getInstance().moveCheck(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), posX, posY, posZ, info.getEffected().getInstanceId()); + } info.getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); } } diff --git a/trunk/dist/game/data/scripts/handlers/effecthandlers/TransferHate.java b/trunk/dist/game/data/scripts/handlers/effecthandlers/TransferHate.java index 0b6b604736..fac4aabe12 100644 --- a/trunk/dist/game/data/scripts/handlers/effecthandlers/TransferHate.java +++ b/trunk/dist/game/data/scripts/handlers/effecthandlers/TransferHate.java @@ -48,12 +48,6 @@ public final class TransferHate extends AbstractEffect return Formulas.calcProbability(_chance, info.getEffector(), info.getEffected(), info.getSkill()); } - @Override - public boolean canStart(BuffInfo info) - { - return Util.checkIfInRange(info.getSkill().getEffectRange(), info.getEffector(), info.getEffected(), true); - } - @Override public boolean isInstant() { @@ -63,6 +57,11 @@ public final class TransferHate extends AbstractEffect @Override public void onStart(BuffInfo info) { + if (!Util.checkIfInRange(info.getSkill().getEffectRange(), info.getEffector(), info.getEffected(), true)) + { + return; + } + for (L2Character obj : info.getEffector().getKnownList().getKnownCharactersInRadius(info.getSkill().getAffectRange())) { if ((obj == null) || !obj.isAttackable() || obj.isDead()) diff --git a/trunk/dist/game/data/scripts/handlers/effecthandlers/Unsummon.java b/trunk/dist/game/data/scripts/handlers/effecthandlers/Unsummon.java index 2f2025c9ca..aa9a961738 100644 --- a/trunk/dist/game/data/scripts/handlers/effecthandlers/Unsummon.java +++ b/trunk/dist/game/data/scripts/handlers/effecthandlers/Unsummon.java @@ -55,16 +55,9 @@ public final class Unsummon extends AbstractEffect return true; } } - return false; } - @Override - public boolean canStart(BuffInfo info) - { - return info.getEffected().isSummon(); - } - @Override public boolean isInstant() { diff --git a/trunk/dist/game/data/scripts/handlers/effecthandlers/VitalityPointUp.java b/trunk/dist/game/data/scripts/handlers/effecthandlers/VitalityPointUp.java index 7a6df1fdce..9bc1213b88 100644 --- a/trunk/dist/game/data/scripts/handlers/effecthandlers/VitalityPointUp.java +++ b/trunk/dist/game/data/scripts/handlers/effecthandlers/VitalityPointUp.java @@ -39,12 +39,6 @@ public final class VitalityPointUp extends AbstractEffect _value = params.getInt("value", 0); } - @Override - public boolean canStart(BuffInfo info) - { - return (info.getEffected() != null) && info.getEffected().isPlayer(); - } - @Override public boolean isInstant() { @@ -54,7 +48,10 @@ public final class VitalityPointUp extends AbstractEffect @Override public void onStart(BuffInfo info) { - info.getEffected().getActingPlayer().updateVitalityPoints(_value, false, false); - info.getEffected().getActingPlayer().sendPacket(new UserInfo(info.getEffected().getActingPlayer())); + if ((info.getEffected() != null) && info.getEffected().isPlayer()) + { + info.getEffected().getActingPlayer().updateVitalityPoints(_value, false, false); + info.getEffected().getActingPlayer().sendPacket(new UserInfo(info.getEffected().getActingPlayer())); + } } } diff --git a/trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PcInstanceAction.java b/trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PcInstanceAction.java index b3d0e53f04..1144640612 100644 --- a/trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PcInstanceAction.java +++ b/trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PcInstanceAction.java @@ -24,6 +24,7 @@ import com.l2jserver.gameserver.enums.InstanceType; import com.l2jserver.gameserver.enums.PrivateStoreType; import com.l2jserver.gameserver.handler.IActionHandler; import com.l2jserver.gameserver.model.L2Object; +import com.l2jserver.gameserver.model.Location; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.entity.TvTEvent; @@ -105,6 +106,12 @@ public class L2PcInstanceAction implements IActionHandler activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); activeChar.onActionRequest(); } + else + { + final Location destination = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId()); + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); + activeChar.onActionRequest(); + } } } else @@ -115,6 +122,12 @@ public class L2PcInstanceAction implements IActionHandler { activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target); } + else + { + final Location destination = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId()); + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); + activeChar.onActionRequest(); + } } } } diff --git a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Fear.java b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Fear.java index 1c07b35c01..326af2db9f 100644 --- a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Fear.java +++ b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Fear.java @@ -18,6 +18,7 @@ */ package handlers.effecthandlers; +import com.l2jserver.Config; import com.l2jserver.gameserver.GeoData; import com.l2jserver.gameserver.ai.CtrlEvent; import com.l2jserver.gameserver.ai.CtrlIntention; @@ -105,7 +106,17 @@ public final class Fear extends AbstractEffect info.getEffected().setRunning(); } - final Location destination = GeoData.getInstance().moveCheck(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), posX, posY, posZ, info.getEffected().getInstanceId()); + // If pathfinding enabled the creature will go to the defined destination (retail like). + // Otherwise it will go to the nearest obstacle. + final Location destination; + if (Config.PATHFINDING > 0) + { + destination = new Location(posX, posY, posZ, info.getEffected().getInstanceId()); + } + else + { + destination = GeoData.getInstance().moveCheck(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), posX, posY, posZ, info.getEffected().getInstanceId()); + } info.getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); } } diff --git a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/TransferHate.java b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/TransferHate.java index 0b6b604736..fac4aabe12 100644 --- a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/TransferHate.java +++ b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/TransferHate.java @@ -48,12 +48,6 @@ public final class TransferHate extends AbstractEffect return Formulas.calcProbability(_chance, info.getEffector(), info.getEffected(), info.getSkill()); } - @Override - public boolean canStart(BuffInfo info) - { - return Util.checkIfInRange(info.getSkill().getEffectRange(), info.getEffector(), info.getEffected(), true); - } - @Override public boolean isInstant() { @@ -63,6 +57,11 @@ public final class TransferHate extends AbstractEffect @Override public void onStart(BuffInfo info) { + if (!Util.checkIfInRange(info.getSkill().getEffectRange(), info.getEffector(), info.getEffected(), true)) + { + return; + } + for (L2Character obj : info.getEffector().getKnownList().getKnownCharactersInRadius(info.getSkill().getAffectRange())) { if ((obj == null) || !obj.isAttackable() || obj.isDead()) diff --git a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Unsummon.java b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Unsummon.java index 2f2025c9ca..aa9a961738 100644 --- a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Unsummon.java +++ b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/Unsummon.java @@ -55,16 +55,9 @@ public final class Unsummon extends AbstractEffect return true; } } - return false; } - @Override - public boolean canStart(BuffInfo info) - { - return info.getEffected().isSummon(); - } - @Override public boolean isInstant() { diff --git a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/VitalityPointUp.java b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/VitalityPointUp.java index 7a6df1fdce..9bc1213b88 100644 --- a/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/VitalityPointUp.java +++ b/trunk/dist/game/data_classic/scripts/handlers/effecthandlers/VitalityPointUp.java @@ -39,12 +39,6 @@ public final class VitalityPointUp extends AbstractEffect _value = params.getInt("value", 0); } - @Override - public boolean canStart(BuffInfo info) - { - return (info.getEffected() != null) && info.getEffected().isPlayer(); - } - @Override public boolean isInstant() { @@ -54,7 +48,10 @@ public final class VitalityPointUp extends AbstractEffect @Override public void onStart(BuffInfo info) { - info.getEffected().getActingPlayer().updateVitalityPoints(_value, false, false); - info.getEffected().getActingPlayer().sendPacket(new UserInfo(info.getEffected().getActingPlayer())); + if ((info.getEffected() != null) && info.getEffected().isPlayer()) + { + info.getEffected().getActingPlayer().updateVitalityPoints(_value, false, false); + info.getEffected().getActingPlayer().sendPacket(new UserInfo(info.getEffected().getActingPlayer())); + } } } diff --git a/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java b/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java index e15b786da1..719913168b 100644 --- a/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java +++ b/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java @@ -636,7 +636,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable } // If NPC with random fixed coord, don't move (unless needs to return to spawnpoint) - if ((TerritoryTable.getInstance().getProcMax(npc.getSpawn().getLocationId()) > 0) && !npc.isReturningToSpawnPoint()) + if (!npc.isReturningToSpawnPoint() && (TerritoryTable.getInstance().getProcMax(npc.getSpawn().getLocationId()) > 0)) { return; } diff --git a/trunk/java/com/l2jserver/gameserver/ai/L2SummonAI.java b/trunk/java/com/l2jserver/gameserver/ai/L2SummonAI.java index 523341c092..578c2f954b 100644 --- a/trunk/java/com/l2jserver/gameserver/ai/L2SummonAI.java +++ b/trunk/java/com/l2jserver/gameserver/ai/L2SummonAI.java @@ -24,12 +24,14 @@ import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE; import java.util.concurrent.Future; +import com.l2jserver.Config; import com.l2jserver.gameserver.GeoData; import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.model.L2Object; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Summon; import com.l2jserver.gameserver.model.skills.Skill; +import com.l2jserver.gameserver.pathfinding.PathFinding; import com.l2jserver.util.Rnd; public class L2SummonAI extends L2PlayableAI implements Runnable @@ -48,6 +50,17 @@ public class L2SummonAI extends L2PlayableAI implements Runnable super(creature); } + @Override + protected void onIntentionAttack(L2Character target) + { + if ((Config.PATHFINDING > 0) && (PathFinding.getInstance().findPath(_actor.getX(), _actor.getY(), _actor.getZ(), target.getX(), target.getY(), target.getZ(), _actor.getInstanceId(), true) == null)) + { + return; + } + + super.onIntentionAttack(target); + } + @Override protected void onIntentionIdle() { diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java b/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java index 6f73a23473..87b8d70ff4 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java @@ -20,7 +20,6 @@ package com.l2jserver.gameserver.model.actor; import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE; import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK; -import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW; import java.util.ArrayList; import java.util.Collection; @@ -4465,15 +4464,17 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe distance = Math.sqrt((dx * dx) + (dy * dy)); } + // @formatter:off // Define movement angles needed // ^ - // | X (x,y) - // | / - // | /distance + // | X (x,y) + // | / + // | / distance // | / // |/ angle // X ----------> // (curx,cury) + // @formatter:on double cos; double sin; @@ -4539,8 +4540,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Movement checks: // when PATHFINDING > 0, for all characters except mobs returning home (could be changed later to teleport if pathfinding fails) - if (((Config.PATHFINDING > 0) && (!(isAttackable() && ((L2Attackable) this).isReturningToSpawnPoint()))) || (isPlayer() && !(isInVehicle && (distance > 1500))) || (isSummon() && !(getAI().getIntention() == AI_INTENTION_FOLLOW)) // assuming intention_follow only when following owner - || isAfraid()) + if (((Config.PATHFINDING > 0) && (!(isAttackable() && ((L2Attackable) this).isReturningToSpawnPoint()))) // + || (isPlayer() && !(isInVehicle && (distance > 1500)))) { if (isOnGeodataPath()) { @@ -4590,7 +4591,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Pathfinding checks. Only when geodata setting is 2, the LoS check gives shorter result // than the original movement was and the LoS gives a shorter distance than 2000 // This way of detecting need for pathfinding could be changed. - if ((Config.PATHFINDING > 0) && ((originalDistance - distance) > 30) && (distance < 2000) && !isAfraid()) + if ((Config.PATHFINDING > 0) && ((originalDistance - distance) > 30) && (distance < 2000)) { // Path calculation // Overrides previous movement check @@ -4599,14 +4600,13 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe m.geoPath = PathFinding.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceId(), isPlayable()); if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found { - // * Even though there's no path found (remember geonodes aren't perfect), + // Even though there's no path found (remember geonodes aren't perfect), // the mob is attacking and right now we set it so that the mob will go // after target anyway, is dz is small enough. - // * With cellpathfinding this approach could be changed but would require taking + // With cellpathfinding this approach could be changed but would require taking // off the geonodes and some more checks. - // * Summons will follow their masters no matter what. - // * Currently minions also must move freely since L2AttackableAI commands - // them to move along with their leader + // Summons will follow their masters no matter what. + // Currently minions also must move freely since L2AttackableAI commands them to move along with their leader if (isPlayer() || (!isPlayable() && !isMinion() && (Math.abs(z - curZ) > 140)) || (isSummon() && !((L2Summon) this).getFollowStatus())) { getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/L2Summon.java b/trunk/java/com/l2jserver/gameserver/model/actor/L2Summon.java index e890ee75fc..24920974de 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/L2Summon.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/L2Summon.java @@ -67,6 +67,7 @@ import com.l2jserver.gameserver.network.serverpackets.RelationChanged; import com.l2jserver.gameserver.network.serverpackets.SummonInfo; import com.l2jserver.gameserver.network.serverpackets.SystemMessage; import com.l2jserver.gameserver.network.serverpackets.TeleportToLocation; +import com.l2jserver.gameserver.pathfinding.PathFinding; import com.l2jserver.gameserver.taskmanager.DecayTaskManager; import com.l2jserver.gameserver.util.Util; import com.l2jserver.util.Rnd; @@ -680,6 +681,12 @@ public abstract class L2Summon extends L2Playable return false; } + if ((this != target) && skill.isPhysical() && (Config.PATHFINDING > 0) && (PathFinding.getInstance().findPath(getX(), getY(), getZ(), target.getX(), target.getY(), target.getZ(), getInstanceId(), true) == null)) + { + sendPacket(SystemMessageId.CANNOT_SEE_TARGET); + return false; + } + // Check if this is bad magic skill if (skill.isBad()) { diff --git a/trunk/java/com/l2jserver/gameserver/model/drops/strategy/IAmountMultiplierStrategy.java b/trunk/java/com/l2jserver/gameserver/model/drops/strategy/IAmountMultiplierStrategy.java index a3b2f5b794..82aa810c83 100644 --- a/trunk/java/com/l2jserver/gameserver/model/drops/strategy/IAmountMultiplierStrategy.java +++ b/trunk/java/com/l2jserver/gameserver/model/drops/strategy/IAmountMultiplierStrategy.java @@ -38,10 +38,10 @@ public interface IAmountMultiplierStrategy { double multiplier = 1; - Float dropChanceMultiplier = Config.RATE_DROP_AMOUNT_MULTIPLIER.get(item.getItemId()); - if (dropChanceMultiplier != null) + Float dropAmountMultiplier = Config.RATE_DROP_AMOUNT_MULTIPLIER.get(item.getItemId()); + if (dropAmountMultiplier != null) { - multiplier *= dropChanceMultiplier; + multiplier *= dropAmountMultiplier; } else if (ItemTable.getInstance().getTemplate(item.getItemId()).hasExImmediateEffect()) { diff --git a/trunk/java/com/l2jserver/gameserver/network/clientpackets/RequestEnchantItem.java b/trunk/java/com/l2jserver/gameserver/network/clientpackets/RequestEnchantItem.java index a97e151081..5df5dc23d3 100644 --- a/trunk/java/com/l2jserver/gameserver/network/clientpackets/RequestEnchantItem.java +++ b/trunk/java/com/l2jserver/gameserver/network/clientpackets/RequestEnchantItem.java @@ -358,14 +358,6 @@ public final class RequestEnchantItem extends L2GameClientPacket activeChar.sendPacket(sm); } - if (!Config.FORCE_INVENTORY_UPDATE) - { - if (crystals != null) - { - iu.addItem(crystals); - } - } - if (crystalId == 0) { activeChar.sendPacket(new EnchantResult(EnchantResult.NO_CRYSTAL, 0, 0));