Energy usage call from script

Energy usage call from script

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Energy usage call from script

Post by unpossible »

Scripts need to be able to see whether or not a unit has enough energy (or any other resource!) to be 'on'.

some kind of check of EnergyUsage and Energy would let 'odd' weapons like shields be turned on and off via script when the energy dries up (by turning the unit off)

i'm sure this'd have a lot more uses too!


(in case anyone is wondering, units that are onoffable such as mexxes don't actually turn off when the energy runs out - they just stop working!)
User avatar
Felix the Cat
Posts: 2383
Joined: 15 Jun 2005, 17:30

Post by Felix the Cat »

This sounds like the sort of thing I'd be able to do, with a little bit of study of the relevant source code.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

Felix the Cat wrote:This sounds like the sort of thing I'd be able to do, with a little bit of study of the relevant source code.
i want your babies!
User avatar
Felix the Cat
Posts: 2383
Joined: 15 Jun 2005, 17:30

Post by Felix the Cat »

So basically we need four additional variables that you can get in the BOS script for the unit:

ENERGY_STORED returns the amount of energy in the player's storage
ENERGY_DELTA returns the net increase/decrease of energy per tick
METAL_STORED
METAL_DELTA

Shouldn't be difficult, I just need to muddle my way through the Spring code to where the resource statistics are stored and then ask if it breaks anything to use that information in CobInstance.cpp.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

i think it might just need to check ENERGY STORED against energy usage by the unit - otherwise it'll be switching of in a funny way.
any units using the other tags would globally switch off, not just enough of them to stop draining
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

Doesn't it already do this? I notice often that my mexxes turn off when i have little E...
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

no, they don't.
when mexxes turn off they stop spinning. all that happens in spring is that they stop functioning. it's quite different to actually deactivating.
Egarwaen
Posts: 1207
Joined: 27 Feb 2006, 21:19

Post by Egarwaen »

Perhaps they should actually deactivate?
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

Egarwaen wrote:Perhaps they should actually deactivate?
well, that'd be a solution,

it'd have to be an optional tag in the unit FBI, i figured this would interfere less with every unit already in existence :|
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

get RESSOURCE (ressourcenumber);
and
set RESSOURCE_DELTA (ressourcenumber) resDelta;

That way it won't need any changes to the syntax when generic ressources are introduced. At first it would be hardcoded so resnum = 0 means metal and 1 means energy.

I could use this a lot, after all I had to abandon some ideas for CvC's energy upgrades because I couldn't check for the current energy amount. It would also allow a unit to produce or drain ressources upon death.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

KDR_11k wrote: I could use this a lot, after all I had to abandon some ideas for CvC's energy upgrades because I couldn't check for the current energy amount. It would also allow a unit to produce or drain ressources upon death.
i've been toying with a few ideas along the same lines (thanks for inspiring me). hopefully these tags will allow research/tech level advancments to be properly possible!
Post Reply

Return to “Feature Requests”