Thread: Npc Random Walking Checks

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11  
    Npc Random Walking Checks



    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    30
    Posts
    16,307
    Thanks given
    7,215
    Thanks received
    12,308
    Rep Power
    5000
    Quote Originally Posted by Advocatus Diaboli View Post
    Yes, if you did it for all npcs it would. But this thread is about doing walking checks. Doing a floor id check would allow you to have npcs that walk around in oddly shaped rooms/ houses. Additionally, this would work for bankers because in some banks, the bankers stand on different floor ids.
    what is a "floor id"?

    Attached image
    Reply With Quote  
     

  2. #12  
    Chemist

    Advocatus's Avatar
    Join Date
    Dec 2009
    Posts
    2,622
    Thanks given
    201
    Thanks received
    813
    Rep Power
    1462
    Quote Originally Posted by Scu11 View Post
    what is a "floor id"?
    The id of the floor used by the client to color/texture the ground.

    In 400+, the client loads this information from files in index 5 based on the file name which are named m_'x'_'y'. 'x' and 'y' are calculated from the region id.
    In the earlier client versions, the information was stored in index 3 and possessed an even file name. The coordinants were related to this file name from the mapindex file which was contained in file 5 of index 0.

    These files are loaded like.
    Code:
    	//Note: chunkRotation only applies to maps created with the construct map region packet.
    	static final void loadFloorData(int tileY, int y, int chunkRotation, int plane, int tileX, int x, Stream stream) {
    		if (x >= 0 && x < 104 && y >= 0 && y < 104) {
    			tileFlags[plane][x][y] = (byte) 0;
    			for (;;) {
    				int opcode = stream.getUByte();
    				if (opcode == 0) {
    					if (plane == 0)
    						tileHeight[0][x][y] = -method425(tileY + y + 556238, x + 932731 + tileX) * 8;
    					else
    						tileHeight[plane][x][y] = (tileHeight[plane - 1][x][y]) - 240;
    					break;
    				}
    				if (opcode == 1) {
    					int heightModifier = stream.getUByte();
    					if (heightModifier == 1)
    						heightModifier = 0;
    					if (plane != 0)
    						tileHeight[plane][x][y] = -(heightModifier * 8) + (tileHeight[plane - 1][x][y]);
    					else
    						tileHeight[0][x][y] = -heightModifier * 8;
    					break;
    				}
    				if (opcode <= 49) {
    					overlayIds[plane][x][y] = stream.getByte();
    					overlayShape[plane][x][y] = (byte) ((opcode - 2) / 4);
    					overlayRotation[plane][x][y] = (byte) ((opcode + (chunkRotation - 2)) & 3);
    				} else if (opcode <= 81) {
    					tileFlags[plane][x][y] = (byte) (opcode - 49);
    				} else {
    					underlayIds[plane][x][y] = (byte) (opcode - 81);
    				}
    			}
    		} else {
    			//Note: Obviously coordinants were out of bounds. 
    			//However, we read the file so that the buffer's reader index will increase.
    			for (;;) {
    				int opcode = stream.getUByte();
    				if (opcode == 0)
    					break;
    				if (opcode == 1) {
    					stream.getUByte();
    					break;
    				}
    				if (opcode <= 49)
    					stream.getUByte();
    			}
    		}	
    	}
    For loading the data server sided, the majority of the file is irrelevant. The floor ids I was talking about are the overlayIds/underlayIds. I use the word floor because the file that these ids applied to was called "flo.dat" in pre 400 rs2.
    Quote Originally Posted by blakeman8192 View Post
    Quitting is the only true failure.
    Reply With Quote  
     

  3. #13  
    Registered Member Makaveli V2's Avatar
    Join Date
    Feb 2014
    Posts
    140
    Thanks given
    18
    Thanks received
    101
    Rep Power
    9
    To check if you're within a radius:
    Code:
    boolean inCircle = Math.sqrt(((x1 - x2)^2) + ((y1 - y2)^2)) <= radius;
    Explanation:


    It's basic pythagoras, if the hypotenuse is less than the radius, they're inside the circle. If it's equal, they're on the very edge and if its greater then they're outside.
    Reply With Quote  
     

  4. #14  


    Major's Avatar
    Join Date
    Jan 2011
    Posts
    2,997
    Thanks given
    1,293
    Thanks received
    3,556
    Rep Power
    5000
    Quote Originally Posted by Patrick Star View Post
    To check if you're within a radius:
    Code:
    boolean inCircle = Math.sqrt(((x1 - x2)^2) + ((y1 - y2)^2)) <= radius;
    Explanation:


    It's basic pythagoras, if the hypotenuse is less than the radius, they're inside the circle. If it's equal, they're on the very edge and if its greater then they're outside.
    Java doesn't have an exponent operator, use Math.pow instead (also drop the Math.sqrt and compare it with radius * radius instead, micro-optimisation but square rooting is still much slower than simple multiplication).
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

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. Npc random walking clipping [317]
    By bebew67 in forum Help
    Replies: 0
    Last Post: 05-05-2013, 07:20 PM
  2. Replies: 3
    Last Post: 03-16-2013, 09:48 PM
  3. [677] npc random walk help
    By Paradox- in forum Help
    Replies: 0
    Last Post: 09-23-2012, 04:13 PM
  4. RuneEscape 562 - Npc random Walking
    By Kayla in forum Requests
    Replies: 6
    Last Post: 08-28-2011, 04:53 PM
  5. (508) NPC random Walk, repping++++
    By Clawscape in forum Help
    Replies: 4
    Last Post: 03-21-2009, 12:24 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
  •