Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # Tower Defence game in minecraft!
- #
- variables:
- {castlehealth} = 10
- {score} = 0
- {start} = false
- {wavenumber} = 1
- {wavemobs} = 8
- {gold.%player%} = 30
- # This is where the commands for tower defence will be kept!
- # This command sets the end for the zombies to go to!
- command /tdend:
- trigger:
- set {end} to location of player
- message "&aYou have set the end zone for the zombies!"
- # This command sets the spawn for the zombies!
- command /tdspawn:
- trigger:
- set {spawn} to location of player
- message "&aYou have set the spawn for the zombies!"
- # This command is a test command for spawning zombies!
- command /zspawn:
- trigger:
- if {spawn} is not set:
- message "&4You have not set a spawn location &a(/tdspawn)"
- set {zombie} to a zombie
- spawn a zombie at {spawn}
- # Resets the tower defence map!
- command /tdreset:
- trigger:
- make console execute "/bc The game is resetting!"
- make console execute "/tdresettowers"
- kill all zombies
- set {castlehealth} to 10
- set {wave} to false
- set {wavenumber} to 1
- clear {wavemobs::*}
- # Starts a new game!
- command /tdstart:
- trigger:
- set {wave} to true
- set {wavenumber} to 1
- make console execute "/bc A new a game has started there is a 30 second waiting period!"
- make console execute "/bc Tip: use &6/gold &ato see your in game cash!"
- loop 8 times:
- add {zombie} to {wavemobs::*}
- command /gold:
- trigger:
- send "&aYou have &6%{gold.%player%}% &agold!"
- # This tests for if a zombie has reached the end! (test command)
- command /tdendtest:
- trigger:
- if {zombie} is set:
- message "&4You have lost a life!"
- kill {zombie}
- command /testthings:
- trigger:
- send "%{tower::*}% ==="
- delete {tower::*}
- # -------------------------------------------------------------------------------
- # This is where the towers are!
- # Tower 1's Spawning
- on right click with stick:
- clicked block is obsidian:
- if {gold.%player%} >= 10:
- subtract 10 from {gold.%player%}
- add location of clicked block to {tower::*}
- set {tower} to clicked block
- set block above clicked block to wool
- add location of block above clicked block to {towerdelete::*}
- # Tower 1's Attack
- every 1 second:
- loop all entities:
- loop {tower::*}:
- set {_range} to the distance between the location at loop-value and location at loop-entity
- if {_range} <= 10:
- wait 1 second
- damage loop-entity by 5 hearts
- # -------------------------------------------------------------------------------
- # This is where the life system is!
- every second:
- loop all entities:
- loop-entity is a zombie:
- set {_life} to the distance between the location at {end} and location at loop-entity
- if {_life} <= 3:
- damage loop-entity by 100 hearts
- {command.lastused} was less than 1.5 seconds ago:
- stop
- set {command.lastused} to now
- make console execute "/lifelost"
- command /lifelost:
- trigger:
- if {wave} = true:
- subtract 1 from {castlehealth}
- make console execute "/bc &4You have &a%{castlehealth}% &4lives remainaing!"
- else:
- kill all zombies
- every second:
- if {castlehealth} <= 0:
- set {castlehealth} to 10
- make console execute "/tdreset"
- make console execute "/bc &4You have died on wave &a%{wavenumber}%&4!"
- # -------------------------------------------------------------------------------
- # This is where the waves of zombies will be!
- every 30 seconds:
- if {wave} is true:
- make console execute "/bc &4Wave &a%{wavenumber}% &4has started!"
- make console execute "/bc &aAll players have received 20 gold!"
- add 1 to {wavenumber}
- loop {wavemobs::*}:
- spawn loop-value at {spawn}
- wait 2 seconds
- add {zombie} to {wavemobs::*}
- add {zombie} to {wavemobs::*}
- # --------------------------------------------------------------------------------
- # This is the path finding!
- every tick:
- if {wave} = true:
- loop all entities:
- loop-entity is a zombie:
- make loop-entity pathfind to {end} with speed 1
- # --------------------------------------------------------------------------------
- # This is where the towers will be deleted!
- command /tdresettowers:
- trigger:
- if {wave} is false:
- clear {tower::*}
- loop {towerdelete::*}:
- set block at loop-value to air
Advertisement
Add Comment
Please, Sign In to add comment