From dd206ece708b90b264ad93d734034c72f041d012 Mon Sep 17 00:00:00 2001 From: Gptaqbc <56596815+Gptaqbc@users.noreply.github.com> Date: Sun, 27 Oct 2019 15:12:47 -0400 Subject: [PATCH] Next (#124) * Update NpcHandler.class Fixed the diagonal safefpotting combat bug. The NPC will move when it detects that the player is standing diagonally to it. Still have some issue around objects but that's another story. * Update NpcHandler.java Fixed the diagonal safefpotting combat bug. The NPC will move when it detects that the player is standing diagonally to it. Still have some issue around objects but that's another story. closes #47 --- .../src/redone/game/npcs/NpcHandler.java | 26 +++++++++++++----- .../redone/game/npcs/NpcHandler.class | Bin 26544 -> 26756 bytes 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/2006Redone Server/src/redone/game/npcs/NpcHandler.java b/2006Redone Server/src/redone/game/npcs/NpcHandler.java index b74f00ff..fa6bfb7f 100644 --- a/2006Redone Server/src/redone/game/npcs/NpcHandler.java +++ b/2006Redone Server/src/redone/game/npcs/NpcHandler.java @@ -1047,17 +1047,25 @@ public class NpcHandler { && y > npc.makeY - Constants.NPC_FOLLOW_DISTANCE) { if (npc.heightLevel == player.heightLevel) { if (player != null && npc != null) { - if (playerY < y) { - npc.moveX = GetMove(x, playerX); + if (playerX > x && playerY < y) { + npc.moveX = GetMove(x,playerX);//Diagonal bottom right + } else if (playerX < x && playerY < y) { + npc.moveY = GetMove(y,playerY); //Diagonal bottom left + } else if (playerX < x && playerY > y) { + npc.moveX = GetMove(x,playerX);// Diagonal top left + } else if (playerX > x && playerY > y) { + npc.moveY = GetMove(y,playerY);// Diagonal top right + } else if (playerY < y) { + npc.moveX = GetMove(x, playerX); //Move South to player npc.moveY = GetMove(y, playerY); } else if (playerY > y) { - npc.moveX = GetMove(x, playerX); + npc.moveX = GetMove(x, playerX); //Move North to player npc.moveY = GetMove(y, playerY); } else if (playerX < x) { - npc.moveX = GetMove(x, playerX); + npc.moveX = GetMove(x, playerX); //Move West to player npc.moveY = GetMove(y, playerY); } else if (playerX > x) { - npc.moveX = GetMove(x, playerX); + npc.moveX = GetMove(x, playerX); //Move East to player npc.moveY = GetMove(y, playerY); } npc.facePlayer(playerId); @@ -1203,12 +1211,16 @@ public class NpcHandler { } } } - public static boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) { return objectX - playerX <= distance && objectX - playerX >= -distance && objectY - playerY <= distance - && objectY - playerY >= -distance; + && objectY - playerY >= -distance + && !((objectX - playerX == distance && objectY - playerY == -distance) //Detect diagonal positioning + || (objectX - playerX == -distance && objectY - playerY == -distance) + || (objectX - playerX == -distance && objectY - playerY == distance) + || (objectX - playerX == distance && objectY - playerY == distance)) + ; } public static int getMaxHit(int i) { diff --git a/CompiledServer/production/2006rebotted/redone/game/npcs/NpcHandler.class b/CompiledServer/production/2006rebotted/redone/game/npcs/NpcHandler.class index 22ff6657e1e27b343f5838c0509e5a1e6622ed81..29f268760b719d3bcc77db8dfa546321e1897816 100644 GIT binary patch delta 1358 zcmY+BYfw~W7{~w5?(-}H25feKl|2h`6A+w5K`RtRa3YX2L2k=MU|U1XQVekh-A2J0 z;}d6cm}VRhmZ6ynFs!lB4>ePG$uPQ1gY=^kY08^$hS$4%sIhxq`B=m?7w~v-;mf6A)5wdlF7R?nZd0^I$wFRBT zs(!NBf+l922@1Ds;zN|KSq5OWu_pFY=y((RhjBqA1NS5r-Jcv7#@JlqL+bwz9i6+* z=fCd1LmkFXTSm;6vBDTEf6D9RNXq3XD&lCWWE;78A?@ZEI>2`7W}SN2LB}|jUgbDC z!Heh&$I}H)ppQ6_W;ltiaWdWD#dMofOu}iVP+npR=X8_C872p3ni6@LDUFw#oSaSJ z05%7RQ3RP)g$<@mDpZnih(_pHrA+9iA!<{~jJK(sn#l>qJG6`9l_xk$+bKaQ3nrpn!eGRaZN`V${_f)nA95M-a!ONaQhO@CmHsH?W4s zQOKtZYwc?9hpK;3-RxLscWXR|C;aQ4Bszl(T9fvTkmmF?mD6V zJ$;D!_srcoh=;-E*VOmS6sF#m5;X|$Y5%0M0zX2B6zth&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