Zeldaboy111

Circle Functie ]|[ Skript #405

Apr 8th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 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 2:
  9. set {_location} to location {_offset} meters northeast of {_location}
  10. else if {_direction} is 3:
  11. set {_location} to location {_offset} meters northwest of {_location}
  12. else if {_direction} is 0:
  13. set {_location} to location {_offset} meters southwest of {_location}
  14. else if {_direction} is 1:
  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: Number) :: boolean:
  52. while {_input} >= {_standsWithTheSameDirection}:
  53. remove {_standsWithTheSameDirection} from {_input}
  54. if {_input} is 0:
  55. return true
  56. return false
  57.  
  58. function circle(loc: location, radius: Integer, amount: Integer, entity: EntityType):
  59. set {_summonLocation} to location {_radius} meters north of {_loc}
  60. set {_standsWithTheSameDirection} to {_amount}/4
  61. set {_distanceBetweenStands} to {_distance}/{_standsWithTheSameDirection}
  62. set {_dir} to 0
  63. loop {_amount} times:
  64. if mustUpdateDirection(loop-value, {_standsWithTheSameDirection}) is true:
  65. add 1 to {_dir}
  66. if {_amount} > 1:
  67. set {_summonLocation} to getNewLocation({_summonLocation}, {_distanceBetweenStands}, {_dir})
  68. summon {_entity} at {_summonLocation}
  69.  
  70.  
  71. # Test commands
  72. command /circle <Integer> <Integer>:
  73. trigger:
  74. circle(location of player, argument 1, argument 2, armor stand)
  75.  
Advertisement
Add Comment
Please, Sign In to add comment