How would I turn off units when there's no energy?

How would I turn off units when there's no energy?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

How would I turn off units when there's no energy?

Post by SanadaUjiosan »

The subject pretty much sums it up.

I am wanting to have it so my radar towers turn off when there's no energy to support them (they'll have an energyUse value). I didn't see a unitdef Tag for this, and I imagine it's something that could be rather easily scripted. Maybe.

So, any good ideas? Remember, I use Lua for my animation script, and I want the easiest method possible.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: How would I turn off units when there's no energy?

Post by Pressure Line »

IIRC if a unit uses energy, when you run out, it stops. (this only applies to things covered by the unit's 'Activation' status ie: radar and cloaking. Obviously weapons that need energy to fire won't fire if you dont have any as well...) no unit scripting required.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: How would I turn off units when there's no energy?

Post by SanadaUjiosan »

Hmmm, well I tested it (gave the tower an energyUse of 300 to make testing easy), and cheated it into a game with no energy makers. The radar kept working, I could see enemy units for verification.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: How would I turn off units when there's no energy?

Post by KDR_11k »

Gundam has an energy use script, it doesn't use the TA resource but runs more like a C&C power economy.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: How would I turn off units when there's no energy?

Post by SanadaUjiosan »

That's exactly what I wanted. Thanks a ton Google_Frog for the suggestion.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: How would I turn off units when there's no energy?

Post by AF »

hmmm, this also refers to a longstanding bug with resource consumption
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: How would I turn off units when there's no energy?

Post by Beherith »

Just as a side note: a few years back, radars stopped worked when you estalled, but this got changed to them keeping on working even on estall. Dont know the specifics, but I can dig them up if you are interested.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: How would I turn off units when there's no energy?

Post by SanadaUjiosan »

I would just assume that if a unit is consuming energy, it should stop working when the energy is no longer there.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How would I turn off units when there's no energy?

Post by Forboding Angel »

More of the retarded spring breaking it's back to support *A modders who couldn't mod their way out of a paper bag.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: How would I turn off units when there's no energy?

Post by AF »

Hardly, its that longstanding bug in energy and metal consumption.

E.g. you have 500 energy income. Unit 1 takes 20 energy to build a structure, 480 left. Unit 2 uses 480 to build a missile. Unit 3 has a static energy consumption of 3 energy per second, oh wait we've already used our 500 energy and there's none in reserve, thats +3 free energy, Unit 4 needs 1 metal to do an uber important thing, oh well too late, it didnt get in quick enough... etc

As a result all your energy/resource is distributed unevenly and can result in free income and bad behaviour
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: How would I turn off units when there's no energy?

Post by SanadaUjiosan »

I've noticed for a long time that Energy in particular didn't always "make sense" in how it worked. Glad to know I wasn't crazy.

Since this is a long-standing bug, apparently, I'm guessing we won't be seeing a fix anytime soon? Is this like a really hard to solve bug, or just a result of laziness?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: How would I turn off units when there's no energy?

Post by AF »

I've raised this in the past, and engine developers have discussed it too, and we're all in agreement that it needs fixing at some point but:

  • Some horrendous consequences of this bug resulting in free resources when stalling where fixed many months ( years? ) ago by the developers, making the bug far less urgent.
  • Content developers who are most affected by this have partially sidestepped the issue entirely with their own resource gadgets, many not even realising there was an issue
  • Now that the effect of the bug is greatly diminished in comparison to the past, the urgency has gone and more important things have taken priority.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: How would I turn off units when there's no energy?

Post by Pxtl »

SanadaUjiosan wrote:I've noticed for a long time that Energy in particular didn't always "make sense" in how it worked. Glad to know I wasn't crazy.

Since this is a long-standing bug, apparently, I'm guessing we won't be seeing a fix anytime soon? Is this like a really hard to solve bug, or just a result of laziness?
It's a hard-to-solve bug, they've been over this.

Spring doesn't handle resource consumption in a nice, fixed-time balance-sheet format. Units don't request resources and then consume them the next cycle - the engine has to determine whether or not the unit gets its requested resource at the exact LOC it requested it. The engine just runs a loop through units. If unit X adds to energy, then energy is added to the current E total. If unit X subtracts energy, then energy is removed from the E total. If there's not enough energy for the unit, then the unit doesn't do what it wants.

The problem is that to fix it you'd have to completely change the unit scripts, since a unit has to ask "can I do this?" and the engine currently gives you a fixed yes/no answer on the spot. To fix it, the correct answer is "I'll get back to you on that, let me finish going through all the mandatory stuff and then we'll talk about whether you can fire your pew-pew".
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How would I turn off units when there's no energy?

Post by Forboding Angel »

From what I've seen, units requesting the least amount of energy will get it first. For example, in Evo all units need energy to fire, so generally the light raider tanks will get assigned energy over the big skirmish/assault dudes.

Some free energy is still given and in terms of metal makers it was bad (I added them a while back as a supplementary thingy), and I noticed that people using them en masse were getting free resources. So, in order to put a stop to that, I simply made it so that they require more energy and produce more metal (proportionally), and that more or less did the trick.
Post Reply

Return to “Game Development”