mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-06-13 12:34:28 +02:00
introduce random stat values for quest items
This commit is contained in:
parent
7a97100509
commit
62963b3424
@ -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
|
||||
|
24
src/item.cpp
24
src/item.cpp
@ -881,28 +881,28 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
|
||||
}
|
||||
else if (it.weaponType != WEAPON_NONE) {
|
||||
if (it.weaponType == WEAPON_DISTANCE && it.ammoType != AMMO_NONE) {
|
||||
if (it.attack != 0) {
|
||||
s << ", Atk" << std::showpos << it.attack << std::noshowpos;
|
||||
if (item->getAttack() != 0) {
|
||||
s << ", Atk" << std::showpos << item->getAttack() << std::noshowpos;
|
||||
}
|
||||
}
|
||||
else if (it.weaponType != WEAPON_WAND && (it.attack != 0 || it.defense != 0)) {
|
||||
else if (it.weaponType != WEAPON_WAND && (item->getAttack() != 0 || item->getDefense() != 0)) {
|
||||
s << " (";
|
||||
if (it.attack != 0) {
|
||||
s << "Atk:" << static_cast<int>(it.attack);
|
||||
if (item->getAttack() != 0) {
|
||||
s << "Atk:" << static_cast<int>(item->getAttack());
|
||||
}
|
||||
|
||||
if (it.defense != 0) {
|
||||
if (it.attack != 0)
|
||||
if (item->getDefense() != 0) {
|
||||
if (item->getAttack() != 0)
|
||||
s << " ";
|
||||
|
||||
s << "Def:" << static_cast<int>(it.defense);
|
||||
s << "Def:" << static_cast<int>(item->getDefense());
|
||||
}
|
||||
|
||||
s << ")";
|
||||
}
|
||||
s << ".";
|
||||
}
|
||||
else if (it.armor != 0 || (it.abilities && it.abilities->speed != 0)) {
|
||||
else if (item->getArmor() != 0 || (it.abilities && it.abilities->speed != 0)) {
|
||||
if (it.charges > 0) {
|
||||
if (subType > 1) {
|
||||
s << " that has " << static_cast<int32_t>(subType) << " charges left";
|
||||
@ -913,11 +913,11 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
|
||||
}
|
||||
|
||||
s << " (";
|
||||
if (it.armor > 0) {
|
||||
s << "Arm:" << it.armor;
|
||||
if (item->getArmor() > 0) {
|
||||
s << "Arm:" << item->getArmor();
|
||||
}
|
||||
if (it.abilities && it.abilities->speed > 0) {
|
||||
if (it.armor > 0) {
|
||||
if (item->getArmor() > 0) {
|
||||
s << ", ";
|
||||
}
|
||||
s << "Speed +" << it.abilities->speed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user