pewax

Minecraft Tower Defence 0.1

Apr 20th, 2016
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. #
  2. # Tower Defence game in minecraft!
  3. #
  4.  
  5. variables:
  6. {castlehealth} = 10
  7. {score} = 0
  8. {start} = false
  9. {wavenumber} = 1
  10. {wavemobs} = 8
  11. {gold.%player%} = 30
  12.  
  13. # This is where the commands for tower defence will be kept!
  14.  
  15. # This command sets the end for the zombies to go to!
  16. command /tdend:
  17. trigger:
  18. set {end} to location of player
  19. message "&aYou have set the end zone for the zombies!"
  20.  
  21. # This command sets the spawn for the zombies!
  22. command /tdspawn:
  23. trigger:
  24. set {spawn} to location of player
  25. message "&aYou have set the spawn for the zombies!"
  26.  
  27. # This command is a test command for spawning zombies!
  28. command /zspawn:
  29. trigger:
  30. if {spawn} is not set:
  31. message "&4You have not set a spawn location &a(/tdspawn)"
  32. set {zombie} to a zombie
  33. spawn a zombie at {spawn}
  34.  
  35. # Resets the tower defence map!
  36. command /tdreset:
  37. trigger:
  38. make console execute "/bc The game is resetting!"
  39. make console execute "/tdresettowers"
  40. kill all zombies
  41. set {castlehealth} to 10
  42. set {wave} to false
  43. set {wavenumber} to 1
  44. clear {wavemobs::*}
  45.  
  46. # Starts a new game!
  47. command /tdstart:
  48. trigger:
  49. set {wave} to true
  50. set {wavenumber} to 1
  51. make console execute "/bc A new a game has started there is a 30 second waiting period!"
  52. make console execute "/bc Tip: use &6/gold &ato see your in game cash!"
  53. loop 8 times:
  54. add {zombie} to {wavemobs::*}
  55.  
  56. command /gold:
  57. trigger:
  58. send "&aYou have &6%{gold.%player%}% &agold!"
  59.  
  60. # This tests for if a zombie has reached the end! (test command)
  61. command /tdendtest:
  62. trigger:
  63. if {zombie} is set:
  64. message "&4You have lost a life!"
  65. kill {zombie}
  66.  
  67. command /testthings:
  68. trigger:
  69. send "%{tower::*}% ==="
  70. delete {tower::*}
  71.  
  72. # -------------------------------------------------------------------------------
  73.  
  74. # This is where the towers are!
  75.  
  76. # Tower 1's Spawning
  77. on right click with stick:
  78. clicked block is obsidian:
  79. if {gold.%player%} >= 10:
  80. subtract 10 from {gold.%player%}
  81. add location of clicked block to {tower::*}
  82. set {tower} to clicked block
  83. set block above clicked block to wool
  84. add location of block above clicked block to {towerdelete::*}
  85.  
  86. # Tower 1's Attack
  87. every 1 second:
  88. loop all entities:
  89. loop {tower::*}:
  90. set {_range} to the distance between the location at loop-value and location at loop-entity
  91. if {_range} <= 10:
  92. wait 1 second
  93. damage loop-entity by 5 hearts
  94.  
  95. # -------------------------------------------------------------------------------
  96.  
  97. # This is where the life system is!
  98.  
  99. every second:
  100. loop all entities:
  101. loop-entity is a zombie:
  102. set {_life} to the distance between the location at {end} and location at loop-entity
  103. if {_life} <= 3:
  104. damage loop-entity by 100 hearts
  105. {command.lastused} was less than 1.5 seconds ago:
  106. stop
  107. set {command.lastused} to now
  108. make console execute "/lifelost"
  109.  
  110. command /lifelost:
  111. trigger:
  112. if {wave} = true:
  113. subtract 1 from {castlehealth}
  114. make console execute "/bc &4You have &a%{castlehealth}% &4lives remainaing!"
  115. else:
  116. kill all zombies
  117.  
  118. every second:
  119. if {castlehealth} <= 0:
  120. set {castlehealth} to 10
  121. make console execute "/tdreset"
  122. make console execute "/bc &4You have died on wave &a%{wavenumber}%&4!"
  123.  
  124. # -------------------------------------------------------------------------------
  125.  
  126. # This is where the waves of zombies will be!
  127.  
  128. every 30 seconds:
  129. if {wave} is true:
  130. make console execute "/bc &4Wave &a%{wavenumber}% &4has started!"
  131. make console execute "/bc &aAll players have received 20 gold!"
  132. add 1 to {wavenumber}
  133. loop {wavemobs::*}:
  134. spawn loop-value at {spawn}
  135. wait 2 seconds
  136. add {zombie} to {wavemobs::*}
  137. add {zombie} to {wavemobs::*}
  138.  
  139. # --------------------------------------------------------------------------------
  140.  
  141. # This is the path finding!
  142.  
  143. every tick:
  144. if {wave} = true:
  145. loop all entities:
  146. loop-entity is a zombie:
  147. make loop-entity pathfind to {end} with speed 1
  148.  
  149. # --------------------------------------------------------------------------------
  150.  
  151. # This is where the towers will be deleted!
  152.  
  153. command /tdresettowers:
  154. trigger:
  155. if {wave} is false:
  156. clear {tower::*}
  157. loop {towerdelete::*}:
  158. set block at loop-value to air
Advertisement
Add Comment
Please, Sign In to add comment