User Tools

Site Tools


4rpl:commands:damageunit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
4rpl:commands:damageunit [2022/03/28 19:33] – Warning about an easy mistake when using this Vertu4rpl:commands:damageunit [2022/09/20 22:04] (current) – [Description] Behavior towards constructing units mentioned Vertu
Line 12: Line 12:
 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. 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.
  
-:WARNINGIf using this API for something like custom missile and applying this API after getting a list of units to damage, __make sure the unit that's doing this __**<color #FF5555>__is not part of the list of units to damage__</color>** otherwise this API will damage the unit that called it and possibly end the loop prematurely by destroying itThis 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 unitsSo for the sake of your sanity please be mindful of this if it appears this API isn't working super reliably.+:NOTEInterestingly 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 [[4rpl:commands:destroyunit|DestroyUnit]] by checking [[4rpl:commands:getunitconstructing|GetUnitConstructing]] for the targeted unit as a Cannon costs 25 energy to build yet has only 2 healthThat is a very large "health increase" while building. It would also be better coding grammar to use [[4rpl:commands:constructunit|ConstructUnit]] to subtract the build ammo of a constructing unit using a negative value than with this API.
  
 +:WARNING: 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 __**<color #FF5555>__is not part of the list of units to damage__</color>** 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. -Vertu | Who temporarily lost his mind to this.
 ===== Examples ===== ===== Examples =====
4rpl/commands/damageunit.txt · Last modified: 2022/09/20 22:04 by Vertu