From 2f1ea0721383997305650487c2f15bd71cda8f43 Mon Sep 17 00:00:00 2001 From: Bukz Date: Mon, 4 Jun 2012 11:47:57 +0000 Subject: [PATCH] trying out bot survival "damage effects" git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6822 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/defaults.cfg | 3 ++- config/menus_bot.cfg | 1 + config/survival.cfg | 55 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/config/defaults.cfg b/config/defaults.cfg index 900e80c8..0b877f80 100644 --- a/config/defaults.cfg +++ b/config/defaults.cfg @@ -35,4 +35,5 @@ timeBetChkPts = 60000 timeUntilTele = 120000 survMaxBots = 32 spamSurvMsgs = 0 -nonSurvDefaults = 0 \ No newline at end of file +nonSurvDefaults = 0 +survDamageEffects = 1 \ No newline at end of file diff --git a/config/menus_bot.cfg b/config/menus_bot.cfg index ad716e4a..b280961a 100644 --- a/config/menus_bot.cfg +++ b/config/menus_bot.cfg @@ -117,6 +117,7 @@ menuitem " Customize" [ showmenu "Survival Mode - Customiz menuitem " Start!" [ survival (at $defaultmaps $survMap) ] newmenu "Survival Mode - Customize" +menuitemcheckbox "Enable survival damage effects (uses gamespeed/gamma)" "$survDamageEffects" [ survDamageEffects = $arg1 ] menuitemslider "# of bots to spawn on start: " 6 20 "$survNumBots" 1 [] [ survNumBots = $arg1; nonSurvDefaults = 1 ] menuitemslider "# of bots to spawn at checkpoints: " 1 5 "$survBotsToAdd" 1 [] [ survBotsToAdd = $arg1; nonSurvDefaults = 1 ] menuitemslider "# of milliseconds between checkpoints: " 10000 120000 "$timeBetChkPts" 10000 [] [ timeBetChkPts = $arg1; nonSurvDefaults = 1 ] diff --git a/config/survival.cfg b/config/survival.cfg index a967f58b..e0b12369 100644 --- a/config/survival.cfg +++ b/config/survival.cfg @@ -9,11 +9,11 @@ // * 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, average amount of time between kills, and total damage dealt while alive are reported as stats when the game ends. -const survResetAliases "gotCheckPoint lastCheckPoint survIsFinished startedSurvival startedOBCount startPreSurvMillis startSurvMillis survKills survTeleported survTotalDmg" +const survResetAliases "gotCheckPoint lastCheckPoint survIsFinished startedSurvival startedOBCount startPreSurvMillis startSurvMillis survKills survTeleported survTotalDmg survOrigSets changingspeed changinggamma" 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 + aliasinit survBotsToAdd 1; aliasinit "spamSurvMsgs survDifficulty" 0; aliasinit survNumBots 12; aliasinit survMaxBots 32; aliasinit timeBetChkPts 60000; aliasinit timeUntilTele 120000; aliasinit survDamageEffects 1 ] if (! (checkalias afterinit)) [ afterinit = "" ] @@ -31,7 +31,7 @@ const genSurvDifStr [ const survival [ kickallbots; if (! (curteam)) [ team RVSF ]; if (> $numargs 1) [ survSetDif $arg2 ] - tmpSurvSets = $survNumBots; curSurvDifficulty = 0; survLastKill = ""; survTimeBetKills = ""; resetSurvAliases + tmpSurvSets = $survNumBots; curSurvDifficulty = 0; survLastKill = ""; survTimeBetKills = ""; resetSurvAliases; storesets "gamma" survOrigSets if (! (checkalias onKill)) [ onKill = "" ] if (! (strstr $onKill survKills)) [ add2alias onKill [ // Use onKill for enemies killed counter and other stats @@ -121,9 +121,55 @@ const teleportPlayer [ if (! (alive)) [ attack ]; if (!= $gamespeed 100) [ games 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 ] ] +changingspeed = 0; changinggamma = 0 + +const changespeed [ + changingspeed = 1; curspeed = $gamespeed; targetspeed = $arg1; increments = $arg2 + if (!= $curspeed $targetspeed) [ + if (> $curspeed $targetspeed) [ + loops = (- $curspeed $targetspeed) + ] [ loops = (- $targetspeed $curspeed) ] + loop i $loops [ + sleep (* $i $increments) [ + gamespeed ((at "+ -" (> $curspeed $targetspeed)) $gamespeed 1) + ] + ] + sleep (* $loops $increments) [ changingspeed = 0 ] + ] [ changingspeed = 0 ] +] + +const changegamma [ + changinggamma = 1; curgamma = $gamma; targetgamma = $arg1; incrementss = $arg2 + if (!= $curgamma $targetgamma) [ + if (> $curgamma $targetgamma) [ + loopss = (- $curgamma $targetgamma) + ] [ loopss = (- $targetgamma $curgamma) ] + loop i $loopss [ + sleep (* $i $incrementss) [ + gamma ((at "+ -" (> $curgamma $targetgamma)) $gamma 1) + ] + ] + sleep (* $loopss $incrementss) [ changinggamma = 0 ] + ] [ changinggamma = 0 ] +] + +const applySurvDamageEffects [ + if (&& (!= $gamespeed (* (player1 health) 2)) (&& (! $changingspeed) (>= (player1 health) 5))) [ + changespeed (* (player1 health) 2) 10 + ] + if (&& (checkrange (player1 health) 15 32) (&& (!= $gamma (* (player1 health) 3)) (! $changinggamma))) [ + changegamma (* (player1 health) 3) 10 + ] +] + const checkzone [ if (! $survIsFinished) [ - if (&& $startedSurvival (&& (>= (- (millis) $startSurvMillis) 500) (|| (|| (idlebots 2) (! (botsshoot 2))) (|| $editing (!= $gamespeed 100))))) [ endSurvival (concatword (genSurvDifStr) (red) " Error: " (blue) editmode (white) ", " (red) gamespeed (white) ", " (yellow) idlebots (white) ", and " (green) botsshoot (white) " are not allowed in Survival Mode.") ] + if $survDamageEffects [ + if (&& $startedSurvival (>= (player1 health) 50)) [ if (&& (!= $gamespeed 100) (! $changingspeed)) [ changespeed 100 10 ] ] + if (&& $startedSurvival (> (player1 health) 32)) [ if (!= $gamma (at $survOrigSets 0)) [ if (! $changinggamma) [ changegamma (at $survOrigSets 0) 10 ] ] ] + if (&& $startedSurvival (< (player1 health) 50)) [ applySurvDamageEffects ] + ] + if (&& $startedSurvival (&& (>= (- (millis) $startSurvMillis) 500) (|| (|| (idlebots 2) (! (botsshoot 2))) $editing))) [ endSurvival (concatword (genSurvDifStr) (red) " Error: " (blue) editmode (white) ", " (yellow) idlebots (white) ", and " (green) botsshoot (white) " are not allowed in Survival Mode.") ] if (&& (isInZone) (! $startedSurvival)) [ startSurvival ] if (&& (! $startedSurvival) (>= (- (millis) $startPreSurvMillis) $timeUntilTele)) [ teleportPlayer ] if (&& (>= (- (millis) $lastCheckPoint) $timeBetChkPts) (&& $startedSurvival $gotCheckPoint)) [ increaseDifficulty ] @@ -151,6 +197,7 @@ const increaseDifficulty [ const endSurvival [ tmp_survstr = $arg1; survIsFinished = 1; startedSurvival = 0; survNumBots = (at $tmpSurvSets 0) add2alias mapstartonce [ + gamma (at $survOrigSets 0); gamespeed 100 if (&& (strstr $tmp_survstr " You survived for ") (strstr $tmp_survstr " enemies. Average: ")) [ echo (green)Bot Survival results for map: (white) (at $tmpSurvSets 1) if (!= (at $tmpSurvSets 2) (at $tmpSurvSets 3)) [