Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. function doUpgrade()
  2. if self.selectedItem then
  3. local selectedData = widget.getData(string.format("%s.%s", self.itemList, self.selectedItem))
  4. local upgradeItem = self.upgradeableWeaponItems[selectedData.index]
  5.  
  6. if upgradeItem then
  7. local consumedItem = player.consumeItem(upgradeItem, false, true)
  8. if consumedItem then
  9. local consumedCurrency = player.consumeCurrency("essence", selectedData.price)
  10. local upgradedItem = copy(consumedItem)
  11. if consumedCurrency then
  12. local itemConfig = root.itemConfig(upgradedItem)
  13. upgradedItem.parameters.level = (itemConfig.parameters.level or itemConfig.config.level or 1) + 1
  14. if upgradedItem.parameters.primaryAbility and (itemConfig.config.primaryAbility.fireTime >= 0.3) then -- does the item have primaryAbility and a Fire Time? if so, we reduce fire time slightly as long as the weapon isnt already fast firing
  15. upgradedItem.parameters.primaryAbility = {fireTime = itemConfig.config.primaryAbility.fireTime - (upgradedItem.parameters.level/7) }
  16. end
  17. upgradedItem.parameters.baseDps = (itemConfig.parameters.baseDps or itemConfig.config.baseDps or 1) + (upgradedItem.parameters.level/5) -- increase DPS a bit
  18. upgradedItem.parameters.critChance = (itemConfig.parameters.critChance or itemConfig.config.critChance or 1) + 1 -- increase Crit Chance
  19. upgradedItem.parameters.critBonus = (itemConfig.parameters.critBonus or itemConfig.config.critBonus or 1) + 1 -- increase Crit Damage
  20. sb.logInfo(sb.printJson(upgradedItem,1)) -- list all current bonuses being applied to the weapon for debug
  21. if itemConfig.config.upgradeParameters then
  22. upgradedItem.parameters = util.mergeTable(upgradedItem.parameters, itemConfig.config.upgradeParameters)
  23. end
  24. end
  25. player.giveItem(upgradedItem)
  26. end
  27. end
  28. populateItemList(true)
  29. end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement