mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-14 14:44:55 +02:00
introduce random stat values for quest items
This commit is contained in:
@@ -45,7 +45,50 @@ function onUse(player, item, fromPosition, target, toPosition)
|
||||
end
|
||||
|
||||
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found " .. rewardName .. ".")
|
||||
player:addItemEx(reward:clone(), true)
|
||||
|
||||
local attackAttribute = math.random(-2, 5)
|
||||
local rewardClone = reward:clone()
|
||||
if rewardClone:getType():getAttack() > 0 then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_ATTACK, rewardClone:getType():getAttack() + attackAttribute)
|
||||
local description = rewardClone:hasAttribute(ITEM_ATTRIBUTE_DESCRIPTION) and rewardClone:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) or rewardClone:getType():getDescription()
|
||||
if attackAttribute == 5 then
|
||||
if description == nil or description == '' then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect attack.")
|
||||
else
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. ". Enchanted with perfect attack.")
|
||||
end
|
||||
end
|
||||
end
|
||||
local defenseAttribute = math.random(-2, 5)
|
||||
if rewardClone:getType():getDefense() > 0 then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DEFENSE, rewardClone:getType():getDefense() + defenseAttribute)
|
||||
local description = rewardClone:hasAttribute(ITEM_ATTRIBUTE_DESCRIPTION) and rewardClone:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) or rewardClone:getType():getDescription()
|
||||
if defenseAttribute == 5 then
|
||||
if attackAttribute == 5 and rewardClone:getType():getAttack() > 0 then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. " Enchanted with perfect defense.")
|
||||
else
|
||||
if description == nil or description == '' then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect defense.")
|
||||
else
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. ". Enchanted with perfect defense.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local armorAttribute = math.random(-1, 2)
|
||||
if rewardClone:getType():getArmor() > 0 then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_ARMOR, rewardClone:getType():getArmor() + armorAttribute)
|
||||
local description = rewardClone:hasAttribute(ITEM_ATTRIBUTE_DESCRIPTION) and rewardClone:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) or rewardClone:getType():getDescription()
|
||||
if armorAttribute == 2 then
|
||||
if description == nil or description == '' then
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect armor protection.")
|
||||
else
|
||||
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. ". Enchanted with perfect armor protection.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
player:addItemEx(rewardClone, true)
|
||||
player:setStorageValue(chestQuestNumber, 1)
|
||||
return true
|
||||
end
|
||||
|
Reference in New Issue
Block a user