@@ -62,33 +62,33 @@ to do-base-logic | |||
end | |||
to claim-base [claimer] | |||
debug who "BASE-CLAIM" (word "by " ([who] of claimer) ": " team " -> " [team] of claimer) | |||
debug who "BASE-TAKE" (word "by " ([who] of claimer) ": " team " -> " [team] of claimer) | |||
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 did-armor-refuel? false | |||
let did-ammo-refuel? false | |||
let time-since-last-refuel timer - last-refuel | |||
ask tank-to-refuel [ | |||
if armor < tank-max-armor and ([armor] of myself) > 1 and time-since-last-refuel > 25 / max-fps [ ; 25 frames | |||
set armor armor + 1 | |||
set did-armor-refuel? true | |||
] | |||
if ammunition < tank-max-ammo and ([ammunition] of myself) > 1 and time-since-last-refuel > 10 / max-fps [ ; 10 frames | |||
set ammunition ammunition + 1 | |||
set did-ammo-refuel? true | |||
] | |||
] | |||
if did-armor-refuel? or did-ammo-refuel? [ | |||
set last-refuel timer | |||
ifelse did-armor-refuel? [ | |||
set armor armor - 1 | |||
ifelse armor < tank-max-armor and ([armor] of myself) > 1 [ | |||
if time-since-last-refuel > 25 / max-fps [ ; 25 frames | |||
set armor armor + 1 | |||
ask myself [ | |||
set armor armor - 1 | |||
set last-refuel timer | |||
] | |||
] | |||
] [ | |||
set ammunition ammunition - 1 | |||
if ammunition < tank-max-ammo and ([ammunition] of myself) > 1 [ | |||
if time-since-last-refuel > 10 / max-fps [ ; 10 frames | |||
set ammunition ammunition + 1 | |||
ask myself [ | |||
set ammunition ammunition - 1 | |||
set last-refuel timer | |||
] | |||
] | |||
] | |||
] | |||
] | |||
end | |||
@@ -97,11 +97,11 @@ to regenerate | |||
let time-since-last-ammo-regen timer - last-ammo-regen | |||
let time-since-last-armor-regen timer - last-armor-regen | |||
if ammunition < base-max-ammo and time-since-last-ammo-regen > 10 [ | |||
if ammunition < base-max-ammo and time-since-last-ammo-regen > 6 [ | |||
set ammunition ammunition + 1 | |||
set last-ammo-regen timer | |||
] | |||
if armor < base-max-armor and time-since-last-armor-regen > 25 [ | |||
if armor < base-max-armor and time-since-last-armor-regen > 15 [ | |||
set armor armor + 1 | |||
set last-armor-regen timer | |||
] | |||
@@ -109,13 +109,14 @@ 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 "decay" | |||
explode "small" | |||
play-sound "shot" | |||
] [ | |||
debug who "BASE-KILL" (word "by " ([shooter] of myself)) | |||
explode "shot" | |||
explode "medium" | |||
play-sound "kill" | |||
] | |||
end | |||
@@ -4,9 +4,12 @@ | |||
breed [bullets bullet] | |||
bullets-own [ | |||
is-shooter-player? | |||
is-shooter-tank? | |||
max-travel-distance | |||
shooter | |||
speed | |||
team-of-shooter | |||
travel-distance | |||
] | |||
@@ -14,14 +17,24 @@ bullets-own [ | |||
;; Procedures | |||
;; ========== | |||
to fire-bullet | |||
to fire-bullet [dist] | |||
hatch-bullets 1 [ | |||
set max-travel-distance 8 | |||
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 | |||
@@ -34,30 +47,30 @@ end | |||
to do-bullet-logic | |||
fd speed | |||
set travel-distance travel-distance + speed | |||
if travel-distance > max-travel-distance [ | |||
explode "decay" | |||
if travel-distance >= max-travel-distance [ | |||
explode "small" | |||
die | |||
] | |||
let mxcor xcor | |||
let mycor ycor | |||
let is-close-enough false | |||
let shootable-bases-here bases-here with [armor > 0 and team != -1 and team != [team] of tank [shooter] of myself] | |||
let targets (turtle-set tanks-here shootable-bases-here) | |||
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] | |||
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 [ | |||
set is-close-enough true | |||
ifelse breed = tanks [ | |||
tank-shot-at | |||
] [ | |||
base-shot-at | |||
if breed = tanks [ tank-shot-at ] | |||
if breed = pillboxes [ pill-shot-at ] | |||
if breed = bases [ base-shot-at ] | |||
ask myself [ | |||
die | |||
] | |||
] | |||
] | |||
] | |||
if is-close-enough [ | |||
die | |||
] | |||
end |
@@ -2,7 +2,7 @@ | |||
;; (c) Ben Kurtovic, 2011 | |||
globals [ | |||
explodes | |||
explosions-table | |||
] | |||
breed [explosions explosion] | |||
@@ -19,19 +19,22 @@ explosions-own [ | |||
to make-explosions-table | |||
; Fun with particle effects! | |||
set explodes table:make | |||
table:put explodes "decay" [["explosion-decay" 0.65 10 0.5]] | |||
table:put explodes "shot" [["explosion-shot" 1.25 10 0.5]] | |||
table:put explodes "kill" [["explosion-kill" 3 20 0.5] ["explosion-shot" 1.25 15 1] | |||
["explosion-shot" 1.25 15 1 ] ["explosion-shot" 1.25 10 1] | |||
["explosion-shot" 1.25 10 1 ] ["explosion-decay" 0.65 10 2] | |||
["explosion-decay" 0.65 10 2 ] ["explosion-decay" 0.65 8 2] | |||
["explosion-decay" 0.65 7 2 ] ["explosion-decay" 0.65 5 3] | |||
["explosion-decay" 0.65 5 3 ]] | |||
set explosions-table table:make | |||
table:put explosions-table "small" [["explosion-small" 0.65 10 0.5]] | |||
table:put explosions-table "medium" [["explosion-med" 1.25 10 0.5]] | |||
table:put explosions-table "large" [["explosion-large" 2.5 15 0.5] ["explosion-med" 1.25 10 1] | |||
["explosion-med" 1.1 8 1 ] ["explosion-small" 0.65 7 2] | |||
["explosion-small" 0.65 5 3 ]] | |||
table:put explosions-table "huge" [["explosion-large" 3 20 0.5] ["explosion-med" 1.25 15 1] | |||
["explosion-med" 1.25 15 1 ] ["explosion-med" 1.25 10 1] | |||
["explosion-med" 1.25 10 1 ] ["explosion-small" 0.65 10 2] | |||
["explosion-small" 0.65 10 2 ] ["explosion-small" 0.65 8 2] | |||
["explosion-small" 0.65 7 2 ] ["explosion-small" 0.65 5 3] | |||
["explosion-small" 0.65 5 3 ]] | |||
end | |||
to explode [name] | |||
let data table:get explodes name | |||
let data table:get explosions-table name | |||
foreach data [ | |||
create-explosion ? | |||
] | |||
@@ -8,6 +8,7 @@ __includes [ | |||
"base.nls" | |||
"bullet.nls" | |||
"explosion.nls" | |||
"pillbox.nls" | |||
"player.nls" | |||
"tank.nls" | |||
] | |||
@@ -38,20 +39,22 @@ to setup | |||
spawn-player 0 0 0 | |||
spawn-tank 0 -6 0 90 | |||
spawn-tank 1 6 0 270 | |||
;spawn-base -3 -7 | |||
spawn-base 0 -7 | |||
;spawn-base 3 -7 | |||
spawn-pillbox 6 6 | |||
render | |||
set last-tick-time timer | |||
end | |||
to go | |||
ask player [ | |||
do-player-logic | |||
do-player-logic | |||
] | |||
ask tanks [ | |||
do-tank-logic | |||
] | |||
ask pillboxes [ | |||
do-pill-logic | |||
] | |||
ask bases [ | |||
do-base-logic | |||
] | |||
@@ -61,7 +64,8 @@ to go | |||
ask explosions [ | |||
keep-exploding | |||
] | |||
show-crosshair | |||
show-crosshairs | |||
show-hud | |||
render | |||
keep-time | |||
end | |||
@@ -102,14 +106,17 @@ to setup-defaults | |||
set tank-max-armor 8 | |||
set base-max-ammo 50 | |||
set base-max-armor 20 | |||
set pill-anger-range [1.2 0.2] | |||
set pill-max-armor 8 | |||
end | |||
to make-sounds-table | |||
set sounds table:make | |||
table:put sounds "fire" "Hand Clap" | |||
table:put sounds "kill" "Electric Snare" | |||
table:put sounds "noammo" "Cowbell" | |||
table:put sounds "pickup" "Hi Bongo" | |||
table:put sounds "shot" "Acoustic Snare" | |||
table:put sounds "kill" "Electric Snare" | |||
end | |||
to load-map | |||
@@ -118,7 +125,7 @@ to load-map | |||
] | |||
end | |||
to show-crosshair | |||
to show-crosshairs | |||
clear-drawing | |||
if mouse-inside? [ | |||
ask patch mouse-xcor mouse-ycor [ | |||
@@ -151,6 +158,9 @@ to draw-border [b-color b-thickness] | |||
] | |||
end | |||
to show-hud | |||
end | |||
to render | |||
display | |||
no-display | |||
@@ -359,6 +369,55 @@ C | |||
NIL | |||
NIL | |||
BUTTON | |||
109 | |||
536 | |||
368 | |||
569 | |||
NIL | |||
ask one-of bases [claim-base tank 2] | |||
NIL | |||
1 | |||
T | |||
OBSERVER | |||
NIL | |||
NIL | |||
NIL | |||
NIL | |||
MONITOR | |||
160 | |||
412 | |||
259 | |||
461 | |||
Player's Pills | |||
[number-of-pills] of player | |||
17 | |||
1 | |||
12 | |||
MONITOR | |||
261 | |||
584 | |||
357 | |||
629 | |||
Pillbox Anger | |||
[anger] of pillbox 4 | |||
6 | |||
1 | |||
11 | |||
MONITOR | |||
148 | |||
584 | |||
246 | |||
629 | |||
Pillbox Armor | |||
[armor] of pillbox 4 | |||
17 | |||
1 | |||
11 | |||
@#$#@#$#@ | |||
WHAT IS IT? | |||
----------- | |||
@@ -456,13 +515,7 @@ Rectangle -7500403 true false 165 210 195 268 | |||
Rectangle -7500403 true false 105 210 135 268 | |||
Polygon -7500403 true false 105 210 135 150 135 210 105 210 | |||
explosion-decay | |||
false | |||
0 | |||
Circle -2674135 true false 2 2 295 | |||
Circle -955883 true false 75 75 148 | |||
explosion-kill | |||
explosion-large | |||
false | |||
0 | |||
Circle -6459832 true false 2 2 297 | |||
@@ -470,13 +523,48 @@ Circle -2674135 true false 30 30 240 | |||
Circle -955883 true false 60 60 180 | |||
Circle -1184463 true false 90 90 120 | |||
explosion-shot | |||
explosion-med | |||
false | |||
0 | |||
Circle -2674135 true false 0 0 300 | |||
Circle -955883 true false 45 45 210 | |||
Circle -1184463 true false 90 90 120 | |||
explosion-small | |||
false | |||
0 | |||
Circle -2674135 true false 2 2 295 | |||
Circle -955883 true false 75 75 148 | |||
pillbox-alive | |||
false | |||
1 | |||
Polygon -2674135 true true 270 240 270 270 240 270 180 210 210 180 270 240 | |||
Rectangle -2674135 true true 225 135 300 165 | |||
Rectangle -2674135 true true 135 0 165 75 | |||
Rectangle -2674135 true true 0 135 75 165 | |||
Rectangle -2674135 true true 135 225 165 300 | |||
Polygon -2674135 true true 240 30 270 30 270 60 210 120 180 90 240 30 | |||
Polygon -2674135 true true 30 60 30 30 60 30 120 90 90 120 30 60 | |||
Polygon -2674135 true true 60 270 30 270 30 240 90 180 120 210 60 270 | |||
Circle -7500403 true false 45 45 210 | |||
pillbox-dead | |||
false | |||
1 | |||
Polygon -7500403 true false 240 30 270 30 270 60 240 90 210 60 240 30 | |||
Rectangle -7500403 true false 135 0 165 45 | |||
Rectangle -7500403 true false 0 135 45 165 | |||
Rectangle -7500403 true false 135 255 165 300 | |||
Rectangle -7500403 true false 255 135 300 165 | |||
Polygon -7500403 true false 30 60 30 30 60 30 90 60 60 90 30 60 | |||
Polygon -7500403 true false 60 270 30 270 30 240 60 210 90 240 60 270 | |||
Polygon -7500403 true false 270 240 270 270 240 270 210 240 240 210 270 240 | |||
Polygon -2674135 true true 195 165 210 180 210 180 210 210 180 210 165 195 | |||
Polygon -2674135 true true 165 105 180 90 180 90 210 90 210 120 195 135 | |||
Polygon -2674135 true true 105 135 90 120 90 120 90 90 120 90 135 105 | |||
Polygon -2674135 true true 135 195 120 210 120 210 90 210 90 180 105 165 | |||
tank | |||
true | |||
1 | |||
@@ -0,0 +1,117 @@ | |||
;; lobo: Logo Bolo | |||
;; (c) Ben Kurtovic, 2011 | |||
globals [ | |||
pill-anger-range | |||
pill-max-armor | |||
] | |||
breed [pillboxes pillbox] | |||
pillboxes-own [ | |||
alive? | |||
anger | |||
armor | |||
last-fire-time | |||
team | |||
] | |||
;; ========== | |||
;; Procedures | |||
;; ========== | |||
to spawn-pillbox [pill-xcor pill-ycor] | |||
create-pillboxes 1 [ | |||
set-pill-vars (first pill-anger-range) pill-max-armor -1 pill-xcor pill-ycor | |||
] | |||
end | |||
to set-pill-vars [p-anger p-armor p-team p-xcor p-ycor] | |||
set alive? true | |||
set anger p-anger | |||
set armor p-armor | |||
set last-fire-time timer | |||
set team p-team | |||
set color get-pill-color | |||
set shape "pillbox-alive" | |||
set size 1.1 | |||
setxy p-xcor p-ycor | |||
end | |||
to do-pill-logic | |||
set label armor | |||
ifelse alive? [ | |||
if timer - last-fire-time > anger [ | |||
let targets tanks in-radius 9 | |||
if any? targets [ | |||
let target min-one-of targets [distancexy [xcor] of myself [ycor] of myself] | |||
face target | |||
fire-bullet 9 | |||
set last-fire-time timer | |||
] | |||
] | |||
relax | |||
] [ | |||
if any? tanks-here [ | |||
pickup-pill | |||
] | |||
] | |||
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" | |||
enrage | |||
] | |||
end | |||
to relax | |||
let min-anger first pill-anger-range | |||
set anger anger + 0.00025 | |||
if anger > min-anger [ | |||
set anger min-anger | |||
] | |||
end | |||
to enrage | |||
let max-anger last pill-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 |
@@ -19,6 +19,7 @@ tanks-own [ | |||
max-fire-rate | |||
max-speed | |||
max-turn | |||
number-of-pills | |||
speed | |||
team | |||
] | |||
@@ -44,6 +45,7 @@ to set-tank-vars [player? tteam txcor tycor theading] | |||
set max-fire-rate 7 | |||
set max-speed 0.25 | |||
set max-turn 24 | |||
set number-of-pills 0 | |||
set speed 0 | |||
set team tteam | |||
@@ -95,9 +97,9 @@ end | |||
to fire | |||
if fire-cool-down = 0 [ | |||
ifelse ammunition > 0 [ | |||
debug who "TANK-FIRE" (word ammunition " left") | |||
debug who "TANK-FIRE" (word (ammunition - 1) " left") | |||
set ammunition ammunition - 1 | |||
fire-bullet | |||
fire-bullet 8 | |||
play-sound "fire" | |||
] [ | |||
play-sound "noammo" | |||
@@ -107,26 +109,26 @@ to fire | |||
end | |||
to tank-shot-at | |||
debug who "TANK-SHOT" (word "by " ([shooter] of myself)) | |||
set armor armor - 1 | |||
ifelse armor = 0 [ | |||
explode "kill" | |||
debug who "TANK-KILL" (word "by " ([shooter] of myself)) | |||
explode "huge" | |||
play-sound "kill" | |||
kill-tank | |||
] [ | |||
explode "shot" | |||
debug who "TANK-SHOT" (word "by " ([shooter] of myself)) | |||
explode "medium" | |||
play-sound "shot" | |||
] | |||
end | |||
to kill-tank | |||
debug who "TANK-KILL" (word "by " ([shooter] of myself)) | |||
if is-player? [ | |||
set player-deaths player-deaths + 1 | |||
] | |||
if [is-player?] of (turtle [shooter] of myself) [ | |||
set player-kills player-kills + 1 | |||
] | |||
if [is-shooter-player?] of myself [ | |||
set player-kills player-kills + 1 | |||
] | |||
die | |||
end | |||