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.

pillbox.nls 2.3 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 (word "pillbox-alive-" armor)
  39. set size 1.1
  40. end
  41. to do-pill-logic
  42. ifelse alive? [
  43. if timer - last-fire-time > anger [
  44. let targets tanks with [team != [team] of myself] in-radius 9
  45. if any? targets [
  46. pill-fire-at min-one-of targets [distancexy [xcor] of myself [ycor] of myself]
  47. ]
  48. ]
  49. relax
  50. ] [
  51. if any? tanks-here [
  52. pickup-pill
  53. ]
  54. ]
  55. end
  56. to pill-fire-at [target]
  57. debug who "PILL-FIRE" (word "at " [who] of target)
  58. face target
  59. play-sound "fire"
  60. fire-bullet 9
  61. set last-fire-time timer
  62. end
  63. to pill-shot-at
  64. set armor armor - 1
  65. ifelse armor = 0 [
  66. debug who "PILL-KILL" (word "by " ([shooter] of myself))
  67. explode "large"
  68. play-sound "kill"
  69. set alive? false
  70. set shape "pillbox-dead"
  71. ] [
  72. debug who "PILL-SHOT" (word "by " ([shooter] of myself))
  73. explode "medium"
  74. play-sound "shot"
  75. set shape (word "pillbox-alive-" armor)
  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