Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doUpgrade()
- if self.selectedItem then
- local selectedData = widget.getData(string.format("%s.%s", self.itemList, self.selectedItem))
- local upgradeItem = self.upgradeableWeaponItems[selectedData.index]
- if upgradeItem then
- local consumedItem = player.consumeItem(upgradeItem, false, true)
- if consumedItem then
- local consumedCurrency = player.consumeCurrency("essence", selectedData.price)
- local upgradedItem = copy(consumedItem)
- if consumedCurrency then
- local itemConfig = root.itemConfig(upgradedItem)
- upgradedItem.parameters.level = (itemConfig.parameters.level or itemConfig.config.level or 1) + 1
- 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
- upgradedItem.parameters.primaryAbility = {fireTime = itemConfig.config.primaryAbility.fireTime - (upgradedItem.parameters.level/7) }
- end
- upgradedItem.parameters.baseDps = (itemConfig.parameters.baseDps or itemConfig.config.baseDps or 1) + (upgradedItem.parameters.level/5) -- increase DPS a bit
- upgradedItem.parameters.critChance = (itemConfig.parameters.critChance or itemConfig.config.critChance or 1) + 1 -- increase Crit Chance
- upgradedItem.parameters.critBonus = (itemConfig.parameters.critBonus or itemConfig.config.critBonus or 1) + 1 -- increase Crit Damage
- sb.logInfo(sb.printJson(upgradedItem,1)) -- list all current bonuses being applied to the weapon for debug
- if itemConfig.config.upgradeParameters then
- upgradedItem.parameters = util.mergeTable(upgradedItem.parameters, itemConfig.config.upgradeParameters)
- end
- end
- player.giveItem(upgradedItem)
- end
- end
- populateItemList(true)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement