• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[317] Fully Working Following

Initiate Mage
Joined
Feb 9, 2007
Messages
4
Reaction score
0
POST IF YOU USE OR I WILL REMOVE!!
ADD CREDITS IN YOUR SERVER!







Description: Adding Player Following

Difficulty: 1.10

Assumed Knowledge: Knowledge

Tested Server: Scratch Source work on all.

Files/Classes Modified: client.java and player.java

Result:
killerjak7 - [317] Fully Working Following - RaGEZONE Forums

Procedure
Step 1: Open up player.java and added this.

Code:
	public int FocusPointX = -1, FocusPointY = -1;	
	public Player followPlayer = null;
	public boolean followPlayerIdle;

	public boolean withinDistance(int distance, Player otherPlr) {
		if(otherPlr == null) return false;
		if(heightLevel != otherPlr.heightLevel) return false;
		int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
		return deltaX <= distance && deltaX >= ((distance + 0) * -1) && deltaY <= distance && deltaY >= ((distance + 0) * -1);
	}

	public void getNextPlayerMovement() {
		mapRegionDidChange = false;
		didTeleport = false;
		dir1 = dir2 = -1;

		if(teleportToX != -1 && teleportToY != -1) {
			followPlayer = null;
			mapRegionDidChange = true;
			if(mapRegionX != -1 && mapRegionY != -1) {
				int relX = teleportToX-mapRegionX*8, relY = teleportToY-mapRegionY*8;
				if(relX >= 2*8 && relX < 11*8 && relY >= 2*8 && relY < 11*8)
					mapRegionDidChange = false;
			}

			if(mapRegionDidChange) {
				mapRegionX = (teleportToX>>3)-6;
				mapRegionY = (teleportToY>>3)-6;

				playerListSize = 0;
			}

			currentX = teleportToX - 8*mapRegionX;
			currentY = teleportToY - 8*mapRegionY;
			absX = teleportToX;
			absY = teleportToY;

			resetWalkingQueue();

			teleportToX = teleportToY = -1;
			didTeleport = true;
		} else {
			if(followPlayer != null) {
				if(followPlayerIdle) {
					followPlayerIdle = false;
					return;
				}
				dir1 = getNextFollowingDirection(followPlayer);
				if(dir1 == -1) followPlayerIdle = true;
			} else
				dir1 = getNextWalkingDirection();
			if(dir1 == -1) return;

			if(isRunning && followPlayer != null)
				dir1 = getNextFollowingDirection(followPlayer);
			else if(isRunning)
				dir2 = getNextWalkingDirection();

			int deltaX = 0, deltaY = 0;
			if(currentX < 2*8) {
				deltaX = 4*8;
				mapRegionX -= 4;
				mapRegionDidChange = true;
			} else if(currentX >= 11*8) {
				deltaX = -4*8;
				mapRegionX += 4;
				mapRegionDidChange = true;
			}

			if(currentY < 2*8) {
				deltaY = 4*8;
				mapRegionY -= 4;
				mapRegionDidChange = true;
			} else if(currentY >= 11*8) {
				deltaY = -4*8;
				mapRegionY += 4;
				mapRegionDidChange = true;
			}

			if(mapRegionDidChange) {
				currentX += deltaX;
				currentY += deltaY;
				for(int i = 0; i < walkingQueueSize; i++) {
					walkingQueueX[i] += deltaX;
					walkingQueueY[i] += deltaY;
				}
			}

		}
	}

	public int getNextFollowingDirection(Player player) {	// Phates: My awsome follow
		int dir = -1;
		boolean goNorth = false, goSouth = false, goEast = false, goWestWhereTheCowboysRoam = false;
		
		if(absX < player.absX)
			goEast = true;
		else if(absX > player.absX)
			goWestWhereTheCowboysRoam = true;
		if(absY < player.absY)
			goNorth = true;
		else if(absY > player.absY)
			goSouth = true;

		if(!goSouth && !goNorth && !goEast && !goWestWhereTheCowboysRoam)	// Phate: if on the player
			return -1;

	
		if(withinDistance(1, player))	// Phate: If within 1 spot of the player
			return -1;

		if(goNorth && goEast)
			dir = 2;
		else if(goNorth && goWestWhereTheCowboysRoam)
			dir = 14;
		else if(goSouth && goEast)
			dir = 6;
		else if(goSouth && goWestWhereTheCowboysRoam)
			dir = 10;
		else if(goNorth)
			dir = 0;
		else if(goEast)
			dir = 4;
		else if(goWestWhereTheCowboysRoam)
			dir = 12;
		else if(goSouth)
			dir = 8;

		dir >>= 1;
		currentX += misc.directionDeltaX[dir];
		currentY += misc.directionDeltaY[dir];
		absX += misc.directionDeltaX[dir];
		absY += misc.directionDeltaY[dir];
		return dir;
	}

	public int getNextWalkingDirection()
	{
		if(wQueueReadPtr == wQueueWritePtr) return -1;		// walking queue empty
		int dir;
		do {
			dir = misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
			if(dir == -1) wQueueReadPtr = (wQueueReadPtr+1) % walkingQueueSize;
			else if((dir&1) != 0) {
				println_debug("Invalid waypoint in walking queue!");

				resetWalkingQueue();
				return -1;

			}
		} while(dir == -1 && wQueueReadPtr != wQueueWritePtr);
		if(dir == -1) return -1;
		dir >>= 1;
		currentX += misc.directionDeltaX[dir];
		currentY += misc.directionDeltaY[dir];
		absX += misc.directionDeltaX[dir];
		absY += misc.directionDeltaY[dir];
		return dir;
	}
