Jump to content

Recommended Posts

Posted

This little code will shows the real diff range of async between server and client position. By default, this code was maked for aCis but can be use for any L2J forks.

 

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/network/clientpackets/MoveBackwardToLocation.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/MoveBackwardToLocation.java	(revision 1133)
+++ java/net/sf/l2j/gameserver/network/clientpackets/MoveBackwardToLocation.java	(working copy)
@@ -2,6 +2,8 @@
 
 import java.nio.BufferUnderflowException;
 
+import net.sf.l2j.commons.math.MathUtil;
+
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.model.actor.ai.CtrlIntention;
 import net.sf.l2j.gameserver.model.actor.instance.Player;
@@ -95,6 +97,18 @@
 			activeChar.sendPacket(ActionFailed.STATIC_PACKET);
 			return;
 		}
+		
+		// Check async range.
+		dx = _originX - activeChar.getX();
+		dy = _originY - activeChar.getY();
+		double dz1 = _originZ - activeChar.getZ();
+		float diff = (float) Math.sqrt(dx * dx + dy * dy + dz1 * dz1);
+		int heading = MathUtil.calculateHeadingFrom(_originX, _originY, activeChar.getX(), activeChar.getY());
+		if (Math.abs(activeChar.getHeading() - heading) > 16000)
+			diff = diff * -1;
+		
+		activeChar.sendMessage("Async distance: " + diff);
+		
 		activeChar.getAI().setIntention(CtrlIntention.MOVE_TO, new Location(_targetX, _targetY, _targetZ));
 	}
 }
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/ValidatePosition.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/ValidatePosition.java	(revision 1133)
+++ java/net/sf/l2j/gameserver/network/clientpackets/ValidatePosition.java	(working copy)
@@ -1,5 +1,7 @@
 package net.sf.l2j.gameserver.network.clientpackets;
 
+import net.sf.l2j.commons.math.MathUtil;
+
 import net.sf.l2j.gameserver.model.actor.instance.Player;
 import net.sf.l2j.gameserver.model.zone.ZoneId;
 import net.sf.l2j.gameserver.network.serverpackets.GetOnVehicle;
@@ -88,5 +90,17 @@
 		player.setClientY(_y);
 		player.setClientZ(_z);
 		player.setClientHeading(_heading); // No real need to validate heading.
+		
+		// Check async range.
+		dx = _x - player.getX();
+		dy = _y - player.getY();
+		dz = _z - player.getZ();
+		float diff = (float) Math.sqrt(dx * dx + dy * dy + dz * dz);
+		
+		int heading = MathUtil.calculateHeadingFrom(_x, _y, player.getX(), player.getY());
+		if (Math.abs(player.getHeading() - heading) > 16000)
+			diff = diff * -1;
+		
+		player.sendMessage("[4] Async distance: " + diff);
 	}
 }
\ No newline at end of file

Have fun, so! :smile:

  • Like 2
Posted
6 hours ago, Pamela32 said:

I love shares like this one

Bcs give a more realistic gameplay

 

?????????????? How a debug is doing that ?????????????? , maybe you mean that help you to fix things and looks more realistic gameplay.

Posted
1 hour ago, StinkyMadness said:

 

?????????????? How a debug is doing that ?????????????? , maybe you mean that help you to fix things and looks more realistic gameplay.

 

Well .. yea .. as u can see ky English sucks anyway 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...