;; lobo: Logo Bolo ;; (c) Ben Kurtovic, 2011-2012 breed [bases base] bases-own [ ammunition armor last-ammo-regen last-armor-regen last-refuel max-ammo max-armor team ] ;; ========== ;; Procedures ;; ========== to spawn-base sprout-bases 1 [ set-base-vars 50 20 -1 ] end to set-base-vars [b-ammo b-armor b-team] set ammunition b-ammo set armor b-armor 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" set size 1.15 end to do-base-logic ifelse team = -1 [ if any? tanks-here [ claim-base one-of tanks-here ] ] [ let allies-here tanks-here with [team = ([team] of myself)] let enemies-here tanks-here with [team != ([team] of myself)] if any? allies-here [ refuel-tank one-of allies-here ] if any? enemies-here and armor = 0 [ claim-base one-of enemies-here set armor 1 ] ] regenerate end to claim-base [claimer] debug who "BASE-TAKE" (word "by " ([who] of claimer) ": " team " -> " [team] of claimer) play-sound "pickup" set team [team] of claimer set color get-base-color set last-armor-regen timer ; Don't regenerate armor right after being claimed end to refuel-tank [tank-to-refuel] let time-since-last-refuel timer - last-refuel ask tank-to-refuel [ ifelse armor < max-armor and ([armor] of myself) > 1 [ if time-since-last-refuel > 20 / max-fps [ ; 20 frames set armor armor + 1 ask myself [ set armor armor - 1 set last-refuel timer ] ] ] [ if ammunition < max-ammo and ([ammunition] of myself) > 1 [ if time-since-last-refuel > 8 / max-fps [ ; 8 frames set ammunition ammunition + 1 ask myself [ set ammunition ammunition - 1 set last-refuel timer ] ] ] ] ] end to regenerate let time-since-last-ammo-regen timer - last-ammo-regen let time-since-last-armor-regen timer - last-armor-regen if ammunition < max-ammo and time-since-last-ammo-regen > 4 [ set ammunition ammunition + 1 set last-ammo-regen timer ] if armor < max-armor and time-since-last-armor-regen > 10 [ set armor armor + 1 set last-armor-regen timer ] end to base-shot-at set armor armor - 1 set last-armor-regen timer ; Don't regenerate armor right after being shot ifelse armor > 0 [ debug who "BASE-SHOT" (word "by " ([shooter] of myself)) explode "small" play-sound "shot" ] [ debug who "BASE-KILL" (word "by " ([shooter] of myself)) explode "medium" play-sound "kill" ] end ;; ========= ;; Reporters ;; ========= to-report get-base-afiliation if team = -1 [ report "neutral" ] if team = 0 [ report "ally" ] report "enemy" end to-report get-base-color let affiliation get-base-afiliation if affiliation = "neutral" [ report gray ] if affiliation = "ally" [ report green ] if affiliation = "enemy" [ report red ] end