Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////
- // OpenTibia - an opensource roleplaying game
- ////////////////////////////////////////////////////////////////////////
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
- ////////////////////////////////////////////////////////////////////////
- #include "otpch.h"
- #include <iostream>
- #include <string>
- #include <libxml/xmlmemory.h>
- #include "tile.h"
- #include "items.h"
- #include "condition.h"
- #include "weapons.h"
- #include "configmanager.h"
- #include "spells.h"
- #include <iostream>
- #include <fstream>
- #include <map>
- extern Spells* g_spells;
- extern ConfigManager g_config;
- // custom added
- extern LuaScriptInterface g_lua;
- // --
- uint32_t Items::dwMajorVersion = 0;
- uint32_t Items::dwMinorVersion = 0;
- uint32_t Items::dwBuildNumber = 0;
- ItemType::ItemType()
- {
- group = ITEM_GROUP_NONE;
- type = ITEM_TYPE_NONE;
- stackable = useable = alwaysOnTop = lookThrough = pickupable = rotable = hasHeight = forceSerialize = false;
- blockSolid = blockProjectile = blockPathFind = allowPickupable = false;
- moveable = true;
- alwaysOnTopOrder = 0;
- rotateTo = 0;
- wieldInfo = 0;
- minReqLevel = 0;
- minReqMagicLevel = 0;
- runeMagLevel = runeLevel = 0;
- speed = id = 0;
- clientId = 100;
- maxItems = 8; //maximum size if this is a container
- weight = 0; //weight of the item, e.g. throwing distance depends on it
- showCount = true;
- weaponType = WEAPON_NONE;
- slotPosition = SLOTP_HAND | SLOTP_AMMO;
- wieldPosition = SLOT_HAND;
- ammoType = AMMO_NONE;
- ammoAction = AMMOACTION_NONE;
- shootType = (ShootEffect_t)0;
- magicEffect = MAGIC_EFFECT_NONE;
- attack = extraAttack = 0;
- defense = extraDefense = 0;
- attackSpeed = 0;
- armor = 0;
- decayTo = -1;
- decayTime = 0;
- stopTime = false;
- corpseType = RACE_NONE;
- fluidSource = FLUID_NONE;
- clientCharges = false;
- allowDistRead = false;
- isVertical = isHorizontal = isHangable = false;
- lightLevel = lightColor = 0;
- maxTextLen = 0;
- canReadText = canWriteText = false;
- writeOnceItemId = 0;
- transformEquipTo = transformDeEquipTo = 0;
- showDuration = showCharges = showAttributes = false;
- charges = 0;
- hitChance = maxHitChance = breakChance = -1;
- shootRange = 1;
- condition = NULL;
- combatType = COMBAT_NONE;
- replaceable = true;
- worth = 0;
- bedPartnerDir = NORTH;
- transformUseTo[PLAYERSEX_FEMALE] = 0;
- transformUseTo[PLAYERSEX_MALE] = 0;
- transformToFree = 0;
- levelDoor = 0;
- memset(floorChange, 0, sizeof(floorChange));
- }
- ItemType::~ItemType()
- {
- delete condition;
- }
- void Items::clear()
- {
- //TODO: clear items?
- moneyMap.clear();
- randomizationMap.clear();
- reverseItemMap.clear();
- }
- bool Items::reload()
- {
- //TODO: reload items?
- /*for(ItemMap::iterator it = items.begin(); it != items.end(); ++it)
- delete it->second->condition;
- clear();
- return loadFromXml();*/
- return false;
- }
- int32_t Items::loadFromOtb(std::string file)
- {
- FileLoader f;
- if(!f.openFile(file.c_str(), false, true))
- return f.getError();
- uint32_t type;
- NODE node = f.getChildNode(NO_NODE, type);
- PropStream props;
- if(f.getProps(node, props))
- {
- //4 byte flags
- //attributes
- //0x01 = version data
- uint32_t flags;
- if(!props.GET_ULONG(flags))
- return ERROR_INVALID_FORMAT;
- attribute_t attr;
- if(!props.GET_VALUE(attr))
- return ERROR_INVALID_FORMAT;
- if(attr == ROOT_ATTR_VERSION)
- {
- datasize_t length = 0;
- if(!props.GET_VALUE(length))
- return ERROR_INVALID_FORMAT;
- if(length != sizeof(VERSIONINFO))
- return ERROR_INVALID_FORMAT;
- VERSIONINFO *vi;
- if(!props.GET_STRUCT(vi))
- return ERROR_INVALID_FORMAT;
- Items::dwMajorVersion = vi->dwMajorVersion; //items otb format file version
- Items::dwMinorVersion = vi->dwMinorVersion; //client version
- Items::dwBuildNumber = vi->dwBuildNumber; //revision
- }
- }
- uint16_t lastId = 99;
- for(node = f.getChildNode(node, type); node != NO_NODE; node = f.getNextNode(node, type))
- {
- PropStream props;
- if(!f.getProps(node, props))
- return f.getError();
- ItemType* iType = new ItemType();
- iType->group = (itemgroup_t)type;
- flags_t flags;
- switch(type)
- {
- case ITEM_GROUP_CONTAINER:
- iType->type = ITEM_TYPE_CONTAINER;
- break;
- case ITEM_GROUP_DOOR:
- //not used
- iType->type = ITEM_TYPE_DOOR;
- break;
- case ITEM_GROUP_MAGICFIELD:
- //not used
- iType->type = ITEM_TYPE_MAGICFIELD;
- break;
- case ITEM_GROUP_TELEPORT:
- //not used
- iType->type = ITEM_TYPE_TELEPORT;
- break;
- case ITEM_GROUP_NONE:
- case ITEM_GROUP_GROUND:
- case ITEM_GROUP_SPLASH:
- case ITEM_GROUP_FLUID:
- case ITEM_GROUP_CHARGES:
- case ITEM_GROUP_DEPRECATED:
- break;
- default:
- return ERROR_INVALID_FORMAT;
- }
- //read 4 byte flags
- if(!props.GET_VALUE(flags))
- return ERROR_INVALID_FORMAT;
- iType->blockSolid = hasBitSet(FLAG_BLOCK_SOLID, flags);
- iType->blockProjectile = hasBitSet(FLAG_BLOCK_PROJECTILE, flags);
- iType->blockPathFind = hasBitSet(FLAG_BLOCK_PATHFIND, flags);
- iType->hasHeight = hasBitSet(FLAG_HAS_HEIGHT, flags);
- iType->useable = hasBitSet(FLAG_USEABLE, flags);
- iType->pickupable = hasBitSet(FLAG_PICKUPABLE, flags);
- iType->moveable = hasBitSet(FLAG_MOVEABLE, flags);
- iType->stackable = hasBitSet(FLAG_STACKABLE, flags);
- iType->alwaysOnTop = hasBitSet(FLAG_ALWAYSONTOP, flags);
- iType->isVertical = hasBitSet(FLAG_VERTICAL, flags);
- iType->isHorizontal = hasBitSet(FLAG_HORIZONTAL, flags);
- iType->isHangable = hasBitSet(FLAG_HANGABLE, flags);
- iType->allowDistRead = hasBitSet(FLAG_ALLOWDISTREAD, flags);
- iType->rotable = hasBitSet(FLAG_ROTABLE, flags);
- iType->canReadText = hasBitSet(FLAG_READABLE, flags);
- iType->clientCharges = hasBitSet(FLAG_CLIENTCHARGES, flags);
- iType->lookThrough = hasBitSet(FLAG_LOOKTHROUGH, flags);
- attribute_t attr;
- while(props.GET_VALUE(attr))
- {
- //size of data
- datasize_t length = 0;
- if(!props.GET_VALUE(length))
- {
- delete iType;
- return ERROR_INVALID_FORMAT;
- }
- switch(attr)
- {
- case ITEM_ATTR_SERVERID:
- {
- if(length != sizeof(uint16_t))
- return ERROR_INVALID_FORMAT;
- uint16_t serverId;
- if(!props.GET_USHORT(serverId))
- return ERROR_INVALID_FORMAT;
- if(serverId > 20000 && serverId < 20100)
- serverId = serverId - 20000;
- else if(lastId > 99 && lastId != serverId - 1)
- {
- static ItemType dummyItemType;
- while(lastId != serverId - 1)
- {
- dummyItemType.id = ++lastId;
- items.addElement(&dummyItemType, lastId);
- }
- }
- iType->id = serverId;
- lastId = serverId;
- break;
- }
- case ITEM_ATTR_CLIENTID:
- {
- if(length != sizeof(uint16_t))
- return ERROR_INVALID_FORMAT;
- uint16_t clientId;
- if(!props.GET_USHORT(clientId))
- return ERROR_INVALID_FORMAT;
- iType->clientId = clientId;
- break;
- }
- case ITEM_ATTR_SPEED:
- {
- if(length != sizeof(uint16_t))
- return ERROR_INVALID_FORMAT;
- uint16_t speed;
- if(!props.GET_USHORT(speed))
- return ERROR_INVALID_FORMAT;
- iType->speed = speed;
- break;
- }
- case ITEM_ATTR_LIGHT2:
- {
- if(length != sizeof(lightBlock2))
- return ERROR_INVALID_FORMAT;
- lightBlock2* block;
- if(!props.GET_STRUCT(block))
- return ERROR_INVALID_FORMAT;
- iType->lightLevel = block->lightLevel;
- iType->lightColor = block->lightColor;
- break;
- }
- case ITEM_ATTR_TOPORDER:
- {
- if(length != sizeof(uint8_t))
- return ERROR_INVALID_FORMAT;
- uint8_t topOrder;
- if(!props.GET_UCHAR(topOrder))
- return ERROR_INVALID_FORMAT;
- iType->alwaysOnTopOrder = topOrder;
- break;
- }
- default:
- {
- //skip unknown attributes
- if(!props.SKIP_N(length))
- return ERROR_INVALID_FORMAT;
- break;
- }
- }
- }
- // store the found item
- items.addElement(iType, iType->id);
- if(iType->clientId)
- reverseItemMap[iType->clientId] = iType->id;
- }
- return ERROR_NONE;
- }
- // this struct is used to parse the lua table, sort of like a jump start for loading all of the numerous fields
- static struct i {
- const char* name;
- int type;
- } itemLua[] = {
- { "itemid", LUA_TNUMBER },
- { "name", LUA_TSTRING },
- { "article", LUA_TSTRING },
- { "plural", LUA_TSTRING },
- { "attributes", LUA_TTABLE },
- { NULL, 0 }
- }, attributesL[] = {
- { "key", LUA_TSTRING },
- { "value", LUA_TSTRING },
- { NULL, 0 }
- };
- bool Items::loadFromXml()
- {
- // this will give the option to load vocations as xml or lua
- bool useXML = g_config.getBool(ConfigManager::USE_XML);
- // we don't always want to build a table of items in lua so this is why we have this setting
- bool constructTable = g_config.getBool(ConfigManager::BUILD_TABLE);
- if (!useXML && !constructTable) {
- lua_State *L = luaL_newstate();
- std::string str;
- uint16_t id = 1;
- if (!L) {
- throw std::runtime_error("Failed to allocate memory in items");
- }
- luaL_openlibs(L);
- if (luaL_dofile(L, "data/lua/items.lua")) {
- std::cout << "[Error - Items] " << lua_tostring(L, -1) << std::endl;
- lua_close(L);
- return false;
- }
- lua_getglobal(L, "items");
- if (lua_istable(L, -1)) {
- for (int i = 1; ; i++) {
- lua_rawgeti(L, -1, i);
- if (lua_isnil(L, -1)) {
- lua_pop(L, 1);
- break;
- }
- lua_getfield(L, -1, itemLua[0].name);
- str = itemLua[0].name;
- if (lua_isnumber(L, -1)) {
- if (str == "itemid") {
- id = (uint16_t)lua_tonumber(L, -1);
- lua_pop(L, 1);
- //std::cout << "item id " << id << std::endl;
- parseItemNodeLua(L, id);
- }
- }
- }
- lua_pop(L, 1);
- }
- lua_close(L);
- return true;
- }
- else{
- std::ofstream out;
- if (constructTable) {
- out.open("data/lua/items.lua");
- }else{
- out.open("data/lua/empty.lua");
- }
- xmlDocPtr itemDoc = xmlParseFile(getFilePath(FILE_TYPE_OTHER, "items/items.xml").c_str());
- if(!itemDoc)
- {
- std::cout << "[Warning - Items::loadFromXml] Cannot load items file." << std::endl;
- std::cout << getLastXMLError() << std::endl;
- return false;
- }
- if (constructTable) {
- out << "items = {" << std::endl;
- }
- xmlNodePtr itemRoot = xmlDocGetRootElement(itemDoc);
- if(xmlStrcmp(itemRoot->name,(const xmlChar*)"items"))
- {
- xmlFreeDoc(itemDoc);
- std::cout << "[Warning - Items::loadFromXml] Malformed items file." << std::endl;
- return false;
- }
- IntegerVec intVector, endVector;
- std::string strValue, endValue;
- StringVec strVector;
- int32_t intValue, id = 0, endId = 0, fromId = 0, toId = 0;
- for(xmlNodePtr itemNode = itemRoot->children; itemNode; itemNode = itemNode->next)
- {
- if(xmlStrcmp(itemNode->name,(const xmlChar*)"item"))
- continue;
- if(readXMLInteger(itemNode, "id", intValue))
- parseItemNode(itemNode, intValue, out, constructTable);
- else if(readXMLString(itemNode, "fromid", strValue) && readXMLString(itemNode, "toid", endValue))
- {
- intVector = vectorAtoi(explodeString(strValue, ";"));
- endVector = vectorAtoi(explodeString(endValue, ";"));
- if(intVector[0] && endVector[0] && intVector.size() == endVector.size())
- {
- size_t size = intVector.size();
- for(size_t i = 0; i < size; ++i)
- {
- parseItemNode(itemNode, intVector[i], out, constructTable);
- while(intVector[i] < endVector[i])
- parseItemNode(itemNode, ++intVector[i], out, constructTable);
- }
- }
- else
- std::cout << "[Warning - Items::loadFromXml] Malformed entry (from: \"" << strValue << "\", to: \"" << endValue << "\")" << std::endl;
- }
- else
- std::cout << "[Warning - Items::loadFromXml] No itemid found" << std::endl;
- }
- xmlFreeDoc(itemDoc);
- for(uint32_t i = 0; i < Item::items.size(); ++i) //lets do some checks...
- {
- const ItemType* it = Item::items.getElement(i);
- if(!it)
- continue;
- //check bed items
- if((it->transformToFree || it->transformUseTo[PLAYERSEX_FEMALE] || it->transformUseTo[PLAYERSEX_MALE]) && it->type != ITEM_TYPE_BED)
- std::cout << "[Warning - Items::loadFromXml] Item " << it->id << " is not set as a bed-type." << std::endl;
- }
- if (constructTable) {
- out << "}" << std::endl;
- }
- out.close();
- }
- return true;
- }
- void Items::parseItemNodeLua(lua_State *L, uint16_t id)
- {
- CombatType_t combatType = COMBAT_NONE;
- int32_t intValue = 0;
- int16_t value = 0;
- std::string strValue = "";
- uint32_t ticks = 0;
- int32_t damage = 0;
- int32_t start = 0;
- int32_t count = 1;
- std::string lstr, lkey, tmpStrValue;
- if(id > 20000 && id < 20100)
- {
- id = id - 20000;
- ItemType* iType = new ItemType();
- iType->id = id;
- items.addElement(iType, iType->id);
- }
- ItemType& it = Item::items.getItemType(id);
- if(!it.name.empty()){
- std::cout << "[Warning - Items::loadFromXml] Duplicate registered item with id " << id << std::endl;
- }
- for (int fields = 1; itemLua[fields].name != NULL; fields++) { // start outter loop
- lua_getfield(L, -1, itemLua[fields].name);
- lstr = itemLua[fields].name;
- //std::cout << lstr << std::endl;
- switch (lua_type(L, -1)) { // start outter switch
- case LUA_TSTRING:
- if (lstr == "name") {
- it.name = lua_tostring(L, -1);
- }
- else if (lstr == "article") {
- it.article = lua_tostring(L, -1);
- }
- else if (lstr == "plural") {
- it.pluralName = lua_tostring(L, -1);
- }
- break;
- case LUA_TTABLE:
- if (lstr == "attributes") {
- if (lua_objlen(L, -1) > 0) {
- for (int i = 1; ; i++) {
- lua_rawgeti(L, -1, i);
- if (lua_isnil(L, -1)) {
- lua_pop(L, 1);
- break;
- }
- for (int x = 0; attributesL[x].name != NULL; x++) { // start inner loop
- lua_getfield(L, -1, attributesL[x].name);
- lstr = attributesL[x].name;
- //testLua(L);
- if (lstr == "key") {
- lkey = lua_tostring(L, -1);
- if (!lkey.empty()) {
- //std::cout << lkey << std::endl;
- }
- }
- if (lstr == "value") {
- if(lkey == "type")
- {
- strValue = lua_tostring(L, -1);
- if(strValue == "container")
- {
- it.type = ITEM_TYPE_CONTAINER;
- it.group = ITEM_GROUP_CONTAINER;
- }
- else if(strValue == "key")
- it.type = ITEM_TYPE_KEY;
- else if(strValue == "magicfield")
- it.type = ITEM_TYPE_MAGICFIELD;
- else if(strValue == "depot")
- it.type = ITEM_TYPE_DEPOT;
- else if(strValue == "mailbox")
- it.type = ITEM_TYPE_MAILBOX;
- else if(strValue == "trashholder")
- it.type = ITEM_TYPE_TRASHHOLDER;
- else if(strValue == "teleport")
- it.type = ITEM_TYPE_TELEPORT;
- else if(strValue == "door")
- it.type = ITEM_TYPE_DOOR;
- else if(strValue == "bed")
- it.type = ITEM_TYPE_BED;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown type " << strValue << std::endl;
- }
- else if (lkey == "description") {
- it.description = lua_tostring(L, -1);
- }
- else if (lkey == "name") {
- it.name = lua_tostring(L, -1);
- }
- else if (lkey == "article") {
- it.article = lua_tostring(L, -1);
- }
- else if (lkey == "plural") {
- it.pluralName = lua_tostring(L, -1);
- }
- else if (lkey == "runespellname") {
- it.runeSpellName = lua_tostring(L, -1);
- }
- else if (lkey == "weight") {
- it.weight = (uint32_t)lua_tonumber(L, -1) / 100.f;
- }// custom added
- /*
- else if (lkey == "tier") {
- it.tier = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "power") {
- it.power = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "heal") {
- it.heal = (uint32_t)lua_tonumber(L, -1);
- }*/
- //--
- else if (lkey == "showcount") {
- it.showCount = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "armor") {
- it.armor = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "defense") {
- it.defense = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "extradefense" || lkey == "extradef") {
- it.extraDefense = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "attack") {
- it.attack = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "extraattack" || lkey == "extraatk") {
- it.attack = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "attackspeed"){
- it.attackSpeed = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "rotateto") {
- it.rotateTo = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "moveable" || lkey == "movable") {
- it.moveable = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "blockprojectile") {
- it.blockProjectile = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "allowpickupable" || lkey == "pickupable") {
- it.allowPickupable = (lua_tonumber(L, -1) != 0);
- }
- else if(lkey == "floorchange")
- {
- strValue = lua_tostring(L, -1);
- if(strValue == "down")
- it.floorChange[CHANGE_DOWN] = true;
- else if(strValue == "north")
- it.floorChange[CHANGE_NORTH] = true;
- else if(strValue == "south")
- it.floorChange[CHANGE_SOUTH] = true;
- else if(strValue == "west")
- it.floorChange[CHANGE_WEST] = true;
- else if(strValue == "east")
- it.floorChange[CHANGE_EAST] = true;
- else if(strValue == "northex")
- it.floorChange[CHANGE_NORTH_EX] = true;
- else if(strValue == "southex")
- it.floorChange[CHANGE_SOUTH_EX] = true;
- else if(strValue == "westex")
- it.floorChange[CHANGE_WEST_EX] = true;
- else if(strValue == "eastex")
- it.floorChange[CHANGE_EAST_EX] = true;
- else
- std::cout << "[Warning - Items::parseItemNodeLua] Unknown floorchange " << strValue << std::endl;
- }
- else if(lkey == "corpsetype")
- {
- strValue = lua_tostring(L, -1);
- if(strValue == "venom")
- it.corpseType = RACE_VENOM;
- else if(strValue == "blood")
- it.corpseType = RACE_BLOOD;
- else if(strValue == "undead")
- it.corpseType = RACE_UNDEAD;
- else if(strValue == "fire")
- it.corpseType = RACE_FIRE;
- else if(strValue == "energy")
- it.corpseType = RACE_ENERGY;
- else
- std::cout << "[Warning - Items::parseItemNodeLua] Unknown corpseType " << strValue << std::endl;
- }
- else if (lkey == "containersize") {
- it.maxItems = (uint16_t)lua_tonumber(L, -1);
- }
- else if(lkey == "fluidsource")
- {
- strValue = lua_tostring(L, -1);
- FluidTypes_t fluid = getFluidType(strValue);
- if(fluid != FLUID_NONE)
- it.fluidSource = fluid;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown fluidSource " << strValue << std::endl;
- }
- else if (lkey == "writeable" || lkey == "writable") {
- it.canWriteText = (lua_tonumber(L, -1) != 0);
- it.canReadText = it.canWriteText;
- }
- else if (lkey == "readable") {
- it.canReadText = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "maxtextlen" || lkey == "maxtextlength") {
- it.maxTextLen = (uint16_t)lua_tonumber(L, -1);
- }
- else if (lkey == "writeonceitemid") {
- it.writeOnceItemId = (uint16_t)lua_tonumber(L, -1);
- }
- else if (lkey == "worth") {
- intValue = (int32_t)lua_tonumber(L, -1);
- if(moneyMap.find(intValue) != moneyMap.end()){
- std::cout << "[Warning - Items::parseItemNodeLua] Duplicated money item " << id << " with worth " << intValue << "!" << std::endl;
- }else{
- moneyMap[intValue] = id;
- it.worth = intValue;
- }
- }
- else if(lkey == "forceserialize" || lkey == "forceserialization" || lkey == "forcesave"){
- it.forceSerialize = (lua_tonumber(L, -1) != 0);
- }
- else if(lkey == "leveldoor"){
- it.levelDoor = (uint32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "weapontype")
- {
- strValue = lua_tostring(L, -1);
- if(strValue == "sword")
- it.weaponType = WEAPON_SWORD;
- else if(strValue == "club")
- it.weaponType = WEAPON_CLUB;
- else if(strValue == "axe")
- it.weaponType = WEAPON_AXE;
- else if(strValue == "shield")
- it.weaponType = WEAPON_SHIELD;
- else if(strValue == "distance")
- it.weaponType = WEAPON_DIST;
- else if(strValue == "wand" || strValue == "rod")
- it.weaponType = WEAPON_WAND;
- else if(strValue == "ammunition")
- it.weaponType = WEAPON_AMMO;
- else if(strValue == "fist")
- it.weaponType = WEAPON_FIST;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown weaponType " << strValue << std::endl;
- }
- else if (lkey == "slottype") {
- strValue = lua_tostring(L, -1);
- if(strValue == "head")
- {
- it.slotPosition |= SLOTP_HEAD;
- it.wieldPosition = SLOT_HEAD;
- }
- else if(strValue == "body")
- {
- it.slotPosition |= SLOTP_ARMOR;
- it.wieldPosition = SLOT_ARMOR;
- }
- else if(strValue == "legs")
- {
- it.slotPosition |= SLOTP_LEGS;
- it.wieldPosition = SLOT_LEGS;
- }
- else if(strValue == "feet")
- {
- it.slotPosition |= SLOTP_FEET;
- it.wieldPosition = SLOT_FEET;
- }
- else if(strValue == "backpack")
- {
- it.slotPosition |= SLOTP_BACKPACK;
- it.wieldPosition = SLOT_BACKPACK;
- }
- else if(strValue == "two-handed")
- {
- it.slotPosition |= SLOTP_TWO_HAND;
- it.wieldPosition = SLOT_TWO_HAND;
- }
- else if(strValue == "necklace")
- {
- it.slotPosition |= SLOTP_NECKLACE;
- it.wieldPosition = SLOT_NECKLACE;
- }
- else if(strValue == "ring")
- {
- it.slotPosition |= SLOTP_RING;
- it.wieldPosition = SLOT_RING;
- }
- else if(strValue == "ammo")
- it.wieldPosition = SLOT_AMMO;
- else if(strValue == "hand")
- it.wieldPosition = SLOT_HAND;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown slotType " << strValue << std::endl;
- }
- else if (lkey == "ammotype") {
- strValue = lua_tostring(L, -1);
- it.ammoType = getAmmoType(strValue);
- if (it.ammoType == AMMO_NONE) {
- std::cout << "[Warning - Items::parseItemNodeLua] Unknown ammoType: " << strValue << std::endl;
- }
- }
- else if (lkey == "shoottype") {
- strValue = lua_tostring(L, -1);
- ShootEffect_t shoot = getShootType(strValue);
- if (shoot != SHOOT_EFFECT_UNKNOWN) {
- it.shootType = shoot;
- }
- else {
- std::cout << "[Warning - Items::parseItemNodeLua] Unknown shootType: " << strValue << std::endl;
- }
- }
- else if (lkey == "effect") {
- strValue = lua_tostring(L, -1);
- MagicEffect_t effect = getMagicEffect(strValue);
- if(effect != MAGIC_EFFECT_UNKNOWN) {
- it.magicEffect = effect;
- }
- else {
- std::cout << "[Warning - Items::parseItemNodeLua] Unknown effect: " << strValue << std::endl;
- }
- }
- else if (lkey == "range") {
- it.shootRange = (uint16_t)lua_tonumber(L, -1);
- }
- else if (lkey == "stopduration") {
- it.stopTime = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "decayto") {
- it.decayTo = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "transformequipto") {
- it.transformEquipTo = (uint16_t)lua_tonumber(L, -1);
- }
- else if (lkey == "transformdeequipto") {
- it.transformDeEquipTo = (uint16_t)lua_tonumber(L, -1);
- }
- else if (lkey == "duration") {
- it.decayTime = std::max((int32_t)0, (int32_t)lua_tonumber(L, -1));
- }
- else if (lkey == "showduration") {
- it.showDuration = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "charges") {
- it.charges = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "showcharges") {
- it.showCharges = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "showattributes") {
- it.showAttributes = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "breakchance") {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.breakChance = std::max(0, std::min(100, intValue));
- }
- else if(lkey == "ammoaction"){
- strValue = lua_tostring(L, -1);
- AmmoAction_t ammo = getAmmoAction(strValue);
- if(ammo != AMMOACTION_NONE)
- it.ammoAction = ammo;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown ammoAction " << strValue << std::endl;
- }
- else if (lkey == "hitchance") {
- it.hitChance = std::max(0, std::min(100, (int)lua_tonumber(L, -1)));
- }
- else if (lkey == "maxhitchance") {
- it.maxHitChance = std::max(0, std::min(100, (int)lua_tonumber(L, -1)));
- }
- else if(lkey == "preventloss"){
- it.abilities.preventLoss = (lua_tonumber(L, -1) != 0);
- }
- else if(lkey == "preventdrop"){
- it.abilities.preventDrop = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "invisible") {
- it.abilities.invisible = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "speed") {
- it.abilities.speed = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "healthgain") {
- it.abilities.regeneration = true;
- it.abilities.healthGain = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "healthticks") {
- it.abilities.regeneration = true;
- it.abilities.healthTicks = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "managain") {
- it.abilities.regeneration = true;
- it.abilities.manaGain = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "manaticks") {
- it.abilities.regeneration = true;
- it.abilities.manaTicks = (uint32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "manashield") {
- it.abilities.manaShield = (lua_tonumber(L, -1) != 0);
- }
- else if (lkey == "skillsword") {
- it.abilities.skills[SKILL_SWORD] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "skillaxe") {
- it.abilities.skills[SKILL_AXE] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "skillclub") {
- it.abilities.skills[SKILL_CLUB] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "skilldist") {
- it.abilities.skills[SKILL_DIST] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "skillfish") {
- it.abilities.skills[SKILL_FISH] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "skillshield") {
- it.abilities.skills[SKILL_SHIELD] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "skillfist") {
- it.abilities.skills[SKILL_FIST] = (int32_t)lua_tonumber(L, -1);
- }/*
- else if (lkey == "critchance") {
- it.abilities.skills[SKILL_CRITICAL_HIT_CHANCE] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "critdamage") {
- it.abilities.skills[SKILL_CRITICAL_HIT_DAMAGE] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "lifeleechchance") {
- it.abilities.skills[SKILL_LIFE_LEECH_CHANCE] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "lifeleechamount") {
- it.abilities.skills[SKILL_LIFE_LEECH_AMOUNT] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "manaleechchance") {
- it.getAbilities().skills[SKILL_MANA_LEECH_CHANCE] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "manaleechamount") {
- it.getAbilities().skills[SKILL_MANA_LEECH_AMOUNT] = (int32_t)lua_tonumber(L, -1);
- }*/
- else if (lkey == "maxhealthpoints" || lkey == "maxhitpoints") {
- it.abilities.stats[STAT_MAXHEALTH] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "maxhealthpercent" || lkey == "maxhitpointspercent") {
- it.abilities.statsPercent[STAT_MAXHEALTH] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "maxmanapoints") {
- it.abilities.stats[STAT_MAXMANA] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "maxmanapercent" || lkey == "maxmanapointspercent") {
- it.abilities.statsPercent[STAT_MAXMANA] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "soulpoints"){
- it.abilities.stats[STAT_SOUL] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "soulpercent" || lkey == "soulpointspercent"){
- it.abilities.statsPercent[STAT_SOUL] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "magiclevelpoints" || lkey == "magicpoints") {
- it.abilities.stats[STAT_MAGICLEVEL] = (int32_t)lua_tonumber(L, -1);
- }
- else if (lkey == "magiclevelpercent" || lkey == "magicpointspercent") {
- it.abilities.statsPercent[STAT_MAGICLEVEL] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "increasemagicvalue"){
- it.abilities.increment[MAGIC_VALUE] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "increasemagicpercent"){
- it.abilities.increment[MAGIC_PERCENT] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "increasehealingvalue"){
- it.abilities.increment[HEALING_VALUE] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "increasehealingpercent"){
- it.abilities.increment[HEALING_PERCENT] = (int32_t)lua_tonumber(L, -1);
- }
- else if(lkey == "absorbpercentall")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
- it.abilities.absorb[i] += intValue;
- }
- }
- else if(lkey == "absorbpercentelements")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentmagic")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentenergy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentfire")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentpoison" || lkey == "absorbpercentearth")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentice")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentholy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentdeath")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentlifedrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_LIFEDRAIN] += intValue;
- }
- else if(lkey == "absorbpercentmanadrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_MANADRAIN] += intValue;
- }
- else if(lkey == "absorbpercentdrown")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_DROWNDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercentphysical")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_PHYSICALDAMAGE] += intValue;
- }
- else if(lkey == "absorbpercenthealing")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_HEALING] += intValue;
- }
- else if(lkey == "absorbpercentundefined")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.absorb[COMBAT_UNDEFINEDDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentall")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++)
- it.abilities.reflect[REFLECT_PERCENT][i] += intValue;
- }
- else if(lkey == "reflectpercentelements")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentmagic")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentenergy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentfire")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentpoison" || lkey == "reflectpercentearth")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentice")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentholy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentdeath")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentlifedrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_LIFEDRAIN] += intValue;
- }
- else if(lkey == "reflectpercentmanadrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_MANADRAIN] += intValue;
- }
- else if(lkey == "reflectpercentdrown")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_DROWNDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercentphysical")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_PHYSICALDAMAGE] += intValue;
- }
- else if(lkey == "reflectpercenthealing")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_HEALING] += intValue;
- }
- else if(lkey == "reflectpercentundefined")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_UNDEFINEDDAMAGE] += intValue;
- }
- else if(lkey == "reflectchanceall")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++)
- it.abilities.reflect[REFLECT_CHANCE][i] += intValue;
- }
- else if(lkey == "reflectchanceelements")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancemagic")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
- }
- else if(lkey == "reflectchanceenergy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancefire")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancepoison" || lkey == "reflectchanceearth")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
- }
- else if(lkey == "reflectchanceice")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
- }
- else if(lkey == "reflectchanceholy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancedeath")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancelifedrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_LIFEDRAIN] += intValue;
- }
- else if(lkey == "reflectchancemanadrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_MANADRAIN] += intValue;
- }
- else if(lkey == "reflectchancedrown")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_DROWNDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancephysical")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_PHYSICALDAMAGE] += intValue;
- }
- else if(lkey == "reflectchancehealing")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_HEALING] += intValue;
- }
- else if(lkey == "reflectchanceundefined")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_UNDEFINEDDAMAGE] += intValue;
- }
- else if(lkey == "suppressshock" || lkey == "suppressenergy")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_ENERGY;
- }
- else if(lkey == "suppressburn" || lkey == "suppressfire")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_FIRE;
- }
- else if(lkey == "suppresspoison" || lkey == "suppressearth")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_POISON;
- }
- else if(lkey == "suppressfreeze" || lkey == "suppressice")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_FREEZING;
- }
- else if(lkey == "suppressdazzle" || lkey == "suppressholy")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_DAZZLED;
- }
- else if(lkey == "suppresscurse" || lkey == "suppressdeath")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_CURSED;
- }
- else if(lkey == "suppressdrown")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_DROWN;
- }
- else if(lkey == "suppressphysical")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_PHYSICAL;
- }
- else if(lkey == "suppresshaste")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_HASTE;
- }
- else if(lkey == "suppressparalyze")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_PARALYZE;
- }
- else if(lkey == "suppressdrunk")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_DRUNK;
- }
- else if(lkey == "suppressregeneration")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_REGENERATION;
- }
- else if(lkey == "suppresssoul")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_SOUL;
- }
- else if(lkey == "suppressoutfit")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_OUTFIT;
- }
- else if(lkey == "suppressinvisible")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_INVISIBLE;
- }
- else if(lkey == "suppressinfight")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_INFIGHT;
- }
- else if(lkey == "suppressexhaust")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_EXHAUST;
- }
- else if(lkey == "suppressmuted")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_MUTED;
- }
- else if(lkey == "suppresspacified")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_PACIFIED;
- }
- else if(lkey == "suppresslight")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_LIGHT;
- }
- else if(lkey == "suppressattributes")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_ATTRIBUTES;
- }
- else if(lkey == "suppressmanashield")
- {
- if(lua_tonumber(L, -1) != 0)
- it.abilities.conditionSuppressions |= CONDITION_MANASHIELD;
- }
- else if(lkey == "elementphysical")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_PHYSICALDAMAGE;
- }
- else if(lkey == "elementfire")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_FIREDAMAGE;
- }
- else if(lkey == "elementenergy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_ENERGYDAMAGE;
- }
- else if(lkey == "elementearth")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_EARTHDAMAGE;
- }
- else if(lkey == "elementice")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_ICEDAMAGE;
- }
- else if(lkey == "elementholy")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_HOLYDAMAGE;
- }
- else if(lkey == "elementdeath")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_DEATHDAMAGE;
- }
- else if(lkey == "elementlifedrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_LIFEDRAIN;
- }
- else if(lkey == "elementmanadrain")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_MANADRAIN;
- }
- else if(lkey == "elementhealing")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_HEALING;
- }
- else if(lkey == "elementundefined")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_UNDEFINEDDAMAGE;
- }
- else if(lkey == "replaceable" || lkey == "replacable")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.replaceable = (intValue != 0);
- }
- else if(lkey == "partnerdirection")
- {
- std::string strValue = lua_tostring(L, -1);
- it.bedPartnerDir = getDirection(strValue);
- }
- else if(lkey == "maletransformto")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.transformUseTo[PLAYERSEX_MALE] = intValue;
- ItemType& ot = getItemType(intValue);
- if(!ot.transformToFree)
- ot.transformToFree = it.id;
- if(!it.transformUseTo[PLAYERSEX_FEMALE])
- it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
- }
- else if(lkey == "femaletransformto")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
- ItemType& ot = getItemType(intValue);
- if(!ot.transformToFree)
- ot.transformToFree = it.id;
- if(!it.transformUseTo[PLAYERSEX_MALE])
- it.transformUseTo[PLAYERSEX_MALE] = intValue;
- }
- else if(lkey == "transformto")
- {
- intValue = (int32_t)lua_tonumber(L, -1);
- it.transformToFree = intValue;
- }
- else {
- std::cout << "[Warning - Items::parseItemNodeLua] Unknown key value: " << lkey << std::endl;
- }
- }// end of value
- //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::parseItemNodeLua] Item " << it.id << " is not set as a bed-type" << std::endl;
- // }//
- lua_pop(L, 1);
- }// end of inner for loop
- lua_pop(L, 1);
- }
- }// end of objlen
- }// end of attributes
- lua_pop(L, 1);
- break;
- } // end of outter switch
- lua_pop(L, 1);
- }//end of outter loop
- }
- // this function not only parses the items.xml but it also can construct items.xml in a lua table
- void Items::parseItemNode(xmlNodePtr itemNode, uint32_t id, std::ofstream& out, bool constructTable)
- {
- int32_t intValue;
- std::string strValue;
- bool description = false, field = false;
- std::string parser, pattribute, desc, key, pfield = "";
- if (constructTable) {
- parser = "\t{\n\t\titemid = " + boost::lexical_cast<std::string>(id) + ", ";
- }
- if(id > 20000 && id < 20100)
- {
- id = id - 20000;
- ItemType* iType = new ItemType();
- iType->id = id;
- items.addElement(iType, iType->id);
- }
- ItemType& it = Item::items.getItemType(id);
- if(!it.name.empty() && (!readXMLString(itemNode, "override", strValue) || !booleanString(strValue))){
- std::cout << "[Warning - Items::loadFromXml] Duplicate registered item with id " << id << std::endl;
- }
- if(readXMLString(itemNode, "name", strValue)){
- it.name = strValue;
- if (constructTable) {
- if (!it.name.empty()) {
- parser += "name = \"" + it.name + "\", ";
- }
- }
- }
- if(readXMLString(itemNode, "article", strValue)){
- it.article = strValue;
- if (constructTable) {
- if (!it.article.empty()) {
- parser += "article = \"" + it.article + "\", ";
- }
- }
- }
- if(readXMLString(itemNode, "plural", strValue)){
- it.pluralName = strValue;
- if (constructTable) {
- if (!it.pluralName.empty()) {
- parser += "plural = \"" + it.pluralName + "\", ";
- }
- }
- }
- xmlNodePtr itemAttributesNode = itemNode->children;
- while(itemAttributesNode)
- {
- if(readXMLString(itemAttributesNode, "key", strValue))
- {
- if (constructTable) {
- std::string key = asLowerCaseString(strValue);
- pattribute += "\t\t\t{ key = \"" + key + "\", ";
- }
- std::string tmpStrValue = asLowerCaseString(strValue);
- if(tmpStrValue == "type")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- if(tmpStrValue == "container")
- {
- it.type = ITEM_TYPE_CONTAINER;
- it.group = ITEM_GROUP_CONTAINER;
- }
- else if(tmpStrValue == "key")
- it.type = ITEM_TYPE_KEY;
- else if(tmpStrValue == "magicfield")
- it.type = ITEM_TYPE_MAGICFIELD;
- 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
- std::cout << "[Warning - Items::loadFromXml] Unknown type " << strValue << std::endl;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "name")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- it.name = strValue;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "article")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- it.article = strValue;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "plural")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- it.pluralName = strValue;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "description")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- it.description = strValue;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "runespellname")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- it.runeSpellName = strValue;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "weight")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.weight = intValue / 100.f;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "showcount")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.showCount = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "armor")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.armor = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "defense")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.defense = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.extraDefense = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "attack")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.attack = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "extraattack" || tmpStrValue == "extraatk")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.extraAttack = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "attackspeed")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.attackSpeed = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "rotateto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.rotateTo = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "moveable" || tmpStrValue == "movable")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.moveable = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "blockprojectile")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.blockProjectile = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "allowpickupable")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.allowPickupable = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "floorchange")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- if(tmpStrValue == "down")
- it.floorChange[CHANGE_DOWN] = true;
- else if(tmpStrValue == "north")
- it.floorChange[CHANGE_NORTH] = true;
- else if(tmpStrValue == "south")
- it.floorChange[CHANGE_SOUTH] = true;
- else if(tmpStrValue == "west")
- it.floorChange[CHANGE_WEST] = true;
- else if(tmpStrValue == "east")
- it.floorChange[CHANGE_EAST] = true;
- else if(tmpStrValue == "northex")
- it.floorChange[CHANGE_NORTH_EX] = true;
- else if(tmpStrValue == "southex")
- it.floorChange[CHANGE_SOUTH_EX] = true;
- else if(tmpStrValue == "westex")
- it.floorChange[CHANGE_WEST_EX] = true;
- else if(tmpStrValue == "eastex")
- it.floorChange[CHANGE_EAST_EX] = true;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "corpsetype")
- {
- tmpStrValue = asLowerCaseString(strValue);
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- 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::loadFromXml] Unknown corpseType " << strValue << std::endl;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "containersize")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.maxItems = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "fluidsource")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- FluidTypes_t fluid = getFluidType(tmpStrValue);
- if(fluid != FLUID_NONE)
- it.fluidSource = fluid;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown fluidSource " << strValue << std::endl;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "writeable" || tmpStrValue == "writable")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.canWriteText = (intValue != 0);
- it.canReadText = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "readable")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.canReadText = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "maxtextlen" || tmpStrValue == "maxtextlength")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.maxTextLen = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "writeonceitemid")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.writeOnceItemId = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "worth")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- if(moneyMap.find(intValue) != moneyMap.end() && (!readXMLString(itemNode, "override", strValue) || !booleanString(strValue)))
- std::cout << "[Warning - Items::loadFromXml] Duplicated money item " << id << " with worth " << intValue << "!" << std::endl;
- else
- {
- moneyMap[intValue] = id;
- it.worth = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "forceserialize" || tmpStrValue == "forceserialization" || tmpStrValue == "forcesave")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.forceSerialize = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "leveldoor")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.levelDoor = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "weapontype")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- 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_DIST;
- else if(tmpStrValue == "wand" || tmpStrValue == "rod")
- it.weaponType = WEAPON_WAND;
- else if(tmpStrValue == "ammunition")
- it.weaponType = WEAPON_AMMO;
- else if(tmpStrValue == "fist")
- it.weaponType = WEAPON_FIST;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown weaponType " << strValue << std::endl;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "slottype")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- if(tmpStrValue == "head")
- {
- it.slotPosition |= SLOTP_HEAD;
- it.wieldPosition = SLOT_HEAD;
- }
- else if(tmpStrValue == "body")
- {
- it.slotPosition |= SLOTP_ARMOR;
- it.wieldPosition = SLOT_ARMOR;
- }
- else if(tmpStrValue == "legs")
- {
- it.slotPosition |= SLOTP_LEGS;
- it.wieldPosition = SLOT_LEGS;
- }
- else if(tmpStrValue == "feet")
- {
- it.slotPosition |= SLOTP_FEET;
- it.wieldPosition = SLOT_FEET;
- }
- else if(tmpStrValue == "backpack")
- {
- it.slotPosition |= SLOTP_BACKPACK;
- it.wieldPosition = SLOT_BACKPACK;
- }
- else if(tmpStrValue == "two-handed")
- {
- it.slotPosition |= SLOTP_TWO_HAND;
- it.wieldPosition = SLOT_TWO_HAND;
- }
- else if(tmpStrValue == "necklace")
- {
- it.slotPosition |= SLOTP_NECKLACE;
- it.wieldPosition = SLOT_NECKLACE;
- }
- else if(tmpStrValue == "ring")
- {
- it.slotPosition |= SLOTP_RING;
- it.wieldPosition = SLOT_RING;
- }
- else if(tmpStrValue == "ammo")
- it.wieldPosition = SLOT_AMMO;
- else if(tmpStrValue == "hand")
- it.wieldPosition = SLOT_HAND;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown slotType " << strValue << std::endl;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "ammotype")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- it.ammoType = getAmmoType(strValue);
- if(it.ammoType == AMMO_NONE)
- std::cout << "[Warning - Items::loadFromXml] Unknown ammoType " << strValue << std::endl;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "shoottype")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- ShootEffect_t shoot = getShootType(strValue);
- if(shoot != SHOOT_EFFECT_UNKNOWN)
- it.shootType = shoot;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown shootType " << strValue << std::endl;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "effect")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- MagicEffect_t effect = getMagicEffect(strValue);
- if(effect != MAGIC_EFFECT_UNKNOWN)
- it.magicEffect = effect;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown effect " << strValue << std::endl;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "range")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.shootRange = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "stopduration")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.stopTime = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "decayto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.decayTo = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "transformequipto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.transformEquipTo = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "transformdeequipto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.transformDeEquipTo = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "duration")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.decayTime = std::max((int32_t)0, intValue);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "showduration")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.showDuration = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "charges")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.charges = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "showcharges")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.showCharges = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "showattributes")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.showAttributes = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "breakchance")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.breakChance = std::max(0, std::min(100, intValue));
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "ammoaction")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- AmmoAction_t ammo = getAmmoAction(strValue);
- if(ammo != AMMOACTION_NONE)
- it.ammoAction = ammo;
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown ammoAction " << strValue << std::endl;
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- }
- else if(tmpStrValue == "hitchance")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.hitChance = std::max(0, std::min(100, intValue));
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "maxhitchance")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.maxHitChance = std::max(0, std::min(100, intValue));
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "preventloss")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.preventLoss = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "preventdrop")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.preventDrop = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "invisible")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.invisible = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "speed")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.speed = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "healthgain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.regeneration = true;
- it.abilities.healthGain = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "healthticks")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.regeneration = true;
- it.abilities.healthTicks = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "managain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.regeneration = true;
- it.abilities.manaGain = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "manaticks")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.regeneration = true;
- it.abilities.manaTicks = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "manashield")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.manaShield = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skillsword")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_SWORD] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skillaxe")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_AXE] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skillclub")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_CLUB] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skilldist")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_DIST] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skillfish")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_FISH] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skillshield")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_SHIELD] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "skillfist")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.skills[SKILL_FIST] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "maxhealthpoints" || tmpStrValue == "maxhitpoints")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.stats[STAT_MAXHEALTH] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "maxhealthpercent" || tmpStrValue == "maxhitpointspercent")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.statsPercent[STAT_MAXHEALTH] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "maxmanapoints")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.stats[STAT_MAXMANA] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "maxmanapercent" || tmpStrValue == "maxmanapointspercent")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.statsPercent[STAT_MAXMANA] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "soulpoints")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.stats[STAT_SOUL] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "soulpercent" || tmpStrValue == "soulpointspercent")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.statsPercent[STAT_SOUL] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "magiclevelpoints" || tmpStrValue == "magicpoints")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.stats[STAT_MAGICLEVEL] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "magiclevelpercent" || tmpStrValue == "magicpointspercent")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.statsPercent[STAT_MAGICLEVEL] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "increasemagicvalue")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.increment[MAGIC_VALUE] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "increasemagicpercent")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.increment[MAGIC_PERCENT] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "increasehealingvalue")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.increment[HEALING_VALUE] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "increasehealingpercent")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.increment[HEALING_PERCENT] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentall")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
- it.abilities.absorb[i] += intValue;
- }
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "absorbpercentelements")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "absorbpercentmagic")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
- it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "absorbpercentenergy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentfire")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentpoison" || tmpStrValue == "absorbpercentearth")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentice")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentholy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentdeath")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentlifedrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_LIFEDRAIN] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentmanadrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_MANADRAIN] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentdrown")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_DROWNDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentphysical")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_PHYSICALDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercenthealing")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_HEALING] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "absorbpercentundefined")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.absorb[COMBAT_UNDEFINEDDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentall")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
- it.abilities.reflect[REFLECT_PERCENT][i] += intValue;
- }
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "reflectpercentelements")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "reflectpercentmagic")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "reflectpercentenergy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentfire")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentpoison" || tmpStrValue == "reflectpercentearth")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentice")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentholy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentdeath")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentlifedrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_LIFEDRAIN] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentmanadrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_MANADRAIN] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentdrown")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_DROWNDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentphysical")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_PHYSICALDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercenthealing")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_HEALING] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectpercentundefined")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_PERCENT][COMBAT_UNDEFINEDDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchanceall")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
- it.abilities.reflect[REFLECT_CHANCE][i] += intValue;
- }
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "reflectchanceelements")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "reflectchancemagic")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "reflectchanceenergy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancefire")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancepoison" || tmpStrValue == "reflectchanceearth")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchanceice")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchanceholy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancedeath")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancelifedrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_LIFEDRAIN] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancemanadrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_MANADRAIN] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancedrown")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_DROWNDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancephysical")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_PHYSICALDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchancehealing")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_HEALING] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "reflectchanceundefined")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.abilities.reflect[REFLECT_CHANCE][COMBAT_UNDEFINEDDAMAGE] += intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressshock" || tmpStrValue == "suppressenergy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_ENERGY;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressburn" || tmpStrValue == "suppressfire")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_FIRE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppresspoison" || tmpStrValue == "suppressearth")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_POISON;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressfreeze" || tmpStrValue == "suppressice")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_FREEZING;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressdazzle" || tmpStrValue == "suppressholy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_DAZZLED;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppresscurse" || tmpStrValue == "suppressdeath")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_CURSED;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressdrown")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_DROWN;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressphysical")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_PHYSICAL;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppresshaste")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_HASTE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressparalyze")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_PARALYZE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressdrunk")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_DRUNK;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressregeneration")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_REGENERATION;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppresssoul")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_SOUL;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressoutfit")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_OUTFIT;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressinvisible")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_INVISIBLE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressinfight")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_INFIGHT;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressexhaust")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_EXHAUST;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressmuted")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_MUTED;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppresspacified")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_PACIFIED;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppresslight")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_LIGHT;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressattributes")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_ATTRIBUTES;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "suppressmanashield")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
- it.abilities.conditionSuppressions |= CONDITION_MANASHIELD;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "field")
- {
- it.group = ITEM_GROUP_MAGICFIELD;
- it.type = ITEM_TYPE_MAGICFIELD;
- CombatType_t combatType = COMBAT_NONE;
- ConditionDamage* conditionDamage = NULL;
- if(readXMLString(itemAttributesNode, "value", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- if(tmpStrValue == "fire")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_FIRE, false, 0);
- combatType = COMBAT_FIREDAMAGE;
- }
- else if(tmpStrValue == "energy")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_ENERGY, false, 0);
- combatType = COMBAT_ENERGYDAMAGE;
- }
- else if(tmpStrValue == "earth" || tmpStrValue == "poison")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_POISON, false, 0);
- combatType = COMBAT_EARTHDAMAGE;
- }
- else if(tmpStrValue == "ice" || tmpStrValue == "freezing")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_FREEZING, false, 0);
- combatType = COMBAT_ICEDAMAGE;
- }
- else if(tmpStrValue == "holy" || tmpStrValue == "dazzled")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_DAZZLED, false, 0);
- combatType = COMBAT_HOLYDAMAGE;
- }
- else if(tmpStrValue == "death" || tmpStrValue == "cursed")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_CURSED, false, 0);
- combatType = COMBAT_DEATHDAMAGE;
- }
- else if(tmpStrValue == "drown")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_DROWN, false, 0);
- combatType = COMBAT_DROWNDAMAGE;
- }
- else if(tmpStrValue == "physical")
- {
- conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_PHYSICAL, false, 0);
- combatType = COMBAT_PHYSICALDAMAGE;
- }
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown field value " << strValue << std::endl;
- if (constructTable) {
- if (!tmpStrValue.empty()) {
- pattribute += "value = \"" + tmpStrValue + "\" },\n";
- }
- }
- if(combatType != COMBAT_NONE)
- {
- it.combatType = combatType;
- it.condition = conditionDamage;
- uint32_t ticks = 0;
- int32_t damage = 0, start = 0, count = 1;
- xmlNodePtr fieldAttributesNode = itemAttributesNode->children;
- while(fieldAttributesNode)
- {
- if(readXMLString(fieldAttributesNode, "key", strValue))
- {
- tmpStrValue = asLowerCaseString(strValue);
- if(tmpStrValue == "ticks")
- {
- if(readXMLInteger(fieldAttributesNode, "value", intValue))
- ticks = std::max(0, intValue);
- }
- if(tmpStrValue == "count")
- {
- if(readXMLInteger(fieldAttributesNode, "value", intValue))
- count = std::max(1, intValue);
- }
- if(tmpStrValue == "start")
- {
- if(readXMLInteger(fieldAttributesNode, "value", intValue))
- start = std::max(0, intValue);
- }
- if(tmpStrValue == "damage")
- {
- if(readXMLInteger(fieldAttributesNode, "value", intValue))
- {
- damage = -intValue;
- if(start > 0)
- {
- std::list<int32_t> damageList;
- ConditionDamage::generateDamageList(damage, start, damageList);
- for(std::list<int32_t>::iterator it = damageList.begin(); it != damageList.end(); ++it)
- conditionDamage->addDamage(1, ticks, -*it);
- start = 0;
- }
- else
- conditionDamage->addDamage(count, ticks, damage);
- }
- }
- }
- fieldAttributesNode = fieldAttributesNode->next;
- }
- if(conditionDamage->getTotalDamage() > 0)
- it.condition->setParam(CONDITIONPARAM_FORCEUPDATE, true);
- }
- }
- }
- else if(tmpStrValue == "elementphysical")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_PHYSICALDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementfire")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_FIREDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementenergy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_ENERGYDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementearth")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_EARTHDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementice")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_ICEDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementholy")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_HOLYDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementdeath")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_DEATHDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementlifedrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_LIFEDRAIN;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementmanadrain")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_MANADRAIN;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementhealing")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_HEALING;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "elementundefined")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.abilities.elementDamage = intValue;
- it.abilities.elementType = COMBAT_UNDEFINEDDAMAGE;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "replaceable" || tmpStrValue == "replacable")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.replaceable = (intValue != 0);
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else if(tmpStrValue == "partnerdirection")
- {
- if(readXMLString(itemAttributesNode, "value", strValue))
- it.bedPartnerDir = getDirection(strValue);
- if (constructTable) {
- if (!strValue.empty()) {
- pattribute += "value = \"" + strValue + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "maletransformto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.transformUseTo[PLAYERSEX_MALE] = intValue;
- ItemType& ot = getItemType(intValue);
- if(!ot.transformToFree)
- ot.transformToFree = it.id;
- if(!it.transformUseTo[PLAYERSEX_FEMALE])
- it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "femaletransformto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- {
- it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
- ItemType& ot = getItemType(intValue);
- if(!ot.transformToFree)
- ot.transformToFree = it.id;
- if(!it.transformUseTo[PLAYERSEX_MALE])
- it.transformUseTo[PLAYERSEX_MALE] = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- }
- else if(tmpStrValue == "transformto")
- {
- if(readXMLInteger(itemAttributesNode, "value", intValue))
- it.transformToFree = intValue;
- if (constructTable) {
- pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
- }
- }
- else
- std::cout << "[Warning - Items::loadFromXml] Unknown key value " << strValue << std::endl;
- }
- itemAttributesNode = itemAttributesNode->next;
- }
- if(it.pluralName.empty() && !it.name.empty())
- {
- it.pluralName = it.name;
- if(it.showCount)
- it.pluralName += "s";
- }
- if (constructTable) {
- //if (!pattribute.empty()){
- parser += "\n\t\tattributes = {\n" + pattribute + "\t\t}\n\t},\n";
- //}else{
- //parser += "\n\t},\n";
- //}
- out << parser;
- }
- }
- void Items::parseRandomizationBlock(int32_t id, int32_t fromId, int32_t toId, int32_t chance)
- {
- RandomizationMap::iterator it = randomizationMap.find(id);
- if(it != randomizationMap.end())
- {
- std::cout << "[Warning - Items::parseRandomizationBlock] Duplicated item with id: " << id << std::endl;
- return;
- }
- RandomizationBlock rand;
- rand.chance = chance;
- rand.fromRange = fromId;
- rand.toRange = toId;
- randomizationMap[id] = rand;
- }
- uint16_t Items::getRandomizedItem(uint16_t id)
- {
- if(!g_config.getBool(ConfigManager::RANDOMIZE_TILES))
- return id;
- RandomizationBlock randomize = getRandomization(id);
- if(randomize.chance > 0 && random_range(0, 100) <= randomize.chance)
- id = random_range(randomize.fromRange, randomize.toRange);
- return id;
- }
- ItemType& Items::getItemType(int32_t id)
- {
- ItemType* iType = items.getElement(id);
- if(iType)
- return *iType;
- #ifdef __DEBUG__
- std::cout << "[Warning - Items::getItemType] Unknown itemtype with id " << id << ", using defaults." << std::endl;
- #endif
- static ItemType dummyItemType; // use this for invalid ids
- return dummyItemType;
- }
- const ItemType& Items::getItemType(int32_t id) const
- {
- if(ItemType* iType = items.getElement(id))
- return *iType;
- static ItemType dummyItemType; // use this for invalid ids
- return dummyItemType;
- }
- const ItemType& Items::getItemIdByClientId(int32_t spriteId) const
- {
- uint32_t i = 100;
- ItemType* iType;
- do
- {
- if((iType = items.getElement(i)) && iType->clientId == spriteId)
- return *iType;
- i++;
- }
- while(iType);
- static ItemType dummyItemType; // use this for invalid ids
- return dummyItemType;
- }
- int32_t Items::getItemIdByName(const std::string& name)
- {
- if(!name.empty())
- {
- uint32_t i = 100;
- ItemType* iType = NULL;
- do
- {
- if((iType = items.getElement(i)) && !strcasecmp(name.c_str(), iType->name.c_str()))
- return i;
- i++;
- }
- while(iType);
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement