Page 1 of 1
Energy usage call from script
Posted: 31 Jul 2006, 23:13
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!)
Posted: 01 Aug 2006, 00:13
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.
Posted: 01 Aug 2006, 00:45
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!
Posted: 01 Aug 2006, 01:52
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.
Posted: 01 Aug 2006, 09:38
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
Posted: 01 Aug 2006, 10:10
by Dragon45
Doesn't it already do this? I notice often that my mexxes turn off when i have little E...
Posted: 01 Aug 2006, 10:54
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.
Posted: 01 Aug 2006, 16:45
by Egarwaen
Perhaps they should actually deactivate?
Posted: 01 Aug 2006, 19:06
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

Posted: 02 Aug 2006, 12:58
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.
Posted: 02 Aug 2006, 13:07
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!