akon1248

RPG Mob System

Mar 7th, 2019
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.63 KB | None | 0 0
  1. function getTagValues(e: entity) :: strings:
  2. set {_tagnbt} to "%tag ""Tags"" of nbt of {_e}%"
  3. replace "[""" and """]" in {_tagnbt} with ""
  4. return split {_tagnbt} by ""","""
  5.  
  6. function getLivingEntityFromUUID(uuid: text) :: living entity:
  7. loop all entities:
  8. if UUID of loop-entity is "%{_uuid}%":
  9. return loop-entity
  10. stop loop
  11.  
  12. function deleteBossBar(bossbar: string):
  13. evaluate "remove all players from bar %{_bossbar}%"
  14. evaluate "delete %{_bossbar}%"
  15.  
  16. function removePrefix(str1: string, str2: string) :: string:
  17. first length of {_str2} characters of {_str1} is {_str2}
  18. return last length of {_str1} - length of {_str2} characters of {_str1}
  19.  
  20. function getMobTypeName(e: entity) :: string:
  21. set {_name} to "%{_e}.getType()%" in lower case
  22. replace "_" in {_name} with " "
  23. set {_splits::*} to {_name} split by ""
  24. set {_size} to size of {_spilts::*}
  25. delete {_splits::%{_size}%}
  26. set {_splits::1} to {_splits::1} in upper case
  27. loop {_splits::*}:
  28. set {_num} to loop-index parsed as integer - 1
  29. {_splits::%{_num}%} is " "
  30. set {_splits::%loop-index%} to {_splits::%loop-index%} in upper case
  31. return join {_splits::*}
  32.  
  33. #Spawn Mob
  34. function spawnOriginalMob(id: string, loc: location, amount: integer, mythic: boolean):
  35. if {_mythic} is true:
  36. loop {_amount} times:
  37. spawn mythicmob {_id} at {_loc} with level 1
  38. if {_mythic} is false:
  39. {originalmob::%{_id}%} is set
  40. loop {_amount} times:
  41. spawn {originalmob::%{_id}%} at {_loc}
  42. add "{Tags:[""originalmob:%{_id}%""]}" to nbt of last spawned entity
  43. if {originalmobnbt::%{_id}%} is set:
  44. add {originalmobnbt::%{_id}%} to nbt of last spawned entity
  45. if {originalmobhealth::%{_id}%} is set:
  46. set max health of last spawned entity to {originalmobhealth::%{_id}%}/2
  47. set health of last spawned entity to {originalmobhealth::%{_id}%}/2
  48. if {originalmobname::%{_id}%} is set:
  49. set name of last spawned entity to {originalmobname::%{_id}%}
  50. if {originalmobexp::%{_id}%} is set:
  51. add "{Tags:[""exp%{originalmobexp::%{_id}%}%""]}" to nbt of last spawned entity
  52. command /originalmob <text> <boolean> <integer>:
  53. permission: originalmob.admin
  54. permission message: &cYou do not have permission to use this command!
  55. usage: /originalmob <ID> <ismythicmob> <amount>
  56. trigger:
  57. spawnOriginalMob(arg-1, location of player, arg-3, arg-2)
  58. on tab complete:
  59. set {_splits::*} to split event-string by " "
  60. {_splits::1} is "/originalmob"
  61. if size of {_splits::*} is 2:
  62. delete completions
  63. if {_splits::2} is "":
  64. loop {originalmob::*}:
  65. add loop-index to completions
  66. else:
  67. loop {originalmob::*}:
  68. first length of {_splits::2} characters of loop-index is {_splits::2}
  69. add loop-index to completions
  70. else if size of {_splits::*} > 2:
  71. cancel event
  72.  
  73. #Custom Drop
  74. command /customdrop [<text>] [<text>] [<text>]:
  75. permission: acd.admin
  76. permission message: &cYou do not permission to use this command.
  77. trigger:
  78. if arg-1 is not set:
  79. send "&cUsage: /customdrop <add|remove> <dropname> OR /customdrop drops"
  80. stop
  81. if arg-1 is not "add" or "remove" or "drops":
  82. send "&cUsage: /customdrop <add|remove> <dropname> OR /customdrop drops"
  83. stop
  84. if arg-1 is "add" or "remove":
  85. if arg-2 is not set:
  86. send "&cUsage: /customdrop %arg-1% <dropname>"
  87. stop
  88. if arg-3 is set:
  89. send "&cドロップアイテム名に空白は使用できません"
  90. stop
  91. if arg-1 is set:
  92. if arg-1 is "add":
  93. if {customdrops::%arg-2%} is set:
  94. send "&cドロップアイテム%arg-2%は既に存在しています"
  95. stop
  96. if player's tool is air:
  97. send "&cメインハンドに追加したいアイテムを持ってください"
  98. stop
  99. if player's tool is not air:
  100. set {customdrops::%arg-2%} to player's tool
  101. send "&e新しいドロップアイテム%arg-2%を追加しました"
  102. stop
  103. if arg-1 is "remove":
  104. if {customdrops::%arg-2%} is not set:
  105. send "&cドロップアイテム%arg-2%は存在しません"
  106. stop
  107. if {customdrops::%arg-2%} is set:
  108. delete {customdrops::%arg-2%}
  109. send "&eドロップアイテム%arg-2%を消去しました"
  110. stop
  111. else if arg-1 is "drops":
  112. if {customdrops::*} is not set:
  113. send "&c登録されているドロップアイテムはありません"
  114. else if {customdrops::*} is set:
  115. loop {customdrops::*}:
  116. set {_dropstext} to "&e%loop-index%"
  117. stop loop
  118. set {_loopnumber} to 0
  119. loop {customdrops::*}:
  120. add 1 to {_loopnumber}
  121. {_loopnumber} >= 2
  122. set {_dropstext} to "%{_dropstext}%&f, &e%loop-index%"
  123. send "&7Drops (%size of {customdrops::*}%): %{_dropstext}%"
  124. on death:
  125. victim is a living entity
  126. victim is not a player
  127. victim is not armor stand
  128. set {_tags::*} to getTagValues(victim)
  129. if {_tags::*} contain "CustomDropOnly":
  130. clear drops
  131. loop {_tags::*}:
  132. set {_dropoptions::*} to loop-value split by ";"
  133. loop {_dropoptions::*}:
  134. if removePrefix(loop-value-2, "Drop:") is set:
  135. set {_customdropname} to removePrefix(loop-value-2, "Drop:")
  136. if removePrefix(loop-value-2, "DropChance:") is set:
  137. set {_dropchance} to removePrefix(loop-value-2, "DropChance:") parsed as number
  138. if removePrefix(loop-value-2, "MinCount:") is set:
  139. set {_mincount} to removePrefix(loop-value-2, "MinCount:") parsed as integer
  140. if removePrefix(loop-value-2, "MaxCount:") is set:
  141. set {_maxcount} to removePrefix(loop-value-2, "MaxCount:") parsed as integer
  142. if removePrefix(loop-value-2, "RareDrop:") is set:
  143. set {_raredrop} to removePrefix(loop-value-2, "RareDrop:") parsed as boolean
  144. {_customdropname} is set
  145. {_dropchance} is set
  146. {_mincount} is set
  147. {_maxcount} is set
  148. {_raredrop} is set
  149. if {_raredrop} is true:
  150. attacker is a player
  151. chance of {_dropchance}%:
  152. loop random integer between {_maxcount} and {_mincount} times:
  153. if {customdrops::%{_customdropname}%} is set:
  154. drop {customdrops::%{_customdropname}%} at victim
  155. else if {customdrops::%{_customdropname}%} is not set:
  156. set {_dropitem} to {_customdropname} parsed as itemtype
  157. {_dropitem} is set
  158. drop {_dropitem} at victim
  159. else if {_raredrop} is false:
  160. chance of {_dropchance}%:
  161. loop random integer between {_maxcount} and {_mincount} times:
  162. if {customdrops::%{_customdropname}%} is set:
  163. drop {customdrops::%{_customdropname}%} at victim
  164. else if {customdrops::%{_customdropname}%} is not set:
  165. set {_dropitem} to {_customdropname} parsed as itemtype
  166. {_dropitem} is set
  167. drop {_dropitem} at victim
  168. delete {_dropoptions::*}
  169. delete {_customdropname}
  170. delete {_dropchance}
  171. delete {_mincount}
  172. delete {_maxcount}
  173. delete {_raredrop}
  174. delete {_dropitem}
  175.  
  176. #BossBar
  177. every tick:
  178. loop {bossbar::*}:
  179. getLivingEntityFromUUID(loop-index) is not set
  180. deleteBossBar("{bossbar::%loop-index%}")
  181. loop all entities:
  182. loop-entity is a living entity
  183. loop-entity is not a player
  184. set {_tags::*} to getTagValues(loop-entity)
  185. loop {_tags::*}:
  186. set {_bossbaroptions::*} to loop-value-2 split by ";"
  187. loop {_bossbaroptions::*}:
  188. if removePrefix(loop-value-3, "BarColor:") is set:
  189. set {_barcolor} to removePrefix(loop-value-3, "BarColor:")
  190. if removePrefix(loop-value-3, "BarStyle:") is set:
  191. set {_barstyle} to removePrefix(loop-value-3, "BarStyle:")
  192. if removePrefix(loop-value-3, "BarRange:") is set:
  193. set {_barrange} to removePrefix(loop-value-3, "BarRange:") parsed as number
  194. {_barcolor} is set
  195. {_barstyle} is set
  196. {_barrange} is set
  197. if {bossbar::%UUID of loop-entity%} is not set:
  198. set {bossbar::%UUID of loop-entity%} to new bossbar
  199. set color of bar {bossbar::%UUID of loop-entity%} to PINK
  200. set style of bar {bossbar::%UUID of loop-entity%} to SOLID
  201. evaluate "set color of bar {bossbar::%UUID of loop-entity%} to %{_barcolor} in upper case%"
  202. evaluate "set style of bar {bossbar::%UUID of loop-entity%} to %{_barstyle} in upper case%"
  203. if name of loop-entity is set:
  204. set name of bar {bossbar::%UUID of loop-entity%} to name of loop-entity
  205. else:
  206. set name of bar {bossbar::%UUID of loop-entity%} to getMobTypeName(loop-entity)
  207. set progress of bar {bossbar::%UUID of loop-entity%} to health of loop-entity/max health of loop-entity
  208. loop all players:
  209. if distance between loop-entity-1 and loop-player-1 <= {_barrange}:
  210. add loop-player-1 to bar {bossbar::%UUID of loop-entity-1%}
  211. if distance between loop-entity-1 and loop-player-1 > {_barrange}:
  212. remove loop-player-1 from bar {bossbar::%UUID of loop-entity-1%}
  213. delete {_bossbaroptions::*}
  214. delete {_barcolor}
  215. delete {_barstyle}
  216. delete {_barrange}
Advertisement
Add Comment
Please, Sign In to add comment