Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

130 linhas
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
  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. setxy pxcor pycor
  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 7
  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 7
  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