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/02/18 15:50] – Updated sound players (fixed incorrect sound orders) Vertucw4:4rpl_tools [2024/05/13 11:42] (current) – [Make Units Unselectable] Kalli
Line 583: Line 583:
 $rmb:1 # right click button $rmb:1 # right click button
  
-Once 
- @MakeSoundList 
-endOnce 
  
-if (GetMappedKey("Custom1" false))+if(<-inputDelay gt0) <-inputDelay 1 - ->inputDelay endif 
 + 
 +if (GetMappedKey("Custom1" false) <-inputDelay eq0 &&) 
 + 2 ->inputDelay
  Mod(<-index 1 +, <-soundCount) ->index  Mod(<-index 1 +, <-soundCount) ->index
  <-soundList[<-index] ->soundName  <-soundList[<-index] ->soundName
Line 593: Line 593:
 endIf endIf
  
-if (GetMappedKey("Custom2" false))+if(GetMappedKey("Custom2" false) <-inputDelay eq0 &&) 
 + 2 ->inputDelay
  Mod2(<-index 1 -, <-soundCount) ->index  Mod2(<-index 1 -, <-soundCount) ->index
  <-soundList[<-index] ->soundName  <-soundList[<-index] ->soundName
Line 600: 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 :Once
  -1 ->index #So we start at 0, not 1.  -1 ->index #So we start at 0, not 1.
 + @MakeSoundList
  
 :MakeSoundList :MakeSoundList
Line 825: Line 827:
 $rmb:1 # right click button $rmb:1 # right click button
  
-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 &&) 
 + 2 ->inputDelay
  Mod(<-index 1 +, <-soundCount) ->index  Mod(<-index 1 +, <-soundCount) ->index
  <-loopSoundList[<-index] ->soundName  <-loopSoundList[<-index] ->soundName
Line 839: Line 838:
 endIf endIf
  
-if(GetMappedKey("Custom2" false))+if(GetMappedKey("Custom2" false) <-inputDelay eq0 &&) 
 + 2 ->inputDelay
  Mod2(<-index 1 -, <-soundCount) ->index  Mod2(<-index 1 -, <-soundCount) ->index
  <-loopSoundList[<-index] ->soundName  <-loopSoundList[<-index] ->soundName
Line 866: Line 866:
 :Once :Once
  -1 ->index #So we start at 0, not 1.  -1 ->index #So we start at 0, not 1.
 + @MakeSoundList
 + CreateUnitOnTerrain("infocache" 1 1 1) ->unitUID
 + false ->soundOn
 + Getpause ->pause
  
 :MakeSoundList :MakeSoundList
Line 2338: Line 2342:
  
 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 2344: Line 2350:
 # 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 2916: Line 2923:
  
 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]] 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>
 +
 +<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:1
 +
 +$applyToEnemyUnits:0
 +
 +$applyToAllUnits:0
 +
 +$makeUnitsSelectable:0
 +$makeUnitsDestroyable:0
 +
 +: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>
  
 ---- ----
cw4/4rpl_tools.1708289424.txt.gz · Last modified: 2024/02/18 15:50 by Vertu