git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6611 e016b1c5-ed68-44aa-a2f7-31cac88cffde
161 lines
9.5 KiB
INI
161 lines
9.5 KiB
INI
// CubeScript survival mode in a nutshell:
|
|
//
|
|
// * All official maps support it.
|
|
// * Each map has a unique "zone" that the player must stay in, to continue playing.
|
|
// * Every "zone" is located somewhere other than the usual two bases.
|
|
// * When the player first enters the "zone", the timers/counters start.
|
|
// * If the player has not found the "zone" within the set timeframe, they are automatically teleported there.
|
|
// * The difficulty is "increased" over time, by spawning more and increasing the skill level of bots at "checkpoints".
|
|
// * If the player dies, or leaves the "zone" for too long of a duration, the game ends.
|
|
// * Total seconds survived, total number of enemies killed during, and average amount of time between kills are reported as stats when the game ends.
|
|
|
|
const survResetAliases "gotCheckPoint lastCheckPoint survIsFinished startedSurvival startedOBCount startPreSurvMillis startSurvMillis survKills survTeleported"
|
|
|
|
const resetSurvAliases [
|
|
loop rsa (listlen $survResetAliases) [ (at $survResetAliases $rsa) = 0 ]
|
|
aliasinit survBotsToAdd 1; aliasinit "spamSurvMsgs survDifficulty" 0; aliasinit survNumBots 12; aliasinit survMaxBots 32; aliasinit timeBetChkPts 60000; aliasinit timeUntilTele 120000
|
|
]
|
|
|
|
if (! (checkalias afterinit)) [ afterinit = "" ]
|
|
if (! (strstr $afterinit resetSurvAliases)) [
|
|
add2alias afterinit resetSurvAliases
|
|
if (! (checkalias survMap)) [ survMap = (rnd (listlen $defaultmaps)) ]
|
|
]
|
|
|
|
const genSurvDifStr [
|
|
if $nonSurvDefaults [ result "[CUSTOM]" ] [
|
|
tmpstrlist = (concat (concatword (c 0) "[EASY]") (concatword (c 2) "[INTERMEDIATE]") (concatword (c 9) "[HARD]") (concatword (c 7) "[IMPOSSIBLE]"))
|
|
if (&& $numargs (checkrange $arg1 0 3)) [ result (at $tmpstrlist $arg1) ] [ result (at $tmpstrlist $survDifficulty) ]
|
|
]
|
|
]
|
|
|
|
const survival [
|
|
kickallbots; if (! (curteam)) [ team RVSF ]; if (> $numargs 1) [ survSetDif $arg2 ]
|
|
tmpSurvSets = $survNumBots; curSurvDifficulty = 0; survLastKill = ""; survTimeBetKills = ""; resetSurvAliases
|
|
if (! (checkalias onKill)) [ onKill = "" ]
|
|
if (! (strstr $onKill survKills)) [
|
|
add2alias onKill [ // Use onKill for enemies killed counter and other stats
|
|
if $startedSurvival [ //
|
|
if (&& (= $arg1 (findcn $curname)) (!= $arg1 $arg2)) [ // Player1 was actor and was not suicide
|
|
+= survKills 1 // Increment enemies killed counter
|
|
if (! (listlen $survTimeBetKills)) [ // First kill
|
|
survTimeBetKills = (- (millis) $startSurvMillis) //
|
|
] [ add2list survTimeBetKills (- (millis) $survLastKill) ] // Other kills
|
|
survLastKill = (millis) // Update last kill
|
|
] [ if (= $arg2 (findcn $curname)) [ add2list tmpSurvSets (concat $arg1 $arg2 $arg3 $arg4 (findpn $arg1)) ] ] // Player1 was target, pass arguments/data along for use in the after game results/stats messages.
|
|
]
|
|
]
|
|
]
|
|
add2alias mapstartonce [
|
|
startPreSurvMillis = (millis); add2list tmpSurvSets (curmap 1)
|
|
echo (genSurvDifStr) (c 2)Bot survival mode prepared, gather items and find the arena to start! (c 9)You have (c 5) (div $timeUntilTele 1000) (c 9)seconds to prepare!
|
|
if (strstr $defaultmaps (curmap 1)) [ survMap = (findlist $defaultmaps (curmap 1)) ]
|
|
setOfcZones; checkzone
|
|
]
|
|
votemap 7 $arg1
|
|
]
|
|
|
|
const startSurvival [
|
|
startedSurvival = 1; startSurvMillis = (millis); addnbot $survNumBots CLA bad
|
|
sleep 1000 [ if $survTeleported [ echo (c 9)You were teleported to the zone. ]; echo (c 3)Starting survival mode, good luck! ]
|
|
sleep $timeBetChkPts [ gotCheckPoint = 1; increaseDifficulty ]
|
|
]
|
|
|
|
const setzone [ if (> (listlen $arg1) 3) [ zone = ""; loop szl 4 [ add2list zone (at $arg1 $szl) ] ]; drawzone (at $arg1 0) (at $arg1 1) (at $arg1 2) (at $arg1 3); ]
|
|
|
|
// Zones consist of two points on a grid. Any area within these points are considered "inner zone".
|
|
// The order of the arguments given to setzone are important: setzone "minX maxX minY maxY"
|
|
// Hint: Use /whereami to find the two points.
|
|
const survOfcZones [
|
|
ac_aqueous 159 198 128 142
|
|
ac_arabian 128 196 93 146
|
|
ac_arctic 81 120 137 176
|
|
ac_arid 135 155 97 138
|
|
ac_complex 105 150 129 181
|
|
ac_depot 137 166 205 262
|
|
ac_desert 89 102 129 174
|
|
ac_desert2 65 98 149 190
|
|
ac_desert3 25 62 97 134
|
|
ac_douze 137 186 121 150
|
|
ac_edifice 33 80 82 120
|
|
ac_elevation 61 102 66 121
|
|
ac_gothic 47 83 41 83
|
|
ac_iceroad 325 374 244 274
|
|
ac_industrial 319 357 180 244
|
|
ac_ingress 133 181 66 112
|
|
ac_keller 66 100 222 244
|
|
ac_mines 83 110 117 131
|
|
ac_outpost 61 99 73 98
|
|
ac_power 155 216 211 244
|
|
ac_rattrap 145 185 57 102
|
|
ac_scaffold 62 91 49 63
|
|
ac_shine 99 124 79 106
|
|
ac_snow 17 54 102 127
|
|
ac_stellar 158 184 49 102
|
|
ac_sunset 148 183 102 127
|
|
ac_toxic 72 114 120 147
|
|
ac_urban 135 200 45 90
|
|
ac_werk 121 147 110 150
|
|
]
|
|
|
|
const setOfcZones [
|
|
survMapIndex = (findlist $survOfcZones (curmap 1))
|
|
if $survMapIndex [ tmpSurvZone = ""; loop soz 4 [ add2list tmpSurvZone (at $survOfcZones (+ $survMapIndex (+ $soz 1))) ]; setzone $tmpSurvZone ]
|
|
]
|
|
|
|
const findCenter [
|
|
midZoneX = (+f (divf (-f (at $tmpSurvZone 1) (at $tmpSurvZone 0)) 2) (at $tmpSurvZone 0))
|
|
midZoneY = (+f (divf (-f (at $tmpSurvZone 3) (at $tmpSurvZone 2)) 2) (at $tmpSurvZone 2))
|
|
]
|
|
|
|
const teleportPlayer [ if (! (alive)) [ attack ]; if (!= $gamespeed 100) [ gamespeed 100 ]; survTeleported = 1; findCenter; if (! $editing) [ edittoggle ]; go_to $midZoneX $midZoneY; sleep 25 [ edittoggle ] ]
|
|
|
|
const isInZone [ if (&& (checkrange (player1 x) (at $zone 0) (at $zone 1)) (checkrange (player1 y) (at $zone 2) (at $zone 3))) [ result 1 ] [ result 0 ] ]
|
|
|
|
const checkzone [
|
|
if (! $survIsFinished) [
|
|
if (&& $startedSurvival (&& (>= (- (millis) $startSurvMillis) 500) (|| (|| (idlebots 2) (! (botsshoot 2))) (|| $editing (!= $gamespeed 100))))) [ endSurvival (concatword (genSurvDifStr) (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 ]
|
|
if (&& (! $startedOBCount) (&& (! (isInZone)) $startedSurvival)) [ startOBCount ]
|
|
if (&& $startedSurvival (&& (! (alive)) (>= (- (millis) $startSurvMillis) 500))) [ finalSurvMillis = (- (millis) $startSurvMillis); endSurvival (concatword (genSurvDifStr) (c 3) " You survived for " (c 5) (divf $finalSurvMillis 1000) (c 3) " seconds, and killed " (c 5) $survKills (c 3) " enemies. Average: " (c 5) (divf (listaverage $survTimeBetKills) 1000) (c 3) " seconds between kills.") ]
|
|
if (&& (! (curteam)) (! $startedSurvival)) [ team RVSF ]; sleep 0 [ checkzone ]
|
|
]
|
|
]
|
|
|
|
const startOBCount [
|
|
startedOBCount = 1; startOBMillis = (millis); backInZone = 0; tmpSCtr = 5
|
|
echo (c 3)Get back into the arena! (c 5)You only have (c 3)5 (c 5)seconds to return.
|
|
loop soc 5 [ sleep (* $soc 1000) [ if (&& (! $survIsFinished) (&& (! (isInZone)) (! $backInZone))) [ if $spamSurvMsgs [ hudecho (concatword (c 9) $tmpSCtr ...) ] [ echo (concatword (c 9) $tmpSCtr ...) ]; -= tmpSCtr 1 ] [ backInZone = 1 ] ] ]
|
|
sleep 5000 [ if (&& (! (isInZone)) (&& (! $backInZone) (>= (- (millis) $startOBMillis) 5000))) [ endSurvival (concatword (genSurvDifStr) (c 3) " You took too long to return to the arena!") ] [ startedOBCount = 0 ] ]
|
|
]
|
|
|
|
const increaseDifficulty [
|
|
lastCheckPoint = (millis)
|
|
if (<= (+ $survNumBots $survBotsToAdd) $survMaxBots) [ += survNumBots $survBotsToAdd; addnbot $survBotsToAdd CLA best ] [ tmpSurvInt = (- $survMaxBots $survNumBots); += survNumBots $tmpSurvInt; addnbot $tmpSurvInt CLA best ]
|
|
if (< $curSurvDifficulty 4) [ += curSurvDifficulty 1; botskillall (at "bad worse medium good best" $curSurvDifficulty) ]
|
|
]
|
|
|
|
const endSurvival [
|
|
tmp_survstr = $arg1; survIsFinished = 1; startedSurvival = 0; survNumBots = (at $tmpSurvSets 0)
|
|
add2alias mapstartonce [
|
|
if (&& (strstr $tmp_survstr " You survived for ") (strstr $tmp_survstr " enemies. Average: ")) [
|
|
echo (c 0)Bot Survival results for map: (c 5) (at $tmpSurvSets 1)
|
|
if (!= (at $tmpSurvSets 2) (at $tmpSurvSets 3)) [
|
|
if (= (at $tmpSurvSets 5) 1) [ sleep 5 [ echo (concatword (c 2) (format "you were %1 by %2" (gibmessage (at $tmpSurvSets 4)) (at $tmpSurvSets 6))) ] ] [
|
|
sleep 5 [ echo (concatword (c 2) (format "you were %1 by %2" (fragmessage (at $tmpSurvSets 4)) (at $tmpSurvSets 6))) ]
|
|
]
|
|
] [ sleep 5 [ echo (concatword (c 2) "you suicided!") ] ]
|
|
]
|
|
echo $tmp_survstr
|
|
if (&& $spamSurvMsgs $survKills) [ hudecho (c 0)GG ]
|
|
]
|
|
tdm (rndmap)
|
|
]
|
|
|
|
// List of aliases that need to be cleared from saved.cfg on quit:
|
|
const survAliases = (concat $survResetAliases "resetSurvAliases genSurvDifStr survival tmpSurvSets curSurvDifficulty survLastKill survTimeBetKills startPreSurvMillis startSurvival startedSurvival setzone survOfcZones setOfcZones survMapIndex tmpSurvZone findCenter midZoneX midZoneY teleportPlayer survTeleported isInZone checkzone startOBCount startedOBCount startOBMillis backInZone tmpSCtr increaseDifficulty lastCheckPoint tmpSurvInt endSurvival tmp_survstr survIsFinished tmpstrlist finalSurvMillis zone survSetsList survDifList survSetDif survResetAliases survAliases")
|
|
|
|
addListOnQuit $survAliases
|