Zeldaboy111

Random Target ]|[ Skript #413

May 6th, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. # Use armor stands to create skills (i.e. comet)
  2. # Zombie boss: hordes of zombies, etc
  3. # Skeleton boss: archer, summon skeletons, shoot arrow with high damage
  4. # Blaze boss: comet/fireball, summon blazes,
  5. # Stray (shaman): holds stick, summon angry wolves,
  6.  
  7. options:
  8. logo: &4&lBoss&8:&7
  9. bossGuiName: Bosses
  10. zombieBossItem: zombie head named "&aZombie Boss" with lore "&8", " &7Click to summon" and " &7the Zombie Boss."
  11. skeletonBossItem: skeleton head named "&fSkeleton Boss" with lore "&8", " &7Click to summon" and " &7the Skeleton Boss."
  12. blazeBossItem: blaze rod named "&cSkeleton Boss" with lore "&8", " &7Click to summon" and " &7the Blaze Boss."
  13. shamanBossItem: stick named "&2Skeleton Boss" with lore "&8", " &7Click to summon" and " &7the Shaman Boss."
  14. permission: "boss.*"
  15.  
  16. function getNewLocation(location: Location, offset: Number, direction: Integer) :: Location:
  17. if {_direction} is 0:
  18. set {_location} to location {_offset} meters northeast of {_location}
  19. else if {_direction} is 1:
  20. set {_location} to location {_offset} meters northwest of {_location}
  21. else if {_direction} is 2:
  22. set {_location} to location {_offset} meters southwest of {_location}
  23. else if {_direction} is 3:
  24. set {_location} to location {_offset} meters southeast of {_location}
  25. return {_location}
  26.  
  27. function mustUpdateDirection(input: Number, standsWithTheSameDirection: Integer, dir: Integer) :: boolean:
  28. if {_standsWithTheSameDirection} < 1:
  29. set {_standsWithTheSameDirection} to 1
  30. while {_input} >= {_standsWithTheSameDirection}:
  31. remove {_standsWithTheSameDirection} from {_input}
  32. if {_input} is 0:
  33. return true
  34. return false
  35.  
  36. function getNewDirection(dir: Integer) :: integer:
  37. add 1 to {_dir}
  38. if {_dir} is 4:
  39. set {_dir} to 0
  40. return {_dir}
  41.  
  42. # Number MUST be a duplicate of four
  43. function circle(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  44. set {_summonLocation} to location {_radius} meters north of {_loc}
  45. set {_standsWithTheSameDirection} to {_amount}/4
  46. set {_distanceBetweenStands} to {_radius}/{_standsWithTheSameDirection}
  47. set {_dir} to 2
  48. summon {_entity} at {_summonLocation}
  49. loop {_amount} -1 times:
  50. set {_summonLocation} to getNewLocation({_summonLocation}, {_distanceBetweenStands}, {_dir})
  51. if mustUpdateDirection(loop-value, "%{_standsWithTheSameDirection}%" parsed as an integer, {_dir}) is true:
  52. set {_dir} to getNewDirection({_dir})
  53. summon {_entity} at {_summonLocation}
  54. set display name of last spawned armor stand to "%loop-value%: %{_dir}%"
  55.  
  56. command /boss:
  57. trigger:
  58. if executor is not player:
  59. send "{@logo} This command can only be executed by a player."
  60. else if player doesn't have permission {@permission}:
  61. send "{@logo} You do not have enough permissions to do this."
  62. else:
  63. open chest with 3 rows named "{@bossGuiName}" to player
  64. loop 10 times:
  65. set slot loop-value - 1 of player's current inventory to gray stained glass pane named "&k"
  66. set slot 26 - loop-value - 1 of player's current inventory to gray stained glass pane named "&k"
  67.  
  68. set slot 10 of player's current inventory to {@zombieBossItem}
  69. set slot 11 of player's current inventory to {@skeletonBossItem}
  70. set slot 12 of player's current inventory to {@blazeBossItem}
  71. set slot 13 of player's current inventory to {@shamanBossItem}
  72. set {boss.currentInventory.%player%} to true
  73.  
  74. #
  75. # B o s s e s
  76. #
  77.  
  78. function getRandomTarget(boss: Entity, radius: Number) :: Entity:
  79. # Doesn't use the correct radius, check for radius
  80. #set {_players::*} to all players in radius {_radius} around {_boss}
  81. set {_possibleTargets::*} to all players in radius {_radius} around {_boss}
  82. set {_targetsAreEntities} to false
  83. while {_possibleTargets::*} is not empty:
  84. set {_target} to random element out of {_possibleTargets::*}
  85. remove {_target} from {_possibleTargets::*}
  86. if {_target} is not a player:
  87. if {_target} is not {_boss}:
  88. return {_target}
  89. else if gamemode of {_target} is survival or adventure:
  90. return {_target}
  91.  
  92. set {_stopLoop} to false
  93. if {_possibleTargets::*} is empty:
  94. set {_stopLoop} to true
  95. else if {_possibleTargets::*} is not set:
  96. set {_stopLoop} to true
  97. if {_stopLoop}:
  98. if {_targetsAreEntities} is false:
  99. set {_targetsAreEntities} to true
  100. set {_possibleTargets::*} to all entities in radius {_radius} around {_boss}
  101. else:
  102. return null
  103.  
  104. #while {_players::*} is not empty:
  105. # set {_p} to random element out of {_players::*}
  106. # remove {_p} from {_players::*}
  107. # if gamemode of {_p} is survival or adventure:
  108. # return {_p}
  109. # else if {_p} is not set:
  110. # clear {_players::*}
  111. #
  112. #set {_entities::*} to all entities in radius {_radius} around {_boss}
  113. #set {_e} to random element out of {_entities::*}
  114. #while type of {_e} is type of {_boss}:
  115. # remove {_e} from {_entities::*}
  116. # if {_entities::*} is empty:
  117. # return null
  118. # set {_e} to random element out of {_entities::*}
  119. #return {_e}
  120.  
  121. function summonZombieBoss(location: Location):
  122. set {_zombie} to zombie
  123. summon {_zombie} at {_location}
  124. set {_zombie} to last spawned zombie
  125. set display name of {_zombie} to "&a&lZombie Boss"
  126. set custom name visibility of {_zombie} to true
  127. wait 20 ticks
  128. while {_zombie} is alive:
  129. if {_hasUsedJumpAbility} is not true:
  130. set {_rng} to random integer between 0 and 10
  131. set {_rng} to 3
  132. broadcast "RNG: %{_rng}%"
  133. if {_rng} is 0, 1 or 2:
  134. circle(location of {_zombie}, 3, 8, zombie)
  135. else if {_rng} is 3 or 4:
  136. set {_target} to getRandomTarget({_zombie}, 5)
  137. if {_target} is set:
  138. jump({_zombie}, 5, {_target})
  139. wait 40 ticks
  140.  
  141. function jump(entity: Entity, height: Number, targetLocation: Location):
  142. set {%{_entity}%.hasUsedJumpAbility} to true
  143. push {_entity} 1.2561 meters upwards
  144. #set {_v} to difference between location at {_targetLocation} and location at location of {_entity}
  145. set {_v} to vector from {_entity} to {_targetLocation}
  146. push {_entity} {_v}
  147.  
  148. on inventory click:
  149. if inventory name of player's current inventory is "{@bossGuiName}":
  150. cancel event
  151. if clicked item is {@zombieBossItem}:
  152. summonZombieBoss(location of player)
  153. close inventory of player
  154. else if clicked item is {@skeletonBossItem}:
  155. send "SKELETON"
  156. close inventory of player
  157. else if clicked item is {@blazeBossItem}:
  158. send "BLAZE"
  159. close inventory of player
  160. else if clicked item is {@shamanBossItem}:
  161. send "SHAMAN"
  162. close inventory of player
  163.  
  164.  
  165. on inventory close:
  166. delete {boss.currentInventory.%player%}
  167. on inventory drag:
  168. if {boss.currentInventory.%player%} is true:
  169. cancel event
  170.  
  171. on quit:
  172. delete {boss.currentInventory.%player%}
  173.  
  174. on damage:
  175. if damage cause is fall:
  176. if {%victim%.hasUsedJumpAbility} is true:
  177. delete {%victim%.hasUsedJumpAbility}
  178. cancel event
  179.  
Advertisement
Add Comment
Please, Sign In to add comment