Page MenuHomeFeedback Tracker

Overriding CanJump with other content than the original one causes desynch
Closed, ResolvedPublic

Description

Everything is said in the title, and below is an exemple of the ingame desynch.

https://la-quarantaine.fr/uploads/jump.gif

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Modding
Steps To Reproduce

Mod DayZPlayerImplement or any child of it, try to override the CanJump method, get ingame with the override loaded client and server side.

modded class DayZPlayerImplement
{

	override bool CanJump()
	{
		if (75 > this.GetHealth())
                {
                        return false;
                }

                return true;
	}
		
}
Additional Information

The desynch is NOT present if you override with the initial CanJump method content.
The desynch is NOT present if the method returns false.

Event Timeline

GrosTon1 created this task.Jan 19 2019, 3:33 PM
GrosTon1 edited Additional Information. (Show Details)Jan 19 2019, 3:36 PM
rVn changed the task status from New to Reviewed.Apr 5 2019, 4:09 PM
rVn added a subscriber: rVn.

Hi,
The video doesn't work anymore and the code around jumping may have changed a little bit but currently this should work when returning true, and shouldn't work when it returns false ( so opposite of your issue? ), because GetHealth() can't be called on the client so it will go something like this:

  1. the client will not know he can't jump when < 75 health
  2. attempts it anyway
  3. becomes corrected by the server which would result in a laggy looking half jump.

It is not working when it returns false.

How is handled the health indicator ? I would like to avoid RPCs everytime a player tries to jump. Can't find anything usefull from workbench. Tried with debug monitor values, but the health returned is always 0.

rVn added a comment.Apr 8 2019, 10:32 AM

Object:GetHealthLevel should achieve what you need, with a bit less precision

	/**
  	\brief Returns global health level specified in object's config class parameter healthLevels
	     (range is usually 0..4, 0 = pristine, 1 = worn, 2 = damaged, 3 = badly damaged, 4 = ruined but can be changed).
	@param zoneName if empty string, returns state of global health level
	*/
	proto native int GetHealthLevel(string zone = "");

leaving the zone empty or using global should work equally

Works like a charm. Thank's a lot.

rVn closed this task as Resolved.Apr 9 2019, 10:00 AM
rVn claimed this task.