survival.cfg 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // CubeScript survival mode in a nutshell:
  2. //
  3. // * All official maps support it.
  4. // * Each map has a unique "zone" that the player must stay in, to continue playing.
  5. // * Every "zone" is located somewhere other than the usual two bases.
  6. // * When the player first enters the "zone", the timers/counters start.
  7. // * If the player has not found the "zone" within the set timeframe, they are automatically teleported there.
  8. // * The difficulty is "increased" over time, by spawning more and increasing the skill level of bots at "checkpoints".
  9. // * If the player dies, or leaves the "zone" for too long of a duration, the game ends.
  10. // * Total seconds survived, total number of enemies killed during, average amount of time between kills, and total damage dealt while alive are reported as stats when the game ends.
  11. persistidents 0 // don't save default values
  12. // set defaults - may be overwritten by saved.cfg
  13. looplist [
  14. spamSurvMsgs 0
  15. survDifficulty 0
  16. nonSurvDefaults 0
  17. survBotsToAdd 1
  18. survDamageEffects 1
  19. survNumBots 6
  20. survMaxBots 20
  21. timeBetChkPts 60000
  22. timeUntilTele 90000
  23. ] [ a v ] [ alias $a $v ]
  24. alias survMap (rnd (listlen $__defaultmaps))
  25. // reset working variables
  26. const survResetAliases [gotCheckPoint lastCheckPoint survIsFinished startedSurvival startedOBCount startPreSurvMillis startSurvMillis survKills survTeleported survTotalDmg survOrigSets backInZone changingspeed changinggamma]
  27. const resetSurvAliases [ looplist $survResetAliases a [ tempalias $a 0 ] ]
  28. //checkinit afterinit resetSurvAliases
  29. resetSurvAliases
  30. // build menus
  31. const survSetsList [survNumBots survBotsToAdd timeBetChkPts timeUntilTele survMaxBots]
  32. const survDifList ["6 1 60000 90000 20" "8 2 45000 60000 30" "10 3 30000 45000 40" "12 5 10000 20000 50"]
  33. const survSetDif [if (checkrange $arg1 0 3) [ survDifficulty = $arg1; loop sdl 5 [ (at $survSetsList $sdl) = (at (at $survDifList $survDifficulty) $sdl) ] ] [ sleep 1000 [ echo "\f3Error: \f5invalid difficulty, defaulting to" (genSurvDifStr 0) ] 1; survSetDif 0 ]; nonSurvDefaults = 0 ]
  34. newmenu [Survival Mode]
  35. menuitemslider "Map: " 0 -1 "$survMap" [ac_aqueous ac_arabian ac_arctic ac_arid ac_avenue ac_cavern ac_complex ac_depot ac_desert ac_desert2 ac_desert3 ac_douze ac_edifice ac_elevation ac_gothic ac_iceroad ac_industrial ac_ingress ac_keller ac_lainio ac_mines ac_outpost ac_power ac_rattrap ac_scaffold ac_shine ac_snow ac_stellar ac_sunset ac_swamp ac_terros ac_toxic ac_urban ac_venison ac_wasteland ac_werk] [ survMap = $arg1 ]
  36. menuitemslider "Difficulty: " 0 3 "$survDifficulty" [easy intermediate hard impossible] [ survSetDif $arg1 ]
  37. menuitem [] -1
  38. menuitem "\t\t Customize..." [ showmenu [Survival Mode - Customize] ]
  39. menuitem "\t\t\f2 [ Start! ]" [ survival (at $__defaultmaps $survMap) ]
  40. newmenu [Survival Mode - Customize]
  41. menuitemcheckbox "Enable survival damage effects (uses gamespeed/gamma)" "$survDamageEffects" [ survDamageEffects = $arg1 ]
  42. menuitemslider "# of bots to spawn on start: " 6 20 "$survNumBots" 1 [ survNumBots = $arg1; nonSurvDefaults = 1 ]
  43. menuitemslider "# of bots to spawn at checkpoints: " 1 5 "$survBotsToAdd" 1 [ survBotsToAdd = $arg1; nonSurvDefaults = 1 ]
  44. menuitemslider "# of milliseconds between checkpoints: " 10000 120000 "$timeBetChkPts" 10000 [ timeBetChkPts = $arg1; nonSurvDefaults = 1 ]
  45. menuitemslider "# of milliseconds before teleporting: " 10000 180000 "$timeUntilTele" 10000 [ timeUntilTele = $arg1; nonSurvDefaults = 1 ]
  46. menuitemslider "Maximum # of bots in survival mode: " 10 50 "$survMaxBots" 2 [ survMaxBots = $arg1; nonSurvDefaults = 1 ]
  47. menuitemslider "Spam survival mode messages: " 0 1 "$spamSurvMsgs" [ no yes ] [ spamSurvMsgs = $arg1 ]
  48. menuitem [] -1
  49. menuitem "\t\t\t\f2 [ Back ]" [ closecurmenu ]
  50. const genSurvDifStr [
  51. if $nonSurvDefaults [ result "[CUSTOM]" ] [
  52. tempalias tmpstrlist (concat (concatword (green) "[EASY]") (concatword (yellow) "[INTERMEDIATE]") (concatword (orange) "[HARD]") (concatword (dred) "[IMPOSSIBLE]"))
  53. if (&& $numargs (checkrange $arg1 0 3)) [ result (at $tmpstrlist $arg1) ] [ result (at $tmpstrlist $survDifficulty) ]
  54. ]
  55. ]
  56. const survOnKill [
  57. if (&& (= $arg1 (player1 cn)) (!= $arg1 $arg2)) [ // Player1 was actor and was not suicide
  58. += survKills 1 // Increment enemies killed counter
  59. if (! (listlen $survTimeBetKills)) [ // First kill
  60. tempalias survTimeBetKills (- (millis) $startSurvMillis) //
  61. ] [ add2list survTimeBetKills (- (millis) $survLastKill) ] // Other kills
  62. tempalias survLastKill (millis) // Update last kill
  63. ] [
  64. if (= $arg2 (player1 cn)) [
  65. add2list tmpSurvSets (concat $arg1 $arg2 $arg3 $arg4 (player $arg1 name)) // Player1 was target, pass arguments/data along for use in the after game results/stats messages.
  66. ]
  67. ]
  68. ]
  69. const survOnHit [
  70. if (&& (= $arg1 (player1 cn)) (!= $arg1 $arg2)) [
  71. += survTotalDmg $arg3
  72. ]
  73. ]
  74. checkinit onKill [if $startedSurvival [survOnKill $arg1 $arg2 $arg3 $arg4]]
  75. checkinit onHit [if $startedSurvival [survOnHit $arg1 $arg2 $arg3 $arg4]]
  76. const survival [
  77. if (> $numargs 1) [ survSetDif $arg2 ]; kickallbots; if (! (player1 team)) [ team RVSF ]
  78. tempalias tmpSurvSets $survNumBots; tempalias curSurvDifficulty 0; tempalias survLastKill []; tempalias survTimeBetKills []; resetSurvAliases
  79. checkinit mapstartonce [
  80. tempalias startPreSurvMillis (millis); add2list tmpSurvSets (curmap); sleep 3 [ storesets gamma survOrigSets ]
  81. echo (genSurvDifStr) (yellow)Bot survival mode prepared, gather items and find the arena to start! (orange)You have (white) (div $timeUntilTele 1000) (orange)seconds to prepare!
  82. setOfcZones; checkzone
  83. ]
  84. btdm $arg1 $MAX_BOT_MATCH_LENGTH
  85. ]
  86. const startSurvival [
  87. tempalias startedSurvival 1; tempalias startSurvMillis (millis); addnbot $survNumBots CLA bad
  88. sleep 1000 [ if $survTeleported [ echo (orange)You were teleported to the zone. ]; echo (red)Starting survival mode, good luck! ]
  89. sleep $timeBetChkPts [ tempalias gotCheckPoint 1; increaseDifficulty ]
  90. ]
  91. const setzone [ if (> (listlen $arg1) 3) [ tempalias zone []; loop szl 4 [ add2list zone (at $arg1 $szl) ] ]; drawzone (at $arg1 0) (at $arg1 1) (at $arg1 2) (at $arg1 3) ]
  92. // Zones consist of two points on a grid. Any area within these points are considered "inner zone".
  93. // The order of the arguments given to setzone are important: setzone "minX maxX minY maxY"
  94. // Hint: Use /whereami to find the two points.
  95. const survOfcZones [
  96. ac_aqueous 159 198 128 142
  97. ac_arabian 128 196 93 146
  98. ac_arctic 81 120 137 176
  99. ac_arid 133 184 88 144
  100. ac_avenue 156 230 64 145
  101. ac_cavern 129 201 77 122
  102. ac_complex 105 150 129 181
  103. ac_depot 137 166 205 262
  104. ac_desert 70 133 110 178
  105. ac_desert2 65 98 149 190
  106. ac_desert3 25 62 97 134
  107. ac_douze 99 140 153 190
  108. ac_edifice 33 80 82 120
  109. ac_elevation 61 102 66 121
  110. ac_gothic 47 83 41 83
  111. ac_iceroad 325 374 244 274
  112. ac_industrial 319 357 180 244
  113. ac_ingress 133 181 66 112
  114. ac_keller 66 100 222 244
  115. ac_lainio 92 204 95 135
  116. ac_mines 95 167 136 193
  117. ac_outpost 84 126 74 137
  118. ac_power 155 216 211 244
  119. ac_rattrap 145 185 57 102
  120. ac_scaffold 34 73 38 99
  121. ac_shine 168 207 120 200
  122. ac_snow 17 54 102 127
  123. ac_stellar 81 144 47 160
  124. ac_sunset 107 152 48 183
  125. ac_swamp 136 180 159 188
  126. ac_terros 122 168 64 137
  127. ac_toxic 72 114 120 147
  128. ac_urban 135 200 45 90
  129. ac_venison 224 280 195 243
  130. ac_wasteland 92 128 100 185
  131. ac_werk 121 147 110 150
  132. ]
  133. // Add zones for custom maps in the alias below...
  134. const survCstZones [
  135. test 93 163 94 162
  136. ]
  137. const setOfcZones [
  138. tempalias survMapIndex (findlist $survOfcZones (curmap))
  139. if (!= $survMapIndex -1) [
  140. tempalias tmpSurvZone []
  141. loop soz 4 [ add2list tmpSurvZone (at $survOfcZones (+ $survMapIndex (+ $soz 1))) ]
  142. setzone $tmpSurvZone
  143. ] [
  144. survMapIndex = (findlist $survCstZones (curmap))
  145. if (!= $survMapIndex -1) [
  146. tempalias tmpSurvZone []
  147. loop soz 4 [ add2list tmpSurvZone (at $survCstZones (+ $survMapIndex (+ $soz 1))) ]
  148. setzone $tmpSurvZone
  149. ]
  150. ]
  151. ]
  152. const findCenter [
  153. tempalias midZoneX (+f (divf (-f (at $tmpSurvZone 1) (at $tmpSurvZone 0)) 2) (at $tmpSurvZone 0))
  154. tempalias midZoneY (+f (divf (-f (at $tmpSurvZone 3) (at $tmpSurvZone 2)) 2) (at $tmpSurvZone 2))
  155. ]
  156. const teleportPlayer [
  157. if (&& (! $survIsFinished) (&& $startPreSurvMillis (>= (- (millis) $startPreSurvMillis) 500))) [
  158. if (! (player1 alive)) attack
  159. if (!= $gamespeed 100) [ gamespeed 100 ]
  160. survTeleported = 1
  161. findCenter
  162. if (! $editing) edittoggle
  163. gotoposition $midZoneX $midZoneY
  164. sleep 25 edittoggle
  165. ]
  166. ]
  167. const isInZone [ result (&& (checkrange (player1 x) (at $zone 0) (at $zone 1)) (checkrange (player1 y) (at $zone 2) (at $zone 3))) ]
  168. tempalias changingspeed 0
  169. tempalias changinggamma 0
  170. const changespeed [
  171. if (= $connected 0) [
  172. if (&& (>= $arg1 10) (<= $arg1 1000)) [
  173. changingspeed = 1; tempalias curspeed $gamespeed; tempalias targetspeed $arg1; tempalias increments $arg2
  174. if (!= $curspeed $targetspeed) [
  175. if (> $curspeed $targetspeed) [
  176. tempalias loops (- $curspeed $targetspeed)
  177. ] [ tempalias loops (- $targetspeed $curspeed) ]
  178. loop CSL $loops [
  179. sleep (* $CSL $increments) [ gamespeed ((at [+ -] (> $curspeed $targetspeed)) $gamespeed 1) ]
  180. ]
  181. sleep (* $loops $increments) [ changingspeed = 0 ]
  182. ] [ changingspeed = 0 ]
  183. ] [
  184. echo "valid range for gamespeed is 10..1000"
  185. ]
  186. ] [
  187. echo "operation not available in multiplayer"
  188. ]
  189. ]
  190. const changegamma [
  191. changinggamma = 1; tempalias curgamma $gamma; tempalias targetgamma $arg1; tempalias incrementss $arg2
  192. if (!= $curgamma $targetgamma) [
  193. if (> $curgamma $targetgamma) [
  194. tempalias loopss (- $curgamma $targetgamma)
  195. ] [ tempalias loopss (- $targetgamma $curgamma) ]
  196. loop CGL $loopss [
  197. sleep (* $CGL $incrementss) [ gamma ((at [+ -] (> $curgamma $targetgamma)) $gamma 1) ]
  198. ]
  199. sleep (* $loopss $incrementss) [ changinggamma = 0 ]
  200. ] [ changinggamma = 0 ]
  201. ]
  202. const applySurvDamageEffects [
  203. if (&& (!= $gamespeed (* (player1 health) 2)) (&& (! $changingspeed) (>= (player1 health) 5))) [
  204. changespeed (* (player1 health) 2) 10
  205. ]
  206. if (&& (checkrange (player1 health) 15 32) (&& (!= $gamma (* (player1 health) 3)) (! $changinggamma))) [
  207. changegamma (* (player1 health) 3) 10
  208. ]
  209. ]
  210. const checkzone [
  211. if (! $survIsFinished) [
  212. if (! $startedSurvival) [
  213. if (! (player1 team)) [ team RVSF ]
  214. if (isInZone) startSurvival
  215. if (>= (- (millis) $startPreSurvMillis) $timeUntilTele) teleportPlayer
  216. ] [
  217. if (>= (- (millis) $startSurvMillis) 500) [
  218. if (|| $editing (|| (idlebots 2) (! (botsshoot 2)))) [ endSurvival (concatword (genSurvDifStr) (red) [ Error: editmode, idlebots, and botsshoot are not allowed in bot survival mode.]) 1 ]
  219. if (! (player1 alive)) [ tempalias finalSurvMillis (- (millis) $startSurvMillis); endSurvival (concatword (genSurvDifStr) (red) [ You survived for ] (white) (divf $finalSurvMillis 1000) (red) [ seconds, killed ] (white) $survKills (red) [ enemies. Average: ] (white) (divf (listaverage $survTimeBetKills) 1000) (red) [ seconds between kills. Total Damage Dealt: ] (white) $survTotalDmg) ]
  220. ]
  221. if (&& (! (isInZone)) (! $startedOBCount)) startOBCount [
  222. if (&& (isInZone) (&& $startedOBCount (! $backInZone))) [ backInZone = 1 ]
  223. ]
  224. if (&& (>= (- (millis) $lastCheckPoint) $timeBetChkPts) $gotCheckPoint) increaseDifficulty
  225. if $survDamageEffects [
  226. if (>= (player1 health) 50) [ if (&& (!= $gamespeed 100) (! $changingspeed)) [ changespeed 100 10 ] ]
  227. if (> (player1 health) 32) [ if (!= $gamma (at $survOrigSets 0)) [ if (! $changinggamma) [ changegamma (at $survOrigSets 0) 10 ] ] ]
  228. if (< (player1 health) 50) applySurvDamageEffects
  229. ]
  230. ]
  231. sleep 0 checkzone
  232. ]
  233. ]
  234. const startOBCount [
  235. if (&& (! $survIsFinished) $startedSurvival) [
  236. tempalias startedOBCount 1; tempalias startOBMillis (millis); tempalias backInZone 0; tempalias tmpSCtr 5
  237. echo (red)Get back into the arena! (white)You only have (red)5 (white)seconds to return.
  238. loop soc 5 [ sleep (* $soc 1000) [ if (&& (! $survIsFinished) (&& (! (isInZone)) (! $backInZone))) [ if $spamSurvMsgs [ hudecho (concatword (orange) $tmpSCtr ...) ] [ echo (concatword (orange) $tmpSCtr ...) ]; -= tmpSCtr 1 ] [ backInZone = 1 ] ] ]
  239. sleep 5000 [ if (&& (! (isInZone)) (&& (! $backInZone) (>= (- (millis) $startOBMillis) 5000))) [ endSurvival (concatword (genSurvDifStr) (red) [ You took too long to return to the arena!]) 1 ] [ startedOBCount = 0 ] ]
  240. ]
  241. ]
  242. const increaseDifficulty [
  243. tempalias lastCheckPoint (millis)
  244. if (curmodeattr bot) [
  245. if (<= (+ $survNumBots $survBotsToAdd) $survMaxBots) [ += survNumBots $survBotsToAdd; addnbot $survBotsToAdd CLA best ] [ tmpSurvInt = (- $survMaxBots $survNumBots); += survNumBots $tmpSurvInt; addnbot $tmpSurvInt CLA best ]
  246. if (< $curSurvDifficulty 4) [ += curSurvDifficulty 1 ; botskillall (at [bad worse medium good best] $curSurvDifficulty) ]
  247. ]
  248. ]
  249. const endSurvival [
  250. if (! $survIsFinished) [
  251. tempalias tmp_survstr $arg1; tempalias tmp_nargs $numargs; tempalias survIsFinished 1; tempalias startedSurvival 0; tempalias survNumBots (at $tmpSurvSets 0)
  252. checkinit mapstartonce [
  253. gamespeed 100
  254. if (< $tmp_nargs 2) [
  255. echo (green)Bot Survival results for map: (white) (at $tmpSurvSets 1)
  256. if (!= (at $tmpSurvSets 2) (at $tmpSurvSets 3)) [
  257. if (= (at $tmpSurvSets 5) 1) [ sleep 5 [ echo (concatword (yellow) (format [you were %1 by %2] (gibmessage (at $tmpSurvSets 4)) (at $tmpSurvSets 6))) ] ] [
  258. sleep 5 [ echo (concatword (yellow) (format [you were %1 by %2] (fragmessage (at $tmpSurvSets 4)) (at $tmpSurvSets 6))) ]
  259. ]
  260. ] [ sleep 5 [ echo (concatword (yellow) [you suicided!]) ] ]
  261. ]
  262. echo $tmp_survstr
  263. if (&& $spamSurvMsgs $survKills) [ hudecho (green)GG ]
  264. ]
  265. if (curmodeattr bot) kickallbots
  266. tdm (rndmap)
  267. ]
  268. ]