|
- ;; lobo: Logo Bolo
- ;; (c) Ben Kurtovic, 2011-2012
-
- breed [pillboxes pillbox]
-
- pillboxes-own [
- alive?
- anger
- anger-range
- armor
- last-fire-time
- max-armor
- team
- ]
-
- ;; ==========
- ;; Procedures
- ;; ==========
-
- to spawn-pillbox [pill-xcor pill-ycor]
- create-pillboxes 1 [
- set-pill-vars -1
- setxy pill-xcor pill-ycor
- ]
- end
-
- to hatch-pillbox
- hatch 1 [
- debug who "PILL-PLACE" (word "by " ([who] of myself))
- set breed pillboxes
- set-pill-vars [team] of myself
- ]
- end
-
- to set-pill-vars [p-team]
- set alive? true
- 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 (word "pillbox-alive-" armor)
- set size 1.1
- end
-
- to do-pill-logic
- ifelse alive? [
- if timer - last-fire-time > anger [
- let targets tanks with [team != [team] of myself] in-radius 9
- if any? targets [
- pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself]
- ]
- ]
- relax
- ] [
- if any? tanks-here [
- pickup-pill
- ]
- ]
- 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 [
- debug who "PILL-KILL" (word "by " ([shooter] of myself))
- explode "large"
- play-sound "kill"
- set alive? false
- set shape "pillbox-dead"
- ] [
- debug who "PILL-SHOT" (word "by " ([shooter] of myself))
- explode "medium"
- play-sound "shot"
- set shape (word "pillbox-alive-" armor)
- enrage
- ]
- end
-
- to relax
- let min-anger first anger-range
- set anger anger + 0.00025
- if anger > min-anger [
- set anger min-anger
- ]
- end
-
- to enrage
- let max-anger last anger-range
- set anger anger - 0.2
- if anger < max-anger [
- set anger max-anger
- ]
- end
-
- to pickup-pill
- ask one-of tanks-here [
- debug ([who] of myself) "PILL-TAKE" (word "by " who)
- set number-of-pills number-of-pills + 1
- ]
- play-sound "pickup"
- die
- end
-
- ;; =========
- ;; Reporters
- ;; =========
-
- to-report get-pill-afiliation
- if team = -1 [ report "neutral" ]
- if team = 0 [ report "ally" ]
- report "enemy"
- end
-
- to-report get-pill-color
- let affiliation get-base-afiliation
- if affiliation = "ally" [ report green ]
- report red
- end
|