Page 1 of 1
[Lua] Any way to get unit's stamina/energy?
Posted: Thu Apr 07, 2016 10:08 am
by jedimoose32
I can't seem to find any callback or other function that gets the amount of energy a unit has. Is there something I'm missing, or is there at least some hackish way to do this?
Re: [Lua] Any way to get unit's stamina/energy?
Posted: Thu Apr 07, 2016 3:56 pm
by AnthonyBF2
I've never seen any Lua functions regarding energy. I searched the game's exe file for "energy" and nothing came up worth while.
If you want to toggle energy I had this idea. Built two ammo droid objects for your map, one that features the odf command SoldierEnergy and the other ammo droid to use SoldierEnergy but with a negative number. Place one of each in your map and set radius to cover the map. Then you can use Lua to kill them and activate them at will. To prevent automatic energy regain you change that in character odf files or using SetClassProperty.
Re: [Lua] Any way to get unit's stamina/energy?
Posted: Thu Apr 07, 2016 4:11 pm
by jedimoose32
Thanks for the suggestion. Unfortunately the droid idea is not quite going to work for what I need. I'm trying to detect when a player's energy is low (from running or rolling). I could get a rough idea by using GetWorldPosition to calculate the player's current speed, and use that to determine approximately how many times they've rolled, or how long they've been running. Then if they have done that enough times the code would tell me the player's final energy level (roughly). I would also have to keep track of the character class so that I know their max speed and roll speed, as well as their max stamina. Yikes!
Edit: the main problem with using the player's speed is, they could be running straight into a wall and their energy would be draining without them going anywhere.
