Thread: Pathfinder for using objects

Results 1 to 8 of 8
  1. #1 Pathfinder for using objects 
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    Hey

    Does any1 got a server-sided pathfinder that finds the path to a tile where an object is usable from?

    Heres a picture to explain more: - so my current pathfinder does find the path to walk next to the object, but if the object is only usable from specific tiles it doesnt work. (unless I manually set the tile to walk-to to something that the object works with)


    EDIT: current code:
    Code:
    ClippedPathFinder.getPathFinder().findRoute(this, def.getPosition().getX(), def.getPosition().getY(), true, object.getSizeX(def.getFace()), object.getSizeY(def.getFace()));
    Code:
    public int getSizeX(int rotation) {
    		if (rotation == 1 || rotation == 3) {
    			return yLength;
    		} else {
    			return xLength;
    		}
    	}
    
    	public int getSizeY(int rotation) {
    		if (rotation == 1 || rotation == 3) {
    			return xLength;
    		} else {
    			return yLength;
    		}
    	}
    Pathfinder: [Only registered and activated users can see links. ]
    ...
    Reply With Quote  
     

  2. #2  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    ObjectDefinitions#opcode69 determines from which side(s) the objects can be interacted with. Implement that into your pathfinder if it isn't already there.
    Reply With Quote  
     

  3. #3  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    Quote Originally Posted by Kris View Post
    ObjectDefinitions#opcode69 determines from which side(s) the objects can be interacted with. Implement that into your pathfinder if it isn't already there.
    Those stairs do not have value set on that opcode.
    ...
    Reply With Quote  
     

  4. #4  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by mige5 View Post
    Those stairs do not have value set on that opcode.
    ObjectDefinitions(id=30367, varbit=-1, anInt453=1, models=[1203], objectTypes=null, transformedIds=null, name=Ladder, ambientSoundId=-1, varp=-1, supportItems=1, anIntArray100=null, mapIconId=-1, sizeX=1, clipType=2, isRotated=false, sizeY=1, hasShadow=false, projectileClip=true, anInt455=0, nonFlatShading=false, adjustType=-1, anInt456=0, modelClipped=false, ambient=0, options=[Climb-down, null, null, null, null], contrast=0, anInt457=0, hollow=false, animationId=-1, modelSizeX=128, decorDisplacement=16, modelSizeHeight=128, modelSizeY=128, modelColour=null, clipped=true, modelTexture=null, mapSceneId=7, replacementColour=null, offsetX=0, replacementTexture=null, offsetHeight=0, offsetY=0, obstructsGround=false, accessBlockFlag=0, params=null)


    You're right. This means you have to force the location for it server-side. There are some - although not that common - cases in which they have custom path handlers for it. You could of course just edit the definitions and set the flag yourself as well.
    Reply With Quote  
     

  5. #5  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,200
    Thanks given
    7,190
    Thanks received
    12,174
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Kris View Post
    You're right. This means you have to force the location for it server-side
    No you don't, those fences either side of it each ladder prevents them from being interacted with from the left/right.

    [Only registered and activated users can see links. ]



    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by Scu11 View Post
    No you don't, those fences either side of it each ladder prevents them from being interacted with from the left/right.
    Ah yes, you're right actually. Didn't go there in-game to actually test it before posting my last reply but that is indeed the case here. Honestly thought those fences were just part of the ladder object itself. Got a little confused and assume it requires a hacky way of handling it like a few things I've encountered have.
    Aaanyways, yeah it is correct.
    [Only registered and activated users can see links. ]
    There's no special code handling the "route" to the object, all ran through generic pathfinding. You just need to check whether the tile you're interacting from has a "wall" in-front of you or not, which should be covered by pathfinding just fine. No clue how 317s handle it though since their pathfinding shit is done through client.
    Reply With Quote  
     

  8. #7  
    REGISTERED MEMBER RAT DONOR MORE COMING

    Major's Avatar
    Join Date
    Jan 2011
    Posts
    3,002
    Thanks given
    1,295
    Thanks received
    3,549
    Rep Power
    5000
    Quote Originally Posted by Kris View Post
    ObjectDefinitions#opcode69 determines from which side(s) the objects can be interacted with. Implement that into your pathfinder if it isn't already there.
    Yeah, the last four bits of this 'surroundings' bitmask control whether or not the pathfinder considers an object to have been reached if approached from that side (the other bits aren't used, at least in 3xx). 0 means reachable from that side, 1 means unreachable, and it's ordered WESN (i.e. the last bit states whether or not the object is reached when standing one tile north of it).

    Code:
    	public boolean reached(int x, int y, int minX, int minY, int rangeX, int rangeY, int surroundings) {
    		int maxX = (minX + rangeX) - 1;
    		int maxY = (minY + rangeY) - 1;
    
    		if (x >= minX && x <= maxX && y >= minY && y <= maxY) { // inside target area
    			return true;
    		} else if (x == minX - 1 && y >= minY && y <= maxY && (matrix[x][y] & WALL_EAST) == 0 && (surroundings & 0x8) == 0) {
    			return true;
    		} else if (x == maxX + 1 && y >= minY && y <= maxY && (matrix[x][y] & WALL_WEST) == 0 && (surroundings & 0x2) == 0) {
    			return true;
    		} else if (y == minY - 1 && x >= minX && x <= maxX && (matrix[x][y] & WALL_NORTH) == 0 && (surroundings & 0x4) == 0) {
    			return true;
    		} else if (y == maxY + 1 && x >= minX && x <= maxX && (matrix[x][y] & WALL_SOUTH) == 0 && (surroundings & 0x1) == 0) {
    			return true;
    		}
    
    		return false;
    	}
    Also worth noting that only three object types support this: 10, 11, 22 (which are 'general object category i never found a name for', that same category just rotated 45 degrees, and ground decorations).
    Last edited by Major; 12-08-2018 at 10:12 PM.
    Reply With Quote  
     

  9. Thankful user:


  10. #8  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    Kind of solved this, just wondering if theres a better way to get the surrounding tiles than this kind of loop:
    Code:
    public Position findTileToUseObjectFrom(GameObjectDef def, GameObjectData object){
    		Position walkToPos = null;
    		int x = def.getPosition().getX();
    		int y = def.getPosition().getY();
    		int sizeX = object.getSizeX(def.getFace())-1;
    		int sizeY = object.getSizeY(def.getFace())-1;
    		for(int i = x-1; i <= x+sizeX+1; i++) {
    		    for(int j = y-1; j <= y+sizeY+1; j++) {
    		        if(i >= x && i <= x+sizeX && j >= y && j <= y+sizeY){
    		        	//these tiles are part of the object
    		        } else {
    		        	//these tiles are the surrounding tiles
    		        }
    		    }
    		}
    		return null;
    	}
    ...
    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. Client Backgrounds - Free for use - Part 2
    By supra s in forum Graphics
    Replies: 60
    Last Post: 12-09-2009, 10:28 PM
  2. Option for a object
    By Ventrix in forum Help
    Replies: 8
    Last Post: 02-28-2009, 02:46 AM
  3. Client Backgrounds - Free For Use
    By supra s in forum Graphics
    Replies: 52
    Last Post: 01-04-2009, 01:12 AM
  4. Replies: 9
    Last Post: 04-20-2008, 01:41 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
  •