test commit/quotes to brackets where possible
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7145 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+49
-42
@@ -1,7 +1,7 @@
|
||||
// CubeScript placed in this file is automatically executed on each startup.
|
||||
|
||||
const MODES "tdm coop dm surv ts ctf pf btdm bdm lss osok tosok bosok htf tktf ktf tpf tlss bpf blss bts btosok"
|
||||
const MODEALIASES "map lms vip sendmap"
|
||||
const MODES [tdm coop dm surv ts ctf pf btdm bdm lss osok tosok bosok htf tktf ktf tpf tlss bpf blss bts btosok]
|
||||
const MODEALIASES [map lms vip sendmap]
|
||||
|
||||
// "editent" command:
|
||||
// This command collects all the attributes of the nearest entity, and then
|
||||
@@ -13,11 +13,11 @@ const MODEALIASES "map lms vip sendmap"
|
||||
const return [ result $arg1 ]
|
||||
|
||||
const editent [
|
||||
if (strcmp (getenttype) "mapmodel") [ saycommand "/entset" (getenttype) (getentattr 1) (getentattr 2) (getentattr 3) ] [
|
||||
if (> (findlist "light sound clip plclip" (getenttype)) -1) [
|
||||
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)))
|
||||
saycommand "/entset" (getenttype) (getentattr ((> (findlist [playerstart ctf-flag] (getenttype)) -1)))
|
||||
]
|
||||
]
|
||||
]
|
||||
@@ -25,8 +25,8 @@ const editent [
|
||||
// "convertclips" command:
|
||||
// This command automatically changes the a "clip" to a "plclip" entity or vice-versa.
|
||||
const convertclips [
|
||||
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) ] [
|
||||
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.
|
||||
]
|
||||
]
|
||||
@@ -72,12 +72,12 @@ const run [ exec (concatword config/ $arg1 .cfg) ]
|
||||
// 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
|
||||
const entcomplete [ listcomplete $arg1 "light playerstart pistol ammobox grenades health armour akimbo mapmodel ladder ctf-flag sound clip plclip helmet" ]
|
||||
complete demo demos dmo
|
||||
const entcomplete [ listcomplete $arg1 [light playerstart pistol ammobox grenades health armour akimbo mapmodel ladder ctf-flag sound clip plclip helmet] ]
|
||||
entcomplete newent; entcomplete clearents; entcomplete closestenttype
|
||||
|
||||
// TODO:FIXME change all occurrence of SPECT(ator) to GHOST
|
||||
listcomplete team "CLA RVSF CLA-SPECT RVSF-SPECT SPECTATOR"
|
||||
listcomplete team [CLA RVSF CLA-SPECT RVSF-SPECT SPECTATOR]
|
||||
|
||||
// Game mode descriptions...
|
||||
gamemodedesc 0 [Team Deathmatch: Shred the enemy team to pieces!]
|
||||
@@ -103,12 +103,13 @@ gamemodedesc 19 [Bot Last Swiss Standing: Knive and bomb the enemy A.I!]
|
||||
|
||||
const resetbinds [ run resetbinds; echo (c 3)All binds have been reset to default values! ]
|
||||
|
||||
const changeteam [ if (< (curteam) 4) [ team (at "RVSF CLA RVSF-SPECT CLA-SPECT" (curteam)) ] ]
|
||||
const changeteam [ if (< (curteam) 4) [ team (at [RVSF CLA RVSF-SPECT CLA-SPECT] (curteam)) ] ]
|
||||
|
||||
const WEAPONS "KNIFE PISTOL CARBINE SHOTGUN SMG SNIPER AR CPISTOL GRENADES AKIMBO"
|
||||
const WEAPONS [KNIFE PISTOL CARBINE SHOTGUN SMG SNIPER AR CPISTOL GRENADES AKIMBO]
|
||||
const NUM_WEAPONS (listlen $WEAPONS)
|
||||
const NUM_MODES (listlen $MODES)
|
||||
const PUNCTUATION "QUOTES BRACKETS PARENTHESIS _$_ QUOTE PERCENT"
|
||||
const MAX_CLIENTS 16
|
||||
const MAX_BOT_MATCH_LENGTH 60
|
||||
const MAX_ARGS 24
|
||||
const ENT_NUM_ATTRS 4
|
||||
@@ -119,9 +120,9 @@ loop g (listlen $PUNCTUATION) [ const (at $PUNCTUATION $g) $g ]
|
||||
|
||||
loop d $NUM_WEAPONS [ const (at $WEAPONS $d) $d ]
|
||||
|
||||
loop r $NUM_MODES [ const (at $MODES $r) (format "votemap %1 %2 %3" $r "$arg1" "$arg2") ]
|
||||
loop r $NUM_MODES [ const (at $MODES $r) (format [votemap %1 %2 %3] $r "$arg1" "$arg2") ]
|
||||
|
||||
const modenum [ f = -1; loop i $NUM_MODES [ if (strcmp (at $MODES $i) $arg1) [f = $i; break] ]; result $f]
|
||||
const modenum [ f = -1; loop i $NUM_MODES [ if (strcmp (at $MODES $i) $arg1) [ f = $i; break ] ]; result $f ]
|
||||
|
||||
// Mode/map-setting aliases.
|
||||
const votemap [ mode $arg1; map $arg2 $arg3 ]
|
||||
@@ -130,7 +131,7 @@ 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)) ]
|
||||
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
|
||||
|
||||
@@ -187,8 +188,8 @@ modifier = 0
|
||||
const domodifier [ modifier = $arg1; onrelease [ modifier = 0 ] ]
|
||||
|
||||
const universaldelta [
|
||||
if $editing [ s = "edit" ] [
|
||||
if (alive) [ s = "game" ] [ s = "spect" ]
|
||||
if $editing [ s = edit ] [
|
||||
if (alive) [ s = game ] [ s = spect ]
|
||||
]
|
||||
(concatword delta _ $s _ $modifier)
|
||||
]
|
||||
@@ -222,17 +223,17 @@ const toggleshowmap [ showmap 1; onrelease [ showmap 0 ] ]
|
||||
// arg7 "server description"
|
||||
// TODO: interpret a#3,4,5,6 [ft:any1:2010apr04]
|
||||
|
||||
sbdns = ""; sbport = ""; sbdesc = ""; sbmsg = ""; sbpwd = ""
|
||||
sbdns = []; sbport = []; sbdesc = []; sbmsg = []; sbpwd = []
|
||||
const sbconnect [
|
||||
sbdns = $arg1; sbport = $arg2; sbdesc = $arg7; sbpwd = ""; sbmsg = ""
|
||||
sbdns = $arg1; sbport = $arg2; sbdesc = $arg7; sbpwd = []; sbmsg = []
|
||||
if (>= $arg5 1) [
|
||||
sbmsg = "This server is set to private."; showmenu "password required"
|
||||
sbmsg = [This server is set to private.]; showmenu [password required]
|
||||
] [
|
||||
if (>= $arg6 1) [
|
||||
sbmsg = "You are banned from this server."; showmenu "password required"
|
||||
sbmsg = [You are banned from this server.]; showmenu [password required]
|
||||
] [
|
||||
if (= $arg4 1) [
|
||||
sbmsg = "This server is password-protected."; showmenu "password required"
|
||||
sbmsg = [This server is password-protected.]; showmenu [password required]
|
||||
] [
|
||||
echo connecting to $arg7; connect $arg1 $arg2;
|
||||
]
|
||||
@@ -241,7 +242,7 @@ const sbconnect [
|
||||
]
|
||||
|
||||
// answer last PM
|
||||
const quickanswer [ if (>= $lastpm 0) [ saycommand (concat "/pm" $lastpm ""); ] [ saycommand (concat "/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 ]
|
||||
@@ -258,26 +259,22 @@ const check2initlist [ loop cll (listlen $arg1) [ check2init (at $arg1 $cll) $a
|
||||
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 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 rndmap [ result (at $defaultmaps (rnd (listlen $defaultmaps))) ]
|
||||
|
||||
// rrnd - Returns a ranged random integer.
|
||||
const rrnd [ + (rnd (- $arg2 $arg1)) $arg1 ]
|
||||
|
||||
// listaverage - Returns the average of a list of numbers. (Supports ints & floats - e.g. echo (listaverage "2 5 5") // Output: 4.0)
|
||||
const listaverage [ if (listlen $arg1) [ tmp_sum = 0; loop gsl (listlen $arg1) [ +=f tmp_sum (at $arg1 $gsl) ]; result (divf $tmp_sum (listlen $arg1)) ] ]
|
||||
|
||||
// copyent & pasteent - Quickly copy/paste the current closest entity. Initialize the two aliases below as "NULL" for error catching.
|
||||
// If /config/saved.cfg is readable/writable, errors are only possible up until the very first use of /copyent.
|
||||
cp_entbuf = NULL; 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)
|
||||
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.
|
||||
]
|
||||
]
|
||||
@@ -295,9 +292,9 @@ const pasteent [
|
||||
|
||||
// genhex - Randomly generates a valid hexadecimal color value (e.g. 0x2FCAF1) - useful for finding fogcolours.
|
||||
const genhex [
|
||||
tmp_hex = "0x"
|
||||
tmp_hex = 0x
|
||||
loop ghl 6 [
|
||||
if (rnd 2) [ tmp_hex = (concatword $tmp_hex (rnd 10)) ] [ tmp_hex = (concatword $tmp_hex (at [ A B C D E F ] (rnd 6))) ]
|
||||
if (rnd 2) [ tmp_hex = (concatword $tmp_hex (rnd 10)) ] [ tmp_hex = (concatword $tmp_hex (at [A B C D E F] (rnd 6))) ]
|
||||
]
|
||||
echo (red)Trying hexadecimal color: (white) $tmp_hex
|
||||
result $tmp_hex
|
||||
@@ -306,7 +303,7 @@ const genhex [
|
||||
// genwc - Randomly generates a valid watercolour value (e.g. 2 17 29) - useful for finding watercolours.
|
||||
const genwc [
|
||||
if $editing [
|
||||
tmp_wc = ""
|
||||
tmp_wc = []
|
||||
loop gwl 3 [ add2list tmp_wc (rrnd 1 256) ]
|
||||
echo (red)Trying water color: (white) $tmp_wc
|
||||
watercolour (at $tmp_wc 0) (at $tmp_wc 1) (at $tmp_wc 2)
|
||||
@@ -316,13 +313,13 @@ const genwc [
|
||||
// gencl - Randomly generates a valid coloured light.
|
||||
const gencl [
|
||||
if $editing [
|
||||
tmp_numargs = $numargs; tmp_cl = ""
|
||||
tmp_numargs = $numargs; 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. ]
|
||||
] [ 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)
|
||||
@@ -338,7 +335,7 @@ const megabind [ if (> $numargs 5) [ bind $arg1 (format "if (watchingdemo) [ %1
|
||||
// storesets - Generates an alias (list) of the current values for the given CVARs.
|
||||
const storesets [
|
||||
if (> $numargs 1) [
|
||||
badargs = 0; $arg2 = ""
|
||||
badargs = 0; $arg2 = []
|
||||
loop ssl (listlen $arg1) [
|
||||
if (isIdent (at $arg1 $ssl)) [
|
||||
add2list $arg2 (getalias (at $arg1 $ssl))
|
||||
@@ -357,18 +354,28 @@ switch = [
|
||||
]
|
||||
|
||||
// cleanshot - Take a "clean" screenshot with no HUD items.
|
||||
const cs_sets "clockdisplay crosshairsize hidecompass hideconsole hidectfhud hidedamageindicator hidehudequipment hidehudmsgs hideradar hidespecthud hideteam hidevote hudgun specthudgun showstats showtargetname showgrid"
|
||||
const cs_newsets "0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0"
|
||||
const cs_sets [clockdisplay crosshairsize hidecompass hideconsole hidectfhud hidedamageindicator hidehudequipment hidehudmsgs hideradar hidespecthud hideteam hidevote hudgun specthudgun showstats showtargetname showgrid]
|
||||
const cs_newsets [0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0]
|
||||
|
||||
const disablehud [ storesets $cs_sets tmp_old_sets; loop csl (listlen $cs_sets) [ (at $cs_sets $csl) (at $cs_newsets $csl) ]; if $editing [ seteditshow 0 ] ]
|
||||
const enablehud [ if (checkalias tmp_old_sets) [ loop ros (listlen $cs_sets) [ (at $cs_sets $ros) (at $tmp_old_sets $ros) ]; if $editing [ seteditshow ] ] ]
|
||||
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) ] [ nl = 100 ]
|
||||
loop h $nl [
|
||||
if (isclient $h) [ hcn = $h ]
|
||||
]
|
||||
result $hcn
|
||||
]
|
||||
|
||||
// convertcase - Zap lists of strings to lower/uppercase.
|
||||
const convertcase [
|
||||
if (> $numargs 1) [
|
||||
tmpCCO = ""
|
||||
loop ccl $numargs [ if (> $ccl 0) [ tmpCCO = (concatword $tmpCCO " " (getalias (format arg%1 (+ $ccl 2)))) ] [ tmpCCO = (concatword $tmpCCO $arg2) ] ]
|
||||
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) ]
|
||||
]
|
||||
]
|
||||
@@ -382,7 +389,7 @@ const ignoreteam [
|
||||
if (|| (strcmp $_arg1 CLA) (strcmp $_arg1 RVSF)) [
|
||||
loop itl 21 [
|
||||
if (isclient $itl) [
|
||||
if (= (player $itl team) (at "0 1" (strcmp $_arg1 RVSF))) [ ignore $itl ]
|
||||
if (= (player $itl team) (at [0 1] (strcmp $_arg1 RVSF))) [ ignore $itl ]
|
||||
]
|
||||
]
|
||||
] [
|
||||
@@ -396,7 +403,7 @@ const ignoreteam [
|
||||
]
|
||||
] [ echo (red)Error: (white)Not in a team mode. ]
|
||||
]
|
||||
const ignoreenemy [ ignoreteam (at "0 1" (! (player1 team))) ]
|
||||
const ignoreenemy [ 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.
|
||||
|
||||
Reference in New Issue
Block a user