WikiArk21
Member
- Joined
- Oct 24, 2023
- Messages
- 23
- Reaction score
- 5
I'm using this system here, which works very well for its purpose.
CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/)
However, I tried to create this script to reroll the rarity of a certain item, but I wanted to know if there is any way to have persistence in obtaining a higher rarity. For example, after using the stone x times on that item, the next time it will give the highest rarity available.
Acript
CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/)
However, I tried to create this script to reroll the rarity of a certain item, but I wanted to know if there is any way to have persistence in obtaining a higher rarity. For example, after using the stone x times on that item, the next time it will give the highest rarity available.
Acript
LUA:
local ENCHANTMENT_ITEM_ID = 26427
function onUse(player, usedItem, fromPosition, target, toPosition, isHotkey)
if usedItem:getId() ~= ENCHANTMENT_ITEM_ID then
player:sendCancelMessage("This item cannot be used in this way.")
return false
end
if not target or not target:isItem() then
player:sendCancelMessage("You need to use the stone on an item.")
return false
end
if not isEquipment(target) then
player:sendCancelMessage("You can only reroll equipment.")
return false
end
target:rollRarity()
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Item rarity has been rerolled!")
usedItem:remove(1)
return true
end
function isEquipment(item)
local itemType = ItemType(item:getId())
return itemType:getSlotPosition() ~= 0
end