Jump to content
Tero

A possible fix for the position bug when attacking (Netcode)

Recommended Posts

This is such a minor tweak that I don't even really think it's worth creating a topic for, but my testers reported that this makes the game feel significantly smoother.

 

This change attempts to address a desync issue when attacking.  When clicking on a monster that is hostile and is also moving towards you, sometimes your character will fail to begin attacking because the client thinks it is within range to attack, but the character is actually too far away to attack on the server side.  It's especially common with monsters that move fast.  With this tweak, this situation should no longer happen.

 

The change is in unit.cpp:

 

Find this comment:

// Player tries to attack but target is too far, notify client

 

Add this line immediately afterwards:

clif_fixpos(src);  // synchronize the player's position with the client

 

Don't change anything else.  The finished code block should look like this.

if(sd && !check_distance_client_bl(src,target,range)) {
		// Player tries to attack but target is too far, notify client
		clif_fixpos(src);  // synchronize the player's position with the client
		clif_movetoattack(sd,target);		
		return 1;	

 

Then just recompile the code and test it out.  Everyone I had test it said it felt instantly noticeable.  This does increase the number of packets being sent so this may cause a very minor increase to network traffic, but based on the number of packets that are typically sent back and forth I don't think the effect is very significant.

  • Love 5
  • MVP 1
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...