Bug with cores that use AC (& workaround)

Started by planetfall, March 05, 2017, 09:47:38 AM

Previous topic - Next topic

planetfall

If you have a core requesting AC packets, don't decrease the core's CONST_AMMOAC by any non-integer amount. Say you have a core that can hold 20AC. The moment that AC drops to 19.9999... it will request a new packet. When the packet arrives, if the core has 19 AC or less, it will just add 1 AC, but if it has, let's say 19.5, the core will fill up to 20 and the extra 0.5 will be wasted.

Because CW3 is older than I am on the inside, I don't think this bug is likely to be patched, so if you really must use fractional amounts of AC, do so abstractly, similar to this:


<-WorkingOre <-OrePerTick lt if
  Self CONST_AMMOAC GetUnitAttribute ->ac
  <-ac if
    <-WorkingOre 1.0 add ->WorkingOre
    Self CONST_AMMOAC <-ac 1 sub SetUnitAttribute
  endif
endif
<-WorkingOre <-OrePerTick gte if
  <-WorkingOre <-OrePerTick sub ->WorkingOre
  @DoThingThatConsumesAC
endif
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.