Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

139 Zeilen
3.0 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  3. globals [
  4. base-max-ammo
  5. base-max-armor
  6. ]
  7. breed [bases base]
  8. bases-own [
  9. ammunition
  10. armor
  11. last-ammo-regen
  12. last-armor-regen
  13. last-refuel
  14. team
  15. ]
  16. ;; ==========
  17. ;; Procedures
  18. ;; ==========
  19. to spawn-base [base-xcor base-ycor]
  20. create-bases 1 [
  21. set-base-vars base-max-ammo base-max-armor -1 base-xcor base-ycor
  22. ]
  23. end
  24. to set-base-vars [b-ammo b-armor b-team b-xcor b-ycor]
  25. set ammunition b-ammo
  26. set armor b-armor
  27. set team b-team
  28. set last-ammo-regen timer
  29. set last-armor-regen timer
  30. set last-refuel timer
  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-CLAIM" (word "by " ([who] of claimer) ": " team " -> " [team] of claimer)
  57. set team [team] of claimer
  58. set color get-base-color
  59. end
  60. to refuel-tank [tank-to-refuel]
  61. let did-armor-refuel? false
  62. let did-ammo-refuel? false
  63. let time-since-last-refuel timer - last-refuel
  64. ask tank-to-refuel [
  65. if armor < tank-max-armor and ([armor] of myself) > 1 and time-since-last-refuel > 25 / max-fps [ ; 25 frames
  66. set armor armor + 1
  67. set did-armor-refuel? true
  68. ]
  69. if ammunition < tank-max-ammo and ([ammunition] of myself) > 1 and time-since-last-refuel > 10 / max-fps [ ; 10 frames
  70. set ammunition ammunition + 1
  71. set did-ammo-refuel? true
  72. ]
  73. ]
  74. if did-armor-refuel? or did-ammo-refuel? [
  75. set last-refuel timer
  76. ifelse did-armor-refuel? [
  77. set armor armor - 1
  78. ] [
  79. set ammunition ammunition - 1
  80. ]
  81. ]
  82. end
  83. to regenerate
  84. let time-since-last-ammo-regen timer - last-ammo-regen
  85. let time-since-last-armor-regen timer - last-armor-regen
  86. if ammunition < base-max-ammo and time-since-last-ammo-regen > 10 [
  87. set ammunition ammunition + 1
  88. set last-ammo-regen timer
  89. ]
  90. if armor < base-max-armor and time-since-last-armor-regen > 25 [
  91. set armor armor + 1
  92. set last-armor-regen timer
  93. ]
  94. end
  95. to base-shot-at
  96. set armor armor - 1
  97. ifelse armor > 0 [
  98. debug who "BASE-SHOT" (word "by " ([shooter] of myself))
  99. explode "decay"
  100. play-sound "shot"
  101. ] [
  102. debug who "BASE-KILL" (word "by " ([shooter] of myself))
  103. explode "shot"
  104. play-sound "kill"
  105. ]
  106. end
  107. ;; =========
  108. ;; Reporters
  109. ;; =========
  110. to-report get-base-afiliation
  111. if team = -1 [ report "neutral" ]
  112. if team = 0 [ report "ally" ]
  113. report "enemy"
  114. end
  115. to-report get-base-color
  116. let affiliation get-base-afiliation
  117. if affiliation = "neutral" [ report gray ]
  118. if affiliation = "ally" [ report green ]
  119. if affiliation = "enemy" [ report red ]
  120. end