diff --git a/base.nls b/base.nls index 7f12355..9eb3024 100644 --- a/base.nls +++ b/base.nls @@ -1,11 +1,6 @@ ;; lobo: Logo Bolo ;; (c) Ben Kurtovic, 2011 -globals [ - base-max-ammo - base-max-armor -] - breed [bases base] bases-own [ @@ -14,6 +9,8 @@ bases-own [ last-ammo-regen last-armor-regen last-refuel + max-ammo + max-armor team ] @@ -23,17 +20,19 @@ bases-own [ to spawn-base [base-xcor base-ycor] create-bases 1 [ - set-base-vars base-max-ammo base-max-armor -1 base-xcor base-ycor + set-base-vars 50 20 -1 base-xcor base-ycor ] end to set-base-vars [b-ammo b-armor b-team b-xcor b-ycor] set ammunition b-ammo set armor b-armor - set team b-team set last-ammo-regen timer set last-armor-regen timer set last-refuel timer + set max-ammo b-armor + set max-armor b-armor + set team b-team set color get-base-color set shape "base" @@ -71,7 +70,7 @@ end to refuel-tank [tank-to-refuel] let time-since-last-refuel timer - last-refuel ask tank-to-refuel [ - ifelse armor < tank-max-armor and ([armor] of myself) > 1 [ + ifelse armor < max-armor and ([armor] of myself) > 1 [ if time-since-last-refuel > 25 / max-fps [ ; 25 frames set armor armor + 1 ask myself [ @@ -80,7 +79,7 @@ to refuel-tank [tank-to-refuel] ] ] ] [ - if ammunition < tank-max-ammo and ([ammunition] of myself) > 1 [ + if ammunition < max-ammo and ([ammunition] of myself) > 1 [ if time-since-last-refuel > 10 / max-fps [ ; 10 frames set ammunition ammunition + 1 ask myself [ @@ -97,11 +96,11 @@ to regenerate let time-since-last-ammo-regen timer - last-ammo-regen let time-since-last-armor-regen timer - last-armor-regen - if ammunition < base-max-ammo and time-since-last-ammo-regen > 6 [ + if ammunition < max-ammo and time-since-last-ammo-regen > 6 [ set ammunition ammunition + 1 set last-ammo-regen timer ] - if armor < base-max-armor and time-since-last-armor-regen > 15 [ + if armor < max-armor and time-since-last-armor-regen > 15 [ set armor armor + 1 set last-armor-regen timer ] diff --git a/lobo.nlogo b/lobo.nlogo index 574de3d..09d08e9 100644 --- a/lobo.nlogo +++ b/lobo.nlogo @@ -47,7 +47,7 @@ end to go ask player [ - do-player-logic + do-player-logic ] ask tanks [ do-tank-logic @@ -89,12 +89,12 @@ end to debug [agent action msg] ; Comment this and remove the output box ; to turn off debugging info: - output-print (word (round timer) ": " agent ": " action " (" msg ")") + print (word (round timer) ": " agent ": " action " (" msg ")") end to setup-defaults - set-patch-size 30 - resize-world -8 8 -8 8 + set-patch-size 20 + resize-world -17 17 -12 12 set max-fps 30 set mouse-was-down? false set player-deaths 0 @@ -102,12 +102,6 @@ to setup-defaults set player-kills 0 set player-target-xcor 0 set player-target-ycor 0 - set tank-max-ammo 24 - set tank-max-armor 8 - set base-max-ammo 50 - set base-max-armor 20 - set pill-anger-range [1.2 0.2] - set pill-max-armor 8 end to make-sounds-table @@ -117,6 +111,8 @@ to make-sounds-table table:put sounds "noammo" "Cowbell" table:put sounds "pickup" "Hi Bongo" table:put sounds "shot" "Acoustic Snare" + table:put sounds "place" "Vibraslap" + table:put sounds "nopill" "Cowbell" end to load-map @@ -159,6 +155,21 @@ to draw-border [b-color b-thickness] end to show-hud + ask patch (max-pxcor - 1) (max-pycor - 1) [ + set plabel (word "Armor: " [armor] of player) + ] + ask patch (max-pxcor - 1) (max-pycor - 2) [ + set plabel (word "Ammo: " [ammunition] of player) + ] + ask patch (max-pxcor - 1) (max-pycor - 3) [ + set plabel (word "Pillboxes: " [number-of-pills] of player) + ] + ask patch (max-pxcor - 1) (min-pycor + 2) [ + set plabel (word "Deaths: " player-deaths) + ] + ask patch (max-pxcor - 1) (min-pycor + 1) [ + set plabel (word "Kills: " player-kills) + ] end to render @@ -177,7 +188,7 @@ end to play-sound [name] if enable-sound? [ let dist distancexy ([xcor] of player) ([ycor] of player) - let volume 127 - (dist * 4) + let volume 127 - (dist * 8) if volume > 0 [ sound:play-drum (table:get sounds name) volume ] @@ -185,36 +196,36 @@ to play-sound [name] end @#$#@#$#@ GRAPHICS-WINDOW -452 +254 10 -972 -551 -8 -8 -30.0 +964 +541 +17 +12 +20.0 1 -10 +12 1 1 1 0 +0 +0 1 -1 -1 --8 -8 --8 -8 +-17 +17 +-12 +12 0 0 1 frames BUTTON -43 -100 -138 -133 +19 +143 +114 +176 New Game setup NIL @@ -227,10 +238,10 @@ NIL NIL BUTTON -290 -99 -384 -132 +129 +143 +223 +176 Play Game go T @@ -242,23 +253,12 @@ G NIL NIL -MONITOR -269 -290 -389 -339 -Player Speed -[speed] of player -8 -1 -12 - BUTTON -109 -172 -230 +21 +208 224 -FIRE! +255 +Fire! player-fire NIL 1 @@ -269,95 +269,22 @@ F NIL NIL -MONITOR -270 -350 -389 -399 -Player Has Target? -player-has-target? -5 -1 -12 - -OUTPUT -1012 -10 -1500 -557 -12 - -MONITOR -55 -290 -149 -339 -Player Deaths -player-deaths -17 -1 -12 - -MONITOR -55 -350 -148 -399 -Player Kills -player-kills -17 -1 -12 - -MONITOR -160 -290 -261 -339 -Player Ammo -[ammunition] of player -17 -1 -12 - -MONITOR -160 -350 -260 -399 -Player Armor -[armor] of player -17 -1 -12 - SWITCH -264 -179 -394 -212 +50 +97 +186 +130 enable-sound? enable-sound? 0 1 -1000 -MONITOR -272 -411 -390 -460 -Player Target -word \"(\" player-target-xcor \", \" player-target-ycor \")\" -10 -1 -12 - BUTTON -109 -235 -230 -268 +22 +308 +225 +341 Cancel Order player-cancel-order NIL @@ -369,54 +296,61 @@ C NIL NIL -BUTTON -109 -536 -368 -569 -NIL -ask one-of bases [claim-base tank 2] -NIL +TEXTBOX +16 +14 +303 +53 +LoBo: Logo Bolo +28 +0.0 1 -T -OBSERVER -NIL -NIL -NIL -NIL -MONITOR -160 -412 -259 -461 -Player's Pills -[number-of-pills] of player -17 +TEXTBOX +41 +53 +304 +87 +a game by Ben Kurtovic +14 +0.0 1 -12 -MONITOR -261 -584 -357 -629 -Pillbox Anger -[anger] of pillbox 4 -6 +TEXTBOX +19 +75 +241 +93 +--------------------------------- +11 +0.0 1 + +TEXTBOX +21 +185 +262 +213 +--------------------------------- 11 +0.0 +1 -MONITOR -148 -584 -246 -629 -Pillbox Armor -[armor] of pillbox 4 -17 +BUTTON +22 +265 +225 +298 +Place Pill +player-place-pill +NIL 1 -11 +T +OBSERVER +NIL +P +NIL +NIL @#$#@#$#@ WHAT IS IT? @@ -560,10 +494,10 @@ Rectangle -7500403 true false 255 135 300 165 Polygon -7500403 true false 30 60 30 30 60 30 90 60 60 90 30 60 Polygon -7500403 true false 60 270 30 270 30 240 60 210 90 240 60 270 Polygon -7500403 true false 270 240 270 270 240 270 210 240 240 210 270 240 -Polygon -2674135 true true 195 165 210 180 210 180 210 210 180 210 165 195 -Polygon -2674135 true true 165 105 180 90 180 90 210 90 210 120 195 135 -Polygon -2674135 true true 105 135 90 120 90 120 90 90 120 90 135 105 -Polygon -2674135 true true 135 195 120 210 120 210 90 210 90 180 105 165 +Polygon -2674135 true true 195 165 210 180 210 210 180 210 165 195 +Polygon -2674135 true true 165 105 180 90 210 90 210 120 195 135 +Polygon -2674135 true true 105 135 90 120 90 90 120 90 135 105 +Polygon -2674135 true true 135 195 120 210 90 210 90 180 105 165 tank true diff --git a/pillbox.nls b/pillbox.nls index 53e4b03..ff21cc8 100644 --- a/pillbox.nls +++ b/pillbox.nls @@ -1,18 +1,15 @@ ;; lobo: Logo Bolo ;; (c) Ben Kurtovic, 2011 -globals [ - pill-anger-range - pill-max-armor -] - breed [pillboxes pillbox] pillboxes-own [ alive? anger + anger-range armor last-fire-time + max-armor team ] @@ -22,33 +19,40 @@ pillboxes-own [ to spawn-pillbox [pill-xcor pill-ycor] create-pillboxes 1 [ - set-pill-vars (first pill-anger-range) pill-max-armor -1 pill-xcor pill-ycor + set-pill-vars -1 + setxy pill-xcor pill-ycor + ] +end + +to hatch-pillbox + hatch 1 [ + debug who "PILL-HATCH" (word "by " ([who] of myself)) + set breed pillboxes + set-pill-vars [team] of myself ] end -to set-pill-vars [p-anger p-armor p-team p-xcor p-ycor] +to set-pill-vars [p-team] set alive? true - set anger p-anger - set armor p-armor + set anger 1.2 + set anger-range [1.2 0.2] + set armor 8 set last-fire-time timer + set max-armor 8 set team p-team set color get-pill-color set shape "pillbox-alive" set size 1.1 - setxy p-xcor p-ycor end to do-pill-logic set label armor ifelse alive? [ if timer - last-fire-time > anger [ - let targets tanks in-radius 9 + let targets tanks with [team != [team] of myself] in-radius 9 if any? targets [ - let target min-one-of targets [distancexy [xcor] of myself [ycor] of myself] - face target - fire-bullet 9 - set last-fire-time timer + pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself] ] ] relax @@ -59,6 +63,14 @@ to do-pill-logic ] end +to pill-fire-at [target] + debug who "PILL-FIRE" (word "at " [who] of target) + face target + play-sound "fire" + fire-bullet 9 + set last-fire-time timer +end + to pill-shot-at set armor armor - 1 ifelse armor = 0 [ @@ -76,7 +88,7 @@ to pill-shot-at end to relax - let min-anger first pill-anger-range + let min-anger first anger-range set anger anger + 0.00025 if anger > min-anger [ set anger min-anger @@ -84,7 +96,7 @@ to relax end to enrage - let max-anger last pill-anger-range + let max-anger last anger-range set anger anger - 0.2 if anger < max-anger [ set anger max-anger diff --git a/player.nls b/player.nls index dbb05fb..7c31c4b 100644 --- a/player.nls +++ b/player.nls @@ -54,6 +54,18 @@ to do-player-logic ] end +to player-place-pill + ask player [ + ifelse number-of-pills > 0 [ + set number-of-pills number-of-pills - 1 + hatch-pillbox + play-sound "place" + ] [ + play-sound "nopill" + ] + ] +end + to cancel-order if player-has-target? [ cancel-target diff --git a/tank.nls b/tank.nls index fb7c3a0..4f15efd 100644 --- a/tank.nls +++ b/tank.nls @@ -1,11 +1,6 @@ ;; lobo: Logo Bolo ;; (c) Ben Kurtovic, 2011 -globals [ - tank-max-ammo - tank-max-armor -] - breed [tanks tank] tanks-own [ @@ -16,6 +11,8 @@ tanks-own [ friction is-accelerating? is-player? + max-ammo + max-armor max-fire-rate max-speed max-turn @@ -36,12 +33,14 @@ end to set-tank-vars [player? tteam txcor tycor theading] set acceleration 0.03 - set ammunition tank-max-ammo - set armor tank-max-armor + set ammunition 20 + set armor 8 set fire-cool-down 0 set friction 0.0075 set is-accelerating? false set is-player? player? + set max-ammo 24 + set max-armor 8 set max-fire-rate 7 set max-speed 0.25 set max-turn 24