Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

138 lignes
3.0 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011-2012
  3. breed [bases base]
  4. bases-own [
  5. ammunition
  6. armor
  7. last-ammo-regen
  8. last-armor-regen
  9. last-refuel
  10. max-ammo
  11. max-armor
  12. team
  13. ]
  14. ;; ==========
  15. ;; Procedures
  16. ;; ==========
  17. to spawn-base
  18. sprout-bases 1 [
  19. set-base-vars 50 20 -1
  20. ]
  21. end
  22. to set-base-vars [b-ammo b-armor b-team]
  23. set ammunition b-ammo
  24. set armor b-armor
  25. set last-ammo-regen timer
  26. set last-armor-regen timer
  27. set last-refuel timer
  28. set max-ammo b-armor
  29. set max-armor b-armor
  30. set team b-team
  31. set color get-base-color
  32. set shape "base"
  33. set size 1.15
  34. end
  35. to do-base-logic
  36. ifelse team = -1 [
  37. if any? tanks-here [
  38. claim-base one-of tanks-here
  39. ]
  40. ] [
  41. let allies-here tanks-here with [team = ([team] of myself)]
  42. let enemies-here tanks-here with [team != ([team] of myself)]
  43. if any? allies-here [
  44. refuel-tank one-of allies-here
  45. ]
  46. if any? enemies-here and armor = 0 [
  47. claim-base one-of enemies-here
  48. set armor 1
  49. ]
  50. ]
  51. regenerate
  52. end
  53. to claim-base [claimer]
  54. debug who "BASE-TAKE" (word "by " ([who] of claimer) ": " team " -> " [team] of claimer)
  55. play-sound "pickup"
  56. set team [team] of claimer
  57. set color get-base-color
  58. set last-armor-regen timer ; Don't regenerate armor right after being claimed
  59. end
  60. to refuel-tank [tank-to-refuel]
  61. let time-since-last-refuel timer - last-refuel
  62. ask tank-to-refuel [
  63. ifelse armor < max-armor and ([armor] of myself) > 1 [
  64. if time-since-last-refuel > 20 / max-fps [ ; 20 frames
  65. set armor armor + 1
  66. ask myself [
  67. set armor armor - 1
  68. set last-refuel timer
  69. ]
  70. ]
  71. ] [
  72. if ammunition < max-ammo and ([ammunition] of myself) > 1 [
  73. if time-since-last-refuel > 8 / max-fps [ ; 8 frames
  74. set ammunition ammunition + 1
  75. ask myself [
  76. set ammunition ammunition - 1
  77. set last-refuel timer
  78. ]
  79. ]
  80. ]
  81. ]
  82. ]
  83. end
  84. to regenerate
  85. let time-since-last-ammo-regen timer - last-ammo-regen
  86. let time-since-last-armor-regen timer - last-armor-regen
  87. if ammunition < max-ammo and time-since-last-ammo-regen > 4 [
  88. set ammunition ammunition + 1
  89. set last-ammo-regen timer
  90. ]
  91. if armor < max-armor and time-since-last-armor-regen > 10 [
  92. set armor armor + 1
  93. set last-armor-regen timer
  94. ]
  95. end
  96. to base-shot-at
  97. set armor armor - 1
  98. set last-armor-regen timer ; Don't regenerate armor right after being shot
  99. ifelse armor > 0 [
  100. debug who "BASE-SHOT" (word "by " ([shooter] of myself))
  101. explode "small"
  102. play-sound "shot"
  103. ] [
  104. debug who "BASE-KILL" (word "by " ([shooter] of myself))
  105. explode "medium"
  106. play-sound "kill"
  107. ]
  108. end
  109. ;; =========
  110. ;; Reporters
  111. ;; =========
  112. to-report get-base-afiliation
  113. if team = -1 [ report "neutral" ]
  114. if team = 0 [ report "ally" ]
  115. report "enemy"
  116. end
  117. to-report get-base-color
  118. let affiliation get-base-afiliation
  119. if affiliation = "neutral" [ report gray ]
  120. if affiliation = "ally" [ report green ]
  121. if affiliation = "enemy" [ report red ]
  122. end