Calculate some key values to determine map geometry viability.
mapareacheck <what>
Returns different sets of statistics, depending on the keyword "what":
vdelta
Returns table of numbers of cubes within a certain range of vdelta
differences (steepness)". First entry is "0..2 cubes steep", next is
"2..4" and so on.
steepest
Returns the coordinates of the steepest heightfield cube.
total
Returns the number of non-solid cubes on the map.
pprest
Returns the number of cubes _not_ visible from one of the probe
positions.
pp (default)
Returns a table of all (currently 64) probe points of the map. Each
probe point is listed with:
- x-coordinate
- y-coordinate
- floor height
- area visible
- volume of visible area
- average height in visible area
DOCREF mapareacheck
520 lines
24 KiB
INI
520 lines
24 KiB
INI
// CubeScript placed in this file is automatically executed on each startup.
|
|
|
|
persistidents 0
|
|
|
|
const MODES [tdm coop dm surv tsurv ctf pf btdm bdm lss osok tosok bosok htf tktf ktf tpf tlss bpf blss btsurv btosok]
|
|
const MODEALIASES [map lms vip sendmap]
|
|
|
|
// "editent" command:
|
|
// This command collects all the attributes of the nearest entity, and then
|
|
// prompts that into a handy command that allows you to edit that entities
|
|
// attributes easily.
|
|
// Note: The editent command can NOT define rotation/yaw inside the command!
|
|
// However, the current yaw of the player will define the rotation/yaw when
|
|
// using the command!
|
|
const editent [
|
|
if $editing [
|
|
if (strcmp (getenttype) mapmodel) [ saycommand "/entset" (getenttype) (getentattr 1) (getentattr 2) (getentattr 3) ] [
|
|
if (> (findlist [light sound clip plclip] (getenttype)) -1) [
|
|
saycommand "/entset" (getenttype) (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3)
|
|
] [
|
|
saycommand "/entset" (getenttype) (getentattr ((> (findlist [playerstart ctf-flag] (getenttype)) -1)))
|
|
]
|
|
]
|
|
]
|
|
]
|
|
|
|
// "convertclips" command:
|
|
// This command automatically changes the a "clip" to a "plclip" entity or vice-versa.
|
|
const convertclips [
|
|
if $editing [
|
|
if (strcmp (getenttype) clip) [ entset plclip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3) ] [
|
|
if (strcmp (getenttype) plclip) [ entset clip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3) ] [
|
|
echo No changes made. This entity isn't a clip or a plclip.; echo Try using the /closestenttype command to find a specific entity.
|
|
]
|
|
]
|
|
]
|
|
]
|
|
|
|
// increase legroom for mapmodels by decreasing the z-offset of a map config mapmodel slot
|
|
// and simultaneously increasing the z-offset of all affected map model entities
|
|
// (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))
|
|
// this will not change anything visible in the map - but allow a mapmodel to be lowered further than before
|
|
// the only argument is the slot number - for more leg room, repeat the script
|
|
const mapmodelzoff [
|
|
if (strlen (editmapmodelslot $arg1)) [ // invalid slot returns empty string
|
|
looplist (editmapmodelslot $arg1) [rad h zoff snap path] [editmapmodelslot $arg1 "" "" (- $zoff 1) ; echo $path in slot # $arg1 : new z-offset (- $zoff 1)]
|
|
looplist (mapmodelslotusage $arg1) ii [editentity $ii "" "" "" "" "" (+ 1 (at (editentity $ii) 6)) ; echo adjusted entity # $ii]
|
|
]
|
|
]
|
|
|
|
// "gibsgore" command:
|
|
// This command controls gib Speed/Number/TTL all in one variable.
|
|
const gibsgore [
|
|
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] [
|
|
gib $a1 ; gibspeed $a2 ; gibnum $a3 ; gibttl $a4 ; __gibsgore = $arg1
|
|
]
|
|
]
|
|
|
|
// "fullscreentoggle" command:
|
|
// This command allows swapping of fullscreen mode to be bound to a key.
|
|
const fullscreentoggle [ fullscreen (! $fullscreen) ]
|
|
const editsvar [ inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " (at $q 0) ; pop q") (concatword "edit " $arg1 :) ]
|
|
const editmapmsg [ editsvar mapmsg ]
|
|
const return [ result $arg1 ]
|
|
const run [ exec (concatword config/ $arg1 .cfg) ]
|
|
const closecurmenu [ closemenu (curmenu) ]
|
|
const resetcurmenu [ delmenu (curmenu) ; newmenu (curmenu) ]
|
|
|
|
// Auto-completions
|
|
const mapcomplete [complete $arg1 "packages/maps/official packages/maps" cgz]
|
|
loop i (listlen (concat $MODES $MODEALIASES)) [ mapcomplete (at (concat $MODES $MODEALIASES) $i) ]
|
|
complete demo demos dmo
|
|
looplist [
|
|
listoptions ""
|
|
newent ents
|
|
addentity ents
|
|
clearents ents
|
|
closestenttype ents
|
|
enumentities ents
|
|
weapon weapons
|
|
burstshots weapons
|
|
team teamnames
|
|
addpunct punctuations // the command addpunct actually wants the punctuation name as second argument, but we can't do that. sry.
|
|
loadcrosshair crosshairnames
|
|
edittexturestack texturestacktypes
|
|
] [ cmd options ] [ listcomplete $cmd (listoptions $options)
|
|
]
|
|
listcomplete getvarrange "min max default"
|
|
listcomplete mapareacheck "vdelta steepest total pprest pp"
|
|
looplist [ addzipmod zipmodremove zipmodgetdesc ] cmd [complete $cmd "mods" zip]
|
|
|
|
// set up list of skymaps
|
|
push skies ""
|
|
looplist (gettexturelist skymaps/ "" _ft.jpg) [c1 c2 c3 c4] [skies = (concat $skies (escape (concatword $c3 "/" $c4)))]
|
|
listcomplete loadsky (pop skies)
|
|
|
|
|
|
// Game mode descriptions...
|
|
gamemodedesc 0 [Team Deathmatch: Shred the enemy team to pieces!]
|
|
gamemodedesc 1 [Co-operative edit: Edit maps with others online!]
|
|
gamemodedesc 2 [Deathmatch: Destroy anything that moves! Everyone for themselves!]
|
|
gamemodedesc 3 [Survivor: Conserve your precious life, destroy the enemy's. Once all your enemies are dead, the round restarts.]
|
|
gamemodedesc 4 [Team Survivor: Conserve your precious life, destroy the enemy team. Once all your enemies are dead, the round restarts.]
|
|
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.]
|
|
gamemodedesc 6 [Pistol Frenzy: Can you make your enemy eat lead with the most simplest of weapons?]
|
|
gamemodedesc 7 [Bot Team Deathmatch: Find the enemy A.I. and destroy them!]
|
|
gamemodedesc 8 [Bot Deathmatch: It's every man and A.I. for themselves! Dismantle those bots!]
|
|
gamemodedesc 9 [Last Swiss Standing: Knive and bomb the enemy!]
|
|
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.]
|
|
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.]
|
|
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.]
|
|
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.]
|
|
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.]
|
|
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!]
|
|
gamemodedesc 16 [Team Pistol Frenzy: Can you make your enemy team eat lead with the most simplest of weapons?]
|
|
gamemodedesc 17 [Team Last Swiss Standing: Knive and bomb the enemy team!]
|
|
gamemodedesc 18 [Bot Pistol Frenzy: Can you make the enemy A.I. eat lead with the most simplest of weapons?]
|
|
gamemodedesc 19 [Bot Last Swiss Standing: Knive and bomb the enemy A.I.!]
|
|
gamemodedesc 20 [Bot Team Survivor: Conserve your precious life, destroy the enemy A.I. team! Once all your enemies are dead, the round restarts.]
|
|
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.]
|
|
|
|
const resetbinds [ run resetbinds; echo (c 3)All binds have been reset to default values! ]
|
|
|
|
const changeteam [ if (< (player1 team) 4) [ team (at [RVSF CLA RVSF-SPECT CLA-SPECT] (player1 team)) ] ]
|
|
|
|
const NUM_WEAPONS (listlen (listoptions weapons))
|
|
const NUM_MODES (listlen $MODES)
|
|
const MAX_CLIENTS 16
|
|
const MAX_BOT_MATCH_LENGTH 60
|
|
const MAX_ARGS 24
|
|
const ENT_NUM_ATTRS 4
|
|
const getgunindex [ findlist (listoptions weapons) $arg1 ]
|
|
|
|
loop r $NUM_MODES [ const (at $MODES $r) (format [votemap %1 %2 %3] $r "$arg1" "$arg2") ]
|
|
|
|
const modenum [ result (findlist $MODES $arg1) ]
|
|
|
|
// Mode/map-setting aliases.
|
|
const votemap [ mode $arg1; map $arg2 $arg3 ]
|
|
|
|
const lms [ surv $arg1 $arg2 ]
|
|
const vip [ htf $arg1 $arg2 ]
|
|
|
|
// Helper aliases for (c) - easy color insertion. (e.g. echo (red)Hello (blue)world! (white)My fov today is: (orange) $fov)
|
|
loop k 10 [ const (at [green blue yellow red gray white dbrown dred purple orange] $k) (format [if (= $arg1 -1) [ result %1 ] [ result %2 ]] $k (addpunct (concat c $k) 2)) ]
|
|
// echo (blue -1) - returns 1
|
|
// echo (purple -1) - returns 8
|
|
|
|
const add2alias [
|
|
if (strcmp [] (getalias $arg1)) [ $arg1 = $arg2 ] [
|
|
$arg1 = (concat (concatword (getalias $arg1) [;]) $arg2)
|
|
]
|
|
]
|
|
const addOnLoadOnce [ add2alias mapstartonce $arg1 ]
|
|
const addOnLoadAlways [ add2alias mapstartalways $arg1 ]
|
|
const addOnQuit [ add2alias onQuit $arg1 ]
|
|
const check2init [ if (! (checkalias $arg1)) [ tempalias $arg1 $arg2 ] ] // only overwrites an alias if it doesn't exist
|
|
const check2initlist [ loop cll (listlen $arg1) [ check2init (at $arg1 $cll) $arg2 ] ] // check2inits multiple aliases
|
|
const forceinit [ loop fil (listlen $arg1) [ (at $arg1 $fil) = $arg2 ] ] // forcibly overwrites multiple aliases
|
|
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
|
|
const aliasinit [ loop ail (listlen $arg1) [ checkinit (at $arg1 $ail) $arg2 ] ] // checkinits multiple aliases
|
|
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")
|
|
const add2bind [ if (! (strstr (keybind $arg1) $arg2)) [ bind $arg1 (format [%1; %2] (keybind $arg1) $arg2) ] ] // works exactly like add2alias except for used with keybinds
|
|
|
|
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
|
|
|
|
// Weapon switching/action utilities.
|
|
const hasprimary [ result (= (curweapon) (currentprimary)) ]
|
|
const primary [ weapon (currentprimary) ]
|
|
const ptoggle [ if (hasprimary) $arg1 primary ] // Toggle between primary/specified weapon
|
|
const secondary [ weapon PISTOL ]
|
|
const sndtoggle [ ptoggle secondary ]
|
|
const melee [ weapon KNIFE ]
|
|
const knftoggle [ ptoggle melee ]
|
|
const grenades [ weapon GRENADE ]
|
|
const gndtoggle [ ptoggle grenades ]
|
|
|
|
const altaction [ (concatword altaction_ (curweapon)) ]
|
|
|
|
const checkmag [ result (|| (magcontent $arg1) (magreserve $arg1)) ]
|
|
const checkrange [ result (&& (>=f $arg1 $arg2) (<=f $arg1 $arg3)) ]
|
|
|
|
loop i $NUM_WEAPONS [ (concatword altaction_ $i) = quicknadethrow ] // Quick nade throw is default
|
|
// Use format to define altaction_N aliases from now on, makes for less edits in the future if weapon IDs change. - Bukz
|
|
// (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.
|
|
(format altaction_%1 (getgunindex sniper)) = [ setscope 1; onrelease [ setscope 0 ] ] // Sniper
|
|
// (format altaction_%1 (getgunindex cpistol)) = [ setburst 1; onrelease [ setburst 0 ] ] // Combat pistol // TODO uncomment when this becomes a priority/testing, for now lets save an unused alias - Bukz
|
|
// (format altaction_%1 (getgunindex grenades)) = attack // Grenade // with this comment, you throw the nade and the nade is unselected : Brahma
|
|
|
|
oldsens = $sensitivity
|
|
|
|
const zoom [
|
|
if (= $arg1 1) [
|
|
if (! (=f $sensitivity $scopesens)) [
|
|
oldsens = $sensitivity
|
|
// avoid error if using 0.001 as sensitivity
|
|
newsens = $scopesens
|
|
if (> (*f 1 1000) $newsens) [ if (< 1000 $newsens) [ sensitivity $scopesens ] ]
|
|
setscope 1
|
|
]
|
|
] [ sensitivity $oldsens; setscope 0 ]
|
|
]
|
|
|
|
delta_game_0 = [ if (= $arg1 1) [ shiftweapon 1 ] [ shiftweapon -1 ] ] // Cycle through weapons
|
|
delta_game_1 = [ if (checkrange (+ $gamma $arg1) 30 300) [ gamma (+ $gamma $arg1) ] ] // Tweak gamma
|
|
delta_game_2 = [ if (checkrange (+ $fov $arg1) 75 120) [ fov (+ $fov $arg1) ] ] // Tweak fov
|
|
delta_spect_0 = [ changefollowplayer $arg1 ]
|
|
|
|
// Map editing using the mousewheel...
|
|
tempalias modifier 0
|
|
tempalias editmeta2down 0
|
|
const domodifier [ modifier = $arg1; onrelease [ modifier = 0 ] ]
|
|
|
|
const universaldelta [
|
|
push s
|
|
if $editing [ s = edit ] [
|
|
if (player1 alive) [ s = game ] [ s = spect ]
|
|
]
|
|
(concatword delta _ (pop s) _ $modifier) (* $arg1 (at "1 3" $editmetakeydown)) (* $arg1 (at "1 10" $editmetakeydown))
|
|
]
|
|
// To utilize the below, you will need to bind "domodifier X"
|
|
// (replace X with the number of the delta_edit) to a key. To
|
|
// use them, simply hold the key that the "domodifier" is bound
|
|
// to and then scroll backwards/forwards while looking at the
|
|
// floor/ceiling.
|
|
delta_edit_0 = [ editheight $flrceil $arg1 ] // Move cubes...
|
|
delta_edit_1 = [ if $flrceil [ vdelta $arg1 ] [ vdelta (- 0 $arg1) ] ] // Change heightfielding...
|
|
delta_edit_2 = [ edittex $flrceil $arg1 ] // Change floor/ceiling textures...
|
|
delta_edit_3 = [ edittex (+ $flrceil 1) $arg1 ] // Change wall/upper-wall textures...
|
|
delta_edit_4 = [ equalize $flrceil ] // Equalize floor/ceiling...
|
|
delta_edit_6 = [ entproperty $editaxis $arg1 ] // Move map entity...
|
|
delta_edit_10 = [ if (checkrange (+f $flyspeed (divf $arg1 4)) 1 5) [ flyspeed (+f $flyspeed (divf $arg1 4)); echo $flyspeed ] ] // Tweak flyspeed
|
|
delta_edit_11 = [ if (> $arg1 0) [ expandselection 1 ] [ shrinkselection 1 ] ] // Expand/shrink the current selection
|
|
delta_edit_attr1 = [ entproperty 0 $arg2 $editmeta2down ] // Changes the first value on entities...
|
|
delta_edit_attr2 = [ entproperty 1 $arg2 $editmeta2down ] // Changes the second value on entities...
|
|
delta_edit_attr3 = [ entproperty 2 $arg2 $editmeta2down ] // Changes the third value on entities...
|
|
delta_edit_attr4 = [ entproperty 3 $arg2 $editmeta2down ] // Changes the fourth value on entities...
|
|
delta_edit_attr5 = [ entproperty 4 $arg2 $editmeta2down ] // Changes the fifth value on entities...
|
|
delta_edit_attr6 = [ entproperty 5 $arg2 $editmeta2down ] // Changes the sixth value on entities...
|
|
delta_edit_attr7 = [ entproperty 6 $arg2 $editmeta2down ] // Changes the seventh value on entities...
|
|
|
|
// Scroll console (in all modes)
|
|
delta_game_conscroll = [ __scrolled = $conopen ; conskip (* 4 $arg1) ]
|
|
delta_spect_conscroll = $delta_game_conscroll
|
|
delta_edit_conscroll = $delta_game_conscroll
|
|
|
|
// HUD toggles
|
|
const toggleshowmap [ showmap 1; onrelease [ showmap 0 ] ]
|
|
|
|
// convenient connecting from the serverbrowser
|
|
// sbconnect arg list:
|
|
// arg1 IP, arg2 port,
|
|
// arg3 1: server full
|
|
// arg4 1: password protected
|
|
// arg5 1: private mode, 2: match mode
|
|
// arg6 1: banned, 2: blacklisted 3: both
|
|
// arg7 "server description"
|
|
// TODO: interpret a#3,4,5,6 [ft:any1:2010apr04]
|
|
|
|
const sbconnect [
|
|
tempalias sbdns $arg1; tempalias sbport $arg2; tempalias sbdesc $arg7; tempalias sbpwd []; tempalias sbmsg []
|
|
if (>= $arg5 1) [
|
|
sbmsg = [This server is set to private.]; showmenu [password required]
|
|
] [
|
|
if (>= $arg6 1) [
|
|
sbmsg = [You are banned from this server.]; showmenu [password required]
|
|
] [
|
|
if (= $arg4 1) [
|
|
sbmsg = [This server is password-protected.]; showmenu [password required]
|
|
] [
|
|
if (> (strlen $arg7) 0) [ echo connecting to $arg7 ]
|
|
connect $arg1 $arg2
|
|
]
|
|
]
|
|
]
|
|
]
|
|
|
|
// answer last PM
|
|
const quickanswer [ if (>= $lastpm 0) [ saycommand (concat /pm $lastpm []) ] [ saycommand (concat /pm []) ] ]
|
|
|
|
// For those players who use IRC too much...
|
|
const join [ connect $arg1 $arg2 $arg3 ]
|
|
const reconnect [ if $numargs [ tempalias svpass $arg1 ] [ tempalias svpass [] ]; if $connected [ tempalias svdata (curserver); afterdisconnect [ connect (at $svdata 0) (at $svdata 1) $svpass ] ] ]
|
|
|
|
const dlmap [ getmap $arg1 [ sleep 2500 (concat map $arg1) ] ]
|
|
const rndmap [ result (at $defaultmaps (rnd (listlen $defaultmaps))) ]
|
|
const rrnd [ + (rnd (- $arg2 $arg1)) $arg1 ]
|
|
|
|
const ++ [ if (checkalias $arg1) [ += $arg1 1 ] ]
|
|
const -- [ if (checkalias $arg1) [ -= $arg1 1 ] ]
|
|
const ++f [ if (checkalias $arg1) [ +=f $arg1 1 ] ]
|
|
const --f [ if (checkalias $arg1) [ -=f $arg1 1 ] ]
|
|
const listaverage [ if (listlen $arg1) [ tempalias tmp_sum 0; loop gsl (listlen $arg1) [ +=f tmp_sum (at $arg1 $gsl) ]; result (divf $tmp_sum (listlen $arg1)) ] ]
|
|
|
|
forceinit [cp_entbuf cp_entstr] NULL
|
|
const get_ent_attrs [ cp_entbuf = (getenttype); loop gea $ENT_NUM_ATTRS [ add2list cp_entbuf (getentattr $gea) ] ]
|
|
|
|
const copyent [
|
|
if $editing [
|
|
get_ent_attrs
|
|
cp_entstr = (concatword (orange) "(" (at $cp_entbuf 0) [ ] (at $cp_entbuf 1) [ ] (at $cp_entbuf 2) [ ] (at $cp_entbuf 3) [ ] (at $cp_entbuf 4) ")" (white)) // Output (a string): (enttype param1 param2 param3 param4)
|
|
echo (blue)Note: (white)The current closest entity: $cp_entstr - has been copied.
|
|
]
|
|
]
|
|
|
|
const pasteent [
|
|
if $editing [
|
|
if (strcmp (at $cp_entbuf 0) mapmodel) [
|
|
newent (at $cp_entbuf 0) (at $cp_entbuf 2) (at $cp_entbuf 3) (at $cp_entbuf 4)
|
|
] [
|
|
newent (at $cp_entbuf 0) (at $cp_entbuf 1) (at $cp_entbuf 2) (at $cp_entbuf 3) (at $cp_entbuf 4)
|
|
]
|
|
echo (blue)Note: (white)The previously copied entity: $cp_entstr - has been pasted.
|
|
]
|
|
]
|
|
|
|
// genhex - Randomly generates a valid hexadecimal color value (e.g. 0x2FCAF1) - useful for finding fogcolours.
|
|
const genhex [
|
|
push genhex [at [0 1 2 3 4 5 6 7 8 9 A B C D E F] (rnd 16)]
|
|
push tmp_hex (concatword 0x (genhex) (genhex) (genhex) (genhex) (genhex) (genhex))
|
|
echo (red)Trying hexadecimal color: (white) $tmp_hex
|
|
result (pop tmp_hex genhex)
|
|
]
|
|
|
|
// genwc - Randomly generates a valid watercolour value (e.g. 2 17 29) - useful for finding watercolours.
|
|
const genwc [
|
|
if $editing [
|
|
loop i 3 [push (concatword wc $i) (rrnd 1 256)]
|
|
echo (red)Trying water color: (white) $wc0 $wc1 $wc2
|
|
watercolour $wc0 $wc1 $wc2
|
|
pop wc0 wc1 wc2
|
|
]
|
|
]
|
|
|
|
// gencl - Randomly generates a valid coloured light.
|
|
const gencl [
|
|
if $editing [
|
|
push tmp_numargs $numargs; push tmp_cl []
|
|
loop gcl 3 [ add2list tmp_cl (rrnd 1 256) ]
|
|
if $tmp_numargs [
|
|
if (|| (!= (selx) 0) (!= (sely) 0)) [
|
|
echo (red)Trying colored light: (white) $arg1 (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
|
|
newent light $arg1 (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
|
|
] [ echo (red)Error: (white)If an argument "(radius)" is given for (concatword (blue) gencl (red) ,) you must select a cube first. ]
|
|
] [
|
|
if (strcmp (getenttype) light) [
|
|
echo (red)Trying colored light: (white) (getentattr 0) (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
|
|
entset light (getentattr 0) (at $tmp_cl 0) (at $tmp_cl 1) (at $tmp_cl 2)
|
|
] [ echo (red)Error: (white)The current closest entity: (orange) (getenttype) (white)is not a light. ]
|
|
]
|
|
pop tmp_numargs tmp_cl
|
|
] [ echo (red)Error: (white)You must be in edit mode for (blue)gencl (white)to function. ]
|
|
]
|
|
|
|
// /expandselection 1 // makes the current selection bigger by 1 cube on all sides
|
|
const expandselection [
|
|
if $numargs [
|
|
et1 = $arg1
|
|
if (> $et1 0) [
|
|
ep1 = (selx)
|
|
ep2 = (sely)
|
|
eps1 = (selxs)
|
|
eps2 = (selys)
|
|
select (- $ep1 $et1) (- $ep2 $et1) (+ $eps1 (* $et1 2)) (+ $eps2 (* $et1 2))
|
|
result 1
|
|
] [ result 0 ]
|
|
] [ result 0 ]
|
|
]
|
|
|
|
// /shrinkselection 1 // makes the current selection smaller by 1 cube on all sides
|
|
const shrinkselection [
|
|
if $numargs [
|
|
st1 = $arg1
|
|
if (> $st1 0) [
|
|
sp1 = (selx)
|
|
sp2 = (sely)
|
|
sps1 = (selxs)
|
|
sps2 = (selys)
|
|
sps1 = (- $sps1 (* $st1 2))
|
|
sps2 = (- $sps2 (* $st1 2))
|
|
if (&& (> $sps1 0) (> $sps2 0)) [
|
|
select (+ $sp1 $st1) (+ $sp2 $st1) $sps1 $sps2
|
|
result 1
|
|
] [ result 0 ]
|
|
] [ result 0 ]
|
|
] [ result 0 ]
|
|
]
|
|
|
|
// megabind - Binds a key to many different actions depending on the current game state.
|
|
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) ] ]
|
|
|
|
// storesets - Generates an alias (list) of the current values for the given CVARs.
|
|
const storesets [
|
|
if (> $numargs 1) [
|
|
tempalias badargs 0; $arg2 = []
|
|
loop ssl (listlen $arg1) [
|
|
if (isIdent (at $arg1 $ssl)) [
|
|
add2list $arg2 (getalias (at $arg1 $ssl))
|
|
] [ badargs = 1; break ]
|
|
]
|
|
if $badargs [ delalias $arg2; echo (red)Error: (white)Bad "argument(s)" given! ]
|
|
]
|
|
]
|
|
|
|
// makeshift "?" operator for cubescript
|
|
// ex: /? (> $maxroll 0) [voicecom negative D:] [voicecom yes :D]
|
|
// /echo I am (? (>= (player1 health) 50) [result healthy] [result weak]) atm
|
|
? = [
|
|
if (> $numargs 1) [
|
|
if (> $numargs 2) [
|
|
if $arg1 $arg2 $arg3
|
|
] [
|
|
if $arg1 $arg2
|
|
]
|
|
]
|
|
]
|
|
|
|
// switch - Takes an integer argument to determine which block of code to execute.
|
|
// NOTE: This command can only handle up to 23 "cases" (24 arguments).
|
|
switch = [
|
|
if (&& (<= $numargs $MAX_ARGS) (checkrange $arg1 0 (- $MAX_ARGS 2))) [
|
|
execute (getalias (format arg%1 (+ $arg1 2)))
|
|
]
|
|
]
|
|
|
|
// cleanshot - Take a "clean" screenshot with no HUD items.
|
|
const __disablehud [ tempalias __tmp_old_sets (concat hudgun $hudgun ";" showclips $showclips) ; hudgun 0 ; showclips 0 ; if $editing [ seteditshow 0 ]; blankouthud 1000 ]
|
|
const __enablehud [ __tmp_old_sets ; if $editing seteditshow ; blankouthud 0 ]
|
|
const cleanshot [ __disablehud; sleep 200 screenshot; sleep 500 __enablehud ]
|
|
|
|
// highestcn - Returns the highest valid client number available.
|
|
const highestcn [
|
|
hcn = -1
|
|
if $connected [ nl = (+ $MAX_CLIENTS 1) ] [ if (curmodeattr bot) [ nl = 100 ] [ nl = 1 ] ]
|
|
loop h $nl [
|
|
if (isclient $h) [ hcn = $h ]
|
|
]
|
|
result $hcn
|
|
]
|
|
|
|
// convertcase - Zap lists of strings to lower/uppercase.
|
|
const convertcase [
|
|
if (> $numargs 1) [
|
|
tempalias tmpCCO []
|
|
loop ccl $numargs [ if (> $ccl 0) [ tmpCCO = (concatword $tmpCCO [ ] (getalias (format arg%1 (+ $ccl 2)))) ] [ tmpCCO = (concatword $tmpCCO $arg2) ] ]
|
|
if (!= $arg1 0) [ result (toupper $tmpCCO) ] [ result (tolower $tmpCCO) ]
|
|
]
|
|
]
|
|
|
|
ingall = 0
|
|
const ignoreall [ if $connected [ ingall = 1; loop ia (+ (highestcn) 1) [ ignore $ia ]; echo (blue)NOTE: (white)all clients currently on the server were ignored ] ]
|
|
const unignoreall [ if $connected [ ingall = 0; clearignored -1; echo (blue)NOTE: (white)all clients currently on the server were unignored ] ]
|
|
const ignoreteam [
|
|
if (curmodeattr team) [
|
|
_arg1 = (toupper $arg1)
|
|
if (|| (strcmp $_arg1 CLA) (strcmp $_arg1 RVSF)) [
|
|
loop itl (+ (highestcn) 1) [
|
|
if (isclient $itl) [
|
|
if (= (player $itl team) (at [0 1] (strcmp $_arg1 RVSF))) [ ignore $itl ]
|
|
]
|
|
]
|
|
] [
|
|
if (checkrange $_arg1 0 1) [
|
|
loop itl (+ (highestcn) 1) [
|
|
if (isclient $itl) [
|
|
if (= (player $itl team) $_arg1) [ ignore $itl ]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
] ignoreall
|
|
]
|
|
const ignoreenemy [ if (! (player1 spect)) [ignoreteam (at [0 1] (! (player1 team)))] ]
|
|
|
|
// Simple claim-admin script for one single-server.
|
|
// Fill in the 3 aliases below, and uncomment the below line to activate.
|
|
// bind F3 "customclaimadminscript"
|
|
_CAS_serverip = "IP ADDRESS"
|
|
_CAS_serverpass = "PASSWORD"
|
|
_CAS_servername = "SERVER NAME"
|
|
const customclaimadminscript [
|
|
if (strcmp (curserver 1) $_CAS_serverip) [
|
|
if (! (player1 role)) [ setadmin 1 $_CAS_serverpass ] [ setadmin 0 ]
|
|
] [ echo (red)Error: (white)you're not connected to $_CAS_servername servers ]
|
|
]
|
|
|
|
// manage per-map gamma values
|
|
|
|
// setgamma <x> sets a persistent gamma value for a map
|
|
const setgamma [
|
|
push nn (concatword "__dyngamma_" (curmap))
|
|
if (checkrange $arg1 30 300) [
|
|
$nn = $arg1
|
|
echo "gamma preset for map" (curmap) "set to" $arg1
|
|
] [
|
|
if (&& [checkalias $nn] [strlen $$nn]) [
|
|
$nn = ""
|
|
echo "gamma preset for map" (curmap) "deleted"
|
|
]
|
|
]
|
|
pop nn
|
|
]
|
|
|
|
const applygamma [
|
|
push nn (concatword "__dyngamma_" (curmap))
|
|
if (&& [checkalias $nn] [strlen $$nn]) [ gamma $$nn ; echo "gamma set to" $$nn ] [ gamma $defaultgamma ]
|
|
pop nn
|
|
]
|
|
|
|
addOnLoadAlways applygamma
|
|
|
|
// get optional scripts on demand
|
|
tempalias load_autosave [ run opt/autosave ; alias load_autosave [] ]
|
|
tempalias load_compatibility [ run opt/compatibility ; alias load_compatibility [] ]
|
|
tempalias load_survival [ load_compatibility ; run opt/survival ; alias load_survival [] ]
|
|
tempalias load_parsestring [ run opt/parsestring ; alias load_parsestring [] ]
|
|
tempalias load_faq [ run opt/faq ; alias load_faq [] ]
|
|
|
|
persistidents 1
|