Resolve "Merge the best from 7.40 branch"

This commit is contained in:
Erikas Kontenis
2022-04-06 14:58:52 +00:00
parent 3bd1a6f07e
commit 155da3573c
928 changed files with 43723 additions and 1221 deletions

View File

@@ -45,7 +45,71 @@ 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 description ~= nil and description ~= '' then
description = description .. ". "
end
if attackAttribute == 5 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect attack.")
else
if attackAttribute ~= 0 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with " .. attackAttribute .. " 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 rewardClone:getType():getAttack() > 0 and attackAttribute ~= 0 then
if defenseAttribute == 5 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. " Enchanted with perfect defense.")
else
if defenseAttribute ~= 0 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. " Enchanted with " .. defenseAttribute .. " defense.")
end
end
else
if description ~= nil and description ~= '' then
description = description .. ". "
end
if defenseAttribute == 5 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect defense.")
else
if defenseAttribute ~= 0 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with " .. defenseAttribute .. " 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 description ~= nil and description ~= '' then
description = description .. ". "
end
if armorAttribute == 2 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with perfect armor protection.")
else
if armorAttribute ~= 0 then
rewardClone:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, description .. "Enchanted with " .. armorAttribute .. " armor protection.")
end
end
end
player:addItemEx(rewardClone, true)
player:setStorageValue(chestQuestNumber, 1)
return true
end