User Tools

Site Tools


4rpl:commands:setcelloccupiedcount

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:setcelloccupiedcount [2021/02/06 13:13] Karsten754rpl:commands:setcelloccupiedcount [2023/10/27 11:41] (current) – [Description] Elaborated why :Awake and :Gameload are not best places for this API. Vertu
Line 1: Line 1:
 ~~NOTOC~~ ~~NOTOC~~
-<=[[4rpl:start| Index]]+<=[[4rpl:start| Index]]\\ 
 +<= [[4rpl:start#Unit]]
 <WRAP tabs> <WRAP tabs>
   * [[4rpl:commands:getcelloccupiedcount|Get]]   * [[4rpl:commands:getcelloccupiedcount|Get]]
Line 11: Line 12:
 ===== Description ===== ===== Description =====
 Sets the occupied count for a map cell. Extreme caution must be exercised when using this command. Normally units will increase the count for cells they occupy when they land or are created. The units will also decrease the count by 1 whenever they take off or are destroyed. Messing with the count can create 'phantom' areas on the map where units can't land or where they can stack. Units do not know that you have altered the count! So if you change the occupied count, a unit will still decrease the count by 1 when it takes off or is destroyed. Sets the occupied count for a map cell. Extreme caution must be exercised when using this command. Normally units will increase the count for cells they occupy when they land or are created. The units will also decrease the count by 1 whenever they take off or are destroyed. Messing with the count can create 'phantom' areas on the map where units can't land or where they can stack. Units do not know that you have altered the count! So if you change the occupied count, a unit will still decrease the count by 1 when it takes off or is destroyed.
 +
 +The effect of SetCellOccupiedCount does not persist between save and loads, as all units rebuild their cell occupied counts whenever the game is loaded and units are rebuilt from the save file.\\
 +:WARNING: This also applies to using this API in :Gameloaded and :Awake (when game is also loaded). This API will not function as desired should it be called in :Gameloaded or :Awake (:Awake will work fine when placing units, just not when units are loaded in). This is due to the game rebuilding cell occupy counts latter than :Awake and :Gameloaded, causing the effects of this API used in such functions to be overwritten.
 +
 +If you're trying to make a custom unit occupy cells in a custom shape rather than the default box shape, refer to [[cw4:4rpl_tools#custom_celloccupiedcount_shape|Custom CellOccupiedCount shape]] for a copy-paste ready script that simplifies creating one and handles all of the difficult parts of using SetCellOccupiedCount, including handling unit movement.
  
 ===== Examples ===== ===== Examples =====
4rpl/commands/setcelloccupiedcount.1612635184.txt.gz · Last modified: 2021/02/06 13:13 by Karsten75