|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- ;; lobo: Logo Bolo
- ;; (c) Ben Kurtovic, 2011-2012
-
- breed [bullets bullet]
-
- bullets-own [
- is-shooter-player?
- is-shooter-tank?
- max-travel-distance
- shooter
- speed
- team-of-shooter
- travel-distance
- ]
-
- ;; ==========
- ;; Procedures
- ;; ==========
-
- to fire-bullet [dist]
- hatch-bullets 1 [
- set max-travel-distance dist
- set is-shooter-player? false
- set is-shooter-tank? false
- if [breed] of myself = tanks [
- if [is-player?] of myself [
- set is-shooter-player? true
- ]
- set is-shooter-tank? true
- ]
- set shooter [who] of myself
- set speed 1
- set team-of-shooter [team] of myself
- set travel-distance 0
-
- set color white
- set label ""
- set shape "bullet"
- set size 0.5
-
- ; Bullets shouldn't travel perfectly straight:
- lt random 5
- rt random 5
- ]
- end
-
- to do-bullet-logic
- fd speed
- set travel-distance travel-distance + speed
- if travel-distance >= max-travel-distance [
- explode "small"
- die
- ]
-
- let mxcor xcor
- let mycor ycor
- let shootable-pills-here pillboxes-here with [alive? = true]
- let targets (turtle-set tanks-here shootable-pills-here)
- if is-shooter-tank? [ ; Only tanks can shoot at bases
- let shootable-bases-here bases-here with [armor > 0 and team != -1 and team != [team-of-shooter] of myself]
- set targets (turtle-set targets shootable-bases-here)
- ]
- let target min-one-of targets [distancexy mxcor mycor]
- if target != nobody [
- ask target [
- if distancexy mxcor mycor < 0.65 [
- if breed = tanks [ tank-shot-at ]
- if breed = pillboxes [ pill-shot-at ]
- if breed = bases [ base-shot-at ]
- ask myself [
- die
- ]
- ]
- ]
- ]
- end
|