:awake once RegisterForMSG("MSG_PostUpdate" "PostUpdate") endonce :once @awake :destroyed <-G_iCurrentlyOccupiedX <-G_iCurrentlyOccupiedZ FALSE @SetCustomOccupiedLand :gameloaded -?G_iCurrentlyOccupiedX if <-G_iCurrentlyOccupiedX <-G_iCurrentlyOccupiedZ TRUE @SetCustomOccupiedLand endif :PostUpdate Self GetUnitMoveCell ->POU_iMoveZ ->POU_iMoveX Self GetUnitCell ->POU_iZ ->POU_iX #Set the initial configuration of our unit once <-POU_iX <-POU_iZ TRUE @SetCustomOccupiedLand <-POU_iX <-POU_iZ ->G_iCurrentlyOccupiedZ ->G_iCurrentlyOccupiedX endonce #If the unit has been ordered to move <-POU_iMoveX <-POU_iLastMoveX neq <-POU_iMoveZ <-POU_iLastMoveZ neq or <-POU_iMoveX -1 neq and if #We clear the last area the unit was set to occupy, and #we set the occupied land at the new target location our unit is meant to land in <-G_iCurrentlyOccupiedX <-G_iCurrentlyOccupiedZ FALSE @SetCustomOccupiedLand <-POU_iMoveX <-POU_iMoveZ TRUE @SetCustomOccupiedLand <-POU_iMoveX <-POU_iMoveZ ->G_iCurrentlyOccupiedZ ->G_iCurrentlyOccupiedX #If the unit is stationary else <-POU_iMoveX <-POU_iLastMoveX eq <-POU_iMoveZ <-POU_iLastMoveZ eq and <-POU_iMoveX -1 eq and if #If the unit was moved in the editor, clear last position and set new position <-POU_iLastX <-POU_iX neq <-POU_iLastZ <-POU_iZ neq or if <-G_iCurrentlyOccupiedX <-G_iCurrentlyOccupiedZ FALSE @SetCustomOccupiedLand <-POU_iX <-POU_iZ TRUE @SetCustomOccupiedLand <-POU_iX <-POU_iZ ->G_iCurrentlyOccupiedZ ->G_iCurrentlyOccupiedX endif endif endif <-POU_iMoveZ <-POU_iMoveX ->POU_iLastMoveX ->POU_iLastMoveZ <-POU_iZ <-POU_iX ->POU_iLastX ->POU_iLastZ #i1 i2 b3 - #Uniformly set or unset a chunk of occupied land #Arguments: CellX and CellY of the last position (if unsetting) or current position (if setting), # boolean that determines if to set or unset #Result: None :SetCustomOccupiedLand ->SOL_bSet ->SOL_iCellZ ->SOL_iCellX 4 ->SOL_iRadius <-SOL_iCellZ <-SOL_iRadius add 1 add <-SOL_iCellZ <-SOL_iRadius sub do <-SOL_iCellX <-SOL_iRadius add 1 add <-SOL_iCellX <-SOL_iRadius sub do <-SOL_iCellX <-SOL_iRadius sub I eq <-SOL_iCellX <-SOL_iRadius add I eq or <-SOL_iCellZ <-SOL_iRadius sub J eq or <-SOL_iCellZ <-SOL_iRadius add J eq or if I J GetCellOccupiedCount ->SOL_iCount <-SOL_bSet if I J <-SOL_iCount 1 add SetCellOccupiedCount else I J <-SOL_iCount 1 sub SetCellOccupiedCount endif endif loop loop