Zeldaboy111

Circle Functie ]|[ Skript #407

Apr 15th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.29 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. function getNewLocation(location: Location, offset: Number, direction: Integer) :: Location:
  8. if {_direction} is 0:
  9. set {_location} to location {_offset} meters northeast of {_location}
  10. else if {_direction} is 1:
  11. set {_location} to location {_offset} meters northwest of {_location}
  12. else if {_direction} is 2:
  13. set {_location} to location {_offset} meters southwest of {_location}
  14. else if {_direction} is 3:
  15. set {_location} to location {_offset} meters southeast of {_location}
  16. return {_location}
  17.  
  18. function getIntegerAsDirection(input: Integer, standAmount: Integer) :: Number:
  19. # Location incorrect with a different number than four stands
  20. set {_value} to {_input} / ({_standAmount}/4)
  21. while {_value} >= 4:
  22. remove 4 from {_value}
  23. return {_value}
  24.  
  25. function circle1(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  26. set {_distance} to {_radius} / {_amount} * 2 + 1
  27. #broadcast "%{_distance}%"
  28. set {_startLocation} to location {_distance} meters north of {_loc}
  29. if {_amount} > 4:
  30. set {_startLocation} to location {_distance} meters northwest of {_loc}
  31.  
  32. set {_sameDir} to {_amount}/4
  33. set {_dir} to -1
  34. loop 4 times:
  35. add 1 to {_dir}
  36. loop {_sameDir} times:
  37. # Or-statement would not work for some reason.
  38. if loop-value-2 > 1:
  39. set {_startLocation} to getNewLocation({_startLocation}, {_distance}, {_dir})
  40. else if {_dir} > 0:
  41. set {_startLocation} to getNewLocation({_startLocation}, {_distance}, {_dir})
  42. summon {_entity} at {_startLocation}
  43.  
  44. #loop {_amount} times:
  45. # if loop-value > 1:
  46. # set {_i} to getIntegerAsDirection("%loop-value%" parsed as an integer, {_amount})
  47. # broadcast "%{_i}%"
  48. # set {_startLocation} to getNewLocation({_startLocation}, {_distance}, getIntegerAsDirection(("%loop-value%" parsed as an integer), {_amount}))
  49. # summon {_entity} at {_startLocation}
  50.  
  51. function mustUpdateDirection(input: Number, standsWithTheSameDirection: Integer) :: boolean:
  52. if {_standsWithTheSameDirection} < 1:
  53. set {_standsWithTheSameDirection} to 1
  54. while {_input} >= {_standsWithTheSameDirection}:
  55. remove {_standsWithTheSameDirection} from {_input}
  56. if {_input} is 0:
  57. return true
  58. return false
  59.  
  60. function circle(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  61. set {_summonLocation} to location {_radius} meters north of {_loc}
  62. set {_standsWithTheSameDirection} to {_amount}/4
  63. set {_distanceBetweenStands} to {_radius}/{_standsWithTheSameDirection}
  64. set {_dir} to 0
  65. if {_standsWithTheSameDirection} > 1:
  66. set {_summonLocation} to location {_distanceBetweenStands}*{_standsWithTheSameDirection} meters south and {_distanceBetweenStands} meters east of {_summonLocation}
  67. #if {_standsWithTheSameDirection} > 1:
  68. # add 1 to {_standsWithTheSameDirection}
  69. broadcast "%{_standsWithTheSameDirection}%"
  70. loop {_amount} times:
  71. if mustUpdateDirection(loop-value, "%{_standsWithTheSameDirection}%" parsed as an integer) is true:
  72. add 1 to {_dir}
  73. if {_dir} is 4:
  74. set {_dir} to 0
  75. #if loop-value > {_standsWithTheSameDirection}:
  76. set {_summonLocation} to getNewLocation({_summonLocation}, {_distanceBetweenStands}, {_dir})
  77. #broadcast "%{_dir}% UPDATE"
  78. summon {_entity} at {_summonLocation}
  79. set display name of last spawned armor stand to "%{_dir}%"
  80.  
  81.  
  82. # Test commands
  83. command /circle <Integer> <Integer>:
  84. trigger:
  85. circle(location of player, argument 1, argument 2, armor stand)
  86.  
  87. # Use armor stands to create skills (i.e. comet)
  88. # Zombie boss: hordes of zombies, etc
  89. # Skeleton boss: archer, summon skeletons, shoot arrow with high damage
  90. # Blaze boss: comet/fireball, summon blazes,
  91. # Stray (shaman): holds stick, summon angry wolves,
  92.  
  93. function getNewLocation(location: Location, offset: Number, direction: Integer) :: Location:
  94. if {_direction} is 0:
  95. set {_location} to location {_offset} meters northeast of {_location}
  96. else if {_direction} is 1:
  97. set {_location} to location {_offset} meters northwest of {_location}
  98. else if {_direction} is 2:
  99. set {_location} to location {_offset} meters southwest of {_location}
  100. else if {_direction} is 3:
  101. set {_location} to location {_offset} meters southeast of {_location}
  102. return {_location}
  103.  
  104. function getIntegerAsDirection(input: Integer, standAmount: Integer) :: Number:
  105. # Location incorrect with a different number than four stands
  106. set {_value} to {_input} / ({_standAmount}/4)
  107. while {_value} >= 4:
  108. remove 4 from {_value}
  109. return {_value}
  110.  
  111. function circle1(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  112. set {_distance} to {_radius} / {_amount} * 2 + 1
  113. #broadcast "%{_distance}%"
  114. set {_startLocation} to location {_distance} meters north of {_loc}
  115. if {_amount} > 4:
  116. set {_startLocation} to location {_distance} meters northwest of {_loc}
  117.  
  118. set {_sameDir} to {_amount}/4
  119. set {_dir} to -1
  120. loop 4 times:
  121. add 1 to {_dir}
  122. loop {_sameDir} times:
  123. # Or-statement would not work for some reason.
  124. if loop-value-2 > 1:
  125. set {_startLocation} to getNewLocation({_startLocation}, {_distance}, {_dir})
  126. else if {_dir} > 0:
  127. set {_startLocation} to getNewLocation({_startLocation}, {_distance}, {_dir})
  128. summon {_entity} at {_startLocation}
  129.  
  130. #loop {_amount} times:
  131. # if loop-value > 1:
  132. # set {_i} to getIntegerAsDirection("%loop-value%" parsed as an integer, {_amount})
  133. # broadcast "%{_i}%"
  134. # set {_startLocation} to getNewLocation({_startLocation}, {_distance}, getIntegerAsDirection(("%loop-value%" parsed as an integer), {_amount}))
  135. # summon {_entity} at {_startLocation}
  136.  
  137. function mustUpdateDirection(input: Number, standsWithTheSameDirection: Integer) :: boolean:
  138. if {_standsWithTheSameDirection} < 1:
  139. set {_standsWithTheSameDirection} to 1
  140. while {_input} >= {_standsWithTheSameDirection}:
  141. remove {_standsWithTheSameDirection} from {_input}
  142. if {_input} is 0:
  143. return true
  144. return false
  145.  
  146. function circle(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  147. set {_summonLocation} to location {_radius} meters north of {_loc}
  148. set {_standsWithTheSameDirection} to {_amount}/4
  149. set {_distanceBetweenStands} to {_radius}/{_standsWithTheSameDirection}
  150. set {_dir} to 0
  151. if {_standsWithTheSameDirection} > 1:
  152. set {_summonLocation} to location {_distanceBetweenStands}*{_standsWithTheSameDirection} meters south and {_distanceBetweenStands} meters east of {_summonLocation}
  153. #if {_standsWithTheSameDirection} > 1:
  154. # add 1 to {_standsWithTheSameDirection}
  155. broadcast "%{_standsWithTheSameDirection}%"
  156. loop {_amount} times:
  157. if mustUpdateDirection(loop-value, "%{_standsWithTheSameDirection}%" parsed as an integer) is true:
  158. add 1 to {_dir}
  159. if {_dir} is 4:
  160. set {_dir} to 0
  161. #if loop-value > {_standsWithTheSameDirection}:
  162. set {_summonLocation} to getNewLocation({_summonLocation}, {_distanceBetweenStands}, {_dir})
  163. #broadcast "%{_dir}% UPDATE"
  164. summon {_entity} at {_summonLocation}
  165. set display name of last spawned armor stand to "%{_dir}%"
  166.  
  167.  
  168. # Test commands
  169. command /circle <Integer> <Integer>:
  170. trigger:
  171. circle(location of player, argument 1, argument 2, armor stand)
  172.  
  173.  
Advertisement
Add Comment
Please, Sign In to add comment