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.

140 lines
3.1 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 [base-xcor base-ycor]
  18. create-bases 1 [
  19. set-base-vars 50 20 -1 base-xcor base-ycor
  20. ]
  21. end
  22. to set-base-vars [b-ammo b-armor b-team b-xcor b-ycor]
  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. setxy b-xcor b-ycor
  35. end
  36. to do-base-logic
  37. ifelse team = -1 [
  38. if any? tanks-here [
  39. claim-base one-of tanks-here
  40. ]
  41. ] [
  42. let allies-here tanks-here with [team = ([team] of myself)]
  43. let enemies-here tanks-here with [team != ([team] of myself)]
  44. if any? allies-here [
  45. refuel-tank one-of allies-here
  46. ]
  47. if any? enemies-here and armor = 0 [
  48. claim-base one-of enemies-here
  49. set armor 1
  50. ]
  51. ]
  52. regenerate
  53. set label armor
  54. end
  55. to claim-base [claimer]
  56. debug who "BASE-TAKE" (word "by " ([who] of claimer) ": " team " -> " [team] of claimer)
  57. play-sound "pickup"
  58. set team [team] of claimer
  59. set color get-base-color
  60. set last-armor-regen timer ; Don't regenerate armor right after being claimed
  61. end
  62. to refuel-tank [tank-to-refuel]
  63. let time-since-last-refuel timer - last-refuel
  64. ask tank-to-refuel [
  65. ifelse armor < max-armor and ([armor] of myself) > 1 [
  66. if time-since-last-refuel > 25 / max-fps [ ; 25 frames
  67. set armor armor + 1
  68. ask myself [
  69. set armor armor - 1
  70. set last-refuel timer
  71. ]
  72. ]
  73. ] [
  74. if ammunition < max-ammo and ([ammunition] of myself) > 1 [
  75. if time-since-last-refuel > 10 / max-fps [ ; 10 frames
  76. set ammunition ammunition + 1
  77. ask myself [
  78. set ammunition ammunition - 1
  79. set last-refuel timer
  80. ]
  81. ]
  82. ]
  83. ]
  84. ]
  85. end
  86. to regenerate
  87. let time-since-last-ammo-regen timer - last-ammo-regen
  88. let time-since-last-armor-regen timer - last-armor-regen
  89. if ammunition < max-ammo and time-since-last-ammo-regen > 6 [
  90. set ammunition ammunition + 1
  91. set last-ammo-regen timer
  92. ]
  93. if armor < max-armor and time-since-last-armor-regen > 15 [
  94. set armor armor + 1
  95. set last-armor-regen timer
  96. ]
  97. end
  98. to base-shot-at
  99. set armor armor - 1
  100. set last-armor-regen timer ; Don't regenerate armor right after being shot
  101. ifelse armor > 0 [
  102. debug who "BASE-SHOT" (word "by " ([shooter] of myself))
  103. explode "small"
  104. play-sound "shot"
  105. ] [
  106. debug who "BASE-KILL" (word "by " ([shooter] of myself))
  107. explode "medium"
  108. play-sound "kill"
  109. ]
  110. end
  111. ;; =========
  112. ;; Reporters
  113. ;; =========
  114. to-report get-base-afiliation
  115. if team = -1 [ report "neutral" ]
  116. if team = 0 [ report "ally" ]
  117. report "enemy"
  118. end
  119. to-report get-base-color
  120. let affiliation get-base-afiliation
  121. if affiliation = "neutral" [ report gray ]
  122. if affiliation = "ally" [ report green ]
  123. if affiliation = "enemy" [ report red ]
  124. end