Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # objective horseRide = stat.horseOneCm
- # objective driveTime = how long the car has been in motion
- # objective idleTime = how long the car has been idling
- # objective uniCount = universal counter for using /execute to check amount of certain entities
- # objective checkObCount = amount of times the checkingObstacles loop has run
- # objective obs_valid_loc = 1 if check_obs armorstand is in an intersection, otherwise 0
- # objective car_damage = car damage
- # objective points = Player's score in the game
- # objective powerup = Time until powerup runs out (0 if player doesn't have powerup)
- # objective eventTimer = Does a random event every 400 ticks
- # objective money_bags = how many money bags the player has picked up
- function reset() {
- removeOld()
- scoreboard players tag @a remove alreadyBegun
- scoreboard players tag @a remove game_over
- scoreboard players tag @a remove isLoading
- scoreboard players tag @a remove isPlaying
- scoreboard players tag @a remove failed_objective
- scoreboard players tag @a remove winner
- scoreboard players set @a policeNum -1
- scoreboard players set @a car_damage 0
- scoreboard players set @a eventTimer -1
- scoreboard players set @a points 0
- scoreboard players set @e[tag=car] powerup 0
- scoreboard players tag @e[tag=toll_3] remove toll_1
- scoreboard players tag @e[tag=toll_3] remove toll_2
- scoreboard players set @a money_bags 0
- scoreboard players tag @a remove unlockedTolls
- scoreboard players tag @a remove criticalmessage
- tp @e[tag=car_model] @e[tag=car]
- stopAllEvents()
- stop forceCar
- stop driveCar
- stop checkForStart
- stop carSelect
- stop openGarageDoor
- stop generateObstacles
- stop checkingObstacles
- stop gameplay
- setup()
- }
- # In case these somehow get destroyed
- # summon armor_stand ~ ~ ~ {Tags:["car_model"],NoGravity:1,ArmorItems:[{},{},{},{id:diamond_hoe,Count:1,Damage:1}],Invisible:1}
- # summon horse ~ ~ ~ {Tags:["car"],Attributes:[{Name:"generic.movementSpeed",Base:0.1f},{Name:"horse.jumpStrength",Base:0f}],Tame:1,SaddleItem:{id:saddle,Count:1},Silent:1,Invisible:1}
- function removeOld() {
- # Remove old entities
- # Don't leave behind extra barriers
- execute @e[tag=NPCCar] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~1 ~1 air 0 replace barrier
- kill @e[tag=NPCCar]
- kill @e[tag=police_car_part]
- kill @e[tag=tank_part]
- tp @e[tag=target_sheep] ~ ~-1000 ~
- kill @e[type=item]
- kill @e[tag=powerup_part]
- kill @e[tag=meteor]
- }
- function criticalDamageMessage() {
- scoreboard players tag @a add criticalmessage
- execute @a ~ ~ ~ playsound critical_damage neutral @a ~ ~ ~ 10
- start criticalDamageMessageRepeat
- delay 100 {
- stop criticalDamageMessageRepeat
- }
- }
- repeat criticalDamageMessageRepeat:off {
- title @a actionbar ["",{"text":"!","bold":true,"color":"gold"},{"text":"!","bold":true,"color":"black"},{"text":"!","bold":true,"color":"gold"},{"text":"!","bold":true,"color":"black"},{"text":" ","bold":true},{"text":"Car Damage Critical","bold":true,"color":"dark_red"},{"text":" ","bold":true},{"text":"!","bold":true,"color":"gold"},{"text":"!","bold":true,"color":"black"},{"text":"!","bold":true,"color":"gold"},{"text":"!","bold":true,"color":"black"}]
- }
- function helpScreen() {
- tp @a 1034 9 974.35 180 90
- start helpScreenTp
- title @a actionbar {"text":""}
- execute @a ~ ~ ~ playsound help neutral @a ~ ~ ~ 10
- effect @a invisibility 100000 1 true
- delay 1 {
- entitydata @e[tag=help_screen] {ArmorItems:[{},{},{},{id:golden_hoe,Count:1,Damage:11,tag:{Unbreakable:1}}]}
- delay 140
- {
- entitydata @e[tag=help_screen] {ArmorItems:[{},{},{},{id:golden_hoe,Count:1,Damage:12,tag:{Unbreakable:1}}]}
- delay 120
- {
- entitydata @e[tag=help_screen] {ArmorItems:[{},{},{},{id:golden_hoe,Count:1,Damage:13,tag:{Unbreakable:1}}]}
- delay 120
- {
- entitydata @e[tag=help_screen] {ArmorItems:[{},{},{},{id:golden_hoe,Count:1,Damage:14,tag:{Unbreakable:1}}]}
- delay 120
- {
- entitydata @e[tag=help_screen] {ArmorItems:[{},{},{},{id:golden_hoe,Count:1,Damage:15,tag:{Unbreakable:1}}]}
- delay 120
- {
- entitydata @e[tag=help_screen] {ArmorItems:[{},{},{},{id:golden_hoe,Count:1,Damage:16,tag:{Unbreakable:1}}]}
- delay 120
- {
- stop helpScreenTp
- stopsound @a
- execute @a ~ ~ ~ playsound whoosh neutral @a ~ ~ ~ 10
- reset()
- }
- }
- }
- }
- }
- }
- }
- }
- repeat helpScreenTp:off {
- tp @a 1034 9 974.35 180 90
- }
- repeat forceCar:off {
- # If player gets out of car
- execute @a[x=1011,y=7,z=995,dx=200,dy=10,dz=200,tag=!game_over] ~ ~ ~ execute @s[tag=!driving] ~ ~ ~ gameOver()
- execute @a[tag=!driving] ~ ~ ~ scoreboard players tag @s[x=1011,y=7,z=995,dx=200,dy=10,dz=200,tag=!game_over] add game_over
- }
- repeat main {
- title @a[x=1000,y=6,z=999,dx=2,dy=2,dz=2] actionbar ["",{"text":"Set your render distance to 12,","bold":true,"color":"yellow"},{"text":" then press SPACE!","bold":true}]
- execute @a ~ ~ ~ detect ~ ~-1 ~ concrete_powder 15 helpScreen()
- execute @a ~ ~ ~ detect ~ ~-1 ~ jukebox -1 reset()
- # Aesthetic
- particle droplet 1017 11 1020 0.3 0 0.3 1 10
- tp @a[x=1000,y=7,z=991,dx=2,dy=3,dz=2] ~ ~ ~ 0 0
- # weather clear 10000
- scoreboard players tag @a remove driving
- scoreboard players tag @a add driving {RootVehicle:{Entity:{id:"minecraft:horse"}}}
- effect @e[tag=car] minecraft:invisibility 5 1 true
- effect @a[tag=driving] minecraft:invisibility 5 1 true
- execute @a[tag=alreadyBegun] ~ ~ ~ teleport @e[tag=target_sheep] ~ ~3 ~
- effect @e[type=sheep] invisibility 10 1 true
- effect @e[type=sheep] resistance 10 5 true
- if (@a[tag=driving]) {
- # Player is driving the car
- start driveCar
- } else {
- # The car is inactive
- stop driveCar
- entitydata @e[tag=car] {Attributes:[{Name:"generic.movementSpeed",Base:0.0f},{Name:"horse.jumpStrength",Base:0f}],NoAI:1}
- scoreboard players set @e[tag=car] driveTime 0
- scoreboard players set @a idleTime 0
- }
- # Loading screen
- execute @a[tag=!isSelectingCar] ~ ~ ~ execute @a[tag=isLoading] ~ ~ ~ tp @e[tag=loading_spinner] ~ ~ ~ ~4 ~
- execute @a[tag=!isSelectingCar] ~ ~ ~ tp @a[tag=isLoading] 1013 9 974 180 90
- execute @a[tag=!isSelectingCar] ~ ~ ~ title @a[tag=isLoading] actionbar [""]
- execute @e[tag=tank_top] ~ ~ ~ teleport @e[tag=tank_bottom,c=1] ~ ~ ~
- execute @e[tag=tank_wolf] ~ ~ ~ tp @e[tag=tank_top,c=1] @e[tag=tank_wolf,c=1]
- # Multi-purpose dummy objective used to make tank rotations look cooler
- scoreboard players add @e[tag=tank_wolf] MP 1
- execute @e[tag=tank_wolf,score_MP_min=40] ~ ~ ~ tp @e[tag=tank_bottom,c=1] @e[tag=tank_top,c=1]
- scoreboard players reset @e[tag=tank_wolf,score_MP_min=40] MP
- # Tanks only move once player is within 32 blocks
- execute @a ~ ~ ~ effect @e[tag=tank_wolf,rm=32] minecraft:slowness 4 100 true
- execute @a ~ ~ ~ execute @e[tag=tank_wolf,r=32] ~ ~ ~ tankControl()
- # Check if the player's car has taken too much damage
- execute @a[tag=!winner] ~ ~ ~ execute @a[score_car_damage_min=80,tag=!game_over] ~ ~ ~ gameOver()
- scoreboard players set @a[score_car_damage_min=80] car_damage 0
- if ("clear @a redstone_torch 0 1") {
- reset()
- }
- if ("clear @a baked_potato 0 1") {
- # Player picked up a powerup
- activatePowerup()
- }
- scoreboard players remove @e[tag=car,score_powerup_min=1] powerup 1
- # Cartoon outlines
- #scoreboard teams join cartoonOutline @e[tag=cartoon_outline]
- #effect @e[tag=cartoon_outline] glowing 10
- # During the Game OVER screen
- execute @e[tag=car] ~ ~ ~ teleport @a[tag=game_over] ~ ~5 ~ ~1 90
- scoreboard players set @a[tag=game_over] car_damage -999
- effect @a[tag=game_over] invisibility 1 1 true
- execute @a[tag=game_over] ~ ~ ~ execute @e[tag=car] ~ ~ ~ particle smoke ~ ~ ~ 0.5 0.5 0.5 0.001 5
- # Make horse (car) invincible
- effect @e[tag=car] minecraft:resistance 30 5 true
- # Winning
- execute @a[tag=!winner] ~ ~ ~ execute @e[tag=car] ~ ~ ~ detect ~ ~-2 ~ sponge -1 wonGame()
- execute @a[tag=!winner] ~ ~ ~ execute @e[tag=car] ~ ~ ~ detect ~ ~-2 ~ sponge -1 scoreboard players tag @a add winner
- # Critical damage
- execute @a[tag=!criticalmessage,score_car_damage_min=40] ~ ~ ~ criticalDamageMessage()
- execute @a[score_car_damage_min=40] ~ ~ ~ execute @e[tag=car] ~ ~ ~ particle smoke ~ ~ ~ 0 0 0 0.2 2
- }
- repeat driveCar:off {
- # keep the car_model at the horse entity at all times while driving
- tp @e[tag=car_model] @e[tag=car]
- # driveTime tracking
- scoreboard players set @e[score_horseRide_min=1] idleTime 0
- scoreboard players add @e[score_horseRide=0] idleTime 1
- execute @a[score_horseRide=0,score_idleTime_min=5] ~ ~ ~ scoreboard players set @e[tag=car] driveTime 1
- execute @a[score_horseRide_min=1] ~ ~ ~ scoreboard players add @e[tag=car] driveTime 1
- scoreboard players set @a[tag=driving] horseRide 0
- # Ignition sound
- execute @a[score_idleTime_min=1,score_idleTime=1,tag=CarNotStarted] ~ ~ ~ playsound ignition neutral @a ~ ~ ~ 0.3
- execute @a[score_idleTime_min=1,score_idleTime=1,tag=CarNotStarted] ~ ~ ~ start forceCar
- scoreboard players tag @a[score_idleTime_min=1,score_idleTime=1,tag=CarNotStarted] remove CarNotStarted
- # acceleration
- entitydata @e[tag=car,score_driveTime_min=1] {Attributes:[{Name:"generic.movementSpeed",Base:0.1f},{Name:"horse.jumpStrength",Base:0f}],NoAI:0}
- entitydata @e[tag=car,score_driveTime_min=4] {Attributes:[{Name:"generic.movementSpeed",Base:0.15f},{Name:"horse.jumpStrength",Base:0f}]}
- entitydata @e[tag=car,score_driveTime_min=8] {Attributes:[{Name:"generic.movementSpeed",Base:0.2f},{Name:"horse.jumpStrength",Base:0f}]}
- entitydata @e[tag=car,score_driveTime_min=15] {Attributes:[{Name:"generic.movementSpeed",Base:0.25f},{Name:"horse.jumpStrength",Base:0f}]}
- entitydata @e[tag=car,score_driveTime_min=30] {Attributes:[{Name:"generic.movementSpeed",Base:0.3f},{Name:"horse.jumpStrength",Base:0f}]}
- entitydata @e[tag=car,score_driveTime_min=65] {Attributes:[{Name:"generic.movementSpeed",Base:0.32f},{Name:"horse.jumpStrength",Base:0f}]}
- execute @e[tag=car,score_driveTime_min=40] ~ ~ ~ execute @e[tag=car_model] ~ ~ ~ particle smoke ~ ~-0.5 ~ 0 0 0 0.1 10
- execute @e[tag=car,score_driveTime=5] ~ ~ ~ stopsound @a neutral engine_accelerate
- execute @e[tag=car,score_driveTime_min=5,score_driveTime=5] ~ ~ ~ playsound engine_accelerate neutral @a ~ ~ ~ 10
- # Car bounce (suspension) - very minor and not noticable unless you specifically look for it
- #entitydata @e[tag=car_model,c=1] {Pose:{Head:[0f,0f,0f]}}
- #execute @e[tag=car,score_driveTime_min=2,score_driveTime=4] ~ ~ ~ entitydata @e[tag=car_model,c=1] {Pose:{Head:[-1f,0f,0f]}}
- #execute @e[tag=car,score_driveTime_min=5,score_driveTime=8] ~ ~ ~ entitydata @e[tag=car_model,c=1] {Pose:{Head:[-2f,0f,0f]}}
- #execute @e[tag=car,score_driveTime_min=9,score_driveTime=15] ~ ~ ~ entitydata @e[tag=car_model,c=1] {Pose:{Head:[-3f,0f,0f]}}
- #execute @e[tag=car,score_driveTime_min=16,score_driveTime=19] ~ ~ ~ entitydata @e[tag=car_model,c=1] {Pose:{Head:[-2f,0f,0f]}}
- #execute @e[tag=car,score_driveTime_min=20,score_driveTime=22] ~ ~ ~ entitydata @e[tag=car_model,c=1] {Pose:{Head:[-1f,0f,0f]}}
- # Puddles
- execute @e[tag=car,score_driveTime_min=5] ~ ~ ~ detect ~ ~ ~ carpet 11 scoreboard players set @e[tag=car,c=1,r=1] driveTime 6
- execute @e[tag=car,score_driveTime_min=5] ~ ~ ~ detect ~ ~ ~ carpet 11 particle splash ~ ~ ~ 0.8 0.8 0.8 1 20
- }
- // Coordinates of spawn box
- $spawnCapsule = "1001 7.6 992";
- # Changed to a trigger (stepping on a jukebox)
- #delay 10 {
- # reset()
- # delay 5 {
- # setup()
- # }
- #}
- function setup() {
- // Runs to setup the game and put the player into the menu screen
- tp @a $spawnCapsule
- replaceitem entity @a slot.armor.head air
- replaceitem entity @a slot.armor.head pumpkin
- effect @a minecraft:invisibility 10000 1 true
- stopsound @a
- delay 20 {
- // Delay so that the sound plays in the new location after the /tp
- execute @a ~ ~ ~ playsound menu neutral @a ~ ~ ~ 10
- }
- start checkForStart
- }
- function activatePowerup() {
- # Player has picked up a powerup
- stopsound @a
- execute @a ~ ~ ~ playsound powerup neutral @a ~ ~ ~ 10
- title @a times 10 20 10
- title @a subtitle {"text":"Demolish other cars","italic":true,"color":"dark_purple"}
- title @a title {"text":"Powerup!","bold":true,"color":"dark_red"}
- delay 45 {
- execute @e[tag=car] ~ ~ ~ particle dragonbreath ~ ~ ~ 0 0 0 0.3 100
- scoreboard players set @e[tag=car] powerup 240
- effect @e[tag=car_model] glowing 13
- }
- }
- repeat checkForStart:off {
- // If there is an emerald block under the player, then they
- // have pressed space meaning they are ready to start the game
- # say checking for emerald block
- # Just for testing purposes to exit the menu easier
- replaceitem entity @a[x=1000,y=7,z=991,dx=2,dy=3,dz=2,score_sneak_min=3] slot.armor.head air
- stopsound @a[x=1000,y=7,z=991,dx=2,dy=3,dz=2,score_sneak_min=3]
- tp @a[x=1000,y=7,z=991,dx=2,dy=3,dz=2,score_sneak_min=3] ~-6 ~ ~
- scoreboard players set @a[score_sneak_min=3] sneak 0
- execute @a ~ ~ ~ detect ~ ~-1 ~ emerald_block -1 gotoCarSelect()
- }
- function gotoCarSelect() {
- # Go to car select screen
- stopsound @a
- stop checkForStart
- replaceitem entity @a slot.armor.head air
- instant obstacleSetup()
- delay 10 {
- tp @a @e[tag=CarSelect,name=CarSelect]
- scoreboard players tag @e[tag=CarSelect] remove CarSelectMove
- scoreboard players tag @a add isSelectingCar
- delay 2 {
- execute @a ~ ~ ~ playsound apocal master @a ~ ~ ~ 0.45
- }
- start carSelect
- title @a actionbar ["",{"text":"Use","color":"gray"},{"text":" A "},{"text":"and D to switch / / ","color":"gray"},{"text":"SPACE "},{"text":"to select","color":"gray"}]
- }
- }
- $_selectedCar = 1
- $_selectedCarCD = 0
- $_unlockedCars = 1
- $_checkUnlocked = 0
- repeat carSelect:off {
- // Scrolling left and right through the cars
- scoreboard players tag @e[tag=CarSelect] remove CarSelectMove
- execute @a ~ ~ ~ detect ~ ~ ~1 pumpkin -1 scoreboard players tag @e[tag=CarSelect,c=1] add CarSelectMove
- // Scroll left
- if (@e[type=armor_stand,name=CarSelectLeft,tag=CarSelectMove] and $_selectedCarCD==0) {
- $_selectedCar--
- $_selectedCarCD = 5
- execute @a ~ ~ ~ playsound click neutral @a
- }
- // Scroll right
- if (@e[type=armor_stand,name=CarSelectRight,tag=CarSelectMove] and $_selectedCarCD==0) {
- $_selectedCar++
- $_selectedCarCD = 5
- execute @a ~ ~ ~ playsound click neutral @a
- }
- if (@e[type=armor_stand,name=CarSelectRight,tag=CarSelectMove] and $_unlockedCars==1) {
- title @a actionbar ["",{"text":"You haven't unlocked any more cars yet! ","bold":true,"italic":true,"color":"dark_red"},{"text":"Press SPACE to play","color":"yellow"}]
- execute @a ~ ~ ~ playsound error neutral @a
- }
- if ($_selectedCarCD > 0) {
- $_selectedCarCD--
- }
- if ($_selectedCar<1) {
- $_selectedCar = $_unlockedCars
- }
- # Si no lo tiene
- $_checkUnlocked = $_selectedCar
- $_checkUnlocked -= $_unlockedCars
- if ($_checkUnlocked>0) {
- # say set to 1
- $_selectedCar = 1
- }
- if ($_selectedCar==1) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:1}]}
- }
- if ($_selectedCar==2) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:2}]}
- }
- if ($_selectedCar==3) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:3}]}
- }
- if ($_selectedCar==4) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:4}]}
- }
- if ($_selectedCar==5) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:7}]}
- }
- if ($_selectedCar==6) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:6}]}
- }
- if ($_selectedCar==7) {
- entitydata @e[tag=CarDisplay] {ArmorItems:[{},{},{},{id:"diamond_hoe",Count:1,Damage:5}]}
- }
- # tellraw @a [{"text":"selected: "},$_selectedCar]
- # tellraw @a [{"text":"cd: "},$_selectedCarCD]
- execute @e[tag=CarSelectMove,name=!CarSelect] ~ ~ ~ tp @a @e[tag=CarSelect,name=CarSelect]
- tp @e[tag=CarDisplay] 992 7 977 ~2 ~
- tp @a ~ ~ ~ 180 30
- execute @a ~ ~ ~ detect ~ ~ ~1 emerald_block -1 stop carSelect
- execute @a ~ ~ ~ detect ~ ~ ~1 emerald_block -1 scoreboard players tag @a remove isSelectingCar
- execute @a ~ ~ ~ detect ~ ~ ~1 emerald_block -1 stopsound @a
- execute @a ~ ~ ~ detect ~ ~ ~1 emerald_block -1 playsound menu neutral @a ~ ~ ~ 10
- execute @a ~ ~ ~ detect ~ ~ ~1 emerald_block -1 tp @a 978 7 994
- }
- $carSpawnLoc = "1020 7 1014.0"
- function begin() {
- tp @e[tag=car] ~ ~-1000 ~
- stopsound @a
- effect @a clear
- effect @a blindness 4 4 true
- tp @a 1017 8 1021 -80 15
- execute @a ~ ~ ~ playsound alarm neutral @a
- # the first one doesn't have the money_bag tag so that it can't disappear over time
- summon item 1023 9 1020 {Item:{id:cooked_rabbit,Count:1,Age:-32768}}
- # the rest are spawned in the spawnCoins() function below
- tp @e[tag=garage_door] ~ 8.0 ~
- execute @a ~ ~30 ~ summon sheep ~ ~ ~ {Tags:["target_sheep"],Silent:1,NoGravity:1}
- # Also spawns powerups
- spawnCoins()
- start spawnMoneyBags
- musicLoop()
- tp @e[tag=car_model] $carSpawnLoc -90 0
- summon horse $carSpawnLoc {Tags:["car","carPart"],Attributes:[{Name:"generic.movementSpeed",Base:0.1f},{Name:"horse.jumpStrength",Base:0f}],Rotation:[-90f,0f],Tame:1,SaddleItem:{id:saddle,Count:1},Silent:1,Invisible:1}
- scoreboard players set @e[tag=car] powerup 0
- scoreboard players set @a car_damage 0
- spawnPedestrian()
- spawnNPCCars()
- # This ~might~ does not work
- # stop spawnPolice
- delay 130 {
- scoreboard players set @a policeNum 0
- spawnPolice()
- start openGarageDoor
- scoreboard players set @a eventTimer 0
- }
- execute @e[tag=toll_1] ~ ~ ~ clone 965 7 1015 971 12 1021 ~-3 ~ ~-3
- execute @e[tag=toll_2] ~ ~ ~ clone 965 7 1023 971 12 1029 ~-3 ~ ~-3
- execute @e[tag=toll_3] ~ ~ ~ clone 973 7 1015 979 12 1021 ~-3 ~ ~-3
- scoreboard players tag @e[tag=toll_3] add toll_1
- scoreboard players tag @e[tag=toll_3] add toll_2
- start gameplay
- scoreboard players tag @a add isPlaying
- scoreboard players tag @a add CarNotStarted
- }
- repeat openGarageDoor:off {
- # Garage door
- tp @e[tag=garage_door,x=1017,y=7,z=1004,dx=2,dy=3,dz=3] ~ ~0.03 ~
- }
- function musicLoop() {
- execute @a[tag=isPlaying] ~ ~ ~ playsound shopping neutral @a ~ ~ ~ 1000
- delay 3055 {
- execute @a[tag=isPlaying] ~ ~ ~ playsound mangowalk neutral @a ~ ~ ~ 1000
- delay 4015 {
- musicLoop()
- }
- }
- }
- function obstacleSetup() {
- kill @e[tag=check_obs]
- scoreboard players tag @e[tag=intersection] add unused
- execute @e[tag=intersection] ~ ~ ~ fill ~-3 ~ ~-3 ~3 ~10 ~3 air
- start generateObstacles
- }
- $tempObstacleCoords = 982 7 1015
- $tempObstacleCoords2 = 988 16 1021
- repeat generateObstacles:off {
- # 7x7 Obstacle squares = squareobstacle
- # Centers of intersections = intersection
- # Starting corner = start_corner
- # 2 armorstands at the final corner = obs_fin
- # Temporary obstacle holding coordinates = 982 7 1015 or $tempObstacleCoords
- # Other corner of temp. obstacle coordinates = 988 16 1021 or $tempObstacleCoords2
- //say generateObstacles is running
- scoreboard players tag @r[type=armor_stand,tag=unused] add cur_loc
- execute @r[type=armor_stand,tag=squareobstacle] ~ ~ ~ clone ~ ~ ~ ~6 ~10 ~6 $tempObstacleCoords
- execute @e[tag=cur_loc] ~ ~ ~ execute @e[tag=!obs_fin,c=1,r=1] ~ ~ ~ clone $tempObstacleCoords $tempObstacleCoords2 ~-3 ~ ~-3
- scoreboard players tag @e[tag=cur_loc] remove unused
- scoreboard players tag @e[tag=cur_loc] remove cur_loc
- #say Placed obstacle.
- scoreboard players set @a uniCount 0
- execute @e[tag=unused] ~ ~ ~ scoreboard players add @a uniCount 1
- //execute @a[score_uniCount=0] ~ ~ ~ say Obstacle generation complete.
- execute @a[score_uniCount=0] ~ ~ ~ stop generateObstacles
- execute @a[score_uniCount=0] ~ ~ ~ checkObstacles()
- }
- function checkObstacles() {
- kill @e[tag=check_obs]
- execute @e[tag=start_corner] ~ ~ ~ summon armor_stand ~ ~ ~ {NoGravity:1,Marker:1,Invisible:1,Tags:["check_obs"]}
- scoreboard players set @a checkObCount 0
- #execute @e[tag=intersection] ~ ~ ~ setblock ~ ~11 ~ air
- scoreboard players tag @a add isLoading
- start checkingObstacles
- }
- repeat checkingObstacles:off {
- # Makes sure that the obstacle placement doesn't make it impossible to reach the end
- # If it is impossible, obstacleSetup() should be called again to redo the obstacles
- # If it is possible, there should be a check_obs armorstand at one of the armorstands near the final corner
- //say checking obstacles
- scoreboard players tag @e[tag=check_obs] add check_obs_old
- execute @e[tag=check_obs_old] ~ ~ ~ summon armor_stand ~24 ~ ~ {NoGravity:1,Marker:1,Invisible:1,Tags:["check_obs"]}
- execute @e[tag=check_obs_old] ~ ~ ~ summon armor_stand ~ ~ ~24 {NoGravity:1,Marker:1,Invisible:1,Tags:["check_obs"]}
- execute @e[tag=check_obs_old] ~ ~ ~ summon armor_stand ~-24 ~ ~ {NoGravity:1,Marker:1,Invisible:1,Tags:["check_obs"]}
- execute @e[tag=check_obs_old] ~ ~ ~ summon armor_stand ~ ~ ~-24 {NoGravity:1,Marker:1,Invisible:1,Tags:["check_obs"]}
- scoreboard players set @e[tag=check_obs] obs_valid_loc 0
- execute @e[tag=is_valid_loc] ~ ~ ~ scoreboard players set @e[tag=check_obs,r=2,c=1] obs_valid_loc 1
- execute @e[tag=check_obs] ~ ~ ~ detect ~ ~ ~ wool 15 scoreboard players set @e[tag=check_obs,r=1] obs_valid_loc 0
- kill @e[tag=check_obs,score_obs_valid_loc=0]
- kill @e[tag=check_obs_old]
- #execute @e[tag=check_obs] ~ ~ ~ setblock ~ ~11 ~ gold_block
- #scoreboard players set @a uniCount 0
- #execute @e[tag=check_obs] ~ ~ ~ scoreboard players add @a uniCount 1
- # If this is successful, then the current obstacles are possible
- //execute @e[tag=obs_fin] ~ ~ ~ execute @e[tag=check_obs,r=2] ~ ~ ~ say POSSIBLE
- execute @e[tag=obs_fin] ~ ~ ~ execute @e[tag=check_obs,r=2] ~ ~ ~ scoreboard players tag @a remove isLoading
- execute @e[tag=obs_fin] ~ ~ ~ execute @e[tag=check_obs,r=2] ~ ~ ~ start tryBegin
- execute @e[tag=obs_fin] ~ ~ ~ execute @e[tag=check_obs,r=2] ~ ~ ~ stop checkingObstacles
- # Once it reaches this point and it is still going, it is for sure impossible, so it will start over
- execute @a[score_checkObCount_min=16] ~ ~ ~ obstacleSetup()
- execute @a[score_checkObCount_min=16] ~ ~ ~ stop checkingObstacles
- scoreboard players add @a checkObCount 1
- }
- repeat tryBegin:off {
- execute @a[tag=!isSelectingCar] ~ ~ ~ execute @a[tag=!alreadyBegun] ~ ~ ~ begin()
- scoreboard players tag @a[tag=!isSelectingCar] add alreadyBegun
- execute @a[tag=!isSelectingCar] ~ ~ ~ stop tryBegin
- }
- repeat gameplay:off {
- # Runs while the game is playing
- # Pedestrians
- if (@a[tag=!game_over]) {
- tp @e[type=villager,name=pedestrian,tag=ped_south] ~ ~ ~.3
- tp @e[type=villager,name=pedestrian,tag=ped_north] ~ ~ ~-.3
- tp @e[type=villager,name=pedestrian,tag=ped_east] ~.3 ~ ~
- tp @e[type=villager,name=pedestrian,tag=ped_west] ~-.3 ~ ~
- }
- execute @e[type=villager,name=pedestrian] ~ ~ ~ detect ~ ~ ~ stone_slab -1 tp @e[type=villager,name=pedestrian,c=1,r=1] ~ 7.5 ~
- execute @e[type=villager,name=pedestrian] ~ ~ ~ detect ~ ~-1 ~ coal_block -1 tp @e[type=villager,name=pedestrian,c=1,r=1] ~ 7.0 ~
- scoreboard players add @e[type=villager,name=pedestrian] ped_walk 1
- tp @e[type=villager,score_ped_walk_min=45] ~ ~-100 ~
- execute @e[type=villager,name=pedestrian] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ pedestrianCollision()
- scoreboard players add @e[type=villager,name=hit_pedestrian] MP 1
- tp @e[type=villager,name=hit_pedestrian,score_MP_min=50] ~ ~-0.2 ~
- # Near misses
- execute @e[tag=NPCCar] ~ ~ ~ scoreboard players tag @e[tag=car,rm=2,r=3] add tryNearMiss
- execute @e[tag=tryNearMiss] ~ ~ ~ tryNearMiss()
- # Collecting coins
- if ("clear @a pumpkin_pie 0 1")
- {
- execute @a ~ ~ ~ playsound entity.experience_orb.pickup neutral @a ~ ~ ~ 1 2
- scoreboard players add @a points 2
- }
- # Collecting money bags
- if ("clear @a cooked_rabbit 0 1")
- {
- execute @a ~ ~ ~ playsound cinematic neutral @a ~ ~ ~ 10
- execute @e[tag=car] ~ ~ ~ particle fireworksSpark ~ ~ ~ 0 0 0 0.4 50
- scoreboard players add @a money_bags 1
- title @a actionbar ["",{"text":"=== ","bold":true,"color":"dark_red"},{"text":"Collected money bag ","bold":true,"color":"yellow"},{"score":{"name":"@a","objective":"money_bags"},"color":"gold"},{"text":" / 5","color":"gold"},{"text":" ===","bold":true,"color":"dark_red"}]
- scoreboard players add @a points 50
- }
- # Random events such as meteor showers
- scoreboard players add @a[score_eventTimer_min=0] eventTimer 1
- execute @a[score_eventTimer_min=700] ~ ~ ~ doRandomEvent()
- scoreboard players set @a[score_eventTimer_min=700] eventTimer 0
- # Barrier particles at toll booths
- execute @a[score_money_bags=4] ~ ~ ~ execute @e[tag=toll_1] ~ ~ ~ particle barrier ~ ~3 ~-4 0 0 0 1
- execute @a[score_money_bags=4] ~ ~ ~ execute @e[tag=toll_2] ~ ~ ~ particle barrier ~-4 ~3 ~ 0 0 0 1
- execute @a[score_money_bags_min=5,tag=!unlockedTolls] ~ ~ ~ openTollBooths()
- # Remove glow when powerup runs out
- execute @e[tag=car,score_powerup=0] ~ ~ ~ effect @e[tag=car_model] clear
- }
- function tryNearMiss() {
- scoreboard players tag @e[tag=hitNPCCar] remove tryNearMiss
- execute @e[tag=NPCCar] ~ ~ ~ scoreboard players tag @e[tag=hitNPCCar,rm=5,r=6] remove hitNPCCar
- execute @e[tag=NPCCar] ~ ~ ~ execute @e[tag=car,r=2] ~ ~ ~ scoreboard players tag @e[tag=car] add hitNPCCar
- execute @e[tag=NPCCar] ~ ~ ~ execute @e[tag=tryNearMiss,rm=4,r=5] ~ ~ ~ didTrick("Near Miss!", 5)
- execute @e[tag=NPCCar] ~ ~ ~ scoreboard players tag @e[tag=tryNearMiss,rm=4,r=5] remove tryNearMiss
- }
- function pedestrianCollision() {
- execute @e[type=villager,name=pedestrian] ~ ~ ~ execute @e[tag=car,r=4] ~ ~ ~ playsound minecraft:entity.villager.hurt neutral @a
- execute @e[tag=car,score_powerup=0] ~ ~ ~ execute @e[type=villager,name=pedestrian,r=4] ~ ~ ~ scoreboard players set @e[tag=car] driveTime 1
- execute @e[tag=car] ~ ~ ~ execute @e[type=villager,name=pedestrian,r=4] ~ ~ ~ particle crit ~ ~ ~ 0 0 0 1 50
- execute @e[tag=car,score_powerup=0] ~ ~ ~ execute @e[type=villager,name=pedestrian,r=4] ~ ~ ~ scoreboard players add @a car_damage 15
- execute @e[tag=car,score_powerup=0] ~ ~ ~ entitydata @e[type=villager,name=pedestrian,r=4] {NoAI:0,NoGravity:0,Motion:[0.0d,2.0d,0.0d],CustomName:hit_pedestrian}
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[type=villager,name=pedestrian,r=4] ~ ~ ~ particle endRod ~ ~ ~ 0 0 0 0.1 100
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[type=villager,name=pedestrian,r=4] ~ ~ ~ title @a actionbar ["",{"text":"Kapow! ","bold":true,"color":"dark_purple"},{"text":"(+20 points)","italic":true,"color":"gold"}]
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[type=villager,name=pedestrian,r=4] ~ ~ ~ summon item ~ ~ ~ {Item:{id:pumpkin_pie,Count:20},Age:-32768,Tags:["coin"],PickupDelay:1}
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ tp @e[type=villager,name=pedestrian,r=4] ~ ~-1000 ~
- }
- function displayMessage($messageText)
- {
- title @a actionbar ["",{"text":"=== ","bold":true,"color":"dark_red"},{"text":"$messageText","bold":true,"color":"yellow"},{"text":" ===","bold":true,"color":"dark_red"}]
- }
- function didTrick($trickText, $trickPoints)
- {
- title @a actionbar ["",{"text":"$trickText ","bold":true,"color":"dark_purple"},{"text":"(+$trickPoints points)","italic":true,"color":"gold"}]
- execute @a ~ ~ ~ summon item ~ ~ ~ {Item:{id:pumpkin_pie,Count:$trickPoints},Age:-32768,Tags:["coin"],PickupDelay:1}
- #scoreboard players add @a points $trickPoints
- }
- function spawnPedestrian() {
- if (@a[tag=isPlaying]) {
- execute @r[type=armor_stand,name=intersection,x=1042,y=5,z=1023,dx=140,dy=10,dz=140] ~ ~ ~ summon villager ~-7 ~0.5 ~-6 {CustomName:pedestrian,Tags:["pedestrian","ped_south","cartoon_outline"],Rotation:[0f],Invulnerable:1,NoGravity:1,NoAI:1}
- execute @r[type=armor_stand,name=intersection,x=1042,y=5,z=1023,dx=140,dy=10,dz=140] ~ ~ ~ summon villager ~-7 ~0.5 ~6 {CustomName:pedestrian,Tags:["pedestrian","ped_north","cartoon_outline"],Rotation:[180f],Invulnerable:1,NoGravity:1,NoAI:1}
- execute @r[type=armor_stand,name=intersection,x=1042,y=5,z=1023,dx=140,dy=10,dz=140] ~ ~ ~ summon villager ~-6 ~0.5 ~-7 {CustomName:pedestrian,Tags:["pedestrian","ped_east","cartoon_outline"],Rotation:[-90f],Invulnerable:1,NoGravity:1,NoAI:1}
- execute @r[type=armor_stand,name=intersection,x=1042,y=5,z=1023,dx=140,dy=10,dz=140] ~ ~ ~ summon villager ~6 ~0.5 ~-7 {CustomName:pedestrian,Tags:["pedestrian","ped_west","cartoon_outline"],Rotation:[90f],Invulnerable:1,NoGravity:1,NoAI:1}
- }
- delay 30 {
- spawnPedestrian()
- }
- }
- function spawnPolice() {
- scoreboard players add @a[score_policeNum_min=0] policeNum 1
- delay 240 {
- execute @p[tag=isPlaying,score_policeNum_min=0,score_policeNum=6] ~ ~ ~ execute @e[tag=police_spawner] ~ ~ ~ summon minecraft:wolf ~ ~2 ~ {Angry:1,CustomName:police_car,CustomNameVisible:1,Attributes:[{Name:"generic.followRange",Base:500},{Name:"generic.movementSpeed",Base:0.4f},{Name:"generic.attackDamage",Base:0}],Silent:1,Invulnerable:1,ActiveEffects:[{Id:14,Amplifier:0,Duration:2147483647,ShowParticles:0b}],Tags:["police_car","police_car_part"],Passengers:[{id:armor_stand,Tags:["police_car_part","cartoon_outline"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:iron_hoe,Count:1}]}]}
- # Limit to 6 police
- execute @p[tag=isPlaying,score_policeNum_min=0,score_policeNum=6] ~ ~ ~ spawnPolice()
- execute @e[tag=police_car] ~ ~ ~ playsound siren neutral @a[r=25] ~ ~ ~ 3 1
- }
- }
- # NPC Cars Traffic control
- # npcCarCD = Cooldown for rotation changes on NPC cars
- # npcCarRot = Rotation of NPC car (1 = X+, 2 = Z+, 3 = X-, 4 = Z-)
- function spawnNPCCars() {
- execute @e[tag=spawnNPCCar] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["NPCCar","cartoon_outline"],NoGravity:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:1,tag:{Unbreakable:1},Count:1}],Invisible:1,Marker:1}
- entitydata @r[type=armor_stand,tag=NPCCar,c=10] {ArmorItems:[{},{},{},{id:golden_hoe,Damage:2,tag:{Unbreakable:1},Count:1}]}
- entitydata @r[type=armor_stand,tag=NPCCar,c=9] {ArmorItems:[{},{},{},{id:golden_hoe,Damage:3,tag:{Unbreakable:1},Count:1}]}
- entitydata @r[type=armor_stand,tag=NPCCar,c=8] {ArmorItems:[{},{},{},{id:golden_hoe,Damage:4,tag:{Unbreakable:1},Count:1}]}
- entitydata @r[type=armor_stand,tag=NPCCar,c=7] {ArmorItems:[{},{},{},{id:golden_hoe,Damage:5,tag:{Unbreakable:1},Count:1}]}
- # Set initial directions
- execute @e[tag=NPCCar] ~ ~ ~ detect ~ ~-2 ~-2 gold_block 0 scoreboard players set @s npcCarRot 1
- execute @e[tag=NPCCar] ~ ~ ~ detect ~2 ~-2 ~ gold_block 0 scoreboard players set @s npcCarRot 2
- execute @e[tag=NPCCar] ~ ~ ~ detect ~ ~-2 ~2 gold_block 0 scoreboard players set @s npcCarRot 3
- execute @e[tag=NPCCar] ~ ~ ~ detect ~-2 ~-2 ~ gold_block 0 scoreboard players set @s npcCarRot 4
- #delay 10 {
- # For cases where 2 cars spawned in the same spot
- #execute @e[tag=NPCCar] ~ ~ ~ detect ~ ~-2 ~-2 gold_block 0 scoreboard players set @e[tag=NPCCar,c=1,r=1] npcCarRot 1
- #execute @e[tag=NPCCar] ~ ~ ~ detect ~2 ~-2 ~ gold_block 0 scoreboard players set @e[tag=NPCCar,c=1,r=1] npcCarRot 2
- #execute @e[tag=NPCCar] ~ ~ ~ detect ~ ~-2 ~2 gold_block 0 scoreboard players set @e[tag=NPCCar,c=1,r=1] npcCarRot 3
- #execute @e[tag=NPCCar] ~ ~ ~ detect ~-2 ~-2 ~ gold_block 0 scoreboard players set @e[tag=NPCCar,c=1,r=1] npcCarRot 4
- #}
- # Also spawns the tanks
- execute @e[tag=tank_spawner] ~ ~ ~ summon wolf ~ ~ ~ {Angry:1,Attributes:[{Name:"generic.followRange",Base:500},{Name:"generic.movementSpeed",Base:0.22f},{Name:"generic.attackDamage",Base:0}],Silent:1,Invulnerable:1,ActiveEffects:[{Id:14,Amplifier:0,Duration:2147483647,ShowParticles:0b}],Tags:["tank_part","tank_wolf"]}
- execute @e[tag=tank_spawner] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["tank_part","tank_bottom","cartoon_outline"],Invisible:1,Marker:1,NoGravity:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:6,Count:1,tag:{Unbreakable:1}}]}
- execute @e[tag=tank_spawner] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["tank_part","tank_top","cartoon_outline"],Invisible:1,Marker:1,NoGravity:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:7,Count:1,tag:{Unbreakable:1}}]}
- }
- repeat traffic {
- # Player collisions with NPC cars
- execute @e[tag=NPCCar] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~1 ~1 air 0 replace barrier
- execute @e[tag=NPCCar] ~ ~ ~ fill ~ ~ ~ ~ ~1 ~ barrier 0 replace air
- # This starts running at r=3 so that it has a head start to catch it on time in the function call (1 tick later)
- execute @e[tag=NPCCar] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ npcCollision()
- # If a pedestrian is near an NPC car, the car will stop moving until the pedestrian crosses the road
- scoreboard players tag @e[tag=NPCCar] remove near_pedestrian
- execute @e[tag=pedestrian] ~ ~ ~ scoreboard players tag @e[tag=NPCCar,r=5] add near_pedestrian
- if (@a[tag=!game_over]) {
- execute @a ~ ~ ~ tp @e[tag=!near_pedestrian,score_npcCarRot_min=1,score_npcCarRot=1,r=50] ~0.3 ~ ~ 90 0
- execute @a ~ ~ ~ tp @e[tag=!near_pedestrian,score_npcCarRot_min=2,score_npcCarRot=2,r=50] ~ ~ ~0.3 180 0
- execute @a ~ ~ ~ tp @e[tag=!near_pedestrian,score_npcCarRot_min=3,score_npcCarRot=3,r=50] ~-0.3 ~ ~ -90 0
- execute @a ~ ~ ~ tp @e[tag=!near_pedestrian,score_npcCarRot_min=4,score_npcCarRot=4,r=50] ~ ~ ~-0.3 0 0
- }
- scoreboard players add @e[tag=NPCCar] npcCarCD 0
- # Deciding whether to continue or turn
- execute @e[tag=!atDeadEnd,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 npcControl()
- scoreboard players remove @e[tag=NPCCar,score_npcCarCD_min=1] npcCarCD 1
- # Turning around at dead ends
- scoreboard players tag @e[tag=NPCCar] remove atDeadEnd
- execute @a ~ ~ ~ execute @e[tag=NPCCar,score_npcCarRot_min=1,score_npcCarRot=1,r=50] ~ ~ ~ detect ~3 ~ ~ wool 15 scoreboard players tag @e[tag=NPCCar,c=1,r=1] add atDeadEnd
- execute @a ~ ~ ~ execute @e[tag=NPCCar,score_npcCarRot_min=2,score_npcCarRot=2,r=50] ~ ~ ~ detect ~ ~ ~3 wool 15 scoreboard players tag @e[tag=NPCCar,c=1,r=1] add atDeadEnd
- execute @a ~ ~ ~ execute @e[tag=NPCCar,score_npcCarRot_min=3,score_npcCarRot=3,r=50] ~ ~ ~ detect ~-3 ~ ~ wool 15 scoreboard players tag @e[tag=NPCCar,c=1,r=1] add atDeadEnd
- execute @a ~ ~ ~ execute @e[tag=NPCCar,score_npcCarRot_min=4,score_npcCarRot=4,r=50] ~ ~ ~ detect ~ ~ ~-3 wool 15 scoreboard players tag @e[tag=NPCCar,c=1,r=1] add atDeadEnd
- execute @e[tag=atDeadEnd] ~ ~ ~ npcUTurns()
- # In case any car somehow gets off track
- execute @e[tag=NPCCarRand] ~ ~ ~ detect ~ ~-1 ~ stained_hardened_clay 3 tp @e[tag=NPCCarRand,c=1,r=1] 1100 7 1081
- # Police cars catching the player
- execute @e[tag=police_car] ~ ~ ~ execute @e[tag=car,r=9] ~ ~ ~ execute @a[score_car_damage=999,tag=!game_over] ~ ~ ~ playsound siren neutral @a ~ ~ ~ 10
- execute @e[tag=police_car] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ execute @a[score_car_damage=999,tag=!game_over] ~ ~ ~ playsound impact.random neutral @a ~ ~ ~ 10
- execute @e[tag=police_car] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ scoreboard players set @a[score_car_damage=999] car_damage 1000
- # Hitting meteors
- execute @e[tag=car] ~ ~ ~ execute @e[tag=meteor,r=2] ~ ~ ~ hitMeteor()
- }
- function hitMeteor() {
- execute @e[tag=car] ~ ~ ~ execute @e[tag=meteor,r=3] ~ ~ ~ scoreboard players add @a car_damage 25
- execute @e[tag=car] ~ ~ ~ execute @e[tag=meteor,r=3] ~ ~ ~ particle crit ~ ~ ~ 0 0 0 1 100
- execute @e[tag=car] ~ ~ ~ execute @e[tag=meteor,r=3] ~ ~ ~ playsound impact.random neutral @a ~ ~ ~ 10
- execute @e[tag=car] ~ ~ ~ kill @e[tag=meteor,r=3]
- }
- function npcCollision() {
- execute @e[tag=NPCCar] ~ ~ ~ execute @e[tag=car,r=2,score_powerup=0] ~ ~ ~ scoreboard players add @a car_damage 3
- execute @e[tag=NPCCar] ~ ~ ~ execute @e[tag=car,r=2] ~ ~ ~ execute particle explode ~ ~ ~ 0 0 0 0.3 20
- execute @e[tag=NPCCar] ~ ~ ~ execute @e[tag=car,r=2] ~ ~ ~ playsound impact.random neutral @a[tag=!game_over]
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[tag=NPCCar,r=2] ~ ~ ~ particle endRod ~ ~ ~ 0 0 0 0.1 100
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[tag=NPCCar,r=2] ~ ~ ~ title @a actionbar ["",{"text":"Demolished a car! ","bold":true,"color":"dark_purple"},{"text":"(+15 points)","italic":true,"color":"gold"}]
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[tag=NPCCar,r=2] ~ ~ ~ summon item ~ ~ ~ {Item:{id:pumpkin_pie,Count:15},Age:-32768,Tags:["coin"],PickupDelay:1}
- # Spawn new NPC car somewhere, to make up for loss
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[tag=NPCCar,r=2] ~ ~ ~ execute @r[type=armor_stand,tag=spawnNPCCar,rm=20] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["NPCCar","cartoon_outline"],NoGravity:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:1,tag:{Unbreakable:1},Count:1}],Invisible:1,Marker:1}
- execute @e[tag=NPCCar] ~ ~ ~ detect ~ ~-2 ~-2 gold_block 0 scoreboard players set @s npcCarRot 1
- execute @e[tag=NPCCar] ~ ~ ~ detect ~2 ~-2 ~ gold_block 0 scoreboard players set @s npcCarRot 2
- execute @e[tag=NPCCar] ~ ~ ~ detect ~ ~-2 ~2 gold_block 0 scoreboard players set @s npcCarRot 3
- execute @e[tag=NPCCar] ~ ~ ~ detect ~-2 ~-2 ~ gold_block 0 scoreboard players set @s npcCarRot 4
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ execute @e[tag=NPCCar,r=2] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~1 ~1 air 0 replace barrier
- execute @e[tag=car,score_powerup_min=1] ~ ~ ~ kill @e[tag=NPCCar,r=2]
- }
- function npcControl() {
- execute @e[tag=NPCCar,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 execute @e[tag=NPCCar,score_npcCarCD=0,c=1] ~ ~ ~ detect ~1 ~-2 ~ bedrock 0 summon armor_stand ~ ~ ~ {CustomName:"NPCCarRand1",Tags:["NPCCarRand"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=NPCCar,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 execute @e[tag=NPCCar,score_npcCarCD=0,c=1] ~ ~ ~ detect ~ ~-2 ~1 bedrock 0 summon armor_stand ~ ~ ~ {CustomName:"NPCCarRand2",Tags:["NPCCarRand"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=NPCCar,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 execute @e[tag=NPCCar,score_npcCarCD=0,c=1] ~ ~ ~ detect ~-1 ~-2 ~ bedrock 0 summon armor_stand ~ ~ ~ {CustomName:"NPCCarRand3",Tags:["NPCCarRand"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=NPCCar,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 execute @e[tag=NPCCar,score_npcCarCD=0,c=1] ~ ~ ~ detect ~ ~-2 ~-1 bedrock 0 summon armor_stand ~ ~ ~ {CustomName:"NPCCarRand4",Tags:["NPCCarRand"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=NPCCar,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 scoreboard players tag @r[type=armor_stand,tag=NPCCarRand,r=1] add NPCCarRandSelect
- execute @e[tag=NPCCarRandSelect,name=NPCCarRand1] ~ ~ ~ scoreboard players set @e[tag=NPCCar,score_npcCarCD=0,c=1,r=1] npcCarRot 1
- execute @e[tag=NPCCarRandSelect,name=NPCCarRand2] ~ ~ ~ scoreboard players set @e[tag=NPCCar,score_npcCarCD=0,c=1,r=1] npcCarRot 2
- execute @e[tag=NPCCarRandSelect,name=NPCCarRand3] ~ ~ ~ scoreboard players set @e[tag=NPCCar,score_npcCarCD=0,c=1,r=1] npcCarRot 3
- execute @e[tag=NPCCarRandSelect,name=NPCCarRand4] ~ ~ ~ scoreboard players set @e[tag=NPCCar,score_npcCarCD=0,c=1,r=1] npcCarRot 4
- execute @e[tag=NPCCar,score_npcCarCD=0] ~ ~ ~ detect ~ ~-2 ~ diamond_block 0 scoreboard players set @e[tag=NPCCar,score_npcCarCD=0,c=1,r=0] npcCarCD 50
- kill @e[tag=NPCCarRand]
- }
- function npcUTurns() {
- # Turn left (start of U-turn)
- scoreboard players remove @e[tag=atDeadEnd] npcCarRot 1
- # Rotation boundaries
- scoreboard players set @e[tag=atDeadEnd,score_npcCarRot=0] npcCarRot 4
- scoreboard players set @e[tag=atDeadEnd,score_npcCarRot_min=5] npcCarRot 1
- # Move to other side of road
- execute @e[tag=atDeadEnd] ~ ~ ~ fill ~-1 ~ ~-1 ~1 ~1 ~1 air 0 replace barrier
- tp @e[tag=atDeadEnd,score_npcCarRot_min=1,score_npcCarRot=1] ~4 ~ ~ 90 0
- tp @e[tag=atDeadEnd,score_npcCarRot_min=2,score_npcCarRot=2] ~ ~ ~4 180 0
- tp @e[tag=atDeadEnd,score_npcCarRot_min=3,score_npcCarRot=3] ~-4 ~ ~ -90 0
- tp @e[tag=atDeadEnd,score_npcCarRot_min=4,score_npcCarRot=4] ~ ~ ~-4 0 0
- # Turn left again then the U-turn is done
- scoreboard players remove @e[tag=atDeadEnd] npcCarRot 1
- # Rotation boundaries
- scoreboard players set @e[tag=atDeadEnd,score_npcCarRot=0] npcCarRot 4
- scoreboard players set @e[tag=atDeadEnd,score_npcCarRot_min=5] npcCarRot 1
- }
- $tankShotCD = 30
- function tankControl() {
- # This function runs every tick when a players is within 32 blocks of a tank
- # MP on tag=tank_top is used to count the time until the tank should shoot
- execute @a[tag=!game_over] ~ ~ ~ scoreboard players add @e[tag=tank_top,r=32] MP 1
- # Facing Motion generator http://i.imgur.com/15Qfr9o.png
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-180,ry=-158] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[0.45855d,0.4d,-2.25383d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-157,ry=-135] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[1.30273d,0.4d,-1.89549d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-134,ry=-112] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[1.93980d,0.4d,-1.23579d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-111,ry=-89] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[2.26846d,0.4d,-0.37961d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-88,ry=-66] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[2.23645d,0.4d,0.53692d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-65,ry=-43] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[1.84887d,0.4d,1.36809d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-42,ry=-20] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[1.16734d,0.4d,1.98175d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=-19,ry=3] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[0.30021d,0.4d,2.28032d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=4,ry=26] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-0.61465d,0.4d,2.21635d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=27,ry=49] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-1.43178d,0.4d,1.80000d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=50,ry=72] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-2.02128d,0.4d,1.09747d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=73,ry=95] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-2.28941d,0.4d,0.22045d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=96,ry=118] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-2.19355d,0.4d,-0.69162d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=119,ry=141] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-1.74893d,0.4d,-1.49373d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=142,ry=164] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-1.02625d,0.4d,-2.05835d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD,rym=165,ry=187] ~ ~ ~ summon armor_stand ~ ~1 ~ {Tags:["tank_bullet"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:spider_eye,Count:1}],Motion:[-0.14041d,0.4d,-2.29571d]}
- execute @e[tag=tank_top,score_MP_min=$tankShotCD] ~ ~ ~ particle smoke ~ ~ ~ 0 0 0 0.3 60
- execute @e[tag=tank_top,score_MP_min=$tankShotCD] ~ ~ ~ playsound tank_shot neutral @a ~ ~ ~ 10
- scoreboard players reset @e[tag=tank_top,score_MP_min=$tankShotCD] MP
- # Make the bullets sink into the ground and disappear after a bit
- scoreboard players add @e[tag=tank_bullet] MP 1
- tp @e[tag=tank_bullet,score_MP_min=60] ~ ~-0.03 ~
- kill @e[tag=tank_bullet,score_MP_min=120]
- # Getting hit by tank bullets
- execute @e[tag=tank_bullet] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ scoreboard players add @a car_damage 40
- execute @e[tag=tank_bullet] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ particle flame ~ ~ ~ 0 0 0 0.2 50
- execute @e[tag=car] ~ ~ ~ tp @e[tag=tank_bullet,r=3] ~ ~-1000 ~
- # If the player runs into the tank or is hit by a bullet
- execute @e[tag=tank_wolf] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ scoreboard players add @a car_damage 3
- execute @e[tag=tank_wolf] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ execute particle explode ~ ~ ~ 0 0 0 0.3 20
- execute @e[tag=tank_wolf] ~ ~ ~ execute @e[tag=car,r=3] ~ ~ ~ playsound impact.random neutral @a[tag=!game_over]
- }
- function spawnCoins() {
- # Spawn coins
- execute @r[type=armor_stand,tag=intersection,c=10] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~-4 ~-2 ~ gold_block 0 summon armor_stand ~-2 ~ ~ {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~ ~-2 ~-4 gold_block 0 summon armor_stand ~ ~ ~-2 {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~-2 ~-2 ~ gold_block 0 summon armor_stand ~-4 ~ ~ {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~ ~-2 ~-2 gold_block 0 summon armor_stand ~ ~ ~-4 {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~-4 ~-2 ~ gold_block 0 summon armor_stand ~-8 ~ ~ {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~ ~-2 ~-4 gold_block 0 summon armor_stand ~ ~ ~-8 {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~-8 ~-2 ~ gold_block 0 summon armor_stand ~-16 ~ ~ {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ detect ~ ~-2 ~-8 gold_block 0 summon armor_stand ~ ~ ~-16 {Tags:["spawn_coins"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=spawn_coins] ~ ~ ~ summon item ~ ~ ~ {Item:{id:pumpkin_pie,Count:1},Age:-32768,Tags:["coin"]}
- kill @e[tag=spawn_coins]
- delay 50 {
- scoreboard players tag @e[tag=coin] add bad_coin
- execute @e[tag=coin] ~ ~ ~ detect ~ ~-2 ~ gold_block 0 scoreboard players tag @e[tag=coin,c=1,r=1] remove bad_coin
- kill @e[tag=bad_coin]
- }
- # Spawn powerups
- execute @r[type=armor_stand,tag=intersection,c=3] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["powerup_part","powerup_base"],Invisible:1,Marker:1,NoGravity:1,ArmorItems:[{},{},{},{id:potato,Count:1}]}
- execute @e[tag=powerup_base] ~ ~ ~ detect ~ ~ ~ wool 15 tp @e[tag=powerup_base,c=1,r=1] ~ ~ ~-8
- execute @e[tag=powerup_base] ~ ~ ~ summon item ~ ~ ~ {Item:{id:baked_potato,Count:1},Age:-32768,Tags:["powerup_part","powerup"]}
- # Spawn money bags
- execute @r[type=armor_stand,tag=spawn_money_bag,c=5] ~ ~ ~ summon item ~ ~ ~ {Tags:["money_bag"],Item:{id:cooked_rabbit,Count:1,Age:-32768}}
- execute @e[tag=money_bag] ~ ~ ~ detect ~ ~ ~ wool -1 tp @s ~ ~ ~-15
- execute @e[tag=powerup_base] ~ ~ ~ tp @e[tag=money_bag,r=2] ~ ~ ~8
- }
- $_spawn_moneyBag = 0
- repeat spawnMoneyBags:off {
- execute @e[tag=money_bag] ~ ~ ~ kill @e[tag=coin,r=2]
- if ("execute @a ~ ~ ~ testfor @e[tag=money_bag,r=10]")
- {
- $_spawn_moneyBag = 0
- }
- $_spawn_moneyBag++
- if ($_spawn_moneyBag > 300)
- {
- # execute @a ~ ~ ~ kill @e[tag=money_bag,c=-1]
- execute @e[tag=car] ~ ~ ~ execute @r[type=armor_stand,tag=spawn_money_bag,rm=15] ~ ~ ~ summon item ~ ~ ~ {Tags:["money_bag"],Item:{id:cooked_rabbit,Count:1,Age:-32768}}
- $_spawn_moneyBag = 0
- }
- }
- function gameOver() {
- # Used to prevent cars from moving and pedestrians from walking
- scoreboard players tag @a add game_over
- execute @a ~ ~ ~ playsound gameover neutral @a ~ ~ ~ 10
- # Makes the police and tanks stop moving
- entitydata @e[type=wolf] {NoAI:1,Attributes:[{Name:"generic.movementSpeed",Base:0.0f}]}
- delay 40 {
- title @a times 20 100 20
- title @a subtitle {"score":{"name":"@a","objective":"points"},"color":"yellow","bold":true}
- title @a title {"text":"Game OVER","color":"dark_purple","bold":true}
- delay 170 {
- # Done showing Game OVER and the player's score
- tp @e[tag=car] 967 6 995
- reset()
- }
- }
- }
- function failedObjective($reason) {
- # Used to prevent cars from moving and pedestrians from walking
- scoreboard players tag @a add game_over
- scoreboard players tag @a add failed_objective
- execute @a ~ ~ ~ playsound gameover neutral @a ~ ~ ~ 10
- # Makes the police and tanks stop moving
- entitydata @e[type=wolf] {NoAI:1,Attributes:[{Name:"generic.movementSpeed",Base:0.0f}]}
- delay 40 {
- title @a times 20 100 20
- title @a subtitle {"text":"$reason","color":"dark_red","bold":true}
- title @a title {"text":"You Failed!","color":"dark_purple","bold":true}
- delay 170 {
- # Done showing Game OVER and the player's score
- tp @e[tag=car] 967 6 995
- reset()
- }
- }
- }
- function displayTitle($message) {
- title @a times 10 60 10
- title @a subtitle {"text":"$message","color":"dark_purple","bold":true}
- title @a title {"text":"","color":"dark_purple"}
- }
- function wonGame() {
- # The player won the game (reached the desert area)
- # This function will run once
- stopAllEvents()
- title @a times 20 100 20
- title @a subtitle {"text":"Congrats!"}
- title @a title {"text":"You WON!","bold":true,"color":"gold"}
- tp @e[tag=car] 991 7 1095
- tp @e[tag=car_model] 991 7 1095
- execute @e[tag=car_model] ~ ~ ~ teleport @a ~-2 ~1 ~2.5 -140 45
- stopsound @a
- execute @a ~ ~ ~ playsound win neutral @a ~ ~ ~ 10
- start winnerScreen
- delay 180 {
- # Title and subtitle are done being shown
- title @a times 20 100 20
- title @a subtitle {"text":"Your Score","bold":true,"color":"dark_red"}
- title @a title {"score":{"name":"@a","objective":"points"},"bold":true,"color":"dark_purple"}
- delay 180 {
- # Second title and subtitle are done being shown
- title @a times 20 60 20
- title @a subtitle {"text":"New car unlocked!","bold":true,"color":"dark_purple"}
- title @a title {"text":""}
- delay 100 {
- # All titles done
- # Player unlocks the next car
- stop winnerScreen
- delay 3 {
- $_unlockedCars++
- reset()
- }
- }
- }
- }
- }
- repeat winnerScreen:off {
- tp @e[tag=car_model] ~ ~ ~0.2 0 0
- execute @e[tag=car_model] ~ ~ ~ teleport @a ~-2 ~1 ~2.5 -140 45
- effect @a invisibility 2 1 true
- execute @e[tag=car_model] ~ ~ ~ teleport @e[tag=NPCVan] ~-2.5 ~ ~-6
- }
- function openTollBooths() {
- scoreboard players tag @a add unlockedTolls
- execute @e[tag=toll_booth] ~ ~ ~ fill ~-3 ~ ~-3 ~3 ~10 ~3 concrete 5 replace concrete 14
- execute @e[tag=toll_booth] ~ ~ ~ fill ~-3 ~ ~-3 ~3 ~10 ~3 air 0 replace end_rod
- execute @a ~ ~ ~ playsound entity.player.levelup neutral @a
- #displayMessage("You now have enough money to pass through toll booths!")
- displayTitle("Toll booths have opened!")
- }
- #$_ring1 = -1
- #repeat tollBoothOpen:off {
- # Makes cars able to pass through to
- #$_ring1 += 8
- #execute @e[tag=car] ~ ~ ~ particle happyVillager ~$sin($_ring1) ~ ~$cos($_ring1) 0 0 0 1 1
- #if ($_ring1>360) {
- # $_ring1=-1
- #}
- #}
- $_randEvent = -1
- function doRandomEvent() {
- #say DO RANDOM EVENT
- $_randEvent = $random(1, 3)
- # tellraw @a $_randEvent
- if ($_randEvent==1) {
- instant displayMessage("Meteor Shower!")
- start eventMeteors
- eventEndTimer()
- }
- if ($_randEvent==2) {
- instant displayMessage("Dust Storm!")
- start eventDustStorm
- execute @a[tag=!game_over] ~ ~ ~ playsound wind neutral @a ~ ~ ~ 10
- eventEndTimerShort()
- }
- if ($_randEvent==3) {
- # Earthquake (message is shown through the dropMoneyBag function below)
- start eventEarthquake
- eventEndTimer()
- execute @a[score_money_bags_min=1] ~ ~ ~ dropMoneyBag()
- }
- }
- $_meteorTimer = 0
- $_meteorRand = 0
- repeat eventMeteors:off {
- $_meteorTimer++
- if ($_meteorTimer > 2) {
- execute @e[tag=car] ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["spawn_meteor"],Invisible:1,Marker:1,NoGravity:1}
- execute @e[tag=car] ~ ~ ~ spreadplayers ~ ~ 15 16 false @e[tag=spawn_meteor]
- $_meteorRand = $random(0, 2)
- if ($_meteorRand == 0) {
- execute @e[tag=spawn_meteor] ~ ~ ~ summon armor_stand ~ ~20 ~ {Tags:["meteor"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:8,Count:1,tag:{Unbreakable:1}}]}
- }
- if ($_meteorRand == 1) {
- execute @e[tag=spawn_meteor] ~ ~ ~ summon armor_stand ~ ~20 ~ {Tags:["meteor"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:9,Count:1,tag:{Unbreakable:1}}]}
- }
- if ($_meteorRand == 2) {
- execute @e[tag=spawn_meteor] ~ ~ ~ summon armor_stand ~ ~20 ~ {Tags:["meteor"],Invisible:1,Marker:1,ArmorItems:[{},{},{},{id:golden_hoe,Damage:10,Count:1,tag:{Unbreakable:1}}]}
- }
- kill @e[tag=spawn_meteor]
- execute @a[tag=!game_over] ~ ~ ~ playsound meteor neutral @a ~ ~ ~ 0.6
- $_meteorTimer = 0
- }
- scoreboard players add @e[tag=meteor] MP 1
- # say meteor loop
- tp @e[tag=meteor,score_MP_min=50] ~ ~-0.1 ~
- kill @e[tag=meteor,score_MP_min=100]
- }
- repeat eventDustStorm:off {
- execute @a ~ ~ ~ particle blockcrack ~ ~ ~ 3 2 3 0.1 150 force @a 12
- execute @a ~ ~ ~ particle blockcrack ~ ~ ~ 3 2 3 0.1 150 force @a 13
- scoreboard players set @e[tag=car,score_driveTime_min=30] driveTime 15
- }
- repeat eventEarthquake:off {
- #scoreboard players add @e[tag=car] onGround 0
- #scoreboard players remove @e[tag=car,score_onGround_min=1] onGround 1
- #scoreboard players set @e[tag=car] onGround 6 {OnGround:1b}
- execute @e[tag=car,score_onGround_min=1] ~ ~ ~ particle blockcrack ~ 7.0 ~ 8 0 8 1 100 force @a 173
- #tp @e[tag=car,score_onGround_min=1] ~ ~0.3 ~
- }
- function dropMoneyBag() {
- instant displayMessage("Earthquake!")
- delay 50 {
- execute @a ~ ~ ~ summon armor_stand ~ ~ ~ {Tags:["drop_money"],Invisible:1,Marker:1,NoGravity:1}
- delay 10 {
- execute @e[tag=drop_money] ~ ~ ~ summon item ~ ~ ~ {Tags:["money_bag"],Item:{id:cooked_rabbit,Count:1,Age:-32768}}
- kill @e[tag=drop_money]
- scoreboard players remove @a money_bags 1
- title @a actionbar ["",{"text":"=== ","bold":true,"color":"dark_red"},{"text":"The earthquake made you drop a money bag! ","bold":true,"color":"yellow"},{"score":{"name":"@a","objective":"money_bags"},"color":"gold"},{"text":" / 5","color":"gold"},{"text":" ===","bold":true,"color":"dark_red"}]
- }
- }
- }
- function eventEndTimer() {
- # regular end timer
- delay 150 {
- stopAllEvents()
- }
- }
- function eventEndTimerShort() {
- # shortened end timer
- delay 100 {
- stopAllEvents()
- }
- }
- function stopAllEvents() {
- stop eventMeteors
- stop eventDustStorm
- stop eventEarthquake
- }
Advertisement
Add Comment
Please, Sign In to add comment