;; lobo: Logo Bolo ;; (c) Ben Kurtovic, 2011-2012 breed [tanks tank] tanks-own [ acceleration ammunition armor fire-cool-down friction is-accelerating? is-player? max-ammo max-armor max-fire-rate max-speed max-turn number-of-pills speed team ] ;; ========== ;; Procedures ;; ========== to spawn-tank [tank-team tank-xcor tank-ycor tank-heading] create-tanks 1 [ set-tank-vars false tank-team tank-xcor tank-ycor tank-heading ] end to set-tank-vars [player? tteam txcor tycor theading] set acceleration 0.03 set ammunition 4 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 set number-of-pills 0 set speed 0 set team tteam set color get-tank-color set heading theading set shape "tank" set size 1.5 setxy txcor tycor end to do-tank-logic if is-accelerating? [ accelerate acceleration ] fd speed * ground-friction decelerate friction if fire-cool-down > 0 [ set fire-cool-down fire-cool-down - 1 ] end to accelerate [amount] set speed speed + amount if speed > max-speed [ set speed max-speed ] end to decelerate [amount] set speed speed - amount if speed < 0 [ set speed 0 ] end to tank-facexy [txcor tycor] ;; Face a target at (txcor, tycor) like facexy, but don't ;; turn more than our max turn rate (max-turn¡): let old-heading heading facexy txcor tycor if subtract-headings old-heading heading > max-turn [ set heading old-heading - max-turn ] if subtract-headings old-heading heading < 0 - max-turn [ set heading old-heading + max-turn ] end to fire if fire-cool-down = 0 [ ifelse ammunition > 0 [ debug who "TANK-FIRE" (word (ammunition - 1) " left") set ammunition ammunition - 1 fire-bullet 5 play-sound "fire" ] [ play-sound "noammo" ] set fire-cool-down max-fire-rate ] end to tank-shot-at set armor armor - 1 ifelse armor = 0 [ debug who "TANK-KILL" (word "by " ([shooter] of myself)) explode "huge" play-sound "kill" kill-tank ] [ debug who "TANK-SHOT" (word "by " ([shooter] of myself)) explode "medium" play-sound "shot" ] end to kill-tank if is-player? [ set player-death-time timer set player-deaths player-deaths + 1 ] if [is-shooter-player?] of myself [ set player-kills player-kills + 1 ] die end to place-pill ifelse number-of-pills > 0 and count bases-here = 0 [ set number-of-pills number-of-pills - 1 hatch-pillbox play-sound "place" ] [ play-sound "nopill" ] end ;; ========= ;; Reporters ;; ========= to-report get-tank-affiliation if is-player? [ report "player" ] if team = 0 [ report "ally" ] report "enemy" end to-report get-tank-color let affiliation get-tank-affiliation if affiliation = "player" [ report black ] if affiliation = "ally" [ report green ] if affiliation = "enemy" [ report red ] end