This shows you the differences between two versions of the page.
cw4:4rpl_tools [2024/03/16 23:53] – [Automated Tower Grid Building] Added a statement for clarity of how to use it. LiteralNoob | cw4:4rpl_tools [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2212: | Line 2212: | ||
#By Vertu | #By Vertu | ||
- | $HEIGHT:100.0 #Float or Integer | + | $HEIGHT:3000.0 #Float or Integer |
- | $RAND_MAX:8 #Integer | + | $RAND_MAX:15 #Integer |
- | $RAND_MIN:-8 | + | $RAND_MIN:25 #Integer |
+ | $STEP: | ||
+ | $$BUFFER:2 | ||
- | if(GetKey(" | + | if(< |
+ | |||
+ | if(GetKey(" | ||
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
- | SetUnitPosition(< | + | SetUnitPosition(< |
GetTerrain(GetUnitCell(< | GetTerrain(GetUnitCell(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
Line 2226: | Line 2231: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
- | if(GetKey(" | + | if(GetKey(" |
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
- | SetUnitPosition(< | + | SetUnitPosition(< |
GetTerrain(GetUnitCell(< | GetTerrain(GetUnitCell(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
Line 2240: | Line 2246: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
- | if(GetKey(" | + | if(GetKey(" |
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
- | SetUnitPosition(< | + | SetUnitPosition(< |
GetTerrain(GetUnitCell(< | GetTerrain(GetUnitCell(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
Line 2254: | Line 2261: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
- | if(GetKey(" | + | if(GetKey(" |
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
- | SetUnitPosition(< | + | SetUnitPosition(< |
GetTerrain(GetUnitCell(< | GetTerrain(GetUnitCell(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
Line 2268: | Line 2276: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
- | if(GetKey(" | + | if(GetKey(" |
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
- | SetUnitPosition(< | + | SetUnitPosition(< |
GetTerrain(GetUnitCell(< | GetTerrain(GetUnitCell(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
Line 2282: | Line 2291: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
- | if(GetKey(" | + | if(GetKey(" |
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
- | SetUnitPosition(< | + | SetUnitPosition(< |
GetTerrain(GetUnitCell(< | GetTerrain(GetUnitCell(< | ||
GetUnitPosition(< | GetUnitPosition(< | ||
Line 2296: | Line 2306: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
if(GetKey(" | if(GetKey(" | ||
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
Line 2310: | Line 2321: | ||
SetUnitOccupiesLand(< | SetUnitOccupiesLand(< | ||
else | else | ||
- | if(< | + | if(< |
endif | endif | ||
loop | loop | ||
endif | endif | ||
- | if(GetKey(" | + | if(GetKey(" |
+ | true -> | ||
GetSelectedUnits ->units | GetSelectedUnits ->units | ||
do(GetListCount(< | do(GetListCount(< | ||
Line 2322: | Line 2334: | ||
SetUnitPosition(< | SetUnitPosition(< | ||
loop | loop | ||
+ | endif | ||
+ | |||
+ | if(< | ||
+ | false -> | ||
+ | < | ||
endif | endif | ||
Line 2923: | Line 2940: | ||
The snapping tool makes use of a unit for highlighting the nearest buildable cell, so it's a cpack instead of a script : [[https:// | The snapping tool makes use of a unit for highlighting the nearest buildable cell, so it's a cpack instead of a script : [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Make Units Unselectable ===== | ||
+ | |||
+ | You can make friendly/ | ||
+ | |||
+ | The $ variables are now set so that friendly (=human) units are set unselectable and undestroyable, | ||
+ | |||
+ | Enemy (=creeper) units are always undestroyable. Changing this setting with 4rpl does nothing, but also doesn' | ||
+ | |||
+ | 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> | ||
+ | |||
+ | <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 -> | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | 0 -> | ||
+ | else | ||
+ | < | ||
+ | endif | ||
+ | |||
+ | # The position is the center of the map. The max possible range for units within the map boundaries is (512/2^2 + 128/ | ||
+ | "" | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | loop | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Set terrain higher than 20 ===== | ||
+ | A console script that lets you place terrain higher than 20. Details below. | ||
+ | <hidden click here for source code> | ||
+ | Notes about terrain higher than 20:\\ | ||
+ | * There is a limit to how high terrain can be before it causes an overflow and crashes your game should the script try to make that terrain height. I have limited the script to a height of 100 to be safe, I have not tested when this crash occurs but I do know it does. Terrain higher than 100 gets excessive anyways. | ||
+ | * The game was not built to account for terrain higher than 20, this means Creeper will not render at the top of the terrain but at a height of 20 (the maximum terrain height) should Creeper be on terrain higher than 20. | ||
+ | * The build system does not detect terrain higher than 20, you have to point your mouse down as if it was a height of 20 in order to place units on that terrain. Obviously the best workaround to this is using top-down view. | ||
+ | * The game doesn' | ||
+ | * The surfaces of various terrain higher than 20 will have **<fc # | ||
+ | * I recommend only using terrain higher than 20 for visual effect rather than gameplay due to Creeper not rendering at the surface of the terrain. Best to make it impossible for Creeper to reach such areas. | ||
+ | <code 4rpl SetTerrainAbove20.4rpl> | ||
+ | # SetTerrainAbove20 | ||
+ | #By Vertu. | ||
+ | |||
+ | $HEIGHT: | ||
+ | |||
+ | $$BUFFER:2 | ||
+ | |||
+ | if(< | ||
+ | |||
+ | if(< | ||
+ | GetPointerTerrainCoords ->y1 ->x1 | ||
+ | if(IsV2InMap(V2(< | ||
+ | true ->phase2 | ||
+ | Trace4(" | ||
+ | else | ||
+ | Trace(" | ||
+ | endif | ||
+ | else | ||
+ | if(< | ||
+ | GetPointerTerrainCoords ->y2 ->x2 | ||
+ | if(IsV2InMap(V2(< | ||
+ | false ->phase2 | ||
+ | Trace4(" | ||
+ | else | ||
+ | Trace(" | ||
+ | endif | ||
+ | endif | ||
+ | endif | ||
+ | if(GetKeyDown(" | ||
+ | <-y2 1 add <-y1 do | ||
+ | < | ||
+ | while I J GetTerrain < | ||
+ | SetTerrainInRange(I J < | ||
+ | endwhile | ||
+ | loop | ||
+ | loop | ||
+ | ClearTraceLog | ||
+ | Trace4(< | ||
+ | Height set to " < | ||
+ | EditAddUndo(0) | ||
+ | endif | ||
+ | |||
+ | if(GetKeyDown(" | ||
+ | ClearTraceLog | ||
+ | Trace4(< | ||
+ | Height set to " < | ||
+ | GetPointerTerrainCoords ->posZ ->posX | ||
+ | FloodFillTerrain(< | ||
+ | do(GetListCount(< | ||
+ | EV2(< | ||
+ | while <-cellyX <-cellyZ GetTerrain < | ||
+ | SetTerrainInRange(< | ||
+ | endwhile | ||
+ | loop | ||
+ | Trace3(" | ||
+ | EditAddUndo(0) | ||
+ | endif | ||
+ | |||
+ | if(GetKey(" | ||
+ | < | ||
+ | ClearTraceLog | ||
+ | Trace4(< | ||
+ | Height set to " < | ||
+ | < | ||
+ | endif | ||
+ | if(GetKey(" | ||
+ | < | ||
+ | ClearTraceLog | ||
+ | Trace4(< | ||
+ | Height set to " < | ||
+ | < | ||
+ | endif | ||
+ | |||
+ | :Once | ||
+ | < | ||
+ | "Key binds: | ||
+ | SpaceBar to specify coordinates, | ||
+ | |||
+ | PageUp and PageDown to increase and decrease set terrain height. | ||
+ | |||
+ | Pressing Keypad0 will conduct a flood-fill to set terrain to specified height." | ||
+ | Trace(< | ||
+ | Trace3(" | ||
+ | -1 ->x1 | ||
+ | -1 ->x2 | ||
+ | -1 ->y1 | ||
+ | -1 ->y2 | ||
+ | </ | ||
+ | |||
+ | </ | ||
---- | ---- | ||
Line 3289: | Line 3463: | ||
<fs large> | <fs large> | ||
< | < | ||
- | V3(cos(RandFloat | + | V3(cos(RandFloat RandInt(0 7) +) <-RADIUS * <-cellX + < |
</ | </ | ||
<fs large> | <fs large> | ||
< | < | ||
- | V2(cos(RandFloat | + | V2(cos(RandFloat RandInt(0 7) +) <-RADIUS * <-cellX + sin(RandFloat RandInt(0 7) +) <-RADIUS * <-cellZ +) -> |
</ | </ | ||
Line 3313: | Line 3487: | ||
if(GetEditMode !) | if(GetEditMode !) | ||
GetUnitPosition(self) -> | GetUnitPosition(self) -> | ||
- | SetUnitPosition(self V3(cos(RandFloat | + | SetUnitPosition(self V3(cos(RandFloat RandInt(0 7) +) 45 * < |
endif | endif | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ===== Random X-Z position along the circumference of a circle ===== | ||
+ | |||
+ | <hidden click here for source code> | ||
+ | This is a simple piece of trigonometry that is able to pick a random position along the circumference of a circle on the X-Z plain with a definable radius. This is useful in the event you wish to introduce circles into your 4RPL code's behavior.\\ | ||
+ | Uses [[4rpl: | ||
+ | Note: Floats will work for the radius.\\ | ||
+ | \\ | ||
+ | < | ||
+ | RandFloat RandInt(0 7) + ->angle | ||
+ | V3(cos(< | ||
+ | </ | ||
</ | </ | ||