User Tools

Site Tools


cw4:4rpl_tools

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
cw4:4rpl_tools [2024/05/12 15:18] Kallicw4:4rpl_tools [2024/05/13 11:42] (current) – [Make Units Unselectable] Kalli
Line 2926: Line 2926:
 ---- ----
  
-===== Next Utility goes here =====+===== Make Units Unselectable ===== 
 + 
 +You can make friendly/enemy/all units (un)selectable and/or (un)destroyable with this script. 
 + 
 +The $ variables are now set so that friendly (=human) units are set unselectable and undestroyable, so that it's ready to use in a pac map. The variables are either 0 or 1. 
 + 
 +Enemy (=creeper) units are always undestroyable. Changing this setting with 4rpl does nothing, but also doesn't break anything. 
 + 
 +The script can be used from the console, or be added as a global script to a cpack. If used as a global script, then the script must run while paused. It will only apply to units that exist at map start.
  
 <hidden click here for source code> <hidden click here for source code>
  
-<code 4rpl file name.4rpl>+<code 4rpl MakeUnitsUnselectable.4rpl> 
 + 
 +# MakeUnitsUnselectable 
 + 
 +# The script can be used from the console, or be added as a global script to a cpack. 
 +# If used as a global script, then the script must run while paused. It will only apply to units that exist at map start. 
 + 
 +$applyToFriendlyUnits:
 + 
 +$applyToEnemyUnits:
 + 
 +$applyToAllUnits:
 + 
 +$makeUnitsSelectable:
 +$makeUnitsDestroyable:
 + 
 +:once 
 + GetMapSize 2 div ->midPointZ 2 div ->midPointX  
 +  
 + <-midPointX 0 <-midpointZ v3 ->pos 
 +  
 + <-applyToAllUnits <-applyToFriendlyUnits <-applyToEnemyUnits and or if 
 + 0 ->enemyState 
 + else 
 + <-applyToFriendlyUnits if 2 else <-applyToEnemyUnits endif ->enemyState 
 + endif 
 +  
 + # The position is the center of the map. The max possible range for units within the map boundaries is (512/2^2 + 128/2^2)^0.5 +1 = 265. To also catch units that have wandered just outside the map boundaries, I chose range 300. 
 + "" <-pos 300 0 0 0 <-enemyState 0 0 getunits ->unitList 
 +  
 + <-unitList 0 do  
 + <-unitList[i] <-makeUnitsSelectable SetUnitSelectable 
 + <-unitList[i] <-makeUnitsDestroyable SetUnitCanDestroy 
 + loop
  
 </code> </code>
cw4/4rpl_tools.1715541537.txt.gz · Last modified: 2024/05/12 15:18 by Kalli