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!)
Energy usage call from script
Moderator: Moderators
- Felix the Cat
- Posts: 2383
- Joined: 15 Jun 2005, 17:30
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
- Felix the Cat
- Posts: 2383
- Joined: 15 Jun 2005, 17:30
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.
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.
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
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.
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.
- unpossible
- Posts: 871
- Joined: 10 May 2005, 19:24
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!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.