Then save.

[B]NOTICE[/B] if you get a error about 2 of the same voids delete old ones.

[B]Step 2[/B]: [I]Open up client.java and find [/I]
public void initialize() {
and add

 	Code:
 			outStream.createFrameVarSize(104);
		outStream.writeByteC(5);
		outStream.writeByteA(0);
		outStream.writeString("Follow");
		outStream.endFrameVarSize(); 
[B]Step 3[/B]: [I]then find [/I]

 	Code:
 	public void parseIncomingPackets() 
and add

 	Code:
 				case 39:	//following
					int pIndex2 = inStream.readUnsignedWordBigEndian();
					server.FollowHandler.follow(pIndex2, playerId);
			break;
Step 4: add this in case 98:

Code:
Code:
 					if(followPlayer != null) {
					sendMessage("You stop following "+followPlayer.playerName);
					followPlayer = null;
				}
Step 5: make a file call FollowHandler.java and add this

Code:
Code:
 	public class FollowHandler {

public void follow(int them,int you) {
Player followplayer = server.playerHandler.players[them];
client c = (client) server.playerHandler.players[you];
		if(c.withinDistance(followplayer)) {
                        		c.faceNPC = 32768+them;//face them
                        		c.faceNPCupdate = true;//face them
			c.sendMessage("You are now following " + followplayer.playerName);
			c.followPlayer = followplayer;
		}
}
}

Step 5: Then in server.java add theses


Code:
Code:
	FollowHandler = new FollowHandler();
Code:
Code:
	public static FollowHandler FollowHandler = null;
ADDON ATTACKING FOLLOWING

Description: Makes you follow while attacking in the wild.

Difficulty: -1

Assumed Knowledge: How to press ctrl+f.

Tested Server: Any. You just have to use the linux's following tutorial

Files/Classes Modified: Client.java

Procedure
Step 1: Search for boolean attack

Step 2: Now add this in it:

Code:
Code:
 	server.FollowHandler.follow(AttackingOn, playerId);
That's it. If it doesn't work for you, to bad.
 
Last edited:
change my name already!
Loyal Member
Joined
Apr 10, 2007
Messages
3,198
Reaction score
1,953
Re: [Fully Working Following

Awsome! Been looking for this actually. Thanks a lot!
 
Initiate Mage
Joined
Apr 19, 2006
Messages
3
Reaction score
0
Re: [Fully Working Following

Code:
Player.java:1236: <identifier> expected
        public boolean withinDistance(int distance, Player, otherPlr) {
                                                          ^
Player.java:1236: <identifier> expected
        public boolean withinDistance(int distance, Player, otherPlr) {
                                                                    ^
2 errors

Fixed the other errors I got but can't seem to get rid of these, any help plz?
 
Initiate Mage
Joined
Feb 9, 2007
Messages
4
Reaction score
0
Re: [Fully Working Following

Code:
Player.java:1236: <identifier> expected
        public boolean withinDistance(int distance, Player, otherPlr) {
                                                          ^
Player.java:1236: <identifier> expected
        public boolean withinDistance(int distance, Player, otherPlr) {
                                                                    ^
2 errors
Fixed the other errors I got but can't seem to get rid of these, any help plz?


try with a different server source
 
There's no RL just AFK
Loyal Member
Joined
May 2, 2006
Messages
473
Reaction score
6
Re: [Fully Working Following

try with a different server source

I ain't doubting you, but i find it hard to believe that you are the creator of this here code, and yet you cannot fix the users problem.
 
Newbie Spellweaver
Joined
May 19, 2008
Messages
20
Reaction score
0
Re: [Fully Working Following

Dear Moderators,
Please lock this thread.
It has been leeched from rune-server, and gave NO CREDITS at all.
Plus, this just screws up the servers,
- DJ WhizzKid

Rate: -999999999999999999999999999999999 out of 0.
 
Last edited:
Newbie Spellweaver
Joined
Apr 12, 2008
Messages
18
Reaction score
0
Re: [Fully Working Following

Error:
Code:
server.java:178: <identifier> expected
FollowHandler = new FollowHandler();
             ^
 
right + down + X
Loyal Member
Joined
May 25, 2006
Messages
1,688
Reaction score
298
Re: [Fully Working Following

server.java:178: <identifier> expected
FollowHandler = new FollowHandler();
^

That's because you don't have anything to name that new instance of it. do this.

Code:
server.java:178: <identifier> expected
FollowHandler [b]follower[/b] = new FollowHandler();
             ^[/quote]
 
right + down + X
Loyal Member
Joined
May 25, 2006
Messages
1,688
Reaction score
298
Re: [Fully Working Following

server.java:178: <identifier> expected
FollowHandler = new FollowHandler();
^

That's because you don't have anything to name that new instance of it. do this.

Code:
FollowHandler [b]FollowHandler[/b] = new FollowHandler();

you're creating a new instance of the object, so you gotta name that instance for reference....I think... I'm self taught, so I don't know the lingo... I program better than I "know" it
 
Newbie Spellweaver
Joined
Oct 25, 2007
Messages
6
Reaction score
0
Re: [Tut - A] [317] Fully Working Following

Does this no-clip following or it's clipped?
 
Elite Diviner
Joined
Jan 6, 2008
Messages
475
Reaction score
2
Re: [Tut - A] [317] Fully Working Following

how do i get the player.java and client.java?
 
Back
Top