Zeldaboy111

Circle Functie ]|[ Skript #406

Apr 11th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 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. # add 1 to {_standsWithTheSameDirection}
  67. broadcast "%{_standsWithTheSameDirection}%"
  68. loop {_amount} times:
  69. if mustUpdateDirection(loop-value, "%{_standsWithTheSameDirection}%" parsed as an integer) is true:
  70. add 1 to {_dir}
  71. if {_dir} is 4:
  72. set {_dir} to 0
  73. if loop-value > {_standsWithTheSameDirection}:
  74. set {_summonLocation} to getNewLocation({_summonLocation}, {_distanceBetweenStands}, {_dir})
  75. broadcast "%{_dir}% UPDATE"
  76. summon {_entity} at {_summonLocation}
  77.  
  78.  
  79. # Test commands
  80. command /circle <Integer> <Integer>:
  81. trigger:
  82. circle(location of player, argument 1, argument 2, armor stand)
  83.  
Advertisement
Add Comment
Please, Sign In to add comment