DamageUnit(<-unit <-amt)
Damages the specified unit. Typical health values for most units are either 0 or 1. Units that have a health of 0 will be destroyed when Damage is called. Other units will have damage deducted from their health. Note that positive values cause damage. If a negative value is passed in, the resulting unit's health increases.
Interestingly enough, when this API is used on a unit that is constructing, it will subtract the construction ammo rather than instantly destroying the unit (and the reverse when causing negative damage). If this is undesired, be sure to amp-up the damage value or call DestroyUnit by checking GetUnitConstructing for the targeted unit as a Cannon costs 25 energy to build yet has only 2 health. That is a very large “health increase” while building. It would also be better coding grammar to use ConstructUnit to subtract the build ammo of a constructing unit using a negative value than with this API.
If using this API for something like a custom missile and applying this API after getting a list of units to damage, make sure the unit that's doing this is not part of the list of units to damage otherwise this API will damage the unit that called it and possibly end the loop prematurely by destroying it. This will either make the unit very unreliable in using this API effectively or reliably destroy the unit using this API before applying it to the intended units. So for the sake of your sanity please be mindful of this if it appears this API isn't working super reliably.
-Vertu | Who temporarily lost his mind to this.
DamageUnit(<-someUnitUID 0.1)
⇐ Index