Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.3 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011-2012
  3. breed [pillboxes pillbox]
  4. pillboxes-own [
  5. alive?
  6. anger
  7. anger-range
  8. armor
  9. last-fire-time
  10. max-armor
  11. team
  12. ]
  13. ;; ==========
  14. ;; Procedures
  15. ;; ==========
  16. to spawn-pillbox [pill-xcor pill-ycor]
  17. create-pillboxes 1 [
  18. set-pill-vars -1
  19. setxy pill-xcor pill-ycor
  20. ]
  21. end
  22. to hatch-pillbox
  23. hatch 1 [
  24. debug who "PILL-PLACE" (word "by " ([who] of myself))
  25. set breed pillboxes
  26. set-pill-vars [team] of myself
  27. ]
  28. end
  29. to set-pill-vars [p-team]
  30. set alive? true
  31. set anger 1.2
  32. set anger-range [1.2 0.2]
  33. set armor 8
  34. set last-fire-time timer
  35. set max-armor 8
  36. set team p-team
  37. set color get-pill-color
  38. set shape "pillbox-alive"
  39. set size 1.1
  40. end
  41. to do-pill-logic
  42. set label armor
  43. ifelse alive? [
  44. if timer - last-fire-time > anger [
  45. let targets tanks with [team != [team] of myself] in-radius 9
  46. if any? targets [
  47. pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself]
  48. ]
  49. ]
  50. relax
  51. ] [
  52. if any? tanks-here [
  53. pickup-pill
  54. ]
  55. ]
  56. end
  57. to pill-fire-at [target]
  58. debug who "PILL-FIRE" (word "at " [who] of target)
  59. face target
  60. play-sound "fire"
  61. fire-bullet 9
  62. set last-fire-time timer
  63. end
  64. to pill-shot-at
  65. set armor armor - 1
  66. ifelse armor = 0 [
  67. debug who "PILL-KILL" (word "by " ([shooter] of myself))
  68. explode "large"
  69. play-sound "kill"
  70. set alive? false
  71. set shape "pillbox-dead"
  72. ] [
  73. debug who "PILL-SHOT" (word "by " ([shooter] of myself))
  74. explode "medium"
  75. play-sound "shot"
  76. enrage
  77. ]
  78. end
  79. to relax
  80. let min-anger first anger-range
  81. set anger anger + 0.00025
  82. if anger > min-anger [
  83. set anger min-anger
  84. ]
  85. end
  86. to enrage
  87. let max-anger last anger-range
  88. set anger anger - 0.2
  89. if anger < max-anger [
  90. set anger max-anger
  91. ]
  92. end
  93. to pickup-pill
  94. ask one-of tanks-here [
  95. debug ([who] of myself) "PILL-TAKE" (word "by " who)
  96. set number-of-pills number-of-pills + 1
  97. ]
  98. play-sound "pickup"
  99. die
  100. end
  101. ;; =========
  102. ;; Reporters
  103. ;; =========
  104. to-report get-pill-afiliation
  105. if team = -1 [ report "neutral" ]
  106. if team = 0 [ report "ally" ]
  107. report "enemy"
  108. end
  109. to-report get-pill-color
  110. let affiliation get-base-afiliation
  111. if affiliation = "ally" [ report green ]
  112. report red
  113. end