Bukz

Survival mode skeleton concept

Apr 20th, 2011
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.37 KB | None | 0 0
  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, and total number of enemies killed during, are reported as stats when the game ends.
  11.  
  12. survResetAliases = "gotCheckPoint lastCheckPoint survIsFinished startedSurvival startedOBCount startPreSurvMillis startSurvMillis survKills survTeleported"
  13.  
  14. resetSurvAliases = [
  15.   loop rsa (listlen $survResetAliases) [ (at $survResetAliases $rsa) = 0 ]
  16.   aliasinit survBotsToAdd 1; aliasinit "spamSurvMsgs survDifficulty" 0; aliasinit survNumBots 12; aliasinit survMaxBots 32; aliasinit timeBetChkPts 60000; aliasinit timeUntilTele 120000
  17. ]
  18.  
  19. resetSurvAliases; if (! (checkalias afterinit)) [ afterinit = "" ]; if (! (strstr $afterinit survMap)) [ add2alias afterinit [ if (! (checkalias survMap)) [ survMap = (rnd (listlen $defaultmaps)) ] ] ]
  20.  
  21. genSurvDifStr = [
  22.   if $nonSurvDefaults [ result "[CUSTOM]" ] [
  23.     result (at (concat (concatword (c 0) "[EASY]") (concatword (c 2) "[INTERMEDIATE]") (concatword (c 9) "[HARD]") (concatword (c 7) "[IMPOSSIBLE]")) $survDifficulty)
  24.   ]
  25. ]
  26.  
  27. survival = [
  28.   kickallbots; tmpSurvSets = $survNumBots; curSurvDifficulty = 0; survLastKill = ""; survTimeBetKills = ""; resetSurvAliases
  29.   if (! (checkalias onKill)) [ onKill = "" ]; if (! (strstr $onKill survKills)) [ add2alias onKill [ if $startedSurvival [ += survKills 1; if (! (listlen $survTimeBetKills)) [ survTimeBetKills = (- (millis) $startSurvMillis) ] [ add2list survTimeBetKills (- (millis) $survLastKill) ]; survLastKill = (millis) ] ] ]
  30.   add2alias mapstartonce [
  31.     startPreSurvMillis = (millis)
  32.     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!
  33.     if (strstr $defaultmaps (curmap 1)) [ survMap = (findlist $defaultmaps (curmap 1)) ]
  34.     setOfcZones; checkzone
  35.   ]
  36.   if (! (curteam)) [ team RVSF ]; mode 7; map $arg1 // Make 'em fight for us :p
  37. ]
  38.  
  39. startSurvival = [
  40.   startedSurvival = 1; startSurvMillis = (millis); addnbot $survNumBots CLA bad
  41.   sleep 1000 [ if $survTeleported [ echo (c 9)You were teleported to the zone. ]; echo (c 3)Starting survival mode, good luck! ]
  42.   sleep $timeBetChkPts [ gotCheckPoint = 1; increaseDifficulty ]
  43. ]
  44.  
  45. setzone = [ if (> (listlen $arg1) 3) [ zone = ""; loop szl 4 [ add2list zone (at $arg1 $szl) ] ] ]
  46.  
  47. // Zones consist of two points on a grid. Any area within these points are considered "inner zone".
  48. // The order of the arguments given to setzone are important: setzone "minX maxX minY maxY"
  49. // Hint: Use /whereami to find the two points.
  50. survOfcZones = [
  51.   ac_aqueous    159.10 198.90 128.10 142.90
  52.   ac_arabian    128.10 196.90 93.10 146.90
  53.   ac_arctic     81.10 120.90 137.10 176.90
  54.   ac_arid       135.10 155.90 97.10 138.90
  55.   ac_complex    105.10 150.90 129.10 181.90
  56.   ac_depot      137.10 166.90 205.10 262.90
  57.   ac_desert     89.10 102.90 129.10 174.90
  58.   ac_desert2    65.10 98.90 149.10 190.90
  59.   ac_desert3    25.10 62.90 97.10 134.90
  60.   ac_douze      137.10 186.90 121.10 150.90
  61.   ac_edifice    33.10 80.90 82.10 120.90
  62.   ac_elevation  61.10 102.90 66.10 121.90
  63.   ac_gothic     47.10 83.90 41.10 83.90
  64.   ac_iceroad    325.10 374.90 244.10 274.90
  65.   ac_industrial 319.10 357.90 180.10 244.90
  66.   ac_ingress    133.10 181.90 66.10 112.90
  67.   ac_keller     66.10 100.90 222.10 244.90
  68.   ac_mines      83.10 110.90 117.10 131.90
  69.   ac_outpost    61.10 99.90 73.10 98.90
  70.   ac_power      155.10 216.90 211.10 244.90
  71.   ac_rattrap    145.10 185.90 57.10 102.90
  72.   ac_scaffold   62.10 91.90 49.10 63.90
  73.   ac_shine      99.10 124.90 79.10 106.90
  74.   ac_snow       17.10 54.90 102.10 127.90
  75.   ac_stellar    158.90 184.90 49.10 102.90
  76.   ac_sunset     148.10 183.90 102.10 127.90
  77.   ac_toxic      72.10 114.90 120.10 147.90
  78.   ac_urban      135.10 200.90 45.10 90.90
  79.   ac_werk       121.10 147.90 110.10 150.90
  80. ]
  81.  
  82. setOfcZones = [
  83.   survMapIndex = (findlist $survOfcZones (curmap 1))
  84.   if (>= $survMapIndex 0) [
  85.     tmpSurvZone = ""; tmpSurvCtr = 0
  86.     loop soz 4 [ += tmpSurvCtr 1; add2list tmpSurvZone (at $survOfcZones (+ $survMapIndex $tmpSurvCtr)) ]
  87.     setzone $tmpSurvZone
  88.   ]
  89. ]
  90.  
  91. findCenter = [
  92.   midZoneX = (+f (divf (-f (at $tmpSurvZone 1) (at $tmpSurvZone 0)) 2) (at $tmpSurvZone 0))
  93.   midZoneY = (+f (divf (-f (at $tmpSurvZone 3) (at $tmpSurvZone 2)) 2) (at $tmpSurvZone 2))
  94.   tmpZoneCenter = (concat $midZoneX $midZoneY)
  95. ]
  96.  
  97. teleportPlayer = [ if (! (alive)) [ attack ]; if (!= $gamespeed 100) [ gamespeed 100 ]; survTeleported = 1; findCenter; if (! $editing) [ edittoggle ]; go_to (at $tmpZoneCenter 0) (at $tmpZoneCenter 1); sleep 25 [ edittoggle ] ]
  98.  
  99. isInZone = [
  100.   if (&& (&& (>= (player1 x) (at $zone 0)) (>= (player1 y) (at $zone 2))) (&& (<= (player1 x) (at $zone 1)) (<= (player1 y) (at $zone 3)))) [
  101.     result 1
  102.   ] [
  103.     result 0
  104.   ]
  105. ]
  106.  
  107. checkzone = [
  108.   if (! $survIsFinished) [
  109.     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.") ]
  110.     if (&& (isInZone) (! $startedSurvival)) [ startSurvival ]
  111.     if (&& (! $startedSurvival) (>= (- (millis) $startPreSurvMillis) $timeUntilTele)) [ teleportPlayer ]
  112.     if (&& (>= (- (millis) $lastCheckPoint) $timeBetChkPts) (&& $startedSurvival $gotCheckPoint)) [ increaseDifficulty ]
  113.     if (&& (! $startedOBCount) (&& (! (isInZone)) $startedSurvival)) [ startOBCount ]
  114.     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.") ]
  115.     if (&& (! (curteam)) (! $startedSurvival)) [ team RVSF ]; sleep 0 [ checkzone ]
  116.   ]
  117. ]
  118.  
  119. startOBCount = [
  120.   startedOBCount = 1; startOBMillis = (millis); backInZone = 0; tmpSCtr = 5
  121.   echo (c 3)Get back into the arena! (c 5)You only have (c 3)5 (c 5)seconds to return.
  122.   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 ] ] ]
  123.   sleep 5000 [ if (&& (! (isInZone)) (&& (! $backInZone) (>= (- (millis) $startOBMillis) 5000))) [ endSurvival (concatword (genSurvDifStr) (c 3) " You took too long to return to the arena!") ] [ startedOBCount = 0 ] ]
  124. ]
  125.  
  126. increaseDifficulty = [
  127.   lastCheckPoint = (millis)
  128.   if (<= (+ $survNumBots $survBotsToAdd) $survMaxBots) [ += survNumBots $survBotsToAdd; addnbot $survBotsToAdd CLA best ] [ tmpSurvInt = (- $survMaxBots $survNumBots); += survNumBots $tmpSurvInt; addnbot $tmpSurvInt CLA best ]
  129.   if (< $curSurvDifficulty 4) [ += curSurvDifficulty 1; botskillall (at "bad worse medium good best" $curSurvDifficulty) ]
  130. ]
  131.  
  132. endSurvival = [
  133.   tmp_survstr = $arg1; survIsFinished = 1; startedSurvival = 0; survNumBots = $tmpSurvSets
  134.   add2alias mapstartonce [ echo $tmp_survstr ]
  135.   tdm (at $defaultmaps (rnd (listlen $defaultmaps)))
  136. ]
  137.  
  138. // List of aliases that need to be cleared from saved.cfg on quit:
  139. survAliases = (concat $survResetAliases "backInZone checkzone curSurvDifficulty endSurvival finalSurvMillis genSurvDifStr increaseDifficulty isInZone midZoneX midZoneY onKill resetSurvAliases setOfcZones setzone startOBCount startOBMillis startSurvival survLastKill survMapIndex survOfcZones survTimeBetKills tmpSCtr tmpSurvCtr tmpSurvInt tmpSurvSets tmp_sum tmp_survstr tmpSurvZone tmpZoneCenter zone aliasinit survResetAliases survAliases")
  140.  
  141. addListOnQuit $survAliases
Advertisement
Add Comment
Please, Sign In to add comment