void ProjectileWeapon::fireBurst() { if(getAmmoType()!=ammo_unlimited) { if(ammo==0) return; ammo--; owner->weapons.updateWeapons(); } Position ownerPos(owner->getPosition()); const Position *shotOffsets = owner->type->getWeaponMounts(numProjectiles()); doSound(); for(unsigned ii=0; ii<numProjectiles(); ii++) if(linkedFire() || ii==fireOrder) { Position shotPosition(ownerPos); shotPosition.setX(ownerPos.getX() + shotOffsets[ii].getX()*cos(ownerPos.getR()) + shotOffsets[ii].getY()*sin(ownerPos.getR())); shotPosition.setY(ownerPos.getY() - shotOffsets[ii].getX()*sin(ownerPos.getR()) + shotOffsets[ii].getY()*cos(ownerPos.getR())); shotPosition.setR_vel(0); if(!shotsGetShipVel) { shotPosition.setX_vel(0); shotPosition.setY_vel(0); } shotPosition.impulse( getSpeed()*cos(shotPosition.getR()), -getSpeed()*sin(shotPosition.getR()) ); createProjectile(&shotPosition); } fireOrder++; if(fireOrder >= numProjectiles()) fireOrder = 0; }
void Items::parseItemNode(const pugi::xml_node& itemNode, uint16_t id) { if (id > 30000 && id < 30100) { id -= 30000; if (id >= items.size()) { items.resize(id + 1); } ItemType& iType = items[id]; iType.id = id; } ItemType& it = getItemType(id); if (it.id == 0) { return; } it.name = itemNode.attribute("name").as_string(); pugi::xml_attribute articleAttribute = itemNode.attribute("article"); if (articleAttribute) { it.article = articleAttribute.as_string(); } pugi::xml_attribute pluralAttribute = itemNode.attribute("plural"); if (pluralAttribute) { it.pluralName = pluralAttribute.as_string(); } for (auto attributeNode : itemNode.children()) { pugi::xml_attribute keyAttribute = attributeNode.attribute("key"); if (!keyAttribute) { continue; } pugi::xml_attribute valueAttribute = attributeNode.attribute("value"); if (!valueAttribute) { continue; } std::string tmpStrValue = asLowerCaseString(keyAttribute.as_string()); if (tmpStrValue == "type") { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "key") { it.type = ITEM_TYPE_KEY; } else if (tmpStrValue == "magicfield") { it.type = ITEM_TYPE_MAGICFIELD; } else if (tmpStrValue == "container") { it.group = ITEM_GROUP_CONTAINER; it.type = ITEM_TYPE_CONTAINER; } else if (tmpStrValue == "depot") { it.type = ITEM_TYPE_DEPOT; } else if (tmpStrValue == "mailbox") { it.type = ITEM_TYPE_MAILBOX; } else if (tmpStrValue == "trashholder") { it.type = ITEM_TYPE_TRASHHOLDER; } else if (tmpStrValue == "teleport") { it.type = ITEM_TYPE_TELEPORT; } else if (tmpStrValue == "door") { it.type = ITEM_TYPE_DOOR; } else if (tmpStrValue == "bed") { it.type = ITEM_TYPE_BED; } else if (tmpStrValue == "rune") { it.type = ITEM_TYPE_RUNE; } else { std::cout << "[Warning - Items::parseItemNode] Unknown type: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "description") { it.description = valueAttribute.as_string(); } else if (tmpStrValue == "runespellname") { it.runeSpellName = valueAttribute.as_string(); } else if (tmpStrValue == "weight") { it.weight = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "showcount") { it.showCount = valueAttribute.as_bool(); } else if (tmpStrValue == "armor") { it.armor = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "defense") { it.defense = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "extradef") { it.extraDefense = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "attack") { it.attack = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "rotateto") { it.rotateTo = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "moveable" || tmpStrValue == "movable") { it.moveable = valueAttribute.as_bool(); } else if (tmpStrValue == "blockprojectile") { it.blockProjectile = valueAttribute.as_bool(); } else if (tmpStrValue == "allowpickupable" || tmpStrValue == "pickupable") { it.allowPickupable = valueAttribute.as_bool(); } else if (tmpStrValue == "floorchange") { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "down") { it.floorChange = TILESTATE_FLOORCHANGE_DOWN; } else if (tmpStrValue == "north") { it.floorChange = TILESTATE_FLOORCHANGE_NORTH; } else if (tmpStrValue == "south") { it.floorChange = TILESTATE_FLOORCHANGE_SOUTH; } else if (tmpStrValue == "southalt") { it.floorChange = TILESTATE_FLOORCHANGE_SOUTH_ALT; } else if (tmpStrValue == "west") { it.floorChange = TILESTATE_FLOORCHANGE_WEST; } else if (tmpStrValue == "east") { it.floorChange = TILESTATE_FLOORCHANGE_EAST; } else if (tmpStrValue == "eastalt") { it.floorChange = TILESTATE_FLOORCHANGE_EAST_ALT; } else { std::cout << "[Warning - Items::parseItemNode] Unknown floorChange: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "corpsetype") { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "venom") { it.corpseType = RACE_VENOM; } else if (tmpStrValue == "blood") { it.corpseType = RACE_BLOOD; } else if (tmpStrValue == "undead") { it.corpseType = RACE_UNDEAD; } else if (tmpStrValue == "fire") { it.corpseType = RACE_FIRE; } else if (tmpStrValue == "energy") { it.corpseType = RACE_ENERGY; } else { std::cout << "[Warning - Items::parseItemNode] Unknown corpseType: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "containersize") { it.maxItems = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "fluidsource") { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "water") { it.fluidSource = FLUID_WATER; } else if (tmpStrValue == "blood") { it.fluidSource = FLUID_BLOOD; } else if (tmpStrValue == "beer") { it.fluidSource = FLUID_BEER; } else if (tmpStrValue == "slime") { it.fluidSource = FLUID_SLIME; } else if (tmpStrValue == "lemonade") { it.fluidSource = FLUID_LEMONADE; } else if (tmpStrValue == "milk") { it.fluidSource = FLUID_MILK; } else if (tmpStrValue == "mana") { it.fluidSource = FLUID_MANA; } else if (tmpStrValue == "life") { it.fluidSource = FLUID_LIFE; } else if (tmpStrValue == "oil") { it.fluidSource = FLUID_OIL; } else if (tmpStrValue == "urine") { it.fluidSource = FLUID_URINE; } else if (tmpStrValue == "coconut") { it.fluidSource = FLUID_COCONUTMILK; } else if (tmpStrValue == "wine") { it.fluidSource = FLUID_WINE; } else if (tmpStrValue == "mud") { it.fluidSource = FLUID_MUD; } else if (tmpStrValue == "fruitjuice") { it.fluidSource = FLUID_FRUITJUICE; } else if (tmpStrValue == "lava") { it.fluidSource = FLUID_LAVA; } else if (tmpStrValue == "rum") { it.fluidSource = FLUID_RUM; } else if (tmpStrValue == "swamp") { it.fluidSource = FLUID_SWAMP; } else if (tmpStrValue == "tea") { it.fluidSource = FLUID_TEA; } else if (tmpStrValue == "mead") { it.fluidSource = FLUID_MEAD; } else { std::cout << "[Warning - Items::parseItemNode] Unknown fluidSource: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "readable") { it.canReadText = valueAttribute.as_bool(); } else if (tmpStrValue == "writeable") { it.canWriteText = valueAttribute.as_bool(); it.canReadText = it.canWriteText; } else if (tmpStrValue == "maxtextlen") { it.maxTextLen = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "writeonceitemid") { it.writeOnceItemId = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "weapontype") { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "sword") { it.weaponType = WEAPON_SWORD; } else if (tmpStrValue == "club") { it.weaponType = WEAPON_CLUB; } else if (tmpStrValue == "axe") { it.weaponType = WEAPON_AXE; } else if (tmpStrValue == "shield") { it.weaponType = WEAPON_SHIELD; } else if (tmpStrValue == "distance") { it.weaponType = WEAPON_DISTANCE; } else if (tmpStrValue == "wand") { it.weaponType = WEAPON_WAND; } else if (tmpStrValue == "ammunition") { it.weaponType = WEAPON_AMMO; } else { std::cout << "[Warning - Items::parseItemNode] Unknown weaponType: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "slottype") { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "head") { it.slotPosition |= SLOTP_HEAD; } else if (tmpStrValue == "body") { it.slotPosition |= SLOTP_ARMOR; } else if (tmpStrValue == "legs") { it.slotPosition |= SLOTP_LEGS; } else if (tmpStrValue == "feet") { it.slotPosition |= SLOTP_FEET; } else if (tmpStrValue == "backpack") { it.slotPosition |= SLOTP_BACKPACK; } else if (tmpStrValue == "two-handed") { it.slotPosition |= SLOTP_TWO_HAND; } else if (tmpStrValue == "right-hand") { it.slotPosition &= ~SLOTP_LEFT; } else if (tmpStrValue == "left-hand") { it.slotPosition &= ~SLOTP_RIGHT; } else if (tmpStrValue == "necklace") { it.slotPosition |= SLOTP_NECKLACE; } else if (tmpStrValue == "ring") { it.slotPosition |= SLOTP_RING; } else if (tmpStrValue == "ammo") { it.slotPosition |= SLOTP_AMMO; } else if (tmpStrValue == "hand") { it.slotPosition |= SLOTP_HAND; } else { std::cout << "[Warning - Items::parseItemNode] Unknown slotType: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "ammotype") { it.ammoType = getAmmoType(valueAttribute.as_string()); if (it.ammoType == AMMO_NONE) { std::cout << "[Warning - Items::parseItemNode] Unknown ammoType: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "shoottype") { ShootType_t shoot = getShootType(valueAttribute.as_string()); if (shoot != CONST_ANI_NONE) { it.shootType = shoot; } else { std::cout << "[Warning - Items::parseItemNode] Unknown shootType: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "effect") { MagicEffectClasses effect = getMagicEffect(valueAttribute.as_string()); if (effect != CONST_ME_NONE) { it.magicEffect = effect; } else { std::cout << "[Warning - Items::parseItemNode] Unknown effect: " << valueAttribute.as_string() << std::endl; } } else if (tmpStrValue == "range") { it.shootRange = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "stopduration") { it.stopTime = valueAttribute.as_bool(); } else if (tmpStrValue == "decayto") { it.decayTo = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "transformequipto") { it.transformEquipTo = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "transformdeequipto") { it.transformDeEquipTo = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "duration") { it.decayTime = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "showduration") { it.showDuration = valueAttribute.as_bool(); } else if (tmpStrValue == "charges") { it.charges = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "showcharges") { it.showCharges = valueAttribute.as_bool(); } else if (tmpStrValue == "showattributes") { it.showAttributes = valueAttribute.as_bool(); } else if (tmpStrValue == "hitchance") { it.hitChance = std::min<int8_t>(100, std::max<int8_t>(-100, pugi::cast<int16_t>(valueAttribute.value()))); } else if (tmpStrValue == "maxhitchance") { it.maxHitChance = std::min<uint32_t>(100, pugi::cast<uint32_t>(valueAttribute.value())); } else if (tmpStrValue == "invisible") { it.getAbilities().invisible = valueAttribute.as_bool(); } else if (tmpStrValue == "speed") { it.getAbilities().speed = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "healthgain") { Abilities& abilities = it.getAbilities(); abilities.regeneration = true; abilities.healthGain = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "healthticks") { Abilities& abilities = it.getAbilities(); abilities.regeneration = true; abilities.healthTicks = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "managain") { Abilities& abilities = it.getAbilities(); abilities.regeneration = true; abilities.manaGain = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "manaticks") { Abilities& abilities = it.getAbilities(); abilities.regeneration = true; abilities.manaTicks = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "manashield") { it.getAbilities().manaShield = valueAttribute.as_bool(); } else if (tmpStrValue == "skillsword") { it.getAbilities().skills[SKILL_SWORD] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "skillaxe") { it.getAbilities().skills[SKILL_AXE] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "skillclub") { it.getAbilities().skills[SKILL_CLUB] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "skilldist") { it.getAbilities().skills[SKILL_DISTANCE] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "skillfish") { it.getAbilities().skills[SKILL_FISHING] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "skillshield") { it.getAbilities().skills[SKILL_SHIELD] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "skillfist") { it.getAbilities().skills[SKILL_FIST] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "maxhitpoints") { it.getAbilities().stats[STAT_MAXHITPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "maxhitpointspercent") { it.getAbilities().statsPercent[STAT_MAXHITPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "maxmanapoints") { it.getAbilities().stats[STAT_MAXMANAPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "maxmanapointspercent") { it.getAbilities().statsPercent[STAT_MAXMANAPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "magicpoints" || tmpStrValue == "magiclevelpoints") { it.getAbilities().stats[STAT_MAGICPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "magicpointspercent") { it.getAbilities().statsPercent[STAT_MAGICPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); } else if (tmpStrValue == "fieldabsorbpercentenergy") { it.getAbilities().fieldAbsorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "fieldabsorbpercentfire") { it.getAbilities().fieldAbsorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "fieldabsorbpercentpoison" || tmpStrValue == "fieldabsorpercentearth") { it.getAbilities().fieldAbsorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentall" || tmpStrValue == "absorbpercentallelements") { int16_t value = pugi::cast<int16_t>(valueAttribute.value()); Abilities& abilities = it.getAbilities(); for (size_t i = 0; i < COMBAT_COUNT; ++i) { abilities.absorbPercent[i] += value; } } else if (tmpStrValue == "absorbpercentelements") { int16_t value = pugi::cast<int16_t>(valueAttribute.value()); Abilities& abilities = it.getAbilities(); abilities.absorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += value; } else if (tmpStrValue == "absorbpercentmagic") { int16_t value = pugi::cast<int16_t>(valueAttribute.value()); Abilities& abilities = it.getAbilities(); abilities.absorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += value; } else if (tmpStrValue == "absorbpercentenergy") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentfire") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentpoison" || tmpStrValue == "absorbpercentearth") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentlifedrain") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_LIFEDRAIN)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentmanadrain") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_MANADRAIN)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentdrown") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_DROWNDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentphysical") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_PHYSICALDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercenthealing") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_HEALING)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "absorbpercentundefined") { it.getAbilities().absorbPercent[combatTypeToIndex(COMBAT_UNDEFINEDDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); } else if (tmpStrValue == "suppressdrunk") { if (valueAttribute.as_bool()) { it.getAbilities().conditionSuppressions |= CONDITION_DRUNK; } } else if (tmpStrValue == "suppressenergy") { if (valueAttribute.as_bool()) { it.getAbilities().conditionSuppressions |= CONDITION_ENERGY; } } else if (tmpStrValue == "suppressfire") { if (valueAttribute.as_bool()) { it.getAbilities().conditionSuppressions |= CONDITION_FIRE; } } else if (tmpStrValue == "suppresspoison") { if (valueAttribute.as_bool()) { it.getAbilities().conditionSuppressions |= CONDITION_POISON; } } else if (tmpStrValue == "suppressdrown") { if (valueAttribute.as_bool()) { it.getAbilities().conditionSuppressions |= CONDITION_DROWN; } } else if (tmpStrValue == "suppressphysical") { if (valueAttribute.as_bool()) { it.getAbilities().conditionSuppressions |= CONDITION_BLEEDING; } } else if (tmpStrValue == "field") { it.group = ITEM_GROUP_MAGICFIELD; it.type = ITEM_TYPE_MAGICFIELD; CombatType_t combatType = COMBAT_NONE; ConditionDamage* conditionDamage = nullptr; tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "fire") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_FIRE); combatType = COMBAT_FIREDAMAGE; } else if (tmpStrValue == "energy") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_ENERGY); combatType = COMBAT_ENERGYDAMAGE; } else if (tmpStrValue == "poison") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_POISON); combatType = COMBAT_EARTHDAMAGE; } else if (tmpStrValue == "drown") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_DROWN); combatType = COMBAT_DROWNDAMAGE; } else if (tmpStrValue == "physical") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_BLEEDING); combatType = COMBAT_PHYSICALDAMAGE; } else { std::cout << "[Warning - Items::parseItemNode] Unknown field value: " << valueAttribute.as_string() << std::endl; } if (combatType != COMBAT_NONE) { it.combatType = combatType; it.conditionDamage.reset(conditionDamage); uint32_t ticks = 0; int32_t damage = 0; int32_t start = 0; int32_t count = 1; for (auto subAttributeNode : attributeNode.children()) { pugi::xml_attribute subKeyAttribute = subAttributeNode.attribute("key"); if (!subKeyAttribute) { continue; } pugi::xml_attribute subValueAttribute = subAttributeNode.attribute("value"); if (!subValueAttribute) { continue; } tmpStrValue = asLowerCaseString(subKeyAttribute.as_string()); if (tmpStrValue == "ticks") { ticks = pugi::cast<uint32_t>(subValueAttribute.value()); } else if (tmpStrValue == "count") { count = std::max<int32_t>(1, pugi::cast<int32_t>(subValueAttribute.value())); } else if (tmpStrValue == "start") { start = std::max<int32_t>(0, pugi::cast<int32_t>(subValueAttribute.value())); } else if (tmpStrValue == "damage") { damage = -pugi::cast<int32_t>(subValueAttribute.value()); if (start > 0) { std::list<int32_t> damageList; ConditionDamage::generateDamageList(damage, start, damageList); for (int32_t damageValue : damageList) { conditionDamage->addDamage(1, ticks, -damageValue); } start = 0; } else { conditionDamage->addDamage(count, ticks, damage); } } } conditionDamage->setParam(CONDITION_PARAM_FIELD, 1); if (conditionDamage->getTotalDamage() > 0) { conditionDamage->setParam(CONDITION_PARAM_FORCEUPDATE, 1); } } } else if (tmpStrValue == "replaceable") { it.replaceable = valueAttribute.as_bool(); } else if (tmpStrValue == "partnerdirection") { it.bedPartnerDir = getDirection(valueAttribute.as_string()); } else if (tmpStrValue == "leveldoor") { it.levelDoor = pugi::cast<uint32_t>(valueAttribute.value()); } else if (tmpStrValue == "maletransformto" || tmpStrValue == "malesleeper") { uint16_t value = pugi::cast<uint16_t>(valueAttribute.value()); it.transformToOnUse[PLAYERSEX_MALE] = value; ItemType& other = getItemType(value); if (other.transformToFree == 0) { other.transformToFree = it.id; } if (it.transformToOnUse[PLAYERSEX_FEMALE] == 0) { it.transformToOnUse[PLAYERSEX_FEMALE] = value; } } else if (tmpStrValue == "femaletransformto" || tmpStrValue == "femalesleeper") { uint16_t value = pugi::cast<uint16_t>(valueAttribute.value()); it.transformToOnUse[PLAYERSEX_FEMALE] = value; ItemType& other = getItemType(value); if (other.transformToFree == 0) { other.transformToFree = it.id; } if (it.transformToOnUse[PLAYERSEX_MALE] == 0) { it.transformToOnUse[PLAYERSEX_MALE] = value; } } else if (tmpStrValue == "transformto") { it.transformToFree = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "destroyto") { it.destroyTo = pugi::cast<uint16_t>(valueAttribute.value()); } else if (tmpStrValue == "elementearth") { Abilities& abilities = it.getAbilities(); abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_EARTHDAMAGE; } else if (tmpStrValue == "elementfire") { Abilities& abilities = it.getAbilities(); abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_FIREDAMAGE; } else if (tmpStrValue == "elementenergy") { Abilities& abilities = it.getAbilities(); abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_ENERGYDAMAGE; } else if (tmpStrValue == "walkstack") { it.walkStack = valueAttribute.as_bool(); } else if (tmpStrValue == "blocking") { it.blockSolid = valueAttribute.as_bool(); } else if (tmpStrValue == "allowdistread") { it.allowDistRead = booleanString(valueAttribute.as_string()); } else { std::cout << "[Warning - Items::parseItemNode] Unknown key value: " << keyAttribute.as_string() << std::endl; } } //check bed items if ((it.transformToFree != 0 || it.transformToOnUse[PLAYERSEX_FEMALE] != 0 || it.transformToOnUse[PLAYERSEX_MALE] != 0) && it.type != ITEM_TYPE_BED) { std::cout << "[Warning - Items::parseItemNode] Item " << it.id << " is not set as a bed-type" << std::endl; } }
void Items::parseItemNode(const pugi::xml_node& itemNode, uint16_t id) { if (id > 30000 && id < 30100) { id -= 30000; if (id >= items.size()) { items.resize(id + 1); } ItemType& iType = items[id]; iType.id = id; } ItemType& it = getItemType(id); if (it.id == 0) { return; } it.name = itemNode.attribute("name").as_string(); nameToItems.insert({ asLowerCaseString(it.name), id }); pugi::xml_attribute articleAttribute = itemNode.attribute("article"); if (articleAttribute) { it.article = articleAttribute.as_string(); } pugi::xml_attribute pluralAttribute = itemNode.attribute("plural"); if (pluralAttribute) { it.pluralName = pluralAttribute.as_string(); } Abilities& abilities = it.getAbilities(); for (auto attributeNode : itemNode.children()) { pugi::xml_attribute keyAttribute = attributeNode.attribute("key"); if (!keyAttribute) { continue; } pugi::xml_attribute valueAttribute = attributeNode.attribute("value"); if (!valueAttribute) { continue; } std::string tmpStrValue = asLowerCaseString(keyAttribute.as_string()); auto parseAttribute = ItemParseAttributesMap.find(tmpStrValue); if (parseAttribute != ItemParseAttributesMap.end()) { ItemParseAttributes_t parseType = parseAttribute->second; switch (parseType) { case ITEM_PARSE_TYPE: { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); auto it2 = ItemTypesMap.find(tmpStrValue); if (it2 != ItemTypesMap.end()) { it.type = it2->second; if (it.type == ITEM_TYPE_CONTAINER) { it.group = ITEM_GROUP_CONTAINER; } } else { std::cout << "[Warning - Items::parseItemNode] Unknown type: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_DESCRIPTION: { it.description = valueAttribute.as_string(); break; } case ITEM_PARSE_RUNESPELLNAME: { it.runeSpellName = valueAttribute.as_string(); break; } case ITEM_PARSE_WEIGHT: { it.weight = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SHOWCOUNT: { it.showCount = valueAttribute.as_bool(); break; } case ITEM_PARSE_ARMOR: { it.armor = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_DEFENSE: { it.defense = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_EXTRADEF: { it.extraDefense = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_ATTACK: { it.attack = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_ROTATETO: { it.rotateTo = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MOVEABLE: { it.moveable = valueAttribute.as_bool(); break; } case ITEM_PARSE_BLOCKPROJECTILE: { it.blockProjectile = valueAttribute.as_bool(); break; } case ITEM_PARSE_PICKUPABLE: { it.allowPickupable = valueAttribute.as_bool(); break; } case ITEM_PARSE_FORCESERIALIZE: { it.forceSerialize = valueAttribute.as_bool(); break; } case ITEM_PARSE_FLOORCHANGE: { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); auto it2 = TileStatesMap.find(tmpStrValue); if (it2 != TileStatesMap.end()) { it.floorChange = it2->second; } else { std::cout << "[Warning - Items::parseItemNode] Unknown floorChange: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_CORPSETYPE: { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); auto it2 = RaceTypesMap.find(tmpStrValue); if (it2 != RaceTypesMap.end()) { it.corpseType = it2->second; } else { std::cout << "[Warning - Items::parseItemNode] Unknown corpseType: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_CONTAINERSIZE: { it.maxItems = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_FLUIDSOURCE: { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); auto it2 = FluidTypesMap.find(tmpStrValue); if (it2 != FluidTypesMap.end()) { it.fluidSource = it2->second; } else { std::cout << "[Warning - Items::parseItemNode] Unknown fluidSource: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_READABLE: { it.canReadText = valueAttribute.as_bool(); break; } case ITEM_PARSE_WRITEABLE: { it.canWriteText = valueAttribute.as_bool(); it.canReadText = it.canWriteText; break; } case ITEM_PARSE_MAXTEXTLEN: { it.maxTextLen = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_WRITEONCEITEMID: { it.writeOnceItemId = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_WEAPONTYPE: { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); auto it2 = WeaponTypesMap.find(tmpStrValue); if (it2 != WeaponTypesMap.end()) { it.weaponType = it2->second; } else { std::cout << "[Warning - Items::parseItemNode] Unknown weaponType: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_SLOTTYPE: { tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "head") { it.slotPosition |= SLOTP_HEAD; } else if (tmpStrValue == "body") { it.slotPosition |= SLOTP_ARMOR; } else if (tmpStrValue == "legs") { it.slotPosition |= SLOTP_LEGS; } else if (tmpStrValue == "feet") { it.slotPosition |= SLOTP_FEET; } else if (tmpStrValue == "backpack") { it.slotPosition |= SLOTP_BACKPACK; } else if (tmpStrValue == "two-handed") { it.slotPosition |= SLOTP_TWO_HAND; } else if (tmpStrValue == "right-hand") { it.slotPosition &= ~SLOTP_LEFT; } else if (tmpStrValue == "left-hand") { it.slotPosition &= ~SLOTP_RIGHT; } else if (tmpStrValue == "necklace") { it.slotPosition |= SLOTP_NECKLACE; } else if (tmpStrValue == "ring") { it.slotPosition |= SLOTP_RING; } else if (tmpStrValue == "ammo") { it.slotPosition |= SLOTP_AMMO; } else if (tmpStrValue == "hand") { it.slotPosition |= SLOTP_HAND; } else { std::cout << "[Warning - Items::parseItemNode] Unknown slotType: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_AMMOTYPE: { it.ammoType = getAmmoType(asLowerCaseString(valueAttribute.as_string())); if (it.ammoType == AMMO_NONE) { std::cout << "[Warning - Items::parseItemNode] Unknown ammoType: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_SHOOTTYPE: { ShootType_t shoot = getShootType(asLowerCaseString(valueAttribute.as_string())); if (shoot != CONST_ANI_NONE) { it.shootType = shoot; } else { std::cout << "[Warning - Items::parseItemNode] Unknown shootType: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_EFFECT: { MagicEffectClasses effect = getMagicEffect(asLowerCaseString(valueAttribute.as_string())); if (effect != CONST_ME_NONE) { it.magicEffect = effect; } else { std::cout << "[Warning - Items::parseItemNode] Unknown effect: " << valueAttribute.as_string() << std::endl; } break; } case ITEM_PARSE_RANGE: { it.shootRange = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_STOPDURATION: { it.stopTime = valueAttribute.as_bool(); break; } case ITEM_PARSE_DECAYTO: { it.decayTo = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_TRANSFORMEQUIPTO: { it.transformEquipTo = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_TRANSFORMDEEQUIPTO: { it.transformDeEquipTo = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_DURATION: { it.decayTime = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SHOWDURATION: { it.showDuration = valueAttribute.as_bool(); break; } case ITEM_PARSE_CHARGES: { it.charges = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SHOWCHARGES: { it.showCharges = valueAttribute.as_bool(); break; } case ITEM_PARSE_SHOWATTRIBUTES: { it.showAttributes = valueAttribute.as_bool(); break; } case ITEM_PARSE_HITCHANCE: { it.hitChance = std::min<int8_t>(100, std::max<int8_t>(-100, pugi::cast<int16_t>(valueAttribute.value()))); break; } case ITEM_PARSE_MAXHITCHANCE: { it.maxHitChance = std::min<uint32_t>(100, pugi::cast<uint32_t>(valueAttribute.value())); break; } case ITEM_PARSE_INVISIBLE: { abilities.invisible = valueAttribute.as_bool(); break; } case ITEM_PARSE_SPEED: { abilities.speed = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_HEALTHGAIN: { abilities.regeneration = true; abilities.healthGain = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_HEALTHTICKS: { abilities.regeneration = true; abilities.healthTicks = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MANAGAIN: { abilities.regeneration = true; abilities.manaGain = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MANATICKS: { abilities.regeneration = true; abilities.manaTicks = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MANASHIELD: { abilities.manaShield = valueAttribute.as_bool(); break; } case ITEM_PARSE_SKILLSWORD: { abilities.skills[SKILL_SWORD] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SKILLAXE: { abilities.skills[SKILL_AXE] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SKILLCLUB: { abilities.skills[SKILL_CLUB] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SKILLDIST: { abilities.skills[SKILL_DISTANCE] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SKILLFISH: { abilities.skills[SKILL_FISHING] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SKILLSHIELD: { abilities.skills[SKILL_SHIELD] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_SKILLFIST: { abilities.skills[SKILL_FIST] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MAXHITPOINTS: { abilities.stats[STAT_MAXHITPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MAXHITPOINTSPERCENT: { abilities.statsPercent[STAT_MAXHITPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MAXMANAPOINTS: { abilities.stats[STAT_MAXMANAPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MAXMANAPOINTSPERCENT: { abilities.statsPercent[STAT_MAXMANAPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MAGICPOINTS: { abilities.stats[STAT_MAGICPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MAGICPOINTSPERCENT: { abilities.statsPercent[STAT_MAGICPOINTS] = pugi::cast<int32_t>(valueAttribute.value()); break; } case ITEM_PARSE_FIELDABSORBPERCENTENERGY: { abilities.fieldAbsorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_FIELDABSORBPERCENTFIRE: { abilities.fieldAbsorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_FIELDABSORBPERCENTPOISON: { abilities.fieldAbsorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTALL: { int16_t value = pugi::cast<int16_t>(valueAttribute.value()); for (auto& i : abilities.absorbPercent) { i += value; } break; } case ITEM_PARSE_ABSORBPERCENTELEMENTS: { int16_t value = pugi::cast<int16_t>(valueAttribute.value()); abilities.absorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_ICEDAMAGE)] += value; break; } case ITEM_PARSE_ABSORBPERCENTMAGIC: { int16_t value = pugi::cast<int16_t>(valueAttribute.value()); abilities.absorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_ICEDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_HOLYDAMAGE)] += value; abilities.absorbPercent[combatTypeToIndex(COMBAT_DEATHDAMAGE)] += value; break; } case ITEM_PARSE_ABSORBPERCENTENERGY: { abilities.absorbPercent[combatTypeToIndex(COMBAT_ENERGYDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTFIRE: { abilities.absorbPercent[combatTypeToIndex(COMBAT_FIREDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTPOISON: { abilities.absorbPercent[combatTypeToIndex(COMBAT_EARTHDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTICE: { abilities.absorbPercent[combatTypeToIndex(COMBAT_ICEDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTHOLY: { abilities.absorbPercent[combatTypeToIndex(COMBAT_HOLYDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTDEATH: { abilities.absorbPercent[combatTypeToIndex(COMBAT_DEATHDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTLIFEDRAIN: { abilities.absorbPercent[combatTypeToIndex(COMBAT_LIFEDRAIN)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTMANADRAIN: { abilities.absorbPercent[combatTypeToIndex(COMBAT_MANADRAIN)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTDROWN: { abilities.absorbPercent[combatTypeToIndex(COMBAT_DROWNDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTPHYSICAL: { abilities.absorbPercent[combatTypeToIndex(COMBAT_PHYSICALDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTHEALING: { abilities.absorbPercent[combatTypeToIndex(COMBAT_HEALING)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ABSORBPERCENTUNDEFINED: { abilities.absorbPercent[combatTypeToIndex(COMBAT_UNDEFINEDDAMAGE)] += pugi::cast<int16_t>(valueAttribute.value()); break; } case ITEM_PARSE_SUPPRESSDRUNK: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_DRUNK; } break; } case ITEM_PARSE_SUPPRESSENERGY: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_ENERGY; } break; } case ITEM_PARSE_SUPPRESSFIRE: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_FIRE; } break; } case ITEM_PARSE_SUPPRESSPOISON: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_POISON; } break; } case ITEM_PARSE_SUPPRESSDROWN: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_DROWN; } break; } case ITEM_PARSE_SUPPRESSPHYSICAL: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_BLEEDING; } break; } case ITEM_PARSE_SUPPRESSFREEZE: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_FREEZING; } break; } case ITEM_PARSE_SUPPRESSDAZZLE: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_DAZZLED; } break; } case ITEM_PARSE_SUPPRESSCURSE: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_CURSED; } break; } case ITEM_PARSE_FIELD: { it.group = ITEM_GROUP_MAGICFIELD; it.type = ITEM_TYPE_MAGICFIELD; CombatType_t combatType = COMBAT_NONE; ConditionDamage* conditionDamage = nullptr; tmpStrValue = asLowerCaseString(valueAttribute.as_string()); if (tmpStrValue == "fire") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_FIRE); combatType = COMBAT_FIREDAMAGE; } else if (tmpStrValue == "energy") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_ENERGY); combatType = COMBAT_ENERGYDAMAGE; } else if (tmpStrValue == "poison") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_POISON); combatType = COMBAT_EARTHDAMAGE; } else if (tmpStrValue == "drown") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_DROWN); combatType = COMBAT_DROWNDAMAGE; } else if (tmpStrValue == "physical") { conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_BLEEDING); combatType = COMBAT_PHYSICALDAMAGE; } else { std::cout << "[Warning - Items::parseItemNode] Unknown field value: " << valueAttribute.as_string() << std::endl; } if (combatType != COMBAT_NONE) { it.combatType = combatType; it.conditionDamage.reset(conditionDamage); uint32_t ticks = 0; int32_t start = 0; int32_t count = 1; for (auto subAttributeNode : attributeNode.children()) { pugi::xml_attribute subKeyAttribute = subAttributeNode.attribute("key"); if (!subKeyAttribute) { continue; } pugi::xml_attribute subValueAttribute = subAttributeNode.attribute("value"); if (!subValueAttribute) { continue; } tmpStrValue = asLowerCaseString(subKeyAttribute.as_string()); if (tmpStrValue == "ticks") { ticks = pugi::cast<uint32_t>(subValueAttribute.value()); } else if (tmpStrValue == "count") { count = std::max<int32_t>(1, pugi::cast<int32_t>(subValueAttribute.value())); } else if (tmpStrValue == "start") { start = std::max<int32_t>(0, pugi::cast<int32_t>(subValueAttribute.value())); } else if (tmpStrValue == "damage") { int32_t damage = -pugi::cast<int32_t>(subValueAttribute.value()); if (start > 0) { std::list<int32_t> damageList; ConditionDamage::generateDamageList(damage, start, damageList); for (int32_t damageValue : damageList) { conditionDamage->addDamage(1, ticks, -damageValue); } start = 0; } else { conditionDamage->addDamage(count, ticks, damage); } } } conditionDamage->setParam(CONDITION_PARAM_FIELD, 1); if (conditionDamage->getTotalDamage() > 0) { conditionDamage->setParam(CONDITION_PARAM_FORCEUPDATE, 1); } } break; } case ITEM_PARSE_REPLACEABLE: { it.replaceable = valueAttribute.as_bool(); break; } case ITEM_PARSE_PARTNERDIRECTION: { it.bedPartnerDir = getDirection(valueAttribute.as_string()); break; } case ITEM_PARSE_LEVELDOOR: { it.levelDoor = pugi::cast<uint32_t>(valueAttribute.value()); break; } case ITEM_PARSE_MALETRANSFORMTO: { uint16_t value = pugi::cast<uint16_t>(valueAttribute.value()); it.transformToOnUse[PLAYERSEX_MALE] = value; ItemType& other = getItemType(value); if (other.transformToFree == 0) { other.transformToFree = it.id; } if (it.transformToOnUse[PLAYERSEX_FEMALE] == 0) { it.transformToOnUse[PLAYERSEX_FEMALE] = value; } break; } case ITEM_PARSE_FEMALETRANSFORMTO: { uint16_t value = pugi::cast<uint16_t>(valueAttribute.value()); it.transformToOnUse[PLAYERSEX_FEMALE] = value; ItemType& other = getItemType(value); if (other.transformToFree == 0) { other.transformToFree = it.id; } if (it.transformToOnUse[PLAYERSEX_MALE] == 0) { it.transformToOnUse[PLAYERSEX_MALE] = value; } break; } case ITEM_PARSE_TRANSFORMTO: { it.transformToFree = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_DESTROYTO: { it.destroyTo = pugi::cast<uint16_t>(valueAttribute.value()); break; } case ITEM_PARSE_ELEMENTICE: { abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_ICEDAMAGE; break; } case ITEM_PARSE_ELEMENTEARTH: { abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_EARTHDAMAGE; break; } case ITEM_PARSE_ELEMENTFIRE: { abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_FIREDAMAGE; break; } case ITEM_PARSE_ELEMENTENERGY: { abilities.elementDamage = pugi::cast<uint16_t>(valueAttribute.value()); abilities.elementType = COMBAT_ENERGYDAMAGE; break; } case ITEM_PARSE_WALKSTACK: { it.walkStack = valueAttribute.as_bool(); break; } case ITEM_PARSE_BLOCKING: { it.blockSolid = valueAttribute.as_bool(); break; } case ITEM_PARSE_ALLOWDISTREAD: { it.allowDistRead = booleanString(valueAttribute.as_string()); break; } default: { // It should not ever get to here, only if you add a new key to the map and don't configure a case for it. std::cout << "[Warning - Items::parseItemNode] Not configured key value: " << keyAttribute.as_string() << std::endl; break; } } } else { std::cout << "[Warning - Items::parseItemNode] Unknown key value: " << keyAttribute.as_string() << std::endl; } } //check bed items if ((it.transformToFree != 0 || it.transformToOnUse[PLAYERSEX_FEMALE] != 0 || it.transformToOnUse[PLAYERSEX_MALE] != 0) && it.type != ITEM_TYPE_BED) { std::cout << "[Warning - Items::parseItemNode] Item " << it.id << " is not set as a bed-type" << std::endl; } }