From 80632194004081a2460b018339c327b6f3722e18 Mon Sep 17 00:00:00 2001 From: Bukz Date: Sat, 14 May 2011 18:12:39 +0000 Subject: [PATCH] botsshoot/bot survival mode update, tolower/upper, convertcase, and testchar git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6436 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/docs.cfg | 17 ++++++ config/scripts.cfg | 13 +++++ config/survival.cfg | 2 +- docs/reference.xml | 105 ++++++++++++++++++++++++++++++++++ source/src/bot/botmanager.cpp | 19 +++--- source/src/command.cpp | 71 +++++++++++++++++++++++ 6 files changed, 218 insertions(+), 9 deletions(-) diff --git a/config/docs.cfg b/config/docs.cfg index 82ba8567..a72f8111 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -221,6 +221,23 @@ docargument [N] [type ID] [min 0/max 5/default 0] [0]; docexample [echo (addpunct hello 1)] [Output: [hello]]; docident [curplayers] [Returns the current number of players.]; docremark [The return value includes the local player "(you)", and works in both singleplayer and multiplayer scenarios.]; +docident [tolower] [Converts a string to all lowercase characters.]; +docargument [S] [a string] [] [0]; +docexample [echo (tolower HELLO)] [Output: hello]; +docident [toupper] [Converts a string to all uppercase characters.]; +docargument [S] [a string] [] [0]; +docexample [echo (toupper hello)] [Output: HELLO]; +docident [convertcase] [Converts a list of strings to lowercase or uppercase characters.]; +docargument [N] [0 - use lowercase, 1 - use uppercase] [min 0/max 1] [0]; +docargument [...] [a list of strings] [] [0]; +docexample [echo (convertcase 0 ZERO ONE TWO THREE)] [Output: zero one two three]; +docexample [echo (convertcase 1 zero one two three)] [Output: ZERO ONE TWO THREE]; +docremark [This command can handle up to 23 string arguments.]; +docident [testchar] [Tests a character argument for various things.]; +docargument [C] [the character to test] [] [0]; +docargument [N] [type of test to run] [min 0/max 7/default 0] [0]; +docexample [echo (testchar 1)] [Output: 1 "(because it is a 0-9 digit)"]; +docremark [See /docs/reference.xml for more information about the usage of this command.]; docsection [General] docident [addserver] [Adds a server to the list of server to query in the server list menu.]; docargument [S] [the address of the server (hostname or IP)] [] [0]; diff --git a/config/scripts.cfg b/config/scripts.cfg index 0f18a2a8..cce29c6d 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -381,6 +381,19 @@ votepending = 0 if (! (checkalias onCallVote)) [ onCallVote = "" ]; if (! (strstr $onCallVote votepending)) [ add2alias onCallVote [ votepending = 1 ] ] if (! (checkalias onVoteEnd)) [ onVoteEnd = "" ]; if (! (strstr $onVoteEnd votepending)) [ add2alias onVoteEnd [ votepending = 0 ] ] +// convertcase - Zap a list of strings to lower/uppercase. +convertcase = [ + if (> $numargs 0) [ + 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) + ] + ] +] + // Simple claim-admin script for one single-server. // Fill in the 3 aliases below, and uncomment the below line to activate. // bind F3 "customclaimadminscript" diff --git a/config/survival.cfg b/config/survival.cfg index 1fadbd78..8fdd4c84 100644 --- a/config/survival.cfg +++ b/config/survival.cfg @@ -100,7 +100,7 @@ isInZone = [ checkzone = [ if (! $survIsFinished) [ - if (&& $startedSurvival (&& (>= (- (millis) $startSurvMillis) 500) (|| $editing (!= $gamespeed 100)))) [ endSurvival (concatword (c 3) "Error: " (c 1) editmode (c 5) " and " (c 1) gamespeed (c 5) " are not allowed in Survival Mode.") ] + if (&& $startedSurvival (&& (>= (- (millis) $startSurvMillis) 500) (|| (|| (idlebots 3) (! (botsshoot 3))) (|| $editing (!= $gamespeed 100))))) [ endSurvival (concatword (c 3) "Error: " (c 1) editmode (c 5) ", " (c 3) gamespeed (c 5) ", " (c 2) idlebots (c 5) ", and " (c 0) botsshoot (c 5) " are not allowed in Survival Mode.") ] if (&& (isInZone) (! $startedSurvival)) [ startSurvival ] if (&& (! $startedSurvival) (>= (- (millis) $startPreSurvMillis) $timeUntilTele)) [ teleportPlayer ] if (&& (>= (- (millis) $lastCheckPoint) $timeBetChkPts) (&& $startedSurvival $gotCheckPoint)) [ increaseDifficulty ] diff --git a/docs/reference.xml b/docs/reference.xml index a998896b..f9ad8e0a 100644 --- a/docs/reference.xml +++ b/docs/reference.xml @@ -893,6 +893,111 @@ The return value includes the local player "(you)", and works in both singleplayer and multiplayer scenarios. + + + Converts a string to all lowercase characters. + + + + Output: hello + + + + + + + + + + + + + Converts a string to all uppercase characters. + + + + Output: HELLO + + + + + + + + + + + + + Converts a list of strings to lowercase or uppercase characters. + + + + Output: zero one two three + + + + Output: ZERO ONE TWO THREE + + + + + + + + This command can handle up to 23 string arguments. + + + + + + + + + Tests a character argument for various things. + + + + Output: 1 // It is a 0-9 digit + + + + Output: 1 // It is a a-z or A-Z character + + + + Output: 1 // It is a a-z or A-Z character or 0-9 digit + + + + Output: 1 // It is a lowercase a-z character + + + + Output: 1 // It is a uppercase A-Z character + + + + Output: 1 // It is a printable character + + + + Output: 1 // It is a punctuation character + + + + Output: 1 // It is a whitespace character + + + + + + + + See the following c++ functions for more information about the usage of this command: + isalpha(), isalnum(), isdigit(), islower(), isprint(), ispunct(), isupper(), and isspace() + + diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 9494efb8..163f914c 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -1010,15 +1010,18 @@ COMMAND(addnbot, ARG_3STR); void botsshoot(int Shoot) { - if (Shoot) + switch(Shoot) { - BotManager.SetBotsShoot(true); - conoutf("Bots will shoot"); - } - else - { - BotManager.SetBotsShoot(false); - conoutf("Bots won't shoot"); + case 0: + BotManager.SetBotsShoot(false); + conoutf("Bots won't shoot"); + break; + case 1: + BotManager.SetBotsShoot(true); + conoutf("Bots will shoot"); + break; + default: + intret(BotManager.BotsShoot()); break; } } diff --git a/source/src/command.cpp b/source/src/command.cpp index e3e20680..c0c41675 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -1131,6 +1131,74 @@ void curplayers(void) result(output); } +void toLower(char *s) +{ + result(strcaps(s, false)); +} + +void toUpper(char *s) +{ + result(strcaps(s, true)); +} + +void testchar(char *s, char *type) +{ + int t = atoi(type); + switch(t) + { + case 1: + if(isalpha(s[0]) != 0) + intret(1); + else + intret(0); + break; + case 2: + if(isalnum(s[0]) != 0) + intret(1); + else + intret(0); + break; + case 3: + if(islower(s[0]) != 0) + intret(1); + else + intret(0); + break; + case 4: + if(isupper(s[0]) != 0) + intret(1); + else + intret(0); + break; + case 5: + if(isprint(s[0]) != 0) + intret(1); + else + intret(0); + break; + case 6: + if(ispunct(s[0]) != 0) + intret(1); + else + intret(0); + break; + case 7: + if(isspace(s[0]) != 0) + intret(1); + else + intret(0); + break; + default: + if(isdigit(s[0]) != 0) + intret(1); + else + intret(0); + break; + } +} + +COMMAND(testchar, ARG_2STR); + COMMANDN(c, colora, ARG_1STR); COMMANDN(loop, loopa, ARG_3STR); COMMANDN(while, whilea, ARG_2STR); @@ -1146,6 +1214,9 @@ COMMAND(listlen, ARG_1EST); COMMAND(findlist, ARG_2STR); COMMAND(addpunct, ARG_2STR); COMMAND(curplayers, ARG_NONE); +COMMANDN(tolower, toLower, ARG_1STR); +COMMANDN(toupper, toUpper, ARG_1STR); + int add(int a, int b) { return a+b; } COMMANDN(+, add, ARG_2EXP); int mul(int a, int b) { return a*b; } COMMANDN(*, mul, ARG_2EXP);