Zeldaboy111

summonFallingBlock af! ]|[ Skript #428

Jun 27th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.09 KB | None | 0 0
  1. # Use armor stands to create skills (i.e. comet)
  2. # Stray (shaman): holds stick, summon angry wolves,
  3. # Add particles & sounds
  4.  
  5.  
  6. options:
  7. logo: &4&lBoss&8:&7
  8. bossGuiName: Bosses
  9.  
  10. # Boss health
  11. maxHealth_zombieBoss: 100
  12. maxHealth_skeletonBoss: 140
  13. maxHealth_blazeBoss: 120
  14. maxHealth_shamanBoss: 110
  15.  
  16. # The permission required to execute the command '/boss'
  17. permission: "boss.*"
  18.  
  19. on enable:
  20. set {zombieBossItem} to zombie head named "&aZombie Boss" with lore " &7Health&8: &7{@maxHealth_zombieBoss}", "&8 ", " &7Click to summon" and " &7the Zombie Boss."
  21. set {skeletonBossItem} to skeleton head named "&fSkeleton Boss" with lore " &7Health&8: &7{@maxHealth_skeletonBoss}", "&8 ", " &7Click to summon" and " &7the Skeleton Boss."
  22. set {blazeBossItem} to blaze rod named "&cBlaze Boss" with lore " &7Health&8: &7{@maxHealth_blazeBoss}", "&8 ", " &7Click to summon" and " &7the Blaze Boss."
  23. set {shamanBossItem} to stick named "&2Shaman Boss" with lore " &7Health&8: &7{@maxHealth_shamanBoss}", "&8 ", " &7Click to summon" and " &7the Shaman Boss."
  24.  
  25.  
  26.  
  27. function getNewLocation(location: Location, offset: Number, direction: Integer) :: Location:
  28. if {_direction} is 0:
  29. set {_location} to location {_offset} meters northeast of {_location}
  30. else if {_direction} is 1:
  31. set {_location} to location {_offset} meters northwest of {_location}
  32. else if {_direction} is 2:
  33. set {_location} to location {_offset} meters southwest of {_location}
  34. else if {_direction} is 3:
  35. set {_location} to location {_offset} meters southeast of {_location}
  36. return {_location}
  37.  
  38. function mustUpdateDirection(input: Number, standsWithTheSameDirection: Integer, dir: Integer) :: boolean:
  39. if {_standsWithTheSameDirection} < 1:
  40. set {_standsWithTheSameDirection} to 1
  41. while {_input} >= {_standsWithTheSameDirection}:
  42. remove {_standsWithTheSameDirection} from {_input}
  43. if {_input} is 0:
  44. return true
  45. return false
  46.  
  47. function getNewDirection(dir: Integer) :: integer:
  48. add 1 to {_dir}
  49. if {_dir} is 4:
  50. set {_dir} to 0
  51. return {_dir}
  52.  
  53. # Number MUST be a duplicate of four
  54. function circle(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  55. set {_summonLocation} to location {_radius} meters north of {_loc}
  56. set {_standsWithTheSameDirection} to {_amount}/4
  57. set {_distanceBetweenStands} to {_radius}/{_standsWithTheSameDirection}
  58. set {_dir} to 2
  59. summon {_entity} at {_summonLocation}
  60. set helmet of last spawned entity to unbreakable skull of "MHF_%{_entity}%" parsed as an offline player
  61. loop {_amount} -1 times:
  62. set {_summonLocation} to getNewLocation({_summonLocation}, {_distanceBetweenStands}, {_dir})
  63. if mustUpdateDirection(loop-value, "%{_standsWithTheSameDirection}%" parsed as an integer, {_dir}) is true:
  64. set {_dir} to getNewDirection({_dir})
  65. summon {_entity} at {_summonLocation}
  66. set helmet of last spawned entity to unbreakable skull of "MHF_%{_entity}%" parsed as an offline player
  67. add "{ArmorDropChances:[0.0f,0.0f,0.0f,0.0f],HandDropChances:[0.0f,0.0f]}" to nbt of {_boss}
  68.  
  69.  
  70. command /boss:
  71. trigger:
  72. if executor is not player:
  73. send "{@logo} This command can only be executed by a player."
  74. else if player doesn't have permission {@permission}:
  75. send "{@logo} You do not have enough permissions to do this."
  76. else:
  77. open chest with 3 rows named "{@bossGuiName}" to player
  78. loop 10 times:
  79. set slot loop-value - 1 of player's current inventory to gray stained glass pane named "&k"
  80. set slot 26 - loop-value - 1 of player's current inventory to gray stained glass pane named "&k"
  81.  
  82. set slot 10 of player's current inventory to {zombieBossItem}
  83. set slot 11 of player's current inventory to {skeletonBossItem}
  84. set slot 12 of player's current inventory to {blazeBossItem}
  85. set slot 13 of player's current inventory to {shamanBossItem}
  86. set {boss.currentInventory.%player%} to true
  87.  
  88. #
  89. # B o s s e s
  90. #
  91.  
  92. function getRandomTarget(boss: Entity, radius: Number) :: Entity:
  93. set {_possibleTargets::*} to all players in radius {_radius} around {_boss}
  94. set {_targetsAreEntities} to false
  95. if size of {_possibleTargets::*} < 1:
  96. set {_targetsAreEntities} to true
  97. set {_possibleTargets::*} to all entities in radius {_radius} around {_boss}
  98. while {_possibleTargets::*} is not empty:
  99. set {_target} to random element out of {_possibleTargets::*}
  100. remove {_target} from {_possibleTargets::*}
  101. if {_target} is not a player:
  102. if {_target} is not {_boss}:
  103. if {_target} is not a dropped item:
  104. if {_target} is not experience orb or painting or item frame or armor stand:
  105. if "%{_target}%" does not contain "arrow":
  106. return {_target}
  107. else if gamemode of {_target} is survival or adventure:
  108. return {_target}
  109.  
  110. set {_stopLoop} to false
  111. if {_possibleTargets::*} is empty:
  112. set {_stopLoop} to true
  113. else if {_possibleTargets::*} is not set:
  114. set {_stopLoop} to true
  115. if {_stopLoop}:
  116. if {_targetsAreEntities} is false:
  117. set {_targetsAreEntities} to true
  118. set {_possibleTargets::*} to all entities in radius {_radius} around {_boss}
  119. else:
  120. return null
  121. function damageEntitiesInRadius(location: Location, radius: Number, damage: Number, ignoreEntity: Entity):
  122. loop all entities in radius {_radius} around {_location}:
  123. if loop-entity is not {_ignoreEntity}:
  124. damage loop-entity by {_damage}/(distance between location of loop-entity and {_location})
  125.  
  126. function summonBoss(entityType: EntityType, location: Location, name: String, heldItem: Item, isAdult: Boolean) :: entity:
  127. set {_boss} to {_entityType}
  128. summon {_boss} at {_location}
  129. set {_boss} to last spawned entity
  130. set display name of {_boss} to "%{_name}%"
  131. set custom name visibility of {_boss} to true
  132. if {_entityType} is stray:
  133. set helmet of {_boss} to unbreakable skull of "12345" parsed as an offline player with nbt "{SkullOwner:{Id:""644c9bad-958b-43ce-9d2f-199d85be607c"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzhkZGY3NmU1NTVkZDVjNGFhOGEwYTVmYzU4NDUyMGNkNjNkNDg5YzI1M2RlOTY5ZjdmMjJmODVhOWEyZDU2In19fQ==""}]}}}" with name "%{_name}% Trophy"
  134. else:
  135. set helmet of {_boss} to unbreakable skull of "MHF_%{_entityType}%" parsed as an offline player with name "%{_name}% Throphy"
  136. set chestplate of {_boss} to air
  137. set leggings of {_boss} to air
  138. set boots of {_boss} to air
  139. set held item of {_boss} to air
  140. add "{ArmorDropChances:[0.0f,0.0f,0.0f,1.1f],HandDropChances:[0.0f,0.0f]}" to nbt of {_boss}
  141. set {_boss} to adult
  142. if {_isAdult} is false:
  143. set {_boss} to baby
  144. return {_boss}
  145.  
  146. function summonZombieBoss(location: Location):
  147. set {_boss} to summonBoss(zombie, {_location}, "&a&lZombie Boss", iron sword, true)
  148. set max health of {_boss} to {@maxHealth_zombieBoss}
  149. set health of {_boss} to {@maxHealth_zombieBoss}
  150. wait 20 ticks
  151. while {_boss} is alive:
  152. if {%{_boss}%.hasUsedJumpAbility} is not true:
  153. set {_rng} to random integer between 0 and 6
  154. if {_rng} is 0, 1 or 2:
  155. circle(location of {_boss}, 3, 8, zombie)
  156. else if {_rng} is 3 or 4:
  157. delete {_target} # Added to resolve an issue whereas the targetted player will be targetted (even when in creative/spectator)
  158. set {_target} to getRandomTarget({_boss}, 9)
  159. if {_target} is set:
  160. jump({_boss}, 5, {_target})
  161. wait 47 ticks
  162.  
  163. function jump(entity: Entity, height: Number, targetLocation: Location):
  164. set {%{_entity}%.hasUsedJumpAbility} to true
  165. push {_entity} (direction from location of {_entity} to {_targetLocation}) at speed 0.7436
  166. push {_entity} 0.9513 meters upwards
  167.  
  168.  
  169. # Skeleton boss
  170. function summonSkeletonBoss(location: Location):
  171. set {_boss} to summonBoss(skeleton, {_location}, "&f&lSkeleton Boss", bow, true)
  172. set max health of {_boss} to {@maxHealth_skeletonBoss}
  173. set health of {_boss} to {@maxHealth_skeletonBoss}
  174. wait 20 ticks
  175. while {_boss} is alive:
  176. set {_rng} to random integer between 0 and 7
  177. if {_rng} is 0, 1 or 2:
  178. circle(location of {_boss}, 3, 4, skeleton)
  179. else if {_rng} is 3 or 4:
  180. delete {_target} # Added to resolve an issue whereas the targetted player will be targetted (even when in creative/spectator)
  181. set {_target} to getRandomTarget({_boss}, 17)
  182. if {_target} is set:
  183. shootArrows({_boss}, random integer between 4 and 7, {_target})
  184. wait 40 ticks
  185.  
  186. function shootArrows(boss: Entity, arrowAmount: Number, target: Entity):
  187. loop {_arrowAmount} times:
  188. if {_boss} is alive:
  189. if {_target} is alive:
  190. if distance between {_boss} and {_target} <= 17:
  191. set {_v} to vector from {_boss} to location of {_target}
  192. make {_boss} shoot arrow at speed 1 {_v}
  193. wait "%random integer between 5 and 9% ticks" parsed as a timespan
  194.  
  195. # Blaze boss
  196. function summonBlazeBoss(location: Location):
  197. set {_boss} to summonBoss(blaze, {_location}, "&c&lBlaze Boss", air, true)
  198. set max health of {_boss} to {@maxHealth_blazeBoss}
  199. set health of {_boss} to {@maxHealth_blazeBoss}
  200. wait 20 ticks
  201. while {_boss} is alive:
  202. set {_rng} to random integer between 0 and 8
  203. if {_rng} is 0, 1 or 2:
  204. circle(location of {_boss}, 4, 4, blaze)
  205. else if {_rng} is 3 or 4:
  206. delete {_target} # Added to resolve an issue whereas the targetted player will be targetted (even when in creative/spectator)
  207. set {_target} to getRandomTarget({_boss}, 17)
  208. if {_target} is set:
  209. summonComet({_boss}, {_target})
  210. wait 40 ticks
  211.  
  212. function summonComet(boss: Entity, target: Entity):
  213. set {_cometY::*} to 0, 0, 0, 0, 0, 0.2 and -0.2
  214. set {_cometX::*} to 0, 0.2, 0, -0.2, 0, 0 and 0
  215. set {_cometZ::*} to 0.2, 0, -0.2, 0, 0, 0 and 0
  216. loop 7 times:
  217. summon armor stand at location 10+{_cometY::%loop-value%} meters above, {_cometX::%loop-value%} meters east and {_cometZ::%loop-value%} meters south of {_target}
  218. set {_stand::%loop-value%} to last spawned armor stand
  219. set metadata value "IsCometStand" of {_stand::%loop-value%} to true
  220. set helmet of {_stand::%loop-value%} to coal block
  221. add "{Invisible:1b}" to nbt of {_stand::%loop-value%}
  222. while {_stand::1} is not on ground:
  223. wait 5 ticks
  224. set {_loc} to location of {_stand::1}
  225. loop {_stand::*}:
  226. kill loop-value
  227. damageEntitiesInRadius({_loc}, 3.9, 3.9, {_boss})
  228.  
  229. # Shaman boss:
  230. # - wolves {Angry:20}
  231. # - Dirt/stone instead of meteor: get block from surrounding and remove that block, summon fallingsand of that type above the target
  232. # - Healing perk
  233.  
  234. function getRandomVector() :: integers:
  235. loop 3 times:
  236. if loop-value is 1:
  237. add random integer between -1 and 0 to {_values::*}
  238. else:
  239. add random integer between -5 and 5 to {_values::*}
  240. return {_values::*}
  241.  
  242. command /fb:
  243. trigger:
  244. summonFallingBlock(player, player)
  245.  
  246. function summonFallingBlock(boss: Entity, target: Location):
  247. set {_loc} to getRandomFallingBlockLocation({_boss}, location 1 meters below {_target}, 5)
  248. set {_block} to block at {_loc}
  249. set {_valid} to true
  250. if isValidBlockLocation({_loc}, location 1 meters below {_target}) is false:
  251. set {_valid} to false
  252. set {_block} to dirt
  253. chance of 4%:
  254. set {_block} to grass block
  255. spawn falling block of {_block} at location 7 meters above {_target}
  256. set {_fallingBlock} to last spawned falling block
  257. set metadata value "IsBossFallingBlock" of {_fallingBlock} to true
  258. if {_valid}:
  259. set block at {_loc} to air
  260.  
  261. function isValidBlockLocation(location: Location, invalidLocation: Location) :: Boolean:
  262. if {_location} is {_invalidLocation}:
  263. return false
  264. else if block at {_location} is air:
  265. return false
  266. return true
  267.  
  268. function getRandomFallingBlockLocation(boss: Entity, invalidLocation: Location, retryCount: Integer) :: location:
  269. loop {_retryCount} times:
  270. set {_vector::*} to getRandomVector()
  271. set {_l} to location {_vector::1} meters north, {_vector::2} meters above and {_vector::3} meters east of {_boss}
  272. if block at {_l} is not air:
  273. if {_l} is not {_invalidLocation}:
  274. return {_l}
  275. return {_l}
  276. # Head is incorrect
  277. function summonShamanBoss(location: Location):
  278. set {_boss} to summonBoss(stray, {_location}, "&2&lShaman Boss", stick, true)
  279. set metadata value "ExcemptWolfTarget" of {_boss} to true
  280. set max health of {_boss} to {@maxHealth_shamanBoss}
  281. set health of {_boss} to {@maxHealth_shamanBoss}
  282. wait 20 ticks
  283. while {_boss} is alive:
  284. set {_rng} to random integer between 0 and 7
  285. set {_rng} to 3
  286. if {_rng} is 0, 1 or 2:
  287. delete {_target} # Added to resolve an issue whereas the targetted player will be targetted (even when in creative/spectator)
  288. set {_target} to getRandomTarget({_boss}, 21)
  289. if {_target} is set:
  290. circle(location of {_boss}, 4, 4, skeleton)
  291. else if {_rng} is 3 or 4:
  292. delete {_target} # Added to resolve an issue whereas the targetted player will be targetted (even when in creative/spectator)
  293. set {_target} to getRandomTarget({_boss}, 27)
  294. if {_target} is set:
  295. summonFallingBlock({_boss}, {_target})
  296. else if {_rng} is 5:
  297. # Healing perk
  298. wait 40 ticks
  299.  
  300.  
  301. on inventory click:
  302. if inventory name of player's current inventory is "{@bossGuiName}":
  303. cancel event
  304. if clicked item is {zombieBossItem}:
  305. summonZombieBoss(location of player)
  306. close inventory of player
  307. else if clicked item is {skeletonBossItem}:
  308. summonSkeletonBoss(location of player)
  309. close inventory of player
  310. else if clicked item is {blazeBossItem}:
  311. summonBlazeBoss(location of player)
  312. close inventory of player
  313. else if clicked item is {shamanBossItem}:
  314. summonShamanBoss(location of player)
  315. close inventory of player
  316.  
  317.  
  318. on inventory close:
  319. delete {boss.currentInventory.%player%}
  320. on inventory drag:
  321. if {boss.currentInventory.%player%} is true:
  322. cancel event
  323.  
  324. on quit:
  325. delete {boss.currentInventory.%player%}
  326.  
  327. on damage:
  328. if damage cause is fall:
  329. if {%victim%.hasUsedJumpAbility} is true:
  330. delete {%victim%.hasUsedJumpAbility}
  331. damageEntitiesInRadius(location of {_victim}, 4.3, 2.6, victim)
  332.  
  333. on right click on armor stand:
  334. if metadata value "IsCometStand" of clicked entity is true:
  335. cancel event
  336.  
  337. on falling block land:
  338. if metadata value "IsBossFallingBlock" of event-entity is true:
  339. clear metadata value "IsBossFallingBlock" of event-entity
  340. damageEntitiesInRadius(location of event-entity, 3.8, 2.1, event-entity)
  341.  
  342.  
Advertisement
Add Comment
Please, Sign In to add comment