;; lobo: Logo Bolo ;; (c) Ben Kurtovic, 2011 breed [tanks tank] tanks-own [ acceleration ammunition armor fire-cool-down friction is-accelerating? is-player? max-fire-rate max-speed max-turn speed team ] to spawn-tank [tank-team] create-tanks 1 [ set-tank-vars tank-team false ] end to set-tank-vars [tank-team player-tank?] set acceleration 0.03 set ammunition 24 set armor 8 set fire-cool-down 0 set friction 0.0075 set is-accelerating? false set is-player? player-tank? set max-fire-rate 7 set max-speed 0.25 set max-turn 24 set speed 0 set team tank-team set color get-tank-color set heading 0 set shape "tank" set size 1.5 end to do-tank-logic if is-accelerating? [ accelerate acceleration ] fd speed 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 ammunition > 0 and fire-cool-down = 0 [ debug "FIRE" (word who " (" ammunition " left)") set ammunition ammunition - 1 set fire-cool-down max-fire-rate fire-bullet play-sound "fire" ] end to shot-at debug "SHOT" (word who " by " ([shooter] of myself)) set armor armor - 1 ifelse armor = 0 [ kill-tank ] [ play-sound (word "shot " get-tank-affiliation) ] end to kill-tank debug "KILL" (word who " by " ([shooter] of myself)) play-sound (word "kill " get-tank-affiliation) if is-player? [ set player-deaths player-deaths + 1 ] if [is-player?] of (turtle [shooter] of myself) [ set player-kills player-kills + 1 ] die end 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