firedemon88

Scatter

Mar 1st, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.92 KB | None | 0 0
  1. # Scatter Skript by Fleft. This is an advanced Skript. Use at your own risk. I am not responsible for any damage caused to servers because of this Skript.
  2.  
  3. # To disable/enable and of these features below, change them to simply "true" or "false".
  4.  
  5. # This was meant to be used in UHC games on www.reddit.com/r/ultrahardcore.
  6.  
  7. # Version: v1.3
  8.  
  9.  
  10. options:
  11.  
  12.  
  13. #--------------------------------------------------
  14. # Options
  15. #--------------------------------------------------
  16.  
  17. Prefix: &8[&Scatter&8]&7
  18. # Prefix for scatter messages
  19.  
  20. ScatterSound: note.bass
  21. # Sound when person is scattered
  22.  
  23. ScatterPitch: 2
  24. # Pitch when person is scattered
  25.  
  26. HC: &3
  27. # Chat color when there's **x** seconds, **player**, misc
  28.  
  29. CC: &7
  30. # Main chat color
  31.  
  32. DisableChat: true
  33. # Disables chat while people are being scattered
  34.  
  35. Tries: 901
  36. # Limit to how many times the Skript will attempt to load a given location
  37.  
  38. ChunkLoadTicks: 7
  39. # Time in between each chunk being loaded in ***TICKS***
  40.  
  41. ScatterTicks: 1
  42. # Time in between each player being teleported in ***TICKS***
  43.  
  44. BroadcastLoadedChunks: false
  45. # Broadcast when the command sender automatically loads each chunk
  46.  
  47. BroadcastScatteredPlayers: true
  48. # Broadcast when each individual is scattered
  49.  
  50. LoadGeneratedChunks: true
  51. # Load the generated chunks? Takes longer, but less lag. You absolutely should use this with 30+ players.
  52.  
  53.  
  54.  
  55. #--------------------------------------------------
  56. # Command
  57. #--------------------------------------------------
  58.  
  59. command /fleftscatter [<world>] [<integer>] [<text>]:
  60. aliases: /fleftscatter, /fscatter, /fsca, /sca
  61. permission: skript.fleftscatter
  62. trigger:
  63.  
  64. #--------------------------------------------------
  65. # Arguments
  66. #--------------------------------------------------
  67.  
  68. if arg-1 is not set:
  69. message "{@Prefix}{@CC} /sca <world> <radius> <*/teams/player>"
  70. command "/playsound random.break %command sender% ~ ~ ~ 1 1 1"
  71. stop trigger
  72. else if arg-2 is not set:
  73. message "{@Prefix}{@CC} /sca <world> <radius> <*/teams/player>"
  74. command "/playsound random.break %command sender% ~ ~ ~ 1 1 1"
  75. stop trigger
  76. else if arg-3 is not set:
  77. message "{@Prefix}{@CC} /sca <world> <radius> <*/teams/player>"
  78. command "/playsound random.break %command sender% ~ ~ ~ 1 1 1"
  79. stop trigger
  80.  
  81.  
  82. #--------------------------------------------------
  83. # FFA Scatter
  84. #--------------------------------------------------
  85.  
  86. if arg-3 is "all" or "*":
  87. set {_Scatter.ListOfAllPlayers::*} to all players
  88. set {_Scatter.AmountOfPlayers} to (size of {_Scatter.ListOfAllPlayers::*})
  89. if (size of ({_Scatter.ListOfAllPlayers::*})) is equal to 0:
  90. message "{@Prefix}{@CC} No one can be scattered!"
  91. stop trigger
  92. set {Scatter.DisableChunkUnload} to true
  93. set {Scatter.DisableChat} to true
  94. set {_Scatter.world} to arg-1
  95. set {_Scatter.radius} to arg-2
  96. set {_Scatter.mindist} to (({_Scatter.radius}/{_Scatter.AmountOfPlayers})*3.5)
  97. broadcast "{@Prefix}{@CC} Attempting to scatter {@HC}%{_Scatter.AmountOfPlayers}%{@CC} players!"
  98. loop {_Scatter.AmountOfPlayers} times:
  99. loop {@Tries} times:
  100. if loop-number-2 is equal to {@Tries}:
  101. broadcast "{@Prefix}{@CC} Could not scatter %loop-number-1%/%{_Scatter.AmountOfPlayers}%"
  102. broadcast "{@Prefix}{@CC} Some players may have been scattered!"
  103. broadcast "{@Prefix}{@CC} You may want to /tpall!"
  104. command "/fleftscattersound random.break 1"
  105. stop trigger
  106. set {_Scatter.Location.Good} to true
  107. set {_Scatter.SkyLocation} to (the location at ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5), 255, ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5) of the world {_Scatter.world})
  108. loop ((loop-number-1)-1) times:
  109. if {_Scatter.Location.Good} is true:
  110. distance between {_Scatter.SkyLocation} and {_Scatter.FinalLocations.Sky::%loop-number-3%} is less than {_Scatter.mindist}:
  111. delete {_Scatter.Location.Good}
  112. if {_Scatter.Location.Good} is true:
  113. set {_Scatter.GroundLocation} to {_Scatter.SkyLocation}
  114. while (block at {_Scatter.GroundLocation}) is air:
  115. if y-coordinate of {_Scatter.GroundLocation} is less than 5:
  116. delete {_Scatter.Location.Good}
  117. stop loop
  118. set {_Scatter.GroundLocation} to location 1 below {_Scatter.GroundLocation}
  119. if {_Scatter.Location.Good} is true:
  120. if (block at {_Scatter.GroundLocation}) is cactus, water, or lava:
  121. delete {_Scatter.Location.Good}
  122. if {_Scatter.Location.Good} is true:
  123. set {_Scatter.GroundLocation} to (location 1 above {_Scatter.GroundLocation})
  124. add 1 to {_Scatter.GeneratedLocations}
  125. add 1 to {_Scatter.GenerationTime}
  126. add {_Scatter.SkyLocation} to {_Scatter.FinalLocations.Sky::*}
  127. add {_Scatter.GroundLocation} to {_Scatter.FinalLocations.Ground::*}
  128. add {_Scatter.GroundLocation} to {_Scatter.ChunkLoading::*}
  129. wait 1 tick
  130. stop loop
  131. broadcast "{@Prefix}{@CC} All locations found!"
  132. broadcast ""
  133. if {@LoadGeneratedChunks} is true:
  134. broadcast "{@Prefix}{@CC} Loading chunks at each location!"
  135. loop {_Scatter.AmountOfPlayers} times:
  136. command sender is not online:
  137. broadcast "{@Prefix}{@CC} Scatter failed, command sender logged out."
  138. loop all players:
  139. execute console command "/playsound random.break %loop-player % ~ ~ ~ 1 1 1"
  140. stop trigger
  141. else:
  142. add 1 to {_Scatter.LoadedChunks}
  143. set {_Scatter.ChunkLoaderLocation} to a random element out of {_Scatter.ChunkLoading::*}
  144. remove {_Scatter.ChunkLoaderLocation} from {_Scatter.ChunkLoading::*}
  145. teleport (command sender) to {_Scatter.ChunkLoaderLocation}
  146. if {@BroadcastLoadedChunks} is true:
  147. broadcast "{@Prefix}{@CC} Loaded {@HC}%{_Scatter.LoadedChunks}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}%"
  148. wait {@ChunkLoadTicks} ticks
  149. broadcast "{@Prefix}{@CC} Loading of chunks completed!"
  150. broadcast ""
  151. wait 1 second
  152. loop {_Scatter.ListOfAllPlayers::*}:
  153. add 1 to {_Scatter.Scattered}
  154. add 1 to {_Scatter.ScatteredTime}
  155. set {_Scatter.FFAPlayer} to loop-value
  156. remove {_Scatter.FFAPlayer} from {_Scatter.ListOfAllPlayers::*}
  157. set {_Scatter.FinalLocation} to a random element out of {_Scatter.FinalLocations.Ground::*}
  158. remove {_Scatter.FinalLocation} from {_Scatter.FinalLocations.Ground::*}
  159. execute console command "/fleftscattersound {@ScatterSound} {@ScatterPitch}"
  160. if {_Scatter.FFAPlayer} is not online:
  161. set {Scatter.schedule::%{_Scatter.FFAPlayer}%} to {_Scatter.FinalLocation}
  162. broadcast "{@Prefix}{@CC} %{_Scatter.FFAPlayer}% - Scheduled Scatter"
  163. else:
  164. if {@BroadcastScatteredPlayers} is true:
  165. broadcast "{@Prefix}{@CC} - {@HC}%{_Scatter.Scattered}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}% - &7 %{_Scatter.FFAPlayer}%"
  166. teleport {_Scatter.FFAPlayer} to {_Scatter.FinalLocation}
  167. wait {@ScatterTicks} tick
  168. broadcast ""
  169. broadcast "{@Prefix}{@CC} All players scattered!"
  170. broadcast "{@Prefix}{@CC} Lowest mindist: {@HC}~%{_Scatter.mindist}%{@CC} with radius {@HC}%{_Scatter.radius}%!"
  171. delete {Scatter.DisableChunkUnload}
  172. delete {Scatter.DisableChat}
  173. loop 7 times:
  174. command "/aps fireworks.largeBlast_far 0.5"
  175. wait 3 ticks
  176.  
  177. #--------------------------------------------------
  178. # Team + Solo Scatter
  179. #--------------------------------------------------
  180. else if arg-3 is "team" or "teams":
  181. set {_Scatter.TeamCount} to 0
  182. loop {Teams::*}:
  183. {Team.%loop-value%::*} is set:
  184. increase {_Scatter.TeamCount} by 1
  185. add {_Scatter.TeamCount} to {_Scatter.Teams::*}
  186. set {_Scatter.Team.%{_Scatter.TeamCount}%::*} to {Team.%loop-value%::*}
  187. set {_Scatter.MainPlayer} to a random element out of {Team.%loop-value%::*}
  188. set {_Scatter.MainPlayer} to {_Scatter.MainPlayer} parsed as offlineplayer
  189. add {_Scatter.MainPlayer} to {_Scatter.ListOfAllPlayers::*}
  190. loop all players:
  191. {Teams.InTeam::%loop-player%} is not set:
  192. add (name of loop-player) to {_Scatter.Solos::*}
  193. add (name of loop-player) to {_Scatter.ListOfAllPlayers::*}
  194. set {_Scatter.AmountOfPlayers} to ((size of {_Scatter.Teams::*})+(size of {_Scatter.Solos::*}))
  195. if (size of ({_Scatter.ListOfAllPlayers::*})) is equal to 0:
  196. message "{@Prefix}{@CC} No one can be scattered!"
  197. stop trigger
  198. set {Scatter.DisableChunkUnload} to true
  199. set {Scatter.DisableChat} to true
  200. set {_Scatter.world} to arg-1
  201. set {_Scatter.radius} to arg-2
  202. set {_Scatter.mindist} to (({_Scatter.radius}/{_Scatter.AmountOfPlayers})*5)
  203. broadcast "{@Prefix}{@CC} Attempting to scatter {@HC}%(size of ({_Scatter.Teams::*}))%{@CC} teams and {@HC}%(size of ({_Scatter.Solos::*}))%{@CC} solos!"
  204. loop {_Scatter.AmountOfPlayers} times:
  205. loop {@Tries} times:
  206. if loop-number-2 is equal to {@Tries}:
  207. broadcast "{@Prefix}{@CC} Could not scatter %loop-number-1%/%{_Scatter.AmountOfPlayers}%"
  208. broadcast "{@Prefix}{@CC} Some players may have been scattered!"
  209. broadcast "{@Prefix}{@CC} You may want to /tpall!"
  210. command "/fleftscattersound random.break 1"
  211. delete {Scatter.DisableChunkLoading}
  212. delete {Scatter.DisableChat}
  213. stop trigger
  214. set {_Scatter.Location.Good} to true
  215. set {_Scatter.SkyLocation} to (the location at ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5), 255, ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5) of the world {_Scatter.world})
  216. loop ((loop-number-1)-1) times:
  217. if {_Scatter.Location.Good} is true:
  218. distance between {_Scatter.SkyLocation} and {_Scatter.FinalLocations.Sky::%loop-number-3%} is less than {_Scatter.mindist}:
  219. delete {_Scatter.Location.Good}
  220. if {_Scatter.Location.Good} is true:
  221. set {_Scatter.GroundLocation} to {_Scatter.SkyLocation}
  222. while (block at {_Scatter.GroundLocation}) is air:
  223. if y-coordinate of {_Scatter.GroundLocation} is less than 5:
  224. delete {_Scatter.Location.Good}
  225. stop loop
  226. set {_Scatter.GroundLocation} to location 1 below {_Scatter.GroundLocation}
  227. if {_Scatter.Location.Good} is true:
  228. if (block at {_Scatter.GroundLocation}) is cactus, water, or lava:
  229. delete {_Scatter.Location.Good}
  230. if {_Scatter.Location.Good} is true:
  231. set {_Scatter.GroundLocation} to (location 1 above {_Scatter.GroundLocation})
  232. add 1 to {_Scatter.GeneratedLocations}
  233. add 1 to {_Scatter.GenerationTime}
  234. add {_Scatter.SkyLocation} to {_Scatter.FinalLocations.Sky::*}
  235. add {_Scatter.GroundLocation} to {_Scatter.FinalLocations.Ground::*}
  236. add {_Scatter.GroundLocation} to {_Scatter.ChunkLoading::*}
  237. wait 1 tick
  238. stop loop
  239. broadcast "{@Prefix}{@CC} All locations found!"
  240. broadcast ""
  241. broadcast "{@Prefix}{@CC} Loading chunks at each location!"
  242. loop {_Scatter.AmountOfPlayers} times:
  243. command sender is not online:
  244. broadcast "{@Prefix}{@CC} Scatter failed, command sender logged out."
  245. execute console command "/fleftscattersound random.break 1"
  246. stop trigger
  247. else:
  248. add 1 to {_Scatter.LoadedChunks}
  249. set {_Scatter.ChunkLoaderLocation} to a random element out of {_Scatter.ChunkLoading::*}
  250. remove {_Scatter.ChunkLoaderLocation} from {_Scatter.ChunkLoading::*}
  251. teleport (command sender) to {_Scatter.ChunkLoaderLocation}
  252. if {@BroadcastLoadedChunks} is true:
  253. broadcast "{@Prefix}{@CC} Loaded {@HC}%{_Scatter.LoadedChunks}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}%"
  254. wait {@ChunkLoadTicks} ticks
  255. broadcast "{@Prefix}{@CC} Loading of chunks completed!"
  256. broadcast ""
  257. wait 1 second
  258. loop {_Scatter.Teams::*}:
  259. broadcast "{@Prefix}{@CC} Scattering {@HC}Team %loop-value%{@CC}/{@HC}%(size of ({_Scatter.Teams::*}))%!"
  260. set {_Scatter.FinalLocation.Team} to a random element out of {_Scatter.FinalLocations.Ground::*}
  261. remove {_Scatter.FinalLocation.Team} from {_Scatter.FinalLocations.Ground::*}
  262. loop {Team.%loop-value%::*}:
  263. set {_Scatter.TeamPlayer} to loop-value-2 parsed as offlineplayer
  264. add 1 to {_Scatter.Scattered}
  265. add 1 to {_Scatter.ScatteredTime}
  266. if {_Scatter.TeamPlayer} is not online:
  267. set {Scatter.schedule::%{_Scatter.TeamPlayer}%} to {_Scatter.FinalLocation.Team}
  268. broadcast "{@Prefix}{@HC} - {@CC}%{_Scatter.TeamPlayer}%: Scheduled Scatter"
  269. else:
  270. if {@BroadcastScatteredPlayers} is true:
  271. broadcast "{@Prefix}{@HC} - {@CC}%{_Scatter.TeamPlayer}%"
  272. teleport {_Scatter.TeamPlayer} to {_Scatter.FinalLocation.Team}
  273. wait {@ScatterTicks} tick
  274. if {_Scatter.Solos::*} is set:
  275. broadcast ""
  276. broadcast "{@Prefix}{@CC} Scattering solos!"
  277. loop {_Scatter.Solos::*}:
  278. add 1 to {_Scatter.Scattered}
  279. add 1 to {_Scatter.ScatteredTime}
  280. set {_Scatter.FinalLocation.Solo} to a random element out of {_Scatter.FinalLocations.Ground::*}
  281. remove {_Scatter.FinalLocation.Solo} from {_Scatter.FinalLocations.Ground::*}
  282. set {_Scatter.NewSolo} to loop-value parsed as offlineplayer
  283. if {_Scatter.NewSolo} is not online:
  284. broadcast "{@Prefix}{@CC} Scheduled late scatter of {@HC}%{_Scatter.NewSolo}%!"
  285. set {Scatter.schedule::%{_Scatter.NewSolo}%} to {_Scatter.FinalLocation.Solo}
  286. else:
  287. teleport {_Scatter.NewSolo} to {_Scatter.FinalLocation.Solo}
  288. if {@BroadcastScatteredPlayers} is true:
  289. broadcast "{@Prefix}{@HC} SOLO: {@CC}%{_Scatter.NewSolo}%"
  290. wait {@ScatterTicks} tick
  291. broadcast ""
  292. broadcast "{@Prefix}{@CC} All teams scattered!"
  293. #broadcast "{@Prefix}{@CC} Lowest mindist: {@HC}~%{_Scatter.mindist}%{@CC} with radius {@HC}%{_Scatter.radius}%"
  294. delete {Scatter.DisableChunkUnload}
  295. delete {Scatter.DisableChat}
  296. loop 7 times:
  297. command "/fleftscattersound fireworks.largeBlast_far 0.5"
  298. wait 2 ticks
  299.  
  300. #--------------------------------------------------
  301. # Single Player Scatter
  302. #--------------------------------------------------
  303.  
  304. else:
  305. set {_Scatter.AllPlayers::*} to all players
  306. if {_Scatter.AllPlayers::*} does not contain arg-3:
  307. broadcast "{@Prefix}{@HC} %arg-3%{@CC} is not online!"
  308. command "/fleftscattersound random.break 1"
  309. stop trigger
  310. else:
  311. set {_Scatter.SinglePlayer} to arg-3 parsed as offlineplayer
  312. add {_Scatter.SinglePlayer} to {_Scatter.ListOfAllPlayers::*}
  313. set {_Scatter.AmountOfPlayers} to 1
  314. set {_Scatter.world} to arg-1
  315. set {_Scatter.radius} to arg-2
  316. broadcast "{@Prefix}{@CC} Attempting to scatter {@HC}%arg-3%!"
  317. loop {_Scatter.AmountOfPlayers} times:
  318. loop {@Tries} times:
  319. if loop-number-2 is equal to {@Tries}:
  320. broadcast "{@Prefix}{@CC} Could not scatter {@HC}%arg-3%{@CC}. Try again!"
  321. command "/fleftscattersound random.break 1"
  322. stop trigger
  323. set {_Scatter.Location.Good} to true
  324. set {_Scatter.SkyLocation} to (the location at ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5), 255, ((random integer between (0-{_Scatter.radius}) and ({_Scatter.radius}-1))+0.5) of the world {_Scatter.world})
  325. loop ((loop-number-1)-1) times:
  326. if {_Scatter.Location.Good} is true:
  327. distance between {_Scatter.SkyLocation} and {_Scatter.FinalLocations.Sky::%loop-number-3%} is less than {_Scatter.mindist}:
  328. delete {_Scatter.Location.Good}
  329. if {_Scatter.Location.Good} is true:
  330. set {_Scatter.GroundLocation} to {_Scatter.SkyLocation}
  331. while (block at {_Scatter.GroundLocation}) is air:
  332. if y-coordinate of {_Scatter.GroundLocation} is less than 5:
  333. delete {_Scatter.Location.Good}
  334. stop loop
  335. set {_Scatter.GroundLocation} to location 1 below {_Scatter.GroundLocation}
  336. if {_Scatter.Location.Good} is true:
  337. if (block at {_Scatter.GroundLocation}) is cactus, water, or lava:
  338. delete {_Scatter.Location.Good}
  339. if {_Scatter.Location.Good} is true:
  340. set {_Scatter.GroundLocation} to (location 1 above {_Scatter.GroundLocation})
  341. add 1 to {_Scatter.GeneratedLocations}
  342. add 1 to {_Scatter.GenerationTime}
  343. wait 1 tick
  344. stop loop
  345. broadcast "{@Prefix}{@CC} Location found!"
  346. broadcast ""
  347. wait 1 second
  348. add 1 to {_Scatter.Scattered}
  349. add 1 to {_Scatter.ScatteredTime}
  350. execute console command "/fleftscattersound {@ScatterSound} {@ScatterPitch}"
  351. wait 1 tick
  352. if {_Scatter.SinglePlayer} is not online:
  353. set {Scatter.schedule::%{_Scatter.SinglePlayer}%} to {_Scatter.GroundLocation}
  354. broadcast "{@Prefix}{@CC} %{_Scatter.SinglePlayer}% - Scheduled Scatter"
  355. else:
  356. if {@BroadcastScatteredPlayers} is true:
  357. broadcast "{@Prefix} {@HC}%{_Scatter.Scattered}%{@CC}/{@HC}%{_Scatter.AmountOfPlayers}% {@CC}- &7 %{_Scatter.SinglePlayer}%"
  358. teleport {_Scatter.SinglePlayer} to {_Scatter.GroundLocation}
  359. wait {@ScatterTicks} tick
  360. broadcast ""
  361. broadcast "{@Prefix}{@HC} %arg-3%{@CC} scattered!"
  362. broadcast "{@Prefix}{@CC} Radius: {@HC}%{_Scatter.radius}%!"
  363.  
  364. #--------------------------------------------------
  365. # End of Scatter - Event section (and sound command)
  366. #--------------------------------------------------
  367.  
  368.  
  369. on chunk unload:
  370. {Scatter.DisableChunkUnload} is true:
  371. cancel the event
  372. on skript start:
  373. delete {Scatter.DisableChunkUnloading}
  374.  
  375. on chat:
  376. {Scatter.DisableChat} is true:
  377. {@DisableChat} is true:
  378. cancel the event
  379. on login:
  380. {Scatter.schedule::%player%} is set:
  381. wait 1 tick
  382. teleport player to {Scatter.schedule::%player%}
  383. broadcast "{@Prefix}{@HC} %player%{@CC} - scheduled late scatter!"
  384. delete {Scatter.schedule::%player%}
  385.  
  386.  
  387. command /fleftscattersound [<text>] [<number>]:
  388. permission: skript.fleftscatter
  389. trigger:
  390. if arg-2 is not set:
  391. set {_pitch} to 1
  392. if arg-2 is set:
  393. set {_pitch} to arg-2
  394. loop all players:
  395. execute console command "/playsound %arg-1% %loop-player% ~ ~ ~ 1 %{_pitch}% 1"
Add Comment
Please, Sign In to add comment