scripts.cfg 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. // CubeScript placed in this file is automatically executed on each startup.
  2. const MODES [tdm coop dm surv tsurv ctf pf btdm bdm lss osok tosok bosok htf tktf ktf tpf tlss bpf blss btsurv btosok]
  3. const MODEALIASES [map lms vip sendmap]
  4. // commands to increment/decrement an alias - or to fail silently, if the alias doesn't exist
  5. const ++ [ if (checkalias $arg1) [ += $arg1 1 ] ]
  6. const -- [ if (checkalias $arg1) [ -= $arg1 1 ] ]
  7. const ++f [ if (checkalias $arg1) [ +=f $arg1 1 ] ]
  8. const --f [ if (checkalias $arg1) [ -=f $arg1 1 ] ]
  9. // makeshift "?" operator for cubescript
  10. // ex: /? (> $maxroll 0) [voicecom negative D:] [voicecom yes :D]
  11. // /echo I am (? (>= (player1 health) 50) [result healthy] [result weak]) atm
  12. ? = [
  13. if (> $numargs 1) [
  14. if (> $numargs 2) [
  15. if $arg1 $arg2 $arg3
  16. ] [
  17. if $arg1 $arg2
  18. ]
  19. ]
  20. ]
  21. // "editent" command:
  22. // This command collects all the attributes of the nearest entity, and then
  23. // prompts that into a handy command that allows you to edit that entities attributes easily.
  24. tempalias __editentprefix ""
  25. const editent [
  26. if $editing [
  27. push n (getclosestent)
  28. if (> $n -1) [
  29. push cced (editentity $n)
  30. __editentprefix = (concat $n (at $cced 1) (at $cced 2) (at $cced 3))
  31. saycommand "/editentattr" (at $cced 4) (at $cced 5) (at $cced 6) (at $cced 7) (at $cced 8) (at $cced 9) (at $cced 10)
  32. pop cced
  33. ]
  34. pop n
  35. ]
  36. ]
  37. // "convertclips" command:
  38. // This command automatically changes the "clip" to a "plclip" entity or vice-versa.
  39. const convertclips [
  40. if $editing [
  41. if (strcmp (getenttype) clip) [ entset plclip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3) (getentattr 4) (getentattr 5) (getentattr 6) (getentattr 7) ] [
  42. if (strcmp (getenttype) plclip) [ entset clip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3) (getentattr 4) (getentattr 5) (getentattr 6) (getentattr 7) ] [
  43. echo No changes made. This entity isn't a clip or a plclip.; echo Try using the /closestenttype command to find a specific entity.
  44. ]
  45. ]
  46. ]
  47. ]
  48. // increase legroom for mapmodels by decreasing the z-offset of a map config mapmodel slot
  49. // and simultaneously increasing the z-offset of all affected map model entities
  50. // (this is to counteract the fact, that the z-offset of an entity can only hold positive numbers - using the ability of the slot config to use negative numbers))
  51. // this will not change anything visible in the map - but allow a mapmodel to be lowered further than before
  52. // the only argument is the slot number - for more leg room, repeat the script
  53. const mapmodelzoff [
  54. if (strlen (editmapmodelslot $arg1)) [ // invalid slot returns empty string
  55. looplist (editmapmodelslot $arg1) [rad h zoff snap path] [editmapmodelslot $arg1 "" "" (- $zoff 1) ; echo $path in slot # $arg1 : new z-offset (- $zoff 1)]
  56. looplist (mapmodelslotusage $arg1) ii [editentity $ii "" "" "" "" "" (+ 1 (at (editentity $ii) 6)) ; echo adjusted entity # $ii]
  57. ]
  58. ]
  59. // "gibsgore" command:
  60. // This command controls gib Speed/Number/TTL all in one variable.
  61. const gibsgore [
  62. looplist (at ["0 30 6 5000" "1 30 6 5000" "1 30 75 5000" "1 15 64 10000" "1 40 100 2500"] $arg1) [a1 a2 a3 a4] [
  63. gib $a1 ; gibspeed $a2 ; gibnum $a3 ; gibttl $a4 ; __gibsgore = $arg1
  64. ]
  65. ]
  66. // "fullscreentoggle" command:
  67. // This command allows swapping of fullscreen mode to be bound to a key.
  68. const fullscreentoggle [ fullscreen (! $fullscreen) ]
  69. const editsvar [ inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " (at $q 0) ; pop q") (concatword "edit " $arg1 :) ]
  70. const editmapmsg [ editsvar mapmsg ]
  71. const editalias [ if (checkalias $arg1) 0 [ alias $arg1 "" ] ; inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " = (at $q 0) ; pop q") (concatword "edit " $arg1 :) ]
  72. const escapenoquotes [ substr (escape $arg1) 1 -2 ]
  73. const run [ push n (concatword "exec config/" $arg1 ".cfg") ; loop i (- $numargs 1) [ n = (concat $n $(concatword arg (+ $i 2))) ] ; n ; pop n]
  74. const closecurmenu [ closemenu (curmenu) ]
  75. const resetcurmenu [ delmenu (curmenu) ; newmenu (curmenu) ]
  76. const refreshcurmenu [ push __curmenu (curmenu); closecurmenu; showmenu (pop __curmenu) ]
  77. const refreshcurmenudelayed [ push __curmenu (curmenu); closecurmenu; sleep 0 [ showmenu (pop __curmenu) ] ]
  78. const switch [ if (&& (< $arg1 $numargs) (>= $arg1 0)) [ arg@(+ $arg1 2) ]]
  79. // Auto-completions
  80. const mapcomplete [complete $arg1 "packages/maps/official packages/maps" cgz]
  81. loop i (listlen (concat $MODES $MODEALIASES)) [ mapcomplete (at (concat $MODES $MODEALIASES) $i) ]
  82. complete demo demos dmo
  83. looplist [
  84. listoptions ""
  85. newent ents
  86. addentity ents
  87. clearents ents
  88. closestenttype ents
  89. enumentities ents
  90. weapon weapons
  91. burstshots weapons
  92. fragmessage weapons
  93. gibmessage weapons
  94. team teamnames
  95. addpunct punctuations // the command addpunct actually wants the punctuation name as second argument, but we can't do that. sry.
  96. loadcrosshair crosshairnames
  97. edittexturestack texturestacktypes
  98. enumsounds soundcategories
  99. ] [ cmd options ] [ listcomplete $cmd (listoptions $options)
  100. ]
  101. listcomplete edittagclip "none plclip clip"
  102. listcomplete getvarrange "min max default"
  103. listcomplete mapareacheck "vdelta steepest total pprest pp"
  104. listcomplete modeinfo "list clear get all ctf|dm|htf|ktf|lss|osok|pf|surv|tdm|tktf|tlss|tosok|tpf|tsurv"
  105. listcomplete mapartist "print get set clear"
  106. listcomplete authsetup "pre priv pub ppass pass passd needpass genpre genpriv genpub newppass newpass unarmed"
  107. listcomplete authkey "clear list delete new add selfcert"
  108. looplist [ addzipmod zipmodremove zipmodgetdesc ] cmd [complete $cmd "mods" zip]
  109. // set up list of skymaps
  110. push skies ""
  111. looplist (gettexturelist skymaps/ "" _ft.jpg) [c1 c2 c3 c4] [skies = (concat $skies (escape (concatword $c3 "/" $c4)))]
  112. listcomplete loadsky (pop skies)
  113. // Game mode descriptions...
  114. gamemodedesc 0 [Team Deathmatch: Shred the enemy team to pieces!]
  115. gamemodedesc 1 [Co-operative Editing: Edit maps with others online!]
  116. gamemodedesc 2 [Deathmatch: Destroy anything that moves! Everyone for themselves!]
  117. gamemodedesc 3 [Survivor: Conserve your precious life, destroy the enemy's. Once all your enemies are dead, the round restarts.]
  118. gamemodedesc 4 [Team Survivor: Conserve your precious life, destroy the enemy team. Once all your enemies are dead, the round restarts.]
  119. gamemodedesc 5 [Capture the Flag: Steal the enemy teams flag and bring it to your home base. Don't let your own flag get stolen.]
  120. gamemodedesc 6 [Pistol Frenzy: Can you make your enemy eat lead with the most simplest of weapons?]
  121. gamemodedesc 7 [Bot Team Deathmatch: Find the enemy A.I. and destroy them!]
  122. gamemodedesc 8 [Bot Deathmatch: It's every man and A.I. for themselves! Dismantle those bots!]
  123. gamemodedesc 9 [Last Swiss Standing: Knive and bomb the enemy!]
  124. gamemodedesc 10 [One Shot, One Kill: You and your opponents start with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  125. gamemodedesc 11 [Team One Shot, One Kill: Your team starts with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  126. gamemodedesc 12 [Bot One Shot, One Kill: You and the bots start with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  127. gamemodedesc 13 [Hunt the Flag: Find the enemy flag, frag the flag bearer and collect the flag to score. Protect your own team flag. If the flag bearer collects the enemy flag, they gain a 1 point bonus.]
  128. gamemodedesc 14 [Team Keep the Flag: There is only one flag. Get the flag and keep it. You score one point every 15 seconds. If your teammate has the flag, protect him. If the flag bearer collects the enemy flag, they gain a 1 point bonus.]
  129. gamemodedesc 15 [Keep the Flag: Get the flag and keep it. You score one point every 15 seconds. Everybody else will want to destroy you!]
  130. gamemodedesc 16 [Team Pistol Frenzy: Can you make your enemy team eat lead with the most simplest of weapons?]
  131. gamemodedesc 17 [Team Last Swiss Standing: Knive and bomb the enemy team!]
  132. gamemodedesc 18 [Bot Pistol Frenzy: Can you make the enemy A.I. eat lead with the most simplest of weapons?]
  133. gamemodedesc 19 [Bot Last Swiss Standing: Knive and bomb the enemy A.I.!]
  134. gamemodedesc 20 [Bot Team Survivor: Conserve your precious life, destroy the enemy A.I. team! Once all your enemies are dead, the round restarts.]
  135. gamemodedesc 21 [Bot Team One Shot, One Kill: You and your A.I. team start with 1hp, a sniper rifle, a knife and no pickups. Survive with your sniper, or humiliate with your swiss steel.]
  136. const resetbinds [ run resetbinds; echo "\f3All binds have been reset to default values!" ]
  137. const changeteam [ if (< (player1 team) 4) [ team (at [RVSF CLA RVSF-SPECT CLA-SPECT] (player1 team)) ] ]
  138. const NUM_WEAPONS (listlen (listoptions weapons))
  139. const NUM_MODES (listlen $MODES)
  140. const MAX_CLIENTS 16
  141. const MAX_BOT_MATCH_LENGTH 60
  142. const getgunindex [ findlist (listoptions weapons) $arg1 ]
  143. loop r $NUM_MODES [ const (at $MODES $r) (format [votemap %1 %2 %3] $r "$arg1" "$arg2") ]
  144. const modenum [ result (findlist $MODES $arg1) ]
  145. // Mode/map-setting aliases.
  146. const votemap [ mode $arg1; map $arg2 $arg3 ]
  147. const lms [ surv $arg1 $arg2 ]
  148. const vip [ htf $arg1 $arg2 ]
  149. const add2alias [
  150. if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [
  151. $arg1 = (concat (concatword (getalias $arg1) [;]) $arg2)
  152. ]
  153. ]
  154. const addOnLoadOnce [ add2alias mapstartonce $arg1 ]
  155. const addOnLoadAlways [ add2alias mapstartalways $arg1 ]
  156. const addOnQuit [ add2alias onQuit $arg1 ]
  157. const check2init [ if (! (checkalias $arg1)) [ tempalias $arg1 $arg2 ] ] // only overwrites an alias if it doesn't exist
  158. const check2initlist [ loop cll (listlen $arg1) [ check2init (at $arg1 $cll) $arg2 ] ] // check2inits multiple aliases
  159. const forceinit [ loop fil (listlen $arg1) [ (at $arg1 $fil) = $arg2 ] ] // forcibly overwrites multiple aliases
  160. const checkinit [ if (! (checkalias $arg1)) [ $arg1 = "" ]; if (> $numargs 1) [ if (! (strstr (getalias $arg1) $arg2)) [ add2alias $arg1 $arg2 ] ] ] // ensures the initialization of an alias, optionally ensures the alias contains string $arg2
  161. const aliasinit [ loop ail (listlen $arg1) [ checkinit (at $arg1 $ail) $arg2 ] ] // checkinits multiple aliases
  162. const add2list [ if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [ $arg1 = (concat (getalias $arg1) $arg2) ] ] // works exactly like concat, use as a shortcut to: alias = (concat $alias "some string")
  163. const add2bind [ if (! (strstr (keybind $arg1) $arg2)) [ bind $arg1 (format [%1; %2] (keybind $arg1) $arg2) ] ] // works exactly like add2alias except for used with keybinds
  164. const concatuniq [ if (< (findlist $$arg1 $arg2) 0) [$arg1 = (concat $$arg1 (escape $arg2)) ; result 1] [result 0] ] // add item to list, if it's not already been in the list
  165. // Weapon switching/action utilities.
  166. const hasprimary [ result (= (curweapon) (currentprimary)) ]
  167. const primary [ weapon (currentprimary) ]
  168. const ptoggle [ if (hasprimary) $arg1 primary ] // Toggle between primary/specified weapon
  169. const secondary [ weapon PISTOL ]
  170. const sndtoggle [ ptoggle secondary ]
  171. const melee [ weapon KNIFE ]
  172. const knftoggle [ ptoggle melee ]
  173. const grenades [ weapon GRENADE ]
  174. const gndtoggle [ ptoggle grenades ]
  175. const altaction [ (concatword altaction_ (curweapon)) ]
  176. const checkmag [ result (|| (magcontent $arg1) (magreserve $arg1)) ]
  177. const checkrange [ && (>=f $arg1 $arg2) (<=f $arg1 $arg3) ] // checkrange x min max
  178. loop i $NUM_WEAPONS [ (concatword altaction_ $i) = quicknadethrow ] // Quick nade throw is default
  179. // Use format to define altaction_N aliases from now on, makes for less edits in the future if weapon IDs change. - Bukz
  180. // (format altaction_%1 (getgunindex knife)) = [ if (checkmag (currentprimary)) primary [ if (|| (checkmag PISTOL) (checkmag AKIMBO)) secondary [ if (checkmag GRENADE) grenades ] ] ] // Knife // uncomment to switch to primary/secondary/grenades with MOUSE2 depending on ammo content for each.
  181. (format altaction_%1 (getgunindex sniper)) = [ setscope 1; onrelease [ setscope 0 ] ] // Sniper
  182. // (format altaction_%1 (getgunindex grenades)) = attack // Grenade // with this comment, you throw the nade and the nade is unselected : Brahma
  183. oldsens = $sensitivity
  184. const zoom [
  185. if (= $arg1 1) [
  186. if (! (=f $sensitivity $scopesens)) [
  187. oldsens = $sensitivity
  188. // avoid error if using 0.001 as sensitivity
  189. newsens = $scopesens
  190. if (> (*f 1 1000) $newsens) [ if (< 1000 $newsens) [ sensitivity $scopesens ] ]
  191. setscope 1
  192. ]
  193. ] [ sensitivity $oldsens; setscope 0 ]
  194. ]
  195. delta_game_0 = [ if (= $arg1 1) [ shiftweapon 1 ] [ shiftweapon -1 ] ] // Cycle through weapons
  196. delta_game_1 = [ if (checkrange (+ $gamma $arg1) 30 300) [ gamma (+ $gamma $arg1) ] ] // Tweak gamma
  197. delta_game_2 = [ if (checkrange (+ $fov $arg1) 75 120) [ fov (+ $fov $arg1) ] ] // Tweak fov
  198. delta_spect_0 = [ changefollowplayer $arg1 ]
  199. // Map editing using the mousewheel...
  200. tempalias modifier 0
  201. tempalias editmeta2down 0
  202. const domodifier [ modifier = $arg1; onrelease [ modifier = 0 ] ]
  203. const universaldelta [
  204. push s
  205. if $editing [ s = edit ] [
  206. if (player1 alive) [ s = game ] [ s = spect ]
  207. ]
  208. [delta_@(pop s)_@modifier] (* $arg1 (at "1 3" $editmetakeydown)) (* $arg1 (at "1 10" $editmetakeydown))
  209. ]
  210. // To utilize the below, you will need to bind "domodifier X"
  211. // (replace X with the number of the delta_edit) to a key. To
  212. // use them, simply hold the key that the "domodifier" is bound
  213. // to and then scroll backwards/forwards while looking at the
  214. // floor/ceiling.
  215. delta_edit_0 = [ editheight $flrceil $arg1 ] // Move cubes...
  216. delta_edit_1 = [ if $flrceil [ vdelta $arg1 ] [ vdelta (- 0 $arg1) ] ] // Change heightfielding...
  217. delta_edit_2 = [ edittex $flrceil $arg1 ] // Change floor/ceiling textures...
  218. delta_edit_3 = [ edittex (+ $flrceil 1) $arg1 ] // Change wall/upper-wall textures...
  219. delta_edit_4 = [ equalize $flrceil ] // Equalize floor/ceiling...
  220. delta_edit_6 = [ entproperty $editaxis $arg1 ] // Move map entity...
  221. delta_edit_10 = [ if (checkrange (+f $flyspeed (divf $arg1 4)) 1 5) [ flyspeed (+f $flyspeed (divf $arg1 4)); echo $flyspeed ] ] // Tweak flyspeed
  222. delta_edit_11 = [ expandselection $arg1 ] // Expand/shrink the current selection
  223. delta_edit_attr1 = [ entproperty 0 $arg2 $editmeta2down ] // Changes the first value on entities...
  224. delta_edit_attr2 = [ entproperty 1 $arg2 $editmeta2down ] // Changes the second value on entities...
  225. delta_edit_attr3 = [ entproperty 2 $arg2 $editmeta2down ] // Changes the third value on entities...
  226. delta_edit_attr4 = [ entproperty 3 $arg2 $editmeta2down ] // Changes the fourth value on entities...
  227. delta_edit_attr5 = [ entproperty 4 $arg2 $editmeta2down ] // Changes the fifth value on entities...
  228. delta_edit_attr6 = [ entproperty 5 $arg2 $editmeta2down ] // Changes the sixth value on entities...
  229. delta_edit_attr7 = [ entproperty 6 $arg2 $editmeta2down ] // Changes the seventh value on entities...
  230. delta_edit_spawns = [ gotonextplayerstart $arg1 ]
  231. delta_edit_todoents = [ gotonexttodoentity $arg1 ]
  232. delta_game_spawns = []
  233. // Scroll console (in all modes)
  234. delta_game_conscroll = [ __scrolled = $conopen ; conskip (* 4 $arg1) ]
  235. delta_spect_conscroll = $delta_game_conscroll
  236. delta_edit_conscroll = $delta_game_conscroll
  237. // HUD toggles
  238. const toggleshowmap [ showmap 1; onrelease [ showmap 0 ] ]
  239. // convenient connecting from the serverbrowser
  240. // sbconnect arg list:
  241. // arg1 IP, arg2 port,
  242. // arg3 1: server full
  243. // arg4 1: password protected
  244. // arg5 1: private mode, 2: match mode
  245. // arg6 1: banned, 2: blacklisted 3: both
  246. // arg7 "server description"
  247. const sbconnect [
  248. tempalias sbdns $arg1; tempalias sbport $arg2; tempalias sbdesc $arg7; tempalias sbpwd []; tempalias sbmsg []
  249. if (>= $arg5 1) [
  250. sbmsg = [This server is set to private.]; showmenu [password required]
  251. ] [
  252. if (>= $arg6 1) [
  253. sbmsg = [You are banned from this server.]; showmenu [password required]
  254. ] [
  255. if (= $arg4 1) [
  256. sbmsg = [This server is password-protected.]; showmenu [password required]
  257. ] [
  258. if (> (strlen $arg7) 0) [ echo connecting to $arg7 ]
  259. connect $arg1 $arg2
  260. ]
  261. ]
  262. ]
  263. ]
  264. // answer last PM
  265. const quickanswer [ if (>= $lastpm 0) [ saycommand (concat /pm $lastpm []) ] [ saycommand (concat /pm []) ] ]
  266. // For those players who use IRC too much...
  267. const join [ connect $arg1 $arg2 $arg3 ]
  268. const reconnect [ if $numargs [ tempalias svpass $arg1 ] [ tempalias svpass [] ]; if $connected [ tempalias svdata (curserver); afterdisconnect [ connect (at $svdata 0) (at $svdata 1) $svpass ] ] ]
  269. const dlmap [ getmap $arg1 [ sleep 2500 (concat map $arg1) ] ]
  270. const rndmap [ result (at $__maps_all (rnd (listlen $__maps_all))) ]
  271. const rrnd [ + (rnd (+ (- $arg2 $arg1) 1)) $arg1]
  272. const listaverage [ push sum "" ; looplist $arg1 n [ +=f sum $n ] ; if (strlen $sum) [ div=f sum (listlen $arg1) ] ; result (pop sum) ]
  273. tempalias pasteent [if $editing [echo no entity copied, yet]]
  274. const copyent [
  275. if $editing [
  276. push entidx (getclosestent)
  277. if (> $entidx -1) [
  278. push n (format2 "%1 %5 %6 %7 %8 %9 %010 %011" (editentity $entidx))
  279. push d (switch (findlist "mapmodel sound" (at $n 0)) [mapmodelslotname (at $n 2)] [at (editmapsoundslot (at $n 1)) 0])
  280. pasteent = [if $editing [if $editmetakeydown [showmenu [Paste entity]] [_nextentityispasted 1 ; newent @@@n ; echo @@@n @@@d pasted.]]]
  281. newmenu [Paste entity]
  282. menuitem [paste: @n @d] [_nextentityispasted 1 ; newent @n ; echo @n @d pasted.]
  283. echo $n $d copied.
  284. pop n d
  285. ]
  286. pop entidx
  287. ]
  288. ]
  289. // used by editent // editentity requires ent index, coordinates (via tempalias) and all seven attributes (via arguments)
  290. const editentattr [
  291. if (strlen $__editentprefix) [
  292. if $numargs [
  293. loop i 4 [ push [p@i] (if (< $i (listlen $__editentprefix)) [result (at $__editentprefix $i)])]
  294. loop i 7 [ push [a@i] (if (< $i $numargs) [result $arg@(+ $i 1)])]
  295. editentity $p0 $p1 $p2 $p3 $a0 $a1 $a2 $a3 $a4 $a5 $a6
  296. __editentprefix = ""
  297. loop i 7 [ pop [a@i] ]
  298. loop i 4 [ pop [p@i] ]
  299. ]
  300. ]
  301. ]
  302. // countwalls - Counts cubes of a specific type in all selections
  303. const countwalls [
  304. push __cnt 0
  305. selectionwalk [ if (= $sw_type $arg1) [ += __cnt 1 ] ]
  306. pop __cnt
  307. ]
  308. // cycle through all playerstarts
  309. const gotonextplayerstart [
  310. if (&& (!= $arg1 1) (!= $arg1 -1)) [ arg1 = 1 ]
  311. if (! (checkalias __gotonextplayerstart)) [ tempalias __gotonextplayerstart -1 ]
  312. push sl ""
  313. looplist [0 1 100] t [
  314. looplist (enumentities playerstart) i [
  315. if (= $t (at (editentity $i) 5)) [
  316. sl = (concat $sl $i)
  317. ]
  318. ]
  319. ]
  320. push n (listlen $sl)
  321. if (&& $n $editing) [
  322. __gotonextplayerstart = (mod (+ $n $n $arg1 $__gotonextplayerstart) $n)
  323. gotoentity (at $sl $__gotonextplayerstart)
  324. edittoggle ; sleep 50 edittoggle
  325. ]
  326. pop n sl
  327. ]
  328. // cycle through todo entities
  329. const gotonexttodoentity [
  330. if (&& (!= $arg1 1) (!= $arg1 -1)) [ arg1 = 1 ]
  331. if (! (checkalias __gotonexttodoentity)) [ tempalias __gotonexttodoentity -1 ]
  332. push l (enumtodoentities)
  333. push n (div (listlen $l) 2)
  334. if (&& $n $editing) [
  335. __gotonexttodoentity = (mod (+ $n $n $arg1 $__gotonexttodoentity) $n)
  336. looplisti $l [e desc] [
  337. if (= $i $__gotonexttodoentity) [
  338. gotoentity $e
  339. echo (concatword "TODO entity #" $e ": \fs\f4" (editentity $e) "\fr ") $desc
  340. ]
  341. ]
  342. ]
  343. pop n l
  344. ]
  345. // select whole map
  346. const selectall [
  347. select 2 2 (- (powf 2 (mapsize)) 4) (- (powf 2 (mapsize)) 4)
  348. ]
  349. // push and pop selection sets
  350. const pushselections [
  351. if (listlen (selx)) [
  352. push selsets ""
  353. selectionwalk [] [ selsets = (concat $selsets "; addselection" $sw_cursel) ]
  354. push popselections (concat "resetselections" (pop selsets) "; pop popselections")
  355. ][
  356. echo no selection
  357. ]
  358. ]
  359. tempalias popselections [ echo no selections stored ]
  360. const __changeselectionsize [
  361. if (&& $editing (= $numargs 4)) [
  362. push selsets ""
  363. selectionwalk [] [ selsets = (concat $selsets $sw_cursel) ]
  364. resetselections
  365. looplist (pop selsets) [x y xs ys] [
  366. if (&& (> (+ $xs $arg3) 0) (> (+ $ys $arg4) 0)) [
  367. addselection (- $x $arg1) (- $y $arg2) (+ $xs $arg3) (+ $ys $arg4)
  368. ] [
  369. addselection $x $y $xs $ys
  370. ]
  371. ]
  372. ]
  373. ]
  374. // enlarge selections after slope or arch placement to change all vdelta values (when enlargearchslopeselections is 0)
  375. const enlargevdeltaselections [ __changeselectionsize 0 0 (if $numargs $arg1 1) (if $numargs $arg1 1) ]
  376. // /expandselection 1 // makes the current selection bigger by 1 cube on all sides
  377. const expandselection [ if $numargs [ __changeselectionsize $arg1 $arg1 (* 2 $arg1) (* 2 $arg1) ] ]
  378. // /shrinkselection 1 // makes the current selection smaller by 1 cube on all sides
  379. const shrinkselection [ if $numargs [ *= arg1 -1 ; __changeselectionsize $arg1 $arg1 (* 2 $arg1) (* 2 $arg1) ] ]
  380. alias updateeditinfopanel explainclosestentity // default hook
  381. const __entexp_light [ at [ "radius: %1\nintensity: %2\n\n\f4(white light)" "radius: %1\nr: %2\ng: %3\nb: %4\n\n\f4(colored light)" ] (|| (getentattr 2 1) (getentattr 3 1)) ]
  382. const __entexp_playerstart [ result "angle: %1\nteam: %2" ]
  383. const __entexp_pistol [ result "elevation: %1" ]
  384. const __entexp_ammobox __entexp_pistol
  385. const __entexp_grenades __entexp_pistol
  386. const __entexp_health __entexp_pistol
  387. const __entexp_helmet __entexp_pistol
  388. const __entexp_armour __entexp_pistol
  389. const __entexp_akimbo __entexp_pistol
  390. const __entexp_mapmodel [ concatword "angle: %1\nconfig slot: #%2\n\elevation: %3\ntexture: %4\npitch: %5\nroll: %6\n\n\fs\f1slot #%2 info:\n" (format2 "\f9%5\fr\nclip radius: %1\nclip height: %2\nelevation: %3 scale: %4" (editmapmodelslot (getentattr 1)))]
  391. const __entexp_trigger [ result "tag: %1\ntype: %2" ]
  392. const __entexp_ladder [ result "height: %1" ]
  393. const __entexp_ctf-flag [ result "angle: %1\nteam: %2" ]
  394. const __entexp_sound [ concatword "config slot: #%1\nradius: %2\nsize: %3\nvolume: %4\n\n\fs\f1slot #%1 info:\n" (format2 "\f9%1\fr\nmaxuses: %2" (editmapsoundslot (getentattr 0)))]
  395. const __entexp_clip [ result "elevation: %1\nx-radius: %2\ny-radius: %3\nheight: %4\nslope: %6\nshape: %7" ]
  396. const __entexp_plclip __entexp_clip
  397. const __entexp_dummy [ if (= (getentattr 1) 222) [ result "The Vantage Point" ] [ result "n/a" ] ]
  398. const explainclosestentity [
  399. if (>= (getclosestent) 0) [
  400. concatword "\fs\f1" (getenttype) "\fr entity:\n\n" (format2 ((concatword __entexp_ (getenttype))) (format2 "%5 %6 %7 %8 %9 %010 %011" (editentity (getclosestent))))
  401. ]
  402. ]
  403. // megabind - Binds a key to many different actions depending on the current game state.
  404. const megabind [ if (> $numargs 5) [ bind $arg1 (format "if (watchingdemo) [ %1 ] [ if (|| $editing (= $gamemode 1)) [ %2 ] [ if $connected [ %3 ] [ if (curmodeattr bot) [ %4 ] [ %5 ] ] ] ]" $arg2 $arg3 $arg4 $arg5 $arg6) ] ]
  405. // storesets - Generates an alias (list) of the current values for the given CVARs.
  406. const storesets [
  407. if (> $numargs 1) [
  408. tempalias badargs 0; $arg2 = []
  409. loop ssl (listlen $arg1) [
  410. if (isIdent (at $arg1 $ssl)) [
  411. add2list $arg2 (getalias (at $arg1 $ssl))
  412. ] [ badargs = 1; break ]
  413. ]
  414. if $badargs [ delalias $arg2; echo "\f3Error: \f5Bad argument(s) given!" ]
  415. ]
  416. ]
  417. // show just one entity type (by name)
  418. const seteditshow [
  419. if $numargs [
  420. push n (findlist (listoptions ents) $arg1)
  421. if (< $n 0) [
  422. echo "\f3" $arg1 is not an entity type
  423. ] [
  424. edithideentmask (- (- (powf 2 (listlen (listoptions ents))) 1) (powf 2 $n))
  425. ]
  426. pop n
  427. ] [ edithideentmask 0 ]
  428. ]
  429. // cleanshot - Take a "clean" screenshot with no HUD items.
  430. const __disablehud [ tempalias __tmp_old_sets (concat hudgun $hudgun ";" showclips $showclips) ; hudgun 0 ; showclips 0 ; if $editing [ seteditshow 0 ]; blankouthud 1000 ]
  431. const __enablehud [ __tmp_old_sets ; if $editing seteditshow ; blankouthud 0 ]
  432. const cleanshot [ __disablehud; sleep 200 screenshot; sleep 500 __enablehud ]
  433. // highestcn - Returns the highest valid client number available.
  434. const highestcn [
  435. hcn = -1
  436. if $connected [ nl = (+ $MAX_CLIENTS 1) ] [ if (curmodeattr bot) [ nl = 100 ] [ nl = 1 ] ]
  437. loop h $nl [
  438. if (isclient $h) [ hcn = $h ]
  439. ]
  440. result $hcn
  441. ]
  442. ingall = 0
  443. const ignoreall [ if $connected [ ingall = 1; loop ia (+ (highestcn) 1) [ ignore $ia ]; echo "\f1NOTE: \f5all clients currently on the server were ignored" ] ]
  444. const unignoreall [ if $connected [ ingall = 0; clearignored -1; echo "\f1NOTE: \f5all clients currently on the server were unignored" ] ]
  445. const ignoreteam [
  446. if (curmodeattr team) [
  447. _arg1 = (toupper $arg1)
  448. if (|| (strcmp $_arg1 CLA) (strcmp $_arg1 RVSF)) [
  449. loop itl (+ (highestcn) 1) [
  450. if (isclient $itl) [
  451. if (= (player $itl team) (at [0 1] (strcmp $_arg1 RVSF))) [ ignore $itl ]
  452. ]
  453. ]
  454. ] [
  455. if (checkrange $_arg1 0 1) [
  456. loop itl (+ (highestcn) 1) [
  457. if (isclient $itl) [
  458. if (= (player $itl team) $_arg1) [ ignore $itl ]
  459. ]
  460. ]
  461. ]
  462. ]
  463. ] ignoreall
  464. ]
  465. const ignoreenemy [ if (! (player1 spect)) [ignoreteam (at [0 1] (! (player1 team)))] ]
  466. // Simple claim-admin script for one single-server.
  467. // Fill in the 3 aliases below, and uncomment the below line to activate.
  468. // bind F3 "customclaimadminscript"
  469. _CAS_serverip = "IP ADDRESS"
  470. _CAS_serverpass = "PASSWORD"
  471. _CAS_servername = "SERVER NAME"
  472. const customclaimadminscript [
  473. if (strcmp (curserver 1) $_CAS_serverip) [
  474. if (! (player1 role)) [ setadmin 1 $_CAS_serverpass ] [ setadmin 0 ]
  475. ] [ echo "\f3Error: \f5you're not connected to" $_CAS_servername servers ]
  476. ]
  477. const claimadmin [ setadmin 1 $arg1 ]
  478. const dropadmin [ setadmin 0 ]
  479. // manage per-map gamma values
  480. // setgamma <x> sets a persistent gamma value for a map
  481. const setgamma [
  482. push nn (concatword "__dyngamma_" (curmap))
  483. if (checkrange $arg1 30 300) [
  484. $nn = $arg1
  485. echo "gamma preset for map" (curmap) "set to" $arg1
  486. ] [
  487. if (&& [checkalias $nn] [strlen $$nn]) [
  488. $nn = ""
  489. echo "gamma preset for map" (curmap) "deleted"
  490. ]
  491. ]
  492. pop nn
  493. ]
  494. const applygamma [
  495. push nn (concatword "__dyngamma_" (curmap))
  496. if (&& [checkalias $nn] [strlen $$nn]) [ gamma $$nn ; echo "gamma set to" $$nn ] [ gamma $defaultgamma ]
  497. pop nn
  498. ]
  499. addOnLoadAlways applygamma
  500. alias togglepause [pause (! (curpausemode) ) ]
  501. // get optional scripts on demand
  502. tempalias load_autosave [ run opt/autosave ; alias load_autosave [] ]
  503. tempalias load_compatibility [ run opt/compatibility ; alias load_compatibility [] ]
  504. tempalias load_survival [ load_compatibility ; run opt/survival ; alias load_survival [] ]
  505. tempalias load_parsestring [ run opt/parsestring ; alias load_parsestring [] ]
  506. tempalias load_faq [ run opt/faq ; alias load_faq [] ]
  507. tempalias load_convmap [ saycommand "/run opt/convmap " ]
  508. tempalias load_mapeditscripts [ run opt/mapeditscripts ]