User Tools

Site Tools


4rpl:commands:setunitammoware

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:setunitammoware [2023/12/08 00:02] – programming woes Grabz4rpl:commands:setunitammoware [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 21: Line 21:
 ===== Programming Notes ===== ===== Programming Notes =====
  
-Do not use SetUnitAmmoWare in the :Awake function. This causes all further units in the map to fail to load.+Do not use SetUnitAmmoWare in the ''[[func_Awake|:Awake]]'' function. This causes all further units in the map to fail to load.
  
 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), if the unit is later changed to use Energy, a reload of the game from a save file will cause the unit to request both Energy and the ware set in the unit's initial blueprint at the same time. 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), if the unit is later changed to use Energy, a reload of the game from a save file will cause the unit to request both Energy and the ware set in the unit's initial blueprint at the same time.
Line 37: Line 37:
 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. 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 :GameLoaded as follows to set the unit to use Liftic from the start, while leaving it as Energy in the unit's CMOD Settings.+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 ''[[func_GameLoaded|:GameLoaded]]'' as follows to set the unit to use Liftic from the start, while leaving it as Energy in the unit's CMOD Settings.
 <code 4rpl> <code 4rpl>
 :GameLoaded :GameLoaded
-once +   @init 
-   SetUnitAmmoWare(Self 3) +:Once 
-endonce+   @init 
 +:init 
 +   once 
 +      SetUnitAmmoWare(Self 3) 
 +   endonce
 </code> </code>
 +
 +===== 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, base units that do not use ammo and base units with ammo that do not show their ammo bar (totems and ultracs).
 +
 +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.
  
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
4rpl/commands/setunitammoware.1701993761.txt.gz · Last modified: 2025/02/14 14:56 (external edit)