Thread: [ANGUISH-ASCEND] NPC pathfinding bug

Results 1 to 3 of 3
  1. #1 [ANGUISH-ASCEND] NPC pathfinding bug 
    Registered Member
    Join Date
    Jun 2013
    Posts
    66
    Thanks given
    7
    Thanks received
    3
    Rep Power
    11
    I'm trying to fix a huge bug with npc path finding.. All melee Npcs can be safe spotted by range/mage from standing 1 square away as long as it is diagonally like this:

    [Only registered and activated users can see links. ]

    Seems to be prevalent across many [ASCEND] based sources. Does anyone know what the solution might be? Or know of any good tutorials on npc pathfinding? Cheers.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jan 2017
    Posts
    119
    Thanks given
    7
    Thanks received
    19
    Discord
    View profile
    Rep Power
    9
    NPCHandler.java

    find this:

    Code:
    		if (player.absX == npcs[i].absX && player.absY == npcs[i].absY) {
    			stepAway(i);
    			npcs[i].randomWalk = false;
    			npcs[i].facePlayer(player.getIndex());
    		}
    underneath it add:

    Code:
    	if ((player.absX == npcs[i].absX-1 && player.absY == npcs[i].absY+1) || (player.absX == npcs[i].absX-1 && player.absY == npcs[i].absY-1)
    		|| (player.absX == npcs[i].absX+1 && player.absY == npcs[i].absY-1) || (player.absX == npcs[i].absX+1 && player.absY == npcs[i].absY+1)){
    			stepAway2(player,i);
    			npcs[i].randomWalk = false;
    			npcs[i].facePlayer(player.getIndex());
    		}
    then add this somewhere:

    Code:
    	public void stepAway2(Player player, int i) {
    		int[][] points = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
    
    		for (int[] k : points) {
    			int dir = NPCClipping.getDirection(k[0], k[1]);
    			if (NPCDumbPathFinder.canMoveTo(npcs[i], dir)) {
    				NPCDumbPathFinder.walkTowards(npcs[i], npcs[i].absX > player.absX ? player.absX-1 : player.absX+1 ,npcs[i].absY > player.absY ? player.absY+1 : player.absY-1);
    				break;
    			}
    		}
    	}
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Jun 2013
    Posts
    66
    Thanks given
    7
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by socklol View Post
    NPCHandler.java

    find this:

    Code:
    		if (player.absX == npcs[i].absX && player.absY == npcs[i].absY) {
    			stepAway(i);
    			npcs[i].randomWalk = false;
    			npcs[i].facePlayer(player.getIndex());
    		}
    underneath it add:

    Code:
    	if ((player.absX == npcs[i].absX-1 && player.absY == npcs[i].absY+1) || (player.absX == npcs[i].absX-1 && player.absY == npcs[i].absY-1)
    		|| (player.absX == npcs[i].absX+1 && player.absY == npcs[i].absY-1) || (player.absX == npcs[i].absX+1 && player.absY == npcs[i].absY+1)){
    			stepAway2(player,i);
    			npcs[i].randomWalk = false;
    			npcs[i].facePlayer(player.getIndex());
    		}
    then add this somewhere:

    Code:
    	public void stepAway2(Player player, int i) {
    		int[][] points = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
    
    		for (int[] k : points) {
    			int dir = NPCClipping.getDirection(k[0], k[1]);
    			if (NPCDumbPathFinder.canMoveTo(npcs[i], dir)) {
    				NPCDumbPathFinder.walkTowards(npcs[i], npcs[i].absX > player.absX ? player.absX-1 : player.absX+1 ,npcs[i].absY > player.absY ? player.absY+1 : player.absY-1);
    				break;
    			}
    		}
    	}
    Thank you very much, worked like a charm and I learnt a bit about how npc pathfinding is coded.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [ANGUISH-ASCEND]NPC drop table bug
    By runtw2 in forum Help
    Replies: 5
    Last Post: 04-25-2020, 10:02 PM
  2. NPC attack bug
    By Oxygen in forum Help
    Replies: 8
    Last Post: 05-06-2009, 06:26 AM
  3. NPC Twitch bug
    By ViperSniper in forum Help
    Replies: 11
    Last Post: 02-18-2009, 06:57 AM
  4. npc agression bug.
    By Bando in forum Help
    Replies: 6
    Last Post: 02-08-2009, 09:21 PM
  5. Npc Dialogue bug
    By joshscape123 in forum Help
    Replies: 2
    Last Post: 11-04-2008, 12:10 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •