This shows you the differences between two versions of the page.
cw4:4rpl_tools [2024/01/18 20:57] – [Automated Tower Grid Building] Kalli | cw4:4rpl_tools [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 582: | Line 582: | ||
$rmb:1 # right click button | $rmb:1 # right click button | ||
- | $index:0 | ||
- | Once | ||
- | @MakeSoundList | ||
- | endOnce | ||
- | if (GetMappedKey(" | + | if(< |
- | Mod(<-Index 1 +, < | + | |
+ | if (GetMappedKey(" | ||
+ | 2 -> | ||
+ | Mod(<-index 1 +, < | ||
< | < | ||
TraceAll ("This is sound #" <-index ", " DQ < | TraceAll ("This is sound #" <-index ", " DQ < | ||
endIf | endIf | ||
- | if (GetMappedKey(" | + | if(GetMappedKey(" |
- | Mod2(<-Index 1 -, < | + | 2 -> |
+ | Mod2(<-index 1 -, < | ||
< | < | ||
TraceAll ("This is sound #" <-index ", " DQ < | TraceAll ("This is sound #" <-index ", " DQ < | ||
Line 601: | Line 601: | ||
if (GetMouseButtonDown(< | if (GetMouseButtonDown(< | ||
- | PlaySoundAtPosition(< | + | PlaySoundAtPosition(< |
endif | endif | ||
- | + | ||
+ | :Once | ||
+ | -1 ->index #So we start at 0, not 1. | ||
+ | @MakeSoundList | ||
: | : | ||
- | + | ||
" | " | ||
" | " | ||
Line 633: | Line 637: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 643: | Line 644: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 715: | Line 719: | ||
" | " | ||
List -> | List -> | ||
- | + | ||
" | " | ||
" | " | ||
Line 724: | Line 728: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 738: | Line 736: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 749: | Line 752: | ||
" | " | ||
" | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 754: | Line 758: | ||
" | " | ||
" | " | ||
- | " | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 764: | Line 776: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 785: | Line 786: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 797: | Line 801: | ||
" | " | ||
List -> | List -> | ||
- | + | ||
GetListCount(< | GetListCount(< | ||
- | TraceAllSp ("List of " < | + | TraceAllSp(" |
- | TraceAllSp (" | + | TraceAllSp(" |
- | TraceAllSP (" | + | TraceAllSP(" |
- | TraceAllSp (" | + | TraceAllSp(" |
</ | </ | ||
Line 812: | Line 816: | ||
A few notes. | A few notes. | ||
- | + | | |
- | * The Greenar Refinery sound is spatial and you have to be in freeview and right upon the unit in location (1,1) to hear it. | + | |
- | | + | |
* Remember to unmute game music. | * Remember to unmute game music. | ||
Line 824: | Line 826: | ||
$rmb:1 # right click button | $rmb:1 # right click button | ||
- | $index:0 | ||
- | Once | + | if(< |
- | @MakeSoundList | + | |
- | CreateUnitOnTerrain(" | + | |
- | false | + | |
- | Getpause | + | |
- | endOnce | + | |
SetUnitPosition(< | SetUnitPosition(< | ||
- | if (GetMappedKey(" | + | if(GetMappedKey(" |
- | Mod(<-Index 1 +, < | + | 2 -> |
+ | Mod(<-index 1 +, < | ||
< | < | ||
- | TraceAll ("This is sound #" <-index ", " DQ < | + | TraceAll(" |
endIf | endIf | ||
- | if (GetMappedKey(" | + | if(GetMappedKey(" |
- | Mod2(<-Index 1 -, < | + | 2 -> |
+ | Mod2(<-index 1 -, < | ||
< | < | ||
- | TraceAll ("This is sound #" <-index ", " DQ < | + | TraceAll(" |
endIf | endIf | ||
- | if (GetMouseButtonDown(< | + | if(GetMouseButtonDown(< |
- | If (< | + | If(< |
StopSoundLoop(< | StopSoundLoop(< | ||
Not(< | Not(< | ||
SetPause(< | SetPause(< | ||
- | TraceAllSp (" | + | TraceAllSp(" |
else | else | ||
- | TraceAllSp ("Can you hear " < | + | TraceAllSp(" |
SetPause (false) | SetPause (false) | ||
PlaySoundLoop(< | PlaySoundLoop(< | ||
Not(< | Not(< | ||
endif | endif | ||
- | |||
endif | endif | ||
Line 864: | Line 862: | ||
TraceAllSp(" | TraceAllSp(" | ||
DestroyUnit(< | DestroyUnit(< | ||
+ | if(< | ||
+ | |||
+ | :Once | ||
+ | -1 ->index #So we start at 0, not 1. | ||
+ | @MakeSoundList | ||
+ | CreateUnitOnTerrain(" | ||
+ | false -> | ||
+ | Getpause ->pause | ||
- | |||
: | : | ||
- | + | ||
" | " | ||
" | " | ||
Line 895: | Line 900: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 905: | Line 907: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 915: | Line 920: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 964: | Line 968: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 989: | Line 991: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 1003: | Line 999: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 1014: | Line 1015: | ||
" | " | ||
" | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 1019: | Line 1021: | ||
" | " | ||
" | " | ||
- | " | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 1029: | Line 1039: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 1050: | Line 1049: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 1062: | Line 1064: | ||
" | " | ||
List -> | List -> | ||
- | + | ||
GetListCount(< | GetListCount(< | ||
- | TraceAllSp ("List of " < | + | TraceAllSp(" |
- | TraceAllSP (" | + | TraceAllSP(" |
- | TraceAllSp ("Move mouse out of edit box. Left-click mouse to listen to a sound. " ) | + | TraceAllSp(" |
- | TraceAllSP (" | + | TraceAllSP(" |
- | TraceAllSp (" | + | TraceAllSp(" |
</ | </ | ||
Line 2210: | 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 2224: | 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 2238: | 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 2252: | 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 2266: | 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 2280: | 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 2294: | 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 2308: | 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 2320: | Line 2334: | ||
SetUnitPosition(< | SetUnitPosition(< | ||
loop | loop | ||
+ | endif | ||
+ | |||
+ | if(< | ||
+ | false -> | ||
+ | < | ||
endif | endif | ||
Line 2340: | Line 2359: | ||
New towers will be constructed if they can connect to: existing riftlab, m-rift, pylons, energy pods and towers. | New towers will be constructed if they can connect to: existing riftlab, m-rift, pylons, energy pods and towers. | ||
+ | |||
+ | To run the console script, simply let it run continuously. | ||
<hidden click here for source code> | <hidden click here for source code> | ||
Line 2346: | Line 2367: | ||
# AutoTowerGrid | # AutoTowerGrid | ||
# by Kalli | # by Kalli | ||
+ | # Script is to run continuously in the console! | ||
$pacMode:0 # Makes all units built by the pilot unselectable and undeletable by the player | $pacMode:0 # Makes all units built by the pilot unselectable and undeletable by the player | ||
Line 2918: | 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 3284: | 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 3308: | 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(< | ||
+ | </ | ||
</ | </ | ||