Zeldaboy111

Prestige ]|[ Skript #445

Aug 27th, 2021
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.22 KB | None | 0 0
  1. options:
  2. prefix: &6Tycoon&8:&7
  3. shop: Shop
  4. upgrades: Upgrades
  5. prestigeUpgrades: Prestige Upgrades
  6. upgradesItem: gold nugget named "&eUpgrades"
  7. prestigeUpgradesItem: ghast tear named "&fPrestige Upgrades"
  8. upgradeItem_multiplierIPrice: 100
  9. upgradeItem_multiplierIIPrice: 200
  10. upgradeItem_multiplierIIIPrice: 400
  11. upgradeItem_multiplierI_locked: gold ingot named "&eMultiplier" with lore " &8Used to multiply", " &8your income.", "&6 ", " &7Multiplier&8: &e2.0x", " &7Price&8: &e100", and " &7Status&8: &eLocked"
  12. upgradeItem_multiplierI_unlocked: gold ingot named "&eMultiplier" with lore " &8Used to multiply", " &8your income.", "&6 ", " &7Multiplier&8: &e2.0x", " &7Price&8: &e100", and " &7Status&8: &eUnlocked"
  13. upgradeItem_multiplierII_locked: 2 gold ingot named "&eMultiplier" with lore " &8Used to multiply", " &8your income.", "&6 ", " &7Multiplier&8: &e2.5x", " &7Price&8: &e200", and " &7Status&8: &eLocked"
  14. upgradeItem_multiplierII_unlocked: 2 gold ingot named "&eMultiplier" with lore " &8Used to multiply", " &8your income.", "&6 ", " &7Multiplier&8: &e2.5x", " &7Price&8: &e200", and " &7Status&8: &eUnlocked"
  15. upgradeItem_multiplierIII_locked: 3 gold ingot named "&eMultiplier" with lore " &8Used to multiply", " &8your income.", "&6 ", " &7Multiplier&8: &e3.0x", " &7Price&8: &e400", and " &7Status&8: &eLocked"
  16. upgradeItem_multiplierIII_unlocked: 3 gold ingot named "&eMultiplier" with lore " &8Used to multiply", " &8your income.", "&6 ", " &7Multiplier&8: &e3.0x", " &7Price&8: &e400", and " &7Status&8: &eUnlocked"
  17.  
  18. function sendBalance():
  19. if {tc.loopingBalance} is true:
  20. stop
  21. set {tc.loopingBalance} to true
  22. while {tc.loopingBalance} is true:
  23. if {tc.stopped} is true:
  24. delete {tc.loopingBalance}
  25. else if size of online players is 0:
  26. delete {tc.loopingBalance}
  27. else:
  28. loop all players:
  29. add {tc.%uuid of loop-player%.income} to {tc.%uuid of loop-player%.balance}
  30. send actionbar "&6Coins&8: &e%{tc.%uuid of loop-player%.balance}%" to loop-player
  31. wait 20 ticks
  32. on join:
  33. if {tc.%uuid of player%.balance} is not set:
  34. set {tc.%uuid of player%.balance} to 0
  35. if {tc.%uuid of player%.prestige} is not set:
  36. set {tc.%uuid of player%.prestige} to 0
  37. if {tc.%uuid of player%.upgradesWorth} is not set:
  38. set {tc.%uuid of player%.upgradesWorth} to 0
  39. if {tc.%uuid of player%.prestigeMultiplier} is not set:
  40. set {tc.%uuid of player%.prestigeMultiplier} to 0
  41. initializePlayerIncome(player)
  42. sendBalance()
  43.  
  44. function initializePlayerIncome(player: Player):
  45. set {_uuid} to uuid of {_player}
  46. set {tc.%{_uuid}%.income} to 1
  47. loop {tc.signList.%{_uuid}%::*}:
  48. add {tc.signdata.%loop-value%.income} to {tc.%{_uuid}%.income}
  49. set {_multipliers::*} to "I", "II" and "III"
  50. set {_multiplierValues::*} to 2.0, 2.5 and 3.0
  51. loop {_multipliers::*}:
  52. if {tc.%{_uuid}%.upgradeItem_multiplier%loop-value%} is true:
  53. set {tc.%{_uuid}%.income} to {tc.%{_uuid}%.income}*{_multiplierValues::%loop-index%}
  54.  
  55. on enable:
  56. set {_d} to 0
  57. while {tc.loopingBalance} is true:
  58. wait 5 ticks
  59. add 1 to {_d}
  60. if {_d} >= 4:
  61. delete {tc.loopingBalance}
  62. wait 1 ticks
  63. delete {tc.stopped}
  64. sendBalance()
  65.  
  66. on disable:
  67. if {tc.loopingBalance} is true:
  68. set {tc.stopped} to true
  69.  
  70. function setLineData(sign: Location, line: String, firstType: String, secondType: String):
  71. set {_lines::*} to {_line} split at " "
  72. if size of {_lines::*} is not 2:
  73. stop
  74.  
  75. set {_firstValue} to {_lines::1} parsed as an integer
  76. set {_secondValue} to {_lines::2} parsed as an integer
  77. if {_firstValue} is set:
  78. if {_secondValue} is set:
  79. if {_firstValue} > 0:
  80. if {_secondValue} > 0:
  81. set {tc.signdata.%{_sign}%.%{_firstType}%} to {_firstValue}
  82. set {tc.signdata.%{_sign}%.%{_secondType}%} to {_secondValue}
  83.  
  84. function updateSignVariables(sign: Location):
  85. add 1 to {tc.signdata.%{_sign}%.level}
  86. add {tc.signdata.%{_sign}%.costIncrease} to {tc.signdata.%{_sign}%.cost}
  87. add {tc.signdata.%{_sign}%.incomeIncrease} to {tc.signdata.%{_sign}%.income}
  88. if {tc.signdata.%{_sign}%.level} >= {tc.signdata.%{_sign}%.maxLevel}:
  89. set {tc.signdata.%{_sign}%.cost} to -1
  90.  
  91. on sign change:
  92. if line 1 doesn't start with "[T] ":
  93. stop
  94. setLineData(location of event-block, line 4 of event-block, "level", "maxLevel")
  95. setLineData(location of event-block, line 3 of event-block, "cost", "costIncrease")
  96. setLineData(location of event-block, line 2 of event-block, "income", "incomeIncrease")
  97. if {tc.signdata.%location of event-block%.level} >= {tc.signdata.%location of event-block%.maxLevel}:
  98. set {tc.signdata.%location of event-block%.cost} to -1
  99. if {tc.signdata.%location of event-block%.cost} is not set:
  100. stop
  101. set {_l1} to line 1
  102. replace "[T] " in {_l1} with ""
  103. set line 1 to "&6&l%{_l1}%"
  104. set line 2 to ""
  105. if {tc.signdata.%location of event-block%.cost} > -1:
  106. set line 3 to "&eCost&8: &7%{tc.signdata.%location of event-block%.cost}%"
  107. else:
  108. set line 3 to "&eCost&8: &7Max Level"
  109. set line 4 to "&bLevel&8: &7%{tc.signdata.%location of event-block%.level}%"
  110. add location of event-block to {tc.signList.%uuid of player%::*}
  111. set {tc.signdata.%location of event-block%.income} to {tc.signdata.%location of event-block%.incomeIncrease}
  112. initializePlayerIncome(player)
  113.  
  114. on right click on sign:
  115. if {tc.signdata.%location of event-block%.cost} is not set:
  116. stop
  117. else if {tc.signdata.%location of event-block%.level} >= {tc.signdata.%location of event-block%.maxLevel}:
  118. play sound "entity.item.break" to player
  119. else if {tc.%uuid of player%.balance} < {tc.signdata.%location of event-block%.cost}:
  120. play sound "entity.item.break" to player
  121. else:
  122. add {tc.signdata.%location of event-block%.cost}/2.0 to {tc.%uuid of player%.upgradesWorth}
  123. remove {tc.signdata.%location of event-block%.cost} from {tc.%uuid of player%.balance}
  124. add {tc.signdata.%location of event-block%.incomeIncrease} to {tc.%uuid of player%.income}
  125.  
  126. updateSignVariables(location of event-block)
  127. play sound "entity.player.levelup" to player
  128. if {tc.signdata.%location of event-block%.cost} > -1:
  129. set line 3 to "&eCost&8: &7%{tc.signdata.%location of event-block%.cost}%"
  130. else:
  131. set line 3 to "&eCost&8: &7Max Level"
  132. set line 4 to "&bLevel&8: &7%{tc.signdata.%location of event-block%.level}%"
  133.  
  134. on break of sign:
  135. if {tc.signdata.%location of event-block%.cost} is set:
  136. if {tc.signList.%uuid of player%::*} does not contain location of event-block:
  137. cancel event
  138. stop
  139. delete {tc.signdata.%location of event-block%.cost}
  140. delete {tc.signdata.%location of event-block%.costIncrease}
  141. delete {tc.signdata.%location of event-block%.level}
  142. delete {tc.signdata.%location of event-block%.maxLevel}
  143. remove location of event-block from {tc.signList.%uuid of player%::*}
  144. initializePlayerIncome(player)
  145.  
  146. #=========================================
  147. # Shop
  148.  
  149. command /shop:
  150. trigger:
  151. set {tc.currentInventory.%player%} to true
  152. open chest with 1 rows named "{@shop}" to player
  153. set slot 0 of player's current inventory to {@upgradesItem}
  154. set slot 1 of player's current inventory to {@prestigeUpgradesItem}
  155.  
  156. function openUpgrades(player: Player):
  157. open chest with 1 rows named "{@upgrades}" to {_player}
  158. setUpgradeInGui({_player}, 0, "upgradeItem_multiplierI", {@upgradeItem_multiplierI_locked}, {@upgradeItem_multiplierI_unlocked})
  159. setUpgradeInGui({_player}, 1, "upgradeItem_multiplierII", {@upgradeItem_multiplierII_locked}, {@upgradeItem_multiplierII_unlocked})
  160. setUpgradeInGui({_player}, 2, "upgradeItem_multiplierIII", {@upgradeItem_multiplierIII_locked}, {@upgradeItem_multiplierIII_unlocked})
  161.  
  162. wait 1 ticks
  163. set {tc.currentInventory.%{_player}%} to true
  164.  
  165. function setUpgradeInGui(player: Player, slot: Integer, variableName: String, notBought: Item, bought: Item):
  166. set {_uuid} to uuid of {_player}
  167. if {tc.%{_uuid}%.%{_variableName}%}:
  168. set slot {_slot} of {_player}'s current inventory to {_bought}
  169. else:
  170. set slot {_slot} of {_player}'s current inventory to {_notBought}
  171.  
  172. function openPrestigeUpgrades(player: Player):
  173. open chest with 1 rows named "{@prestigeUpgrades}" to {_player}
  174. wait 1 ticks
  175. set {tc.currentInventory.%{_player}%} to true
  176.  
  177.  
  178. function handleShopInventoryClick(player: Player, clicked: Item):
  179. if {_clicked} is {@upgradesItem}:
  180. openUpgrades({_player})
  181. else if {_clicked} is {@prestigeUpgradesItem}:
  182. openPrestigeUpgrades({_player})
  183. else:
  184. stop
  185. play sound "ui.button.click" to {_player}
  186.  
  187. function tryBuyUpgrade(player: Player, name: String, variableName: String, price: int, prestigeUpgrades: Boolean):
  188. set {_uuid} to uuid of {_player}
  189. if {tc.%{_uuid}%.%{_variableName}%} is true:
  190. send "{@prefix} You already bought &e%{_name}%" to {_player}
  191. play sound "entity.item.break" to {_player}
  192. else:
  193. if {tc.%{_uuid}%.balance} < {_price}:
  194. send "{@prefix} You do not have enough coins to buy &e%{_name}%" to {_player}
  195. play sound "entity.item.break" to {_player}
  196. else:
  197. set {tc.%{_uuid}%.%{_variableName}%} to true
  198. remove {_price} from {tc.%{_uuid}%.balance}
  199. send "{@prefix} You have bought &e%{_name}%" to {_player}
  200. play sound "entity.player.levelup" to {_player}
  201. add {_price} to {tc.%{_uuid}%.upgradesWorth}
  202. initializePlayerIncome({_player})
  203. if {_prestigeUpgrades}:
  204. openPrestigeUpgrades({_player})
  205. else:
  206. openUpgrades({_player})
  207.  
  208. command /breset:
  209. trigger:
  210. set {tc.%uuid of player%.balance} to 0
  211.  
  212. command /ureset:
  213. trigger:
  214. delete {tc.%uuid of player%.upgradeItem_multiplierI}
  215. delete {tc.%uuid of player%.upgradeItem_multiplierII}
  216. delete {tc.%uuid of player%.upgradeItem_multiplierIII}
  217. initializePlayerIncome(player)
  218.  
  219.  
  220. function handleUpgradeInventoryClick(player: Player, clicked: Item):
  221. if {_clicked} is air:
  222. stop
  223. if checkIfItemIsEqualTo({_clicked}, {@upgradeItem_multiplierI_locked}) or checkIfItemIsEqualTo({_clicked}, {@upgradeItem_multiplierI_unlocked}):
  224. tryBuyUpgrade({_player}, "Multiplier I", "upgradeItem_multiplierI", {@upgradeItem_multiplierIPrice}, false)
  225. else if checkIfItemIsEqualTo({_clicked}, {@upgradeItem_multiplierII_locked}) or checkIfItemIsEqualTo({_clicked}, {@upgradeItem_multiplierII_unlocked}):
  226. tryBuyUpgrade({_player}, "Multiplier II", "upgradeItem_multiplierII", {@upgradeItem_multiplierIIPrice}, false)
  227. else if checkIfItemIsEqualTo({_clicked}, {@upgradeItem_multiplierIII_locked}) or checkIfItemIsEqualTo({_clicked}, {@upgradeItem_multiplierIII_unlocked}):
  228. tryBuyUpgrade({_player}, "Multiplier III", "upgradeItem_multiplierIII", {@upgradeItem_multiplierIIIPrice}, false)
  229.  
  230. function checkIfItemIsEqualTo(check: Item, equalTo: Item) :: Boolean:
  231. if type of {_check} is not type of {_equalTo}:
  232. return false
  233. else if item amount of {_check} is not item amount of {_equalTo}:
  234. return false
  235. else if name of {_check} is not name of {_equalTo}:
  236. return false
  237. else if "%lore of {_check}%" is not "%lore of {_equalTo}%":
  238. return false
  239. return true
  240.  
  241. on inventory click:
  242. if "%event-inventory%" is not "inventory of <none>":
  243. stop
  244. if inventory name of clicked inventory is "{@shop}":
  245. cancel event
  246. handleShopInventoryClick(player, event-item)
  247. else if inventory name of clicked inventory is "{@upgrades}":
  248. cancel event
  249. handleUpgradeInventoryClick(player, event-item)
  250. else if inventory name of clicked inventory is "{@prestigeUpgrades}":
  251. cancel event
  252. send "PRESTIGE UPGRADES"
  253.  
  254. on inventory close:
  255. delete {tc.currentInventory.%player%}
  256.  
  257. on inventory drag:
  258. if {tc.currentInventory.%player%} is set:
  259. cancel event
  260.  
  261. on quit:
  262. delete {tc.currentInventory.%player%}
  263.  
  264. command /prestige:
  265. trigger:
  266. if executor is console:
  267. send "{@prefix} This command can only be executed by a player."
  268. else:
  269. calculatePrestige(player)
  270. send "&8&m "
  271. send " &7Prestiging will have the following effects:"
  272. send " &8• &7Your &eupgrades &7will &ereset"
  273. send " &8• &7You will gain &e%{tc.%uuid of player%.prestigeReceivedOnPrestige}% &eprestige"
  274. send " &8• &7Your &eprestige-multiplier &7will increase by &e0.1"
  275. send "&8&m "
  276.  
  277. function calculatePrestige(player: Player):
  278. set {_uuid} to uuid of {_player}
  279. set {tc.%{_uuid}%.prestigeReceivedOnPrestige} to {tc.%{_uuid}%.upgradesWorth}*{tc.%{_uuid}%.prestigeMultiplier}
  280. # Not working
  281.  
Advertisement
Add Comment
Please, Sign In to add comment