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.

118 rivejä
2.1 KiB

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