From 5f0b07a2c7c9973895a64e7f1ac6d30fc3f14346 Mon Sep 17 00:00:00 2001 From: Zoey76 <zoey_76@msn.com> Date: Sat, 23 May 2015 16:29:24 -0300 Subject: [PATCH] Minor typo fix preventing player from talking with NPCs under certain conditions Reported by: u3games, sahar --- .../handlers/actionhandlers/L2NpcAction.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/L2J_DataPack/dist/game/data/scripts/handlers/actionhandlers/L2NpcAction.java b/L2J_DataPack/dist/game/data/scripts/handlers/actionhandlers/L2NpcAction.java index e486bdada6..94fe9c4333 100644 --- a/L2J_DataPack/dist/game/data/scripts/handlers/actionhandlers/L2NpcAction.java +++ b/L2J_DataPack/dist/game/data/scripts/handlers/actionhandlers/L2NpcAction.java @@ -60,55 +60,55 @@ public class L2NpcAction implements IActionHandler @Override public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) { - if (!((L2Npc) target).canTarget(activeChar)) + final L2Npc npc = (L2Npc) target; + if (!npc.canTarget(activeChar)) { return false; } - activeChar.setLastFolkNPC((L2Npc) target); + activeChar.setLastFolkNPC(npc); // Check if the L2PcInstance already target the L2Npc - if (target != activeChar.getTarget()) + if (npc != activeChar.getTarget()) { // Set the target of the L2PcInstance activeChar - activeChar.setTarget(target); + activeChar.setTarget(npc); // Check if the activeChar is attackable (without a forced attack) - if (target.isAutoAttackable(activeChar)) + if (npc.isAutoAttackable(activeChar)) { - ((L2Npc) target).getAI(); // wake up ai + npc.getAI(); // wake up ai } } else if (interact) { // Check if the activeChar is attackable (without a forced attack) and isn't dead - if (target.isAutoAttackable(activeChar) && !((L2Npc) target).isAlikeDead()) + if (npc.isAutoAttackable(activeChar) && !npc.isAlikeDead()) { - if (GeoData.getInstance().canSeeTarget(activeChar, target)) + if (GeoData.getInstance().canSeeTarget(activeChar, npc)) { - activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target); + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc); } else { - final Location destination = GeoData.getInstance().moveCheck(activeChar, target); + final Location destination = GeoData.getInstance().moveCheck(activeChar, npc); activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); } } - else if (!target.isAutoAttackable(activeChar)) + else if (!npc.isAutoAttackable(activeChar)) { - if (GeoData.getInstance().canSeeTarget(activeChar, target)) + if (!GeoData.getInstance().canSeeTarget(activeChar, npc)) { - final Location destination = GeoData.getInstance().moveCheck(activeChar, target); + final Location destination = GeoData.getInstance().moveCheck(activeChar, npc); activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination); return true; } - // Calculate the distance between the L2PcInstance and the L2Npc - if (!((L2Npc) target).canInteract(activeChar)) + // Verifies if the NPC can interact with the player. + if (!npc.canInteract(activeChar)) { // Notify the L2PcInstance AI with AI_INTENTION_INTERACT - activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, npc); } else { - final L2Npc npc = (L2Npc) target; // Turn NPC to the player. activeChar.sendPacket(new MoveToPawn(activeChar, npc, 100)); if (npc.hasRandomAnimation()) @@ -118,13 +118,13 @@ public class L2NpcAction implements IActionHandler // Open a chat window on client with the text of the L2Npc if (npc.isEventMob()) { - L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId())); + L2Event.showEventHtml(activeChar, String.valueOf(npc.getObjectId())); } else { if (npc.hasListener(EventType.ON_NPC_QUEST_START)) { - activeChar.setLastQuestNpcObject(target.getObjectId()); + activeChar.setLastQuestNpcObject(npc.getObjectId()); } if (npc.hasListener(EventType.ON_NPC_FIRST_TALK)) { -- GitLab