This shows you the differences between two versions of the page.
cw4:4rpl_tools [2023/10/18 19:57] – adding notepad disclaimer Bob | 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 (GetMappedKeyDown(" | + | 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 (GetMappedKeyDown(" | + | 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(< | ||
- | PlaySound(< | + | 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 | + | |
- | if (GetMappedKeyDown(" | + | SetUnitPosition(< |
- | Mod(<-Index 1 +, < | + | |
+ | if(GetMappedKey(" | ||
+ | 2 -> | ||
+ | Mod(<-index 1 +, < | ||
< | < | ||
- | TraceAll ("This is sound #" <-index ", " DQ < | + | TraceAll(" |
endIf | endIf | ||
- | if (GetMappedKeyDown(" | + | 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 863: | Line 862: | ||
TraceAllSp(" | TraceAllSp(" | ||
DestroyUnit(< | DestroyUnit(< | ||
+ | if(< | ||
+ | |||
+ | :Once | ||
+ | -1 ->index #So we start at 0, not 1. | ||
+ | @MakeSoundList | ||
+ | CreateUnitOnTerrain(" | ||
+ | false -> | ||
+ | Getpause ->pause | ||
- | |||
: | : | ||
- | + | ||
" | " | ||
" | " | ||
Line 894: | Line 900: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 904: | Line 907: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 914: | Line 920: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 963: | Line 968: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 988: | Line 991: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 1002: | Line 999: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
" | " | ||
" | " | ||
Line 1013: | Line 1015: | ||
" | " | ||
" | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 1018: | Line 1021: | ||
" | " | ||
" | " | ||
- | " | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 1028: | Line 1039: | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
- | " | ||
- | " | ||
- | " | ||
" | " | ||
" | " | ||
Line 1049: | Line 1049: | ||
" | " | ||
" | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
" | " | ||
" | " | ||
Line 1061: | 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 2209: | 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 2223: | 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 2237: | 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 2251: | 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 2265: | 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 2279: | 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 2293: | 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 2307: | 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 2319: | Line 2334: | ||
SetUnitPosition(< | SetUnitPosition(< | ||
loop | loop | ||
+ | endif | ||
+ | |||
+ | if(< | ||
+ | false -> | ||
+ | < | ||
endif | endif | ||
Line 2329: | Line 2349: | ||
Trace5("'/' | Trace5("'/' | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Automated Tower Grid Building ===== | ||
+ | |||
+ | The below script originally existed as a map script that builds out the tower grid for/ | ||
+ | |||
+ | If you have a large map with varied terrain and you want to want to wire it up fast, then this script is worth a try. | ||
+ | |||
+ | 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> | ||
+ | |||
+ | <code 4rpl file name.4rpl> | ||
+ | # AutoTowerGrid | ||
+ | # 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 | ||
+ | |||
+ | # Quick guide to the variables: | ||
+ | # 1) largeSkip makes the script less accurate, but it saves on computation time. | ||
+ | # 2) optimalCellSelection will keep looking for the cell with the most connections. Or until optimalTowerTarget is met. | ||
+ | # 3) Multiply optimalCellSelection with largeSkip to get an idea of what cellrange will be checked. Higher = more triangles even when square + more towers close to minimum distance. | ||
+ | # 4) Good settings for a well connected tower grid with low average computation times: mintowerdistance=0; | ||
+ | |||
+ | $maxTowerDistance: | ||
+ | $minTowerDistance: | ||
+ | $disLOS:1 # Check LOS when checking for towers within the minimum distance. It makes it easier to climb walls or cliffs, but it becomes messier. | ||
+ | |||
+ | $contaminentSlot: | ||
+ | $creeperRange: | ||
+ | |||
+ | $goSQUARE:1 # The script will either work angular or perpendicular. | ||
+ | $optimalCellSelection: | ||
+ | $largeSkip: | ||
+ | $smallSkip: | ||
+ | $optimalTowerTarget: | ||
+ | |||
+ | $$minTowerCellDistance: | ||
+ | $$maxTowerCellDistance: | ||
+ | $$connectionHeight: | ||
+ | $debugPrint: | ||
+ | |||
+ | " | ||
+ | < | ||
+ | # GetEnergyStore -> | ||
+ | # GetEnergyUse GetEnergyGeneration 1 max div -> | ||
+ | GetTimer3 ->timer3 | ||
+ | GetTimer0 ->timer0 | ||
+ | switch | ||
+ | # " | ||
+ | case(< | ||
+ | 151 Settimer0 | ||
+ | @findOtherNodes | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @findOtherTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @cleanOldNodeList | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | 11 Settimer3 | ||
+ | @buildPlannedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildBlockedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # # " | ||
+ | # case(< | ||
+ | # # The cases above don't need much energy, the cases below do. Only start large scale expansion when there is energy stored. | ||
+ | # 0 @supplyNonEssentialInfrastructure | ||
+ | # endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildPlannedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildBlockedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # case(< | ||
+ | # # Try to prevent overbuilding again. | ||
+ | # endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildPlannedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildBlockedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildPlannedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildBlockedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # case(< | ||
+ | # # Try to prevent overbuilding. | ||
+ | # endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildPlannedTower | ||
+ | # 1 @supplyNonEssentialInfrastructure #turn on supply again for non essentials if there are enough supplies | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildBlockedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | # " | ||
+ | case(< | ||
+ | @buildPlannedTower | ||
+ | @monitorTowers | ||
+ | endcase | ||
+ | endswitch | ||
+ | @stopChrono | ||
+ | |||
+ | : | ||
+ | # the ID is left on the stack, swap to send it. | ||
+ | # < | ||
+ | " | ||
+ | |||
+ | :stopChrono | ||
+ | # < | ||
+ | " | ||
+ | |||
+ | :Once | ||
+ | createlist -> | ||
+ | createlist -> | ||
+ | |||
+ | createlist -> | ||
+ | createlist -> | ||
+ | |||
+ | createlist -> | ||
+ | createlist -> | ||
+ | createlist -> | ||
+ | |||
+ | # Use existing or playerbuild nodes (microrifts, | ||
+ | createlist -> | ||
+ | createlist -> | ||
+ | |||
+ | # If PAC mode is enabled, make friendly pre existing units unselectable or vice versa | ||
+ | do(9999 0) | ||
+ | if(GetUnitCreeperDamages(I)) | ||
+ | I @SetSelectable | ||
+ | endif | ||
+ | loop | ||
+ | |||
+ | # The minimum distance is to block placing a tower within a perfect square of other towers. The absolute minimum ratio is roughly 7.25 / 12. | ||
+ | if(< | ||
+ | < | ||
+ | endif | ||
+ | # The following 2 variables are used in finding other towers at an " | ||
+ | < | ||
+ | < | ||
+ | |||
+ | # 4 DIRECTIONS | ||
+ | createlist -> | ||
+ | createlist -> | ||
+ | createlist -> | ||
+ | createlist -> | ||
+ | |||
+ | # The below cell lists + list sorting were created in excel. | ||
+ | < | ||
+ | list( v2(12 0) v2(11 0) v2(11 1) v2(11 -1) v2(11 2) v2(11 -2) v2(11 3) v2(11 -3) v2(11 4) v2(11 -4) v2(10 0) v2(10 1) v2(10 -1) v2(10 2) v2(10 -2) v2(10 3) v2(10 -3) v2(10 4) v2(10 -4) v2(10 5) v2(10 -5) v2(10 6) v2(9 0) v2(9 1) v2(9 -1) v2(10 -6) v2(9 2) v2(9 -2) v2(9 3) v2(9 -3) v2(9 4) v2(9 -4) v2(9 5) v2(9 -5) v2(9 6) v2(9 -6) v2(9 7) v2(9 -7) v2(8 0) v2(8 1) v2(8 -1) v2(8 2) v2(8 -2) v2(8 3) v2(8 4) v2(8 -3) v2(8 5) v2(8 -4) v2(8 6) v2(8 -5) v2(8 7) v2(8 -6) v2(8 8) v2(8 -7) v2(7 7) v2(7 6) v2(7 5) v2(7 -6) v2(7 -5) v2(7 4) v2(7 -4) v2(7 3) v2(7 -3) v2(7 2) v2(7 -2) v2(7 1) v2(7 -1) v2(7 0) v2(6 6) v2(6 5) v2(6 -5) v2(6 4) v2(6 -4) v2(6 3) v2(6 -3) v2(6 2) v2(6 -2) v2(6 1) v2(6 -1) v2(6 0) v2(5 5) v2(5 4) v2(5 -4) v2(5 3) v2(5 -3) v2(5 2) v2(5 -2) v2(5 1) v2(5 -1) v2(5 0) v2(4 4) v2(4 3) v2(4 -3) v2(4 2) v2(4 -2) v2(4 1) v2(4 -1) v2(4 0) v2(3 3) v2(3 2) v2(3 -2) v2(3 1) v2(3 -1) v2(3 0) v2(2 2) v2(2 1) v2(2 -1) v2(2 0) v2(1 1) v2(1 0) ) -> | ||
+ | else | ||
+ | list( v2(10 6) v2(6 10) v2(9 7) v2(7 9) v2(8 8) v2(11 4) v2(4 11) v2(10 5) v2(5 10) v2(9 6) v2(6 9) v2(8 7) v2(7 8) v2(11 3) v2(3 11) v2(10 4) v2(4 10) v2(12 0) v2(11 2) v2(9 5) v2(2 11) v2(5 9) v2(8 6) v2(6 8) v2(7 7) v2(10 3) v2(11 1) v2(3 10) v2(1 11) v2(9 4) v2(11 0) v2(4 9) v2(10 2) v2(2 10) v2(8 5) v2(5 8) v2(7 6) v2(6 7) v2(10 1) v2(9 3) v2(3 9) v2(1 10) v2(10 0) v2(8 4) v2(4 8) v2(9 2) v2(2 9) v2(7 5) v2(5 7) v2(6 6) v2(9 1) v2(8 3) v2(1 9) v2(3 8) v2(9 0) v2(7 4) v2(4 7) v2(8 2) v2(6 5) v2(2 8) v2(5 6) v2(8 1) v2(1 8) v2(7 3) v2(3 7) v2(8 0) v2(6 4) v2(4 6) v2(5 5) v2(7 2) v2(2 7) v2(7 1) v2(1 7) v2(6 3) v2(3 6) v2(7 0) v2(5 4) v2(4 5) v2(6 2) v2(2 6) v2(6 1) v2(5 3) v2(1 6) v2(3 5) v2(4 4) v2(6 0) v2(5 2) v2(2 5) v2(4 3) v2(3 4) v2(5 1) v2(1 5) v2(5 0) v2(4 2) v2(2 4) v2(3 3) v2(4 1) v2(1 4) v2(4 0) v2(3 2) v2(2 3) v2(3 1) v2(1 3) v2(3 0) v2(2 2) v2(2 1) v2(1 2) v2(2 0) v2(1 1) v2(1 0) ) -> | ||
+ | endif | ||
+ | |||
+ | # throw out the tower positions that are too close or too far. | ||
+ | < | ||
+ | do(-1 < | ||
+ | if (distancecell(0 0 < | ||
+ | < | ||
+ | endif | ||
+ | loop | ||
+ | < | ||
+ | |||
+ | # Find back roughly the center cell of the position list and add it to index [0], so that a pre-emptive tower check can be ran against it. | ||
+ | < | ||
+ | do(< | ||
+ | < | ||
+ | < | ||
+ | else pop | ||
+ | endif | ||
+ | loop | ||
+ | <-maxX 2 div 1 add floor -> | ||
+ | < | ||
+ | <-maxX 2 div 1 add ceil < | ||
+ | else | ||
+ | do(< | ||
+ | < | ||
+ | pop <-maxX max ->maxX | ||
+ | else pop pop | ||
+ | endif | ||
+ | loop | ||
+ | <-maxX 2 div 0.7 add floor dup -> | ||
+ | < | ||
+ | <-maxX 2 div 0.7 add 2 sqrt mul ceil < | ||
+ | endif | ||
+ | < | ||
+ | |||
+ | # Generate the 3 other relative position lists by rotating the 1 1 list. | ||
+ | < | ||
+ | < | ||
+ | ev2 -1 mul swap -1 mul swap v2 -> | ||
+ | ev2 swap -1 mul v2 -> | ||
+ | loop | ||
+ | # < | ||
+ | |||
+ | : | ||
+ | < | ||
+ | |||
+ | : | ||
+ | -> | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | " | ||
+ | |||
+ | : | ||
+ | -> | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | 1 setunitenabled | ||
+ | return | ||
+ | endif | ||
+ | loop | ||
+ | else | ||
+ | -1 < | ||
+ | < | ||
+ | 0 setunitenabled | ||
+ | return | ||
+ | endif | ||
+ | loop | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | # the same functiion as supplyunittype, | ||
+ | -> | ||
+ | < | ||
+ | # supply should be turned on for all units of this type, since construction could have finished with the packets that were already underway. | ||
+ | < | ||
+ | else | ||
+ | < | ||
+ | endif | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | 1 setunitenabled | ||
+ | return | ||
+ | endif | ||
+ | loop | ||
+ | else | ||
+ | -1 < | ||
+ | < | ||
+ | 0 setunitenabled | ||
+ | return | ||
+ | endif | ||
+ | loop | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | do(< | ||
+ | < | ||
+ | # only add pods that are on the ground + containing energy | ||
+ | <-UID GetUnitOccupiesLand if | ||
+ | <-UID getunitsettings " | ||
+ | < | ||
+ | < | ||
+ | endif | ||
+ | endif | ||
+ | endif | ||
+ | loop | ||
+ | do(< | ||
+ | < | ||
+ | < | ||
+ | <-UID @plan4Towers | ||
+ | endif | ||
+ | loop | ||
+ | do(< | ||
+ | < | ||
+ | < | ||
+ | <-UID @plan4Towers | ||
+ | endif | ||
+ | loop | ||
+ | getriftlab ->UID @plan4Towers | ||
+ | < | ||
+ | <-UID @plan4Towers | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | " | ||
+ | do(< | ||
+ | < | ||
+ | < | ||
+ | <-UID @plan4Towers | ||
+ | endif | ||
+ | loop | ||
+ | |||
+ | : | ||
+ | # The below code requires less compute time, but is somehow less effective than the code above. How is getunitsbytype ordered? | ||
+ | " | ||
+ | < | ||
+ | do(< | ||
+ | < | ||
+ | < | ||
+ | <-UID @plan4Towers | ||
+ | endif | ||
+ | loop | ||
+ | < | ||
+ | |||
+ | : | ||
+ | ->UID | ||
+ | <-UID getunitcell pop eq0 if return endif | ||
+ | clearstack <-UID dup dup2 < | ||
+ | 1 2 3 4 < | ||
+ | < | ||
+ | |||
+ | : | ||
+ | # remove destroyed nodes from the list | ||
+ | do(-1 < | ||
+ | < | ||
+ | <-UID getunitcell pop eq0 if | ||
+ | < | ||
+ | endif | ||
+ | loop | ||
+ | # surviving old nodes need to be removed from the old node list periodically, | ||
+ | if(< | ||
+ | 3 -> | ||
+ | do(< | ||
+ | < | ||
+ | < | ||
+ | return | ||
+ | endif | ||
+ | loop | ||
+ | else | ||
+ | < | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | # randint(0 GetListCount(< | ||
+ | < | ||
+ | < | ||
+ | @findOtherTowers2 | ||
+ | else | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <-UID < | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | # randint(0 GetListCount(< | ||
+ | < | ||
+ | < | ||
+ | @buildPlannedTower | ||
+ | else | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <-UID < | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | if(< | ||
+ | GetListCount(< | ||
+ | else | ||
+ | < | ||
+ | endif | ||
+ | if(GetUnitCell(< | ||
+ | if(GetUnitCell(< | ||
+ | < | ||
+ | < | ||
+ | endif | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | # else | ||
+ | # # Some randomized tower building, which might unstuck tower building | ||
+ | # < | ||
+ | endif | ||
+ | |||
+ | : | ||
+ | ->UID | ||
+ | randint(1 5) -> | ||
+ | <-UID < | ||
+ | |||
+ | : | ||
+ | -> | ||
+ | if(GetUnitCell(< | ||
+ | return | ||
+ | endif | ||
+ | |||
+ | GetUnitPosition(< | ||
+ | < | ||
+ | |||
+ | GetUnitType(< | ||
+ | |||
+ | < | ||
+ | elapsedtime -> | ||
+ | <-UID " " < | ||
+ | endif | ||
+ | |||
+ | switch | ||
+ | case(< | ||
+ | < | ||
+ | endcase | ||
+ | case(< | ||
+ | < | ||
+ | endcase | ||
+ | case(< | ||
+ | < | ||
+ | endcase | ||
+ | case(< | ||
+ | < | ||
+ | endcase | ||
+ | endswitch | ||
+ | |||
+ | # Do a pre-emptive tower check and abort if another tower is found in the middle of the positions list | ||
+ | < | ||
+ | GetTerrain(< | ||
+ | < | ||
+ | GetUnits(" | ||
+ | return | ||
+ | # < | ||
+ | endif | ||
+ | |||
+ | # Do a pre-emptive creeper check and classify it as blocked + abort if there is creeper in the middle of the positions list | ||
+ | < | ||
+ | GetCreeperInRange(< | ||
+ | < | ||
+ | < | ||
+ | return | ||
+ | # < | ||
+ | endif | ||
+ | |||
+ | # Check if the chosen direction is (partly) outside the map | ||
+ | GetTerrain(< | ||
+ | |||
+ | < | ||
+ | -1 -> | ||
+ | 0 ->skipI | ||
+ | do(< | ||
+ | switch | ||
+ | case(< | ||
+ | < | ||
+ | break | ||
+ | endcase | ||
+ | case(< | ||
+ | < | ||
+ | < | ||
+ | endcase | ||
+ | if(< | ||
+ | < | ||
+ | endif | ||
+ | < | ||
+ | GetTerrain(< | ||
+ | case(< | ||
+ | # cells outside the map will have a terrain height of -1 | ||
+ | < | ||
+ | # < | ||
+ | endcase | ||
+ | case(GetCellOccupiedCount(< | ||
+ | < | ||
+ | endcase | ||
+ | # case(IsV3InMap(< | ||
+ | # < | ||
+ | # endcase | ||
+ | case(GetTerrainSpecial(< | ||
+ | < | ||
+ | endcase | ||
+ | < | ||
+ | distance(< | ||
+ | case(< | ||
+ | < | ||
+ | # Do NOT use skipI here. | ||
+ | # Sometimes 2 towers at an exact distance of 12 will not connect, so gte and not gt? This was a problem in version 1, also in 2? | ||
+ | endcase | ||
+ | case(< | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | if(< | ||
+ | endcase | ||
+ | GetTerrainLOS(< | ||
+ | < | ||
+ | < | ||
+ | case(< | ||
+ | # < | ||
+ | if(< | ||
+ | < | ||
+ | endcase | ||
+ | < | ||
+ | GetUnits(" | ||
+ | < | ||
+ | else | ||
+ | < | ||
+ | GetUnits(" | ||
+ | endif | ||
+ | case(< | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | if(< | ||
+ | endcase | ||
+ | # check the next few cells to look for more towers at a near optimal distance, to form extra connections. | ||
+ | case(< | ||
+ | < | ||
+ | 0 -> | ||
+ | GetUnits(" | ||
+ | if(< | ||
+ | if(< | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | endif | ||
+ | if(< | ||
+ | < | ||
+ | endcase | ||
+ | < | ||
+ | break # break the loop and build (or plan) the optimal tower outside of the loop | ||
+ | endswitch | ||
+ | loop | ||
+ | |||
+ | if(< | ||
+ | switch | ||
+ | case(GetMeshHealth(< | ||
+ | < | ||
+ | < | ||
+ | endcase | ||
+ | case(GetCreeperInRange(< | ||
+ | < | ||
+ | < | ||
+ | endcase | ||
+ | CreateUnitOnTerrain(" | ||
+ | < | ||
+ | # Start monitoring of that one tower | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | < | ||
+ | endswitch | ||
+ | endif | ||
+ | |||
+ | < | ||
+ | elapsedtime -> | ||
+ | < | ||
+ | if(< | ||
+ | getgameupdatecount " " < | ||
+ | endif | ||
+ | endif | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Faster vanilla unit placement : Snapping Tool ===== | ||
+ | |||
+ | 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 2695: | 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 2719: | 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(< | ||
+ | </ | ||
</ | </ | ||