This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
4rpl:commands:setunitammoware [2021/01/30 20:26] – created virgilw | 4rpl:commands:setunitammoware [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
< | < | ||
+ | <WRAP tabs> | ||
+ | * [[4rpl: | ||
+ | * [[4rpl: | ||
+ | </ | ||
:!: Available in version 1.3 and later. | :!: Available in version 1.3 and later. | ||
====== SetUnitAmmoWare====== | ====== SetUnitAmmoWare====== | ||
Line 7: | Line 10: | ||
===== Description ===== | ===== Description ===== | ||
- | Set the ammo ware type of the unit to the stack. 0 = energy, 1 = anticreeper, | + | |
+ | Set the ammo ware type of the unit to the stack. 0 = energy, 1 = anticreeper, | ||
+ | |||
===== Examples ===== | ===== Examples ===== | ||
<code 4rpl> | <code 4rpl> | ||
SetUnitAmmoWare(self 1) | SetUnitAmmoWare(self 1) | ||
</ | </ | ||
+ | |||
+ | ===== Programming Notes ===== | ||
+ | |||
+ | Do not use SetUnitAmmoWare in the '' | ||
+ | |||
+ | When using SetUnitAmmoWare on a unit, it is advised to make sure that in the unit's blueprint (CMOD Settings), the initial Ammo Ware is set to Energy. Should it be set to one of the special wares (Liftic / Arg / Anticreeper), | ||
+ | |||
+ | Minimum reproducible example of the issue. Create a unit whose initial Ammo Ware is Liftic, and have the unit request ammo. Then give it this code. | ||
+ | <code 4rpl> | ||
+ | GetTimer0 1 eq if | ||
+ | | ||
+ | | ||
+ | endif | ||
+ | |||
+ | :once | ||
+ | 300 SetTimer0 | ||
+ | </ | ||
+ | In the finalized map, wait out a little over 10 seconds until the unit swaps to Energy, then save and load. The unit now requests both Energy and Liftic. | ||
+ | |||
+ | To avoid this issue, ensure the unit's initial Ammo Ware in CMOD Settings is Energy, then if the desired initial Ware is e.g. Liftic, that is later to be swapped to Energy, use '' | ||
+ | <code 4rpl> | ||
+ | :GameLoaded | ||
+ | @init | ||
+ | :Once | ||
+ | @init | ||
+ | :init | ||
+ | once | ||
+ | SetUnitAmmoWare(Self 3) | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== More Programming Notes ===== | ||
+ | |||
+ | In game version 2.5.1 and earlier, **__do not use SetUnitAmmoWare on a unit that does not have an ammo bar__**, this includes units that are under construction, | ||
+ | |||
+ | Attempting to run SetUnitAmmoWare on one of these units causes one of the following to occur: | ||
+ | * The script stops running and does not send any error messages. | ||
+ | * The script pulls additional items from the stack. | ||
+ | Details of what settings cause one error or the other is not yet understood. | ||
+ | |||
+ | For units in a CPACK, the relevant setting is Settings > Interface > Show unit ammo bar; if you want to modify the ammo type of that unit with 4rpl, ensure this setting is enabled. | ||
< | < |