;; 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 20 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 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 hatch-bullets 1 [ set max-travel-distance 8 set shooter [who] of myself set speed 1 set travel-distance 0 set color white set shape "bullet" set size 0.5 lt random 10 ; Bullets shouldn't travel perfectly straight rt random 10 ] play-sound "fire" ] end to shot-at [bullet] debug "SHOT" (word who " by " ([shooter] of myself)) set armor armor - 1 ifelse armor = 0 [ debug "KILL" (word who " by " ([shooter] of myself)) play-sound "kill" die ] [ play-sound "shot" ] 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