User Tools

Site Tools


cw4:4rpl_tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cw4:4rpl_tools [2024/01/18 20:51] Kallicw4: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("Custom1" false)) +if(<-inputDelay gt0) <-inputDelay 1 - ->inputDelay endif 
- Mod(<-Index 1 +, <-soundCount) ->index+ 
 +if (GetMappedKey("Custom1" false) <-inputDelay eq0 &&) 
 + 2 ->inputDelay 
 + Mod(<-index 1 +, <-soundCount) ->index
  <-soundList[<-index] ->soundName  <-soundList[<-index] ->soundName
  TraceAll ("This is sound #" <-index ", " DQ <-soundName DQ)  TraceAll ("This is sound #" <-index ", " DQ <-soundName DQ)
 endIf endIf
  
-if (GetMappedKey("Custom2" false)) +if(GetMappedKey("Custom2" false) <-inputDelay eq0 &&) 
- Mod2(<-Index 1 -, <-soundCount) ->index+ 2 ->inputDelay 
 + Mod2(<-index 1 -, <-soundCount) ->index
  <-soundList[<-index] ->soundName  <-soundList[<-index] ->soundName
  TraceAll ("This is sound #" <-index ", " DQ <-soundName DQ)  TraceAll ("This is sound #" <-index ", " DQ <-soundName DQ)
Line 601: Line 601:
  
 if (GetMouseButtonDown(<-rmb true )) if (GetMouseButtonDown(<-rmb true ))
- PlaySoundAtPosition(<-soundName 8 GetCameraPosition) + PlaySoundAtPosition(<-soundName 8 GetCameraPosition V3(0 0.1 0) +)
 endif endif
- + 
 +:Once 
 + -1 ->index #So we start at 0, not 1. 
 + @MakeSoundList 
 :MakeSoundList :MakeSoundList
- +
  "ADAMessage"    "ADAMessage"  
  "ADAMessagesClose"    "ADAMessagesClose"  
Line 633: Line 637:
  "Explosion"    "Explosion"  
  "Explosion_1"    "Explosion_1"  
- "Explosion_10"   
- "Explosion_11"   
- "Explosion_12"   
  "Explosion_2"    "Explosion_2"  
  "Explosion_3"    "Explosion_3"  
Line 643: Line 644:
  "Explosion_8"    "Explosion_8"  
  "Explosion_9"    "Explosion_9"  
 + "Explosion_10"  
 + "Explosion_11"  
 + "Explosion_12"  
  "HoverOpen"    "HoverOpen"  
  "InfoCacheCollected"    "InfoCacheCollected"  
Line 715: Line 719:
  "Warning2"    "Warning2"  
  List ->soundList  List ->soundList
- +
  "AlarmClock"   "AlarmClock" 
  "GreenarRefinery"    "GreenarRefinery"  
Line 724: Line 728:
  "SoundLoop_alarm0"    "SoundLoop_alarm0"  
  "SoundLoop_alarm1"    "SoundLoop_alarm1"  
- "SoundLoop_alarm10"   
- "SoundLoop_alarm11"   
- "SoundLoop_alarm12"   
- "SoundLoop_alarm13"   
- "SoundLoop_alarm14"   
- "SoundLoop_alarm15"   
  "SoundLoop_alarm2"    "SoundLoop_alarm2"  
  "SoundLoop_alarm3"    "SoundLoop_alarm3"  
Line 738: Line 736:
  "SoundLoop_alarm8"    "SoundLoop_alarm8"  
  "SoundLoop_alarm9"    "SoundLoop_alarm9"  
 + "SoundLoop_alarm10"  
 + "SoundLoop_alarm11"  
 + "SoundLoop_alarm12"  
 + "SoundLoop_alarm13"  
 + "SoundLoop_alarm14"  
 + "SoundLoop_alarm15"  
  "SoundLoop_ambience0"    "SoundLoop_ambience0"  
- "SoundLoop_ambience1"   + "SoundLoop_ambience1"   
- "SoundLoop_ambience10"  +
  "SoundLoop_ambience2"    "SoundLoop_ambience2"  
  "SoundLoop_ambience3"    "SoundLoop_ambience3"  
Line 749: Line 752:
  "SoundLoop_ambience8"    "SoundLoop_ambience8"  
  "SoundLoop_ambience9"    "SoundLoop_ambience9"  
 + "SoundLoop_ambience10"  
  "SoundLoop_gun0"    "SoundLoop_gun0"  
  "SoundLoop_gun1"    "SoundLoop_gun1"  
Line 754: Line 758:
  "SoundLoop_gun3"    "SoundLoop_gun3"  
  "SoundLoop_hum0"    "SoundLoop_hum0"  
- "SoundLoop_hum1"  + "SoundLoop_hum1"  
 + "SoundLoop_hum2"   
 + "SoundLoop_hum3"   
 + "SoundLoop_hum4"   
 + "SoundLoop_hum5"   
 + "SoundLoop_hum6"   
 + "SoundLoop_hum7"   
 + "SoundLoop_hum8"   
 + "SoundLoop_hum9"   
  "SoundLoop_hum10"    "SoundLoop_hum10"  
  "SoundLoop_hum11"    "SoundLoop_hum11"  
Line 764: Line 776:
  "SoundLoop_hum17"   "SoundLoop_hum17" 
  "SoundLoop_hum18"    "SoundLoop_hum18"  
- "SoundLoop_hum2"   
- "SoundLoop_hum3"   
- "SoundLoop_hum4"   
- "SoundLoop_hum5"   
- "SoundLoop_hum6"   
- "SoundLoop_hum7"   
- "SoundLoop_hum8"   
- "SoundLoop_hum9"   
  "SoundLoop_machine0"    "SoundLoop_machine0"  
  "SoundLoop_machine1"    "SoundLoop_machine1"  
- "SoundLoop_machine10"   
- "SoundLoop_machine11"   
- "SoundLoop_machine12"   
  "SoundLoop_machine2"    "SoundLoop_machine2"  
  "SoundLoop_machine3"    "SoundLoop_machine3"  
Line 785: Line 786:
  "SoundLoop_machine8"   "SoundLoop_machine8" 
  "SoundLoop_machine9"    "SoundLoop_machine9"  
 + "SoundLoop_machine10"  
 + "SoundLoop_machine11"  
 + "SoundLoop_machine12"  
  "SoundLoop_misc0"    "SoundLoop_misc0"  
  "SoundLoop_misc1"    "SoundLoop_misc1"  
Line 797: Line 801:
  "ambient"   "ambient" 
  List ->loopSoundList  List ->loopSoundList
- +
  GetListCount(<-soundList) ->soundCount  GetListCount(<-soundList) ->soundCount
- TraceAllSp ("List of " <-soundCount "sounds available"+ TraceAllSp("List of " <-soundCount "sounds available"
- TraceAllSp ("There are also " GetListCOunt(<-loopSoundList) "looping sounds that cannot be played in this module"+ TraceAllSp("There are also " GetListCOunt(<-loopSoundList) "looping sounds that cannot be played in this module"
- TraceAllSP ("Press and hold user key 1/2 to scroll through the sound list." ) + TraceAllSP("Press and hold KeyPad 1 / 2 to scroll through the sound list."
- TraceAllSp ("Left-click mouse to listen to it.")+ TraceAllSp("Left-click mouse to listen to it.")
 </code> </code>
  
Line 812: Line 816:
  
 A few notes. A few notes.
- +  * The script will attempt to unpause the game, since looping sounds only play when not paused due to being attached to a unit.
-  * 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. +
-  * The script will attempt to unpause the game, since looping sounds only play when not paused.+
   * 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(<-inputDelay gt0<-inputDelay 1 - ->inputDelay endif 
- @MakeSoundList +
- CreateUnitOnTerrain("infocache" 1 1 1) ->unitUID +
- false ->soundOn +
- Getpause ->pause +
-endOnce+
 SetUnitPosition(<-unitUID GetCameraPosition V3(0 1.5 0) +) SetUnitPosition(<-unitUID GetCameraPosition V3(0 1.5 0) +)
  
-if (GetMappedKey("Custom1" false)) +if(GetMappedKey("Custom1" false) <-inputDelay eq0 &&) 
- Mod(<-Index 1 +, <-soundCount) ->index+ 2 ->inputDelay 
 + Mod(<-index 1 +, <-soundCount) ->index
  <-loopSoundList[<-index] ->soundName  <-loopSoundList[<-index] ->soundName
- TraceAll ("This is sound #" <-index ", " DQ <-soundName DQ)+ TraceAll("This is sound #" <-index ", " DQ <-soundName DQ)
 endIf endIf
  
-if (GetMappedKey("Custom2" false)) +if(GetMappedKey("Custom2" false) <-inputDelay eq0 &&) 
- Mod2(<-Index 1 -, <-soundCount) ->index+ 2 ->inputDelay 
 + Mod2(<-index 1 -, <-soundCount) ->index
  <-loopSoundList[<-index] ->soundName  <-loopSoundList[<-index] ->soundName
- TraceAll ("This is sound #" <-index ", " DQ <-soundName DQ)+ TraceAll("This is sound #" <-index ", " DQ <-soundName DQ)
 endIf endIf
  
-if (GetMouseButtonDown(<-rmb true )) +if(GetMouseButtonDown(<-rmb true)) 
- If (<-soundOn)+ If(<-soundOn)
  StopSoundLoop(<-unitUID)  StopSoundLoop(<-unitUID)
  Not(<-soundOn) ->soundOn  Not(<-soundOn) ->soundOn
  SetPause(<-pause)  SetPause(<-pause)
- TraceAllSp ("Stopping " <-soundName " from playing")+ TraceAllSp("Stopping " <-soundName " from playing")
  else  else
- TraceAllSp ("Can you hear " <-soundName " playing?")+ TraceAllSp("Can you hear " <-soundName " playing?")
  SetPause (false)  SetPause (false)
  PlaySoundLoop(<-soundName 5 <-unitUID)   PlaySoundLoop(<-soundName 5 <-unitUID)
  Not(<-soundOn) ->soundOn  Not(<-soundOn) ->soundOn
  endif  endif
-  
 endif endif
  
Line 864: Line 862:
  TraceAllSp("Goodbye!")  TraceAllSp("Goodbye!")
  DestroyUnit(<-unitUID true true true)  DestroyUnit(<-unitUID true true true)
 + if(<-soundOn) SetPause(true) endif
 +
 +:Once
 + -1 ->index #So we start at 0, not 1.
 + @MakeSoundList
 + CreateUnitOnTerrain("infocache" 1 1 1) ->unitUID
 + false ->soundOn
 + Getpause ->pause
  
-  
 :MakeSoundList :MakeSoundList
- +
  "ADAMessage"    "ADAMessage"  
  "ADAMessagesClose"    "ADAMessagesClose"  
Line 895: Line 900:
  "Explosion"    "Explosion"  
  "Explosion_1"    "Explosion_1"  
- "Explosion_10"   
- "Explosion_11"   
- "Explosion_12"   
  "Explosion_2"    "Explosion_2"  
  "Explosion_3"    "Explosion_3"  
Line 905: Line 907:
  "Explosion_8"    "Explosion_8"  
  "Explosion_9"    "Explosion_9"  
 + "Explosion_10"  
 + "Explosion_11"  
 + "Explosion_12"  
  "HoverOpen"    "HoverOpen"  
  "InfoCacheCollected"    "InfoCacheCollected"  
Line 915: Line 920:
  "MissionObjectiveFail"    "MissionObjectiveFail"  
  "MissionObjectiveRequiredComplete"    "MissionObjectiveRequiredComplete"  
- "MissionScan"     + "MissionScan"    "InhibitorFiring"   
- "InhibitorFiring"   +
  "MissionSpaceInitiateJump"    "MissionSpaceInitiateJump"  
  "MissionSpacePanelClose"    "MissionSpacePanelClose"  
Line 964: Line 968:
  "SporePrelaunch"    "SporePrelaunch"  
  "SprayerFire"    "SprayerFire"  
- "Stun"     + "Stun"    "CannonFire"  
- "CannonFire"  +
  "SurviveBaseOffline"    "SurviveBaseOffline"  
  "SurviveBaseWarn"    "SurviveBaseWarn"  
  "ThorGun"    "ThorGun"  
- "TotemExplosion"    + "TotemExplosion"   "UnitHoverLand"  
- "UnitHoverLand"  +
  "UnitBuild"    "UnitBuild"  
  "UnitExplosion"    "UnitExplosion"  
Line 989: Line 991:
  "SoundLoop_alarm0"    "SoundLoop_alarm0"  
  "SoundLoop_alarm1"    "SoundLoop_alarm1"  
- "SoundLoop_alarm10"   
- "SoundLoop_alarm11"   
- "SoundLoop_alarm12"   
- "SoundLoop_alarm13"   
- "SoundLoop_alarm14"   
- "SoundLoop_alarm15"   
  "SoundLoop_alarm2"    "SoundLoop_alarm2"  
  "SoundLoop_alarm3"    "SoundLoop_alarm3"  
Line 1003: Line 999:
  "SoundLoop_alarm8"    "SoundLoop_alarm8"  
  "SoundLoop_alarm9"    "SoundLoop_alarm9"  
 + "SoundLoop_alarm10"  
 + "SoundLoop_alarm11"  
 + "SoundLoop_alarm12"  
 + "SoundLoop_alarm13"  
 + "SoundLoop_alarm14"  
 + "SoundLoop_alarm15"  
  "SoundLoop_ambience0"    "SoundLoop_ambience0"  
- "SoundLoop_ambience1"   + "SoundLoop_ambience1"   
- "SoundLoop_ambience10"  +
  "SoundLoop_ambience2"    "SoundLoop_ambience2"  
  "SoundLoop_ambience3"    "SoundLoop_ambience3"  
Line 1014: Line 1015:
  "SoundLoop_ambience8"    "SoundLoop_ambience8"  
  "SoundLoop_ambience9"    "SoundLoop_ambience9"  
 + "SoundLoop_ambience10"  
  "SoundLoop_gun0"    "SoundLoop_gun0"  
  "SoundLoop_gun1"    "SoundLoop_gun1"  
Line 1019: Line 1021:
  "SoundLoop_gun3"    "SoundLoop_gun3"  
  "SoundLoop_hum0"    "SoundLoop_hum0"  
- "SoundLoop_hum1"  + "SoundLoop_hum1"  
 + "SoundLoop_hum2"   
 + "SoundLoop_hum3"   
 + "SoundLoop_hum4"   
 + "SoundLoop_hum5"   
 + "SoundLoop_hum6"   
 + "SoundLoop_hum7"   
 + "SoundLoop_hum8"   
 + "SoundLoop_hum9"   
  "SoundLoop_hum10"    "SoundLoop_hum10"  
  "SoundLoop_hum11"    "SoundLoop_hum11"  
Line 1029: Line 1039:
  "SoundLoop_hum17"   "SoundLoop_hum17" 
  "SoundLoop_hum18"    "SoundLoop_hum18"  
- "SoundLoop_hum2"   
- "SoundLoop_hum3"   
- "SoundLoop_hum4"   
- "SoundLoop_hum5"   
- "SoundLoop_hum6"   
- "SoundLoop_hum7"   
- "SoundLoop_hum8"   
- "SoundLoop_hum9"   
  "SoundLoop_machine0"    "SoundLoop_machine0"  
  "SoundLoop_machine1"    "SoundLoop_machine1"  
- "SoundLoop_machine10"   
- "SoundLoop_machine11"   
- "SoundLoop_machine12"   
  "SoundLoop_machine2"    "SoundLoop_machine2"  
  "SoundLoop_machine3"    "SoundLoop_machine3"  
Line 1050: Line 1049:
  "SoundLoop_machine8"   "SoundLoop_machine8" 
  "SoundLoop_machine9"    "SoundLoop_machine9"  
 + "SoundLoop_machine10"  
 + "SoundLoop_machine11"  
 + "SoundLoop_machine12"  
  "SoundLoop_misc0"    "SoundLoop_misc0"  
  "SoundLoop_misc1"    "SoundLoop_misc1"  
Line 1062: Line 1064:
  "ambient"   "ambient" 
  List ->loopSoundList  List ->loopSoundList
- +
  GetListCount(<-loopSoundList) ->soundCount  GetListCount(<-loopSoundList) ->soundCount
- TraceAllSp ("List of " <-soundCount "looping sounds available"+ TraceAllSp("List of " <-soundCount "looping sounds available"
- TraceAllSP ("Press and hold user key 1/2 to scroll through the sound list." ) + TraceAllSP("Press and hold KeyPad 1 / 2 to scroll through the sound list."
- TraceAllSp ("Move mouse out of edit box. Left-click mouse to listen to a sound. " ) + TraceAllSp("Move mouse out of edit box. Left-click mouse to listen to a sound. ") 
- TraceAllSP ("Left-click to turn off again."+ TraceAllSP("Left-click to turn off again."
- TraceAllSp ("Remember to mute music!")+ TraceAllSp("Remember to mute music!")
 </code> </code>
  
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  #Integer+$RAND_MIN:25 #Integer 
 +$STEP:1.0 #--How far something moves per incrament when using the script. 
 +$$BUFFER:2
  
-if(GetKey("RightArrow" false))+if(<-inputDelay gt0) <-inputDelay 1 - ->inputDelay endif 
 + 
 +if(GetKey("RightArrow" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
  GetUnitPosition(<-units[I]) ->unitPosPre  GetUnitPosition(<-units[I]) ->unitPosPre
- SetUnitPosition(<-units[I] V3(<-unitPosPre.x + <-unitPosPre.y <-unitPosPre.z))+ SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-STEP + <-unitPosPre.y <-unitPosPre.z))
  GetTerrain(GetUnitCell(<-units[I])) ->terrainH  GetTerrain(GetUnitCell(<-units[I])) ->terrainH
  GetUnitPosition(<-units[I]) ->unitPos  GetUnitPosition(<-units[I]) ->unitPos
Line 2224: Line 2231:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
-if(GetKey("LeftArrow" false))+if(GetKey("LeftArrow" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
  GetUnitPosition(<-units[I]) ->unitPosPre  GetUnitPosition(<-units[I]) ->unitPosPre
- SetUnitPosition(<-units[I] V3(<-unitPosPre.x - <-unitPosPre.y <-unitPosPre.z))+ SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-STEP - <-unitPosPre.y <-unitPosPre.z))
  GetTerrain(GetUnitCell(<-units[I])) ->terrainH  GetTerrain(GetUnitCell(<-units[I])) ->terrainH
  GetUnitPosition(<-units[I]) ->unitPos  GetUnitPosition(<-units[I]) ->unitPos
Line 2238: Line 2246:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
-if(GetKey("UpArrow" false))+if(GetKey("UpArrow" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
  GetUnitPosition(<-units[I]) ->unitPosPre  GetUnitPosition(<-units[I]) ->unitPosPre
- SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y <-unitPosPre.z +))+ SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y <-unitPosPre.z <-STEP +))
  GetTerrain(GetUnitCell(<-units[I])) ->terrainH  GetTerrain(GetUnitCell(<-units[I])) ->terrainH
  GetUnitPosition(<-units[I]) ->unitPos  GetUnitPosition(<-units[I]) ->unitPos
Line 2252: Line 2261:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
-if(GetKey("DownArrow" false))+if(GetKey("DownArrow" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
  GetUnitPosition(<-units[I]) ->unitPosPre  GetUnitPosition(<-units[I]) ->unitPosPre
- SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y <-unitPosPre.z -))+ SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y <-unitPosPre.z <-STEP -))
  GetTerrain(GetUnitCell(<-units[I])) ->terrainH  GetTerrain(GetUnitCell(<-units[I])) ->terrainH
  GetUnitPosition(<-units[I]) ->unitPos  GetUnitPosition(<-units[I]) ->unitPos
Line 2266: Line 2276:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
-if(GetKey("PageUp" false))+if(GetKey("PageUp" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
  GetUnitPosition(<-units[I]) ->unitPosPre  GetUnitPosition(<-units[I]) ->unitPosPre
- SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y + <-unitPosPre.z))+ SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y <-STEP + <-unitPosPre.z))
  GetTerrain(GetUnitCell(<-units[I])) ->terrainH  GetTerrain(GetUnitCell(<-units[I])) ->terrainH
  GetUnitPosition(<-units[I]) ->unitPos  GetUnitPosition(<-units[I]) ->unitPos
Line 2280: Line 2291:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
-if(GetKey("PageDown" false))+if(GetKey("PageDown" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
  GetUnitPosition(<-units[I]) ->unitPosPre  GetUnitPosition(<-units[I]) ->unitPosPre
- SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y - <-unitPosPre.z))+ SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-unitPosPre.y <-STEP - <-unitPosPre.z))
  GetTerrain(GetUnitCell(<-units[I])) ->terrainH  GetTerrain(GetUnitCell(<-units[I])) ->terrainH
  GetUnitPosition(<-units[I]) ->unitPos  GetUnitPosition(<-units[I]) ->unitPos
Line 2294: Line 2306:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
 if(GetKey("Backspace" false)) if(GetKey("Backspace" false))
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
Line 2308: Line 2321:
  SetUnitOccupiesLand(<-units[I] true)  SetUnitOccupiesLand(<-units[I] true)
  else  else
- if(<-unitPos.y lt(<-terrainH)) SetUnitOccupiesLand(<-units[I] false) endif+ if(<-unitPos.y lt(<-terrainH)) endif #SetUnitOccupiesLand(<-units[I] false) endif
  endif  endif
  loop  loop
 endif endif
  
-if(GetKey("Slash" false))+if(GetKey("Slash" false) <-inputDelay eq0 &&) 
 + true ->doesBuffer
  GetSelectedUnits ->units  GetSelectedUnits ->units
  do(GetListCount(<-units) 0)  do(GetListCount(<-units) 0)
Line 2320: Line 2334:
  SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-randHeight <-unitPosPre.z))  SetUnitPosition(<-units[I] V3(<-unitPosPre.x <-randHeight <-unitPosPre.z))
  loop  loop
 +endif
 +
 +if(<-doesBuffer)
 + false ->doesBuffer
 + <-BUFFER ->inputDelay
 endif endif
  
Line 2337: Line 2356:
 The below script originally existed as a map script that builds out the tower grid for/alongside the player. I've adapted it for console usage in the editor, by blocking out specicific code and instantly constructing all towers that it places. The below script originally existed as a map script that builds out the tower grid for/alongside the player. I've adapted it for console usage in the editor, by blocking out specicific code and instantly constructing all towers that it places.
  
-If you have a large map with varied terrain and you want to want wire it up fast, then this script is worth a try.+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. 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 2915: Line 2937:
 ---- ----
  
-===== Next Utility goes here =====+===== 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://knucklecracker.com/wiki/doku.php?id=cw4:cpack:docs:e58ef3f2-1468-42fa-ac84-c3561ddd9452|Kalli - SnappingTool]] 
 + 
 +---- 
 + 
 +===== 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> 
 + 
 +</hidden> 
 + 
 +---- 
 + 
 +===== 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't fully render terrain higher than 20 graphically. The cliffs of terrain higher than 20 will have stripes of black and after a height of 50, the final black stripe will continue to "infinity" height. 
 +  * The surfaces of various terrain higher than 20 will have **<fc #ff0000>BLINDING</fc>** bloom effects. If the surface isn't void-black, it is best you do not use that height as with bloom enabled, it **is** blinding. The effect is typically encountered when the terrain is at a height within a black stripe with the exception of height higher than 50. 
 +  * 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:42 #--Integer, incramented by +-1 via hotkeys. 
 + 
 +$$BUFFER:
 + 
 +if(<-inputDelay gt0) <-inputDelay 1 - ->inputDelay endif 
 + 
 +if(<-phase2 ! GetKeyDown("Space" true) &&
 + GetPointerTerrainCoords ->y1 ->x1 
 + if(IsV2InMap(V2(<-x1 <-y1))) 
 + true ->phase2 
 + Trace4("Lower Coord: " <-x1 " " <-y1) 
 + else 
 + Trace("That wasn't in the map. Try again."
 + endif 
 +else 
 +if(<-phase2 GetKeyDown("Space" true) &&
 + GetPointerTerrainCoords ->y2 ->x2 
 + if(IsV2InMap(V2(<-x2 <-y2))) 
 + false ->phase2 
 + Trace4("Upper Coord: " <-x2 " " <-y2) 
 + else 
 + Trace("That wasn't in the map. Try again."
 + endif 
 +endif 
 +endif 
 +if(GetKeyDown("Backspace" true) <-x1 neq(-1) && <-x2 neq(-1) &&
 + <-y2 1 add <-y1 do 
 +    <-x2 1 add <-x1 do 
 + while I J GetTerrain <-setHeight neq repeat 
 + SetTerrainInRange(I J <-setHeight dup 0 false 1) 
 + endwhile 
 +    loop 
 + loop 
 + ClearTraceLog 
 + Trace4(<-keyBindText " 
 +Height set to " <-setHeight "."
 + EditAddUndo(0) 
 +endif 
 + 
 +if(GetKeyDown("Keypad0" true)) 
 + ClearTraceLog 
 + Trace4(<-keyBindText " 
 +Height set to " <-setHeight "."
 + GetPointerTerrainCoords ->posZ ->posX 
 + FloodFillTerrain(<-posX <-posZ GetTerrain(<-posX <-posZ) GetTerrain(<-posX <-posZ) 1 + 10,000,000) ->cells 
 + do(GetListCount(<-cells) 0) 
 + EV2(<-cells[I]) ->cellyZ ->cellyX 
 + while <-cellyX <-cellyZ GetTerrain <-setHeight neq repeat 
 + SetTerrainInRange(<-cellyX <-cellyZ <-setHeight dup 0 false 1) 
 + endwhile 
 + loop 
 + Trace3("Completed flood fill to height" <-setHeight "."
 + EditAddUndo(0) 
 +endif 
 + 
 +if(GetKey("PageUp" false) <-setHeight lt(100) && <-inputDelay eq0 &&
 + <-setHeight 1 + ->setHeight 
 + ClearTraceLog 
 + Trace4(<-keyBindText " 
 +Height set to " <-setHeight "."
 + <-BUFFER ->inputDelay 
 +endif 
 +if(GetKey("PageDown" false) <-setHeight gt0 && <-inputDelay eq0 &&
 + <-setHeight 1 - ->setHeight 
 + ClearTraceLog 
 + Trace4(<-keyBindText " 
 +Height set to " <-setHeight "."
 + <-BUFFER ->inputDelay 
 +endif 
 + 
 +:Once 
 + <-HEIGHT ->setHeight 
 + "Key binds: 
 +SpaceBar to specify coordinates, then backspace to set terrain as a rectangle. 
 + 
 +PageUp and PageDown to increase and decrease set terrain height.
  
 +Pressing Keypad0 will conduct a flood-fill to set terrain to specified height." ->keyBindText
 + Trace(<-keyBindText)
 + Trace3("Height set to " <-HEIGHT ".")
 + -1 ->x1
 + -1 ->x2
 + -1 ->y1
 + -1 ->y2
 </code> </code>
  
Line 3290: Line 3463:
 <fs large>**Applying to a V3:**</fs> <fs large>**Applying to a V3:**</fs>
 <code> <code>
-V3(cos(RandFloat 2.0 / RandInt(0 7) +) <-RADIUS * <-cellX + <-Y_COORDINANT RandInt(-15 16) + sin(RandFloat 2.0 / RandInt(0 7) +) <-RADIUS * <-cellZ +) ->position+V3(cos(RandFloat RandInt(0 7) +) <-RADIUS * <-cellX + <-Y_COORDINANT RandInt(-15 16) + sin(RandFloat RandInt(0 7) +) <-RADIUS * <-cellZ +) ->position
 </code> </code>
 <fs large>**Applying to a V2:**</fs> <fs large>**Applying to a V2:**</fs>
 <code> <code>
-V2(cos(RandFloat 2.0 / RandInt(0 7) +) <-RADIUS * <-cellX + sin(RandFloat 2.0 / RandInt(0 7) +) <-RADIUS * <-cellZ +) ->cellLocation+V2(cos(RandFloat RandInt(0 7) +) <-RADIUS * <-cellX + sin(RandFloat RandInt(0 7) +) <-RADIUS * <-cellZ +) ->cellLocation
 </code> </code>
  
Line 3314: Line 3487:
  if(GetEditMode !)  if(GetEditMode !)
  GetUnitPosition(self) ->placementPos  GetUnitPosition(self) ->placementPos
- SetUnitPosition(self V3(cos(RandFloat 2.0 / RandInt(0 7) +) 45 * <-placementPos.x + <-FALL_HEIGHT RandInt(-15 16) + sin(RandFloat 2.0 / RandInt(0 7) +) 45 * <-placementPos.z +))+ SetUnitPosition(self V3(cos(RandFloat RandInt(0 7) +) 45 * <-placementPos.x + <-FALL_HEIGHT RandInt(-15 16) + sin(RandFloat RandInt(0 7) +) 45 * <-placementPos.z +))
  endif  endif
 </code> </code>
  
 +</hidden>
 +
 +
 +----
 +===== 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:commands:randint|RandInt]] and [[4rpl:commands:randfloat|RandFloat]] to determine the angle on the unit circle where the position along the circumference is.\\
 +Note: Floats will work for the radius.\\
 +\\
 +<code>
 +RandFloat RandInt(0 7) + ->angle
 +V3(cos(<-angle) <-RADIUS * <-cellX + <-Y_COORDINANT RandInt(-15 16) + sin(<-angle) <-RADIUS * <-cellZ +) ->position
 +</code>
 </hidden> </hidden>
  
cw4/4rpl_tools.1705611084.txt.gz · Last modified: 2025/02/14 14:56 (external edit)