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.

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