sandals +5 speed, show ammo atk & show item speed onLook

This commit is contained in:
ErikasKontenis 2021-04-05 17:08:11 +03:00
parent 3bd1a6f07e
commit 6137c91bd2
2 changed files with 401 additions and 367 deletions

View File

@ -16179,7 +16179,7 @@ Attributes = {Weight=1000,SlotType=FEET,ArmorValue=2}
TypeID = 3551
Name = "sandals"
Flags = {Take}
Attributes = {Weight=600,SlotType=FEET}
Attributes = {Weight=600,SlotType=FEET,SpeedBoost=5}
TypeID = 3552
Name = "leather boots"

View File

@ -52,19 +52,26 @@ Item* Item::CreateItem(const uint16_t type, uint16_t count /*= 0*/)
if (it.id != 0) {
if (it.isDepot()) {
newItem = new DepotLocker(type);
} else if (it.isContainer() || it.isChest()) {
}
else if (it.isContainer() || it.isChest()) {
newItem = new Container(type);
} else if (it.isTeleport()) {
}
else if (it.isTeleport()) {
newItem = new Teleport(type);
} else if (it.isMagicField()) {
}
else if (it.isMagicField()) {
newItem = new MagicField(type);
} else if (it.isDoor()) {
}
else if (it.isDoor()) {
newItem = new Door(type);
} else if (it.isMailbox()) {
}
else if (it.isMailbox()) {
newItem = new Mailbox(type);
} else if (it.isBed()) {
}
else if (it.isBed()) {
newItem = new BedItem(type);
} else {
}
else {
newItem = new Item(type, count);
}
@ -136,19 +143,24 @@ Item::Item(const uint16_t type, uint16_t count /*= 0*/) :
if (it.isFluidContainer() || it.isSplash()) {
setFluidType(count);
} else if (it.stackable) {
}
else if (it.stackable) {
if (count != 0) {
setItemCount(count);
} else if (it.charges != 0) {
}
else if (it.charges != 0) {
setItemCount(it.charges);
}
} else if (it.charges != 0) {
}
else if (it.charges != 0) {
if (count != 0) {
setCharges(count);
} else {
}
else {
setCharges(it.charges);
}
} else if (it.isKey()) {
}
else if (it.isKey()) {
setIntAttr(ITEM_ATTRIBUTE_KEYNUMBER, count);
}
@ -196,7 +208,8 @@ bool Item::equals(const Item* otherItem) const
return false;
}
}
} else {
}
else {
for (const auto& otherAttribute : otherAttributeList) {
if (attribute.type == otherAttribute.type && attribute.value.integer != otherAttribute.value.integer) {
return false;
@ -216,7 +229,8 @@ void Item::setDefaultSubtype()
if (it.charges != 0) {
if (it.stackable) {
setItemCount(it.charges);
} else {
}
else {
setCharges(it.charges);
}
}
@ -311,9 +325,11 @@ uint16_t Item::getSubType() const
const ItemType& it = items[id];
if (it.isFluidContainer() || it.isSplash()) {
return getFluidType();
} else if (it.stackable) {
}
else if (it.stackable) {
return count;
} else if (it.charges != 0) {
}
else if (it.charges != 0) {
return getCharges();
}
return count;
@ -337,11 +353,14 @@ void Item::setSubType(uint16_t n)
const ItemType& it = items[id];
if (it.isFluidContainer() || it.isSplash()) {
setFluidType(n);
} else if (it.stackable) {
}
else if (it.stackable) {
setItemCount(n);
} else if (it.charges != 0) {
}
else if (it.charges != 0) {
setCharges(n);
} else {
}
else {
setItemCount(n);
}
}
@ -659,7 +678,8 @@ bool Item::unserializeAttr(PropStream& propStream)
Attr_ReadValue ret = readAttr(static_cast<AttrTypes_t>(attr_type), propStream);
if (ret == ATTR_READ_ERROR) {
return false;
} else if (ret == ATTR_READ_END) {
}
else if (ret == ATTR_READ_END) {
return true;
}
}
@ -865,7 +885,7 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
s << ", Atk" << std::showpos << it.attack << std::noshowpos;
}
}
else if (it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND && (it.attack != 0 || it.defense != 0)) {
else if (it.weaponType != WEAPON_WAND && (it.attack != 0 || it.defense != 0)) {
s << " (";
if (it.attack != 0) {
s << "Atk:" << static_cast<int>(it.attack);
@ -882,7 +902,7 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
}
s << ".";
}
else if (it.armor != 0) {
else if (it.armor != 0 || (it.abilities && it.abilities->speed != 0)) {
if (it.charges > 0) {
if (subType > 1) {
s << " that has " << static_cast<int32_t>(subType) << " charges left";
@ -892,7 +912,17 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
}
}
s << " (Arm:" << it.armor << ").";
s << " (";
if (it.armor > 0) {
s << "Arm:" << it.armor;
}
if (it.abilities && it.abilities->speed > 0) {
if (it.armor > 0) {
s << ", ";
}
s << "Speed +" << it.abilities->speed;
}
s << ").";
}
else if (it.isFluidContainer()) {
if (item && item->getFluidType() != 0) {
@ -1083,15 +1113,18 @@ std::string Item::getWeightDescription(const ItemType& it, uint32_t weight, uint
std::ostringstream ss;
if (it.stackable && count > 1 && it.showCount != 0) {
ss << "They weigh ";
} else {
}
else {
ss << "It weighs ";
}
if (weight < 10) {
ss << "0.0" << weight;
} else if (weight < 100) {
}
else if (weight < 100) {
ss << "0." << weight;
} else {
}
else {
std::string weightString = std::to_string(weight);
weightString.insert(weightString.end() - 2, '.');
ss << weightString;
@ -1193,7 +1226,8 @@ void ItemAttributes::removeAttribute(itemAttrTypes type)
auto prev_it = attributes.cbegin();
if ((*prev_it).type == type) {
attributes.pop_front();
} else {
}
else {
auto it = prev_it, end = attributes.cend();
while (++it != end) {
if ((*it).type == type) {