What uses more processing power? Active Instant Action, or Passive Periodic Action??

This was something I thought about today....

Consider two abilties:

  1. Passive ability that uses a periodic action to apply a buff X
  2. Active ability that uses an instant action to apply a buff X

So, which one uses less processing power?  At face value, intuitively I'd think the active using an instant action....but let us add some extra considerations...

Let's say I want to apply a buff X (via an entity like a ship, SB, or structure, doesn't really matter) to the local planet...furthermore, this buff has no time limit (something like an owner change may end the buff, but that's not important)...now, let us reconsider the two above options...

The passive ability has to apply the buff every t seconds...so, that's an action the processor has to consider every t seconds...

Unlike the passive, the active ability is guided by an autocast...so, while their is no periodic action sucking up processing power, does the game not need to perform "checks" to see if it should activate?  For example, the game should not activate this particular ability more than once since (to my knowledge) autocasts check to see if the buff has already been applied (at least targetted buffs, and I hope buffs applied to local orbity body)....

So the core of my question lies in this...in order to "see" if the buff already exists, wouldn't the autocast function have to constantly perform "checks"?  How is that different than a periodic action that performs an action every t seconds?  Would the active ability using an instant action (guided by autocast) really be any more efficient than the passive ability using a periodic action?

3,064 views 1 replies
Reply #1 Top

It's impossible to know without looking at the code, but it is likely that the passive ability will be slightly cheaper from a CPU utilization standpoint. Yes, the engine is going to be going through each autocast ability for each ship/structure some number of times each second to check if it should fire. The amount of overhead you add to this will depend on the condition and target assigned to the ability, for example the aiUseTime "OnlyWhenManyTargetsInRange" condition will be more expensive than aiUseTime "OnlyInCombat".

But for non-expiring buffs the best way is to copy the phase gate ability. The ability puts a buff on the module once, and the module puts a buff on the planet once. The planet buff has a finishCondition defined, so it will be removed when the module buff is no longer active (i.e. it is destroyed).