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 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..