[Lua] Any way to get unit's stamina/energy?

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

[Lua] Any way to get unit's stamina/energy?

Post 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?
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: [Lua] Any way to get unit's stamina/energy?

Post 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.
jedimoose32
Field Commander
Field Commander
Posts: 938
Joined: Thu Jan 24, 2008 12:41 am
Projects :: Engineering Degree
Location: The Flatlands of Canada

Re: [Lua] Any way to get unit's stamina/energy?

Post 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. :?
Post Reply