Page MenuHomeFeedback Tracker

Energy for battery - set energy not correct?
Need More Info, NormalPublic

Description

PC version stable 1.05

Details

Severity
Tweak
Resolution
Open
Reproducibility
Always
Operating System
Windows 7 x64
Operating System Version
6.1(7601)
Category
Scripting
Steps To Reproduce
  1. Add in my code a some operations with a new item BatteryD in my server code
  2. Use this operation codes:
float  Energy_getted = {EntityAI Item BatteryD}.GetCompEM().GetEnergy(); 
float  Energy_new = Energy_getted - 0.2;
{EntityAI Item BatteryD}.GetCompEM().SetEnergy(Energy_new);
float  Energy_getted_new = {EntityAI Item BatteryD}.GetCompEM().GetEnergy(); 
Print("[#TESTLOG] Energy_getted:  " + Energy_getted.ToString() + "Energy_new: " + Energy_new.ToString() + " Energy_getted_new: " + Energy_getted_new.ToString());
  1. Get in server logs:

[#TESTLOG] Energy_getted: 50 Energy_new: 49.8 Energy_getted_new: -1.65558e-25e

What this is? How this work?

Event Timeline

AXEL7 created this task.Nov 14 2019, 8:16 PM
Geez changed the task status from New to Need More Info.Nov 19 2019, 10:46 AM
Geez added a subscriber: Geez.

Hello AXEL7.
We were unable to reproduce the issue, but try the following:
instead of SetEnergy method, try using something like item.GetCompEM().AddEnergy(-0.2);.
That way, it calls the appropriate events and sync functions from server side, which means the value should be correctly adjusted on both (server and client) instances of the battery, or any other item in question, for that matter, provided it uses the Energy Manager component.

[#TESTLOG] Energy_getted:  40.8Energy_new: 40.6 Energy_getted_new: 40.6
[#TESTLOG] Energy_getted:  40.6Energy_new: 40.4 Energy_getted_new: 40.4
[#TESTLOG] Energy_getted:  40.4Energy_new: 40.2 Energy_getted_new: 40.2

Regards,
Geez

AXEL7 added a comment.Dec 2 2019, 6:09 PM

Ok, thanks, i am will be test this later