Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 115.23 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////
  2. // OpenTibia - an opensource roleplaying game
  3. ////////////////////////////////////////////////////////////////////////
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. ////////////////////////////////////////////////////////////////////////
  17. #include "otpch.h"
  18. #include <iostream>
  19. #include <string>
  20. #include <libxml/xmlmemory.h>
  21.  
  22. #include "tile.h"
  23.  
  24. #include "items.h"
  25. #include "condition.h"
  26. #include "weapons.h"
  27.  
  28. #include "configmanager.h"
  29. #include "spells.h"
  30.  
  31. #include <iostream>
  32. #include <fstream>
  33.  
  34. #include <map>
  35.  
  36. extern Spells* g_spells;
  37. extern ConfigManager g_config;
  38.  
  39. // custom added
  40. extern LuaScriptInterface g_lua;
  41. // --
  42.  
  43. uint32_t Items::dwMajorVersion = 0;
  44. uint32_t Items::dwMinorVersion = 0;
  45. uint32_t Items::dwBuildNumber = 0;
  46.  
  47. ItemType::ItemType()
  48. {
  49.     group = ITEM_GROUP_NONE;
  50.     type = ITEM_TYPE_NONE;
  51.     stackable = useable = alwaysOnTop = lookThrough = pickupable = rotable = hasHeight = forceSerialize = false;
  52.     blockSolid = blockProjectile = blockPathFind = allowPickupable = false;
  53.     moveable = true;
  54.     alwaysOnTopOrder = 0;
  55.     rotateTo = 0;
  56.  
  57.     wieldInfo = 0;
  58.     minReqLevel = 0;
  59.     minReqMagicLevel = 0;
  60.  
  61.     runeMagLevel = runeLevel = 0;
  62.  
  63.     speed = id = 0;
  64.     clientId = 100;
  65.     maxItems = 8; //maximum size if this is a container
  66.     weight = 0; //weight of the item, e.g. throwing distance depends on it
  67.     showCount = true;
  68.     weaponType = WEAPON_NONE;
  69.     slotPosition = SLOTP_HAND | SLOTP_AMMO;
  70.     wieldPosition = SLOT_HAND;
  71.     ammoType = AMMO_NONE;
  72.     ammoAction = AMMOACTION_NONE;
  73.     shootType = (ShootEffect_t)0;
  74.     magicEffect = MAGIC_EFFECT_NONE;
  75.     attack = extraAttack = 0;
  76.     defense = extraDefense = 0;
  77.     attackSpeed = 0;
  78.     armor = 0;
  79.     decayTo = -1;
  80.     decayTime = 0;
  81.     stopTime = false;
  82.     corpseType = RACE_NONE;
  83.     fluidSource = FLUID_NONE;
  84.     clientCharges = false;
  85.     allowDistRead = false;
  86.  
  87.     isVertical = isHorizontal = isHangable = false;
  88.     lightLevel = lightColor = 0;
  89.  
  90.     maxTextLen = 0;
  91.     canReadText = canWriteText = false;
  92.     writeOnceItemId = 0;
  93.  
  94.     transformEquipTo = transformDeEquipTo = 0;
  95.     showDuration = showCharges = showAttributes = false;
  96.     charges = 0;
  97.     hitChance = maxHitChance = breakChance = -1;
  98.     shootRange = 1;
  99.  
  100.     condition = NULL;
  101.     combatType = COMBAT_NONE;
  102.  
  103.     replaceable = true;
  104.     worth = 0;
  105.  
  106.     bedPartnerDir = NORTH;
  107.     transformUseTo[PLAYERSEX_FEMALE] = 0;
  108.     transformUseTo[PLAYERSEX_MALE] = 0;
  109.     transformToFree = 0;
  110.     levelDoor = 0;
  111.  
  112.     memset(floorChange, 0, sizeof(floorChange));
  113. }
  114.  
  115. ItemType::~ItemType()
  116. {
  117.     delete condition;
  118. }
  119.  
  120. void Items::clear()
  121. {
  122.     //TODO: clear items?
  123.     moneyMap.clear();
  124.     randomizationMap.clear();
  125.     reverseItemMap.clear();
  126. }
  127.  
  128. bool Items::reload()
  129. {
  130.     //TODO: reload items?
  131.     /*for(ItemMap::iterator it = items.begin(); it != items.end(); ++it)
  132.         delete it->second->condition;
  133.  
  134.     clear();
  135.     return loadFromXml();*/
  136.     return false;
  137. }
  138.  
  139. int32_t Items::loadFromOtb(std::string file)
  140. {
  141.     FileLoader f;
  142.     if(!f.openFile(file.c_str(), false, true))
  143.         return f.getError();
  144.  
  145.     uint32_t type;
  146.     NODE node = f.getChildNode(NO_NODE, type);
  147.  
  148.     PropStream props;
  149.     if(f.getProps(node, props))
  150.     {
  151.         //4 byte flags
  152.         //attributes
  153.         //0x01 = version data
  154.         uint32_t flags;
  155.         if(!props.GET_ULONG(flags))
  156.             return ERROR_INVALID_FORMAT;
  157.  
  158.         attribute_t attr;
  159.         if(!props.GET_VALUE(attr))
  160.             return ERROR_INVALID_FORMAT;
  161.  
  162.         if(attr == ROOT_ATTR_VERSION)
  163.         {
  164.             datasize_t length = 0;
  165.             if(!props.GET_VALUE(length))
  166.                 return ERROR_INVALID_FORMAT;
  167.  
  168.             if(length != sizeof(VERSIONINFO))
  169.                 return ERROR_INVALID_FORMAT;
  170.  
  171.             VERSIONINFO *vi;
  172.             if(!props.GET_STRUCT(vi))
  173.                 return ERROR_INVALID_FORMAT;
  174.  
  175.             Items::dwMajorVersion = vi->dwMajorVersion; //items otb format file version
  176.             Items::dwMinorVersion = vi->dwMinorVersion; //client version
  177.             Items::dwBuildNumber = vi->dwBuildNumber; //revision
  178.         }
  179.     }
  180.  
  181.     uint16_t lastId = 99;
  182.     for(node = f.getChildNode(node, type); node != NO_NODE; node = f.getNextNode(node, type))
  183.     {
  184.         PropStream props;
  185.         if(!f.getProps(node, props))
  186.             return f.getError();
  187.  
  188.         ItemType* iType = new ItemType();
  189.         iType->group = (itemgroup_t)type;
  190.  
  191.         flags_t flags;
  192.         switch(type)
  193.         {
  194.             case ITEM_GROUP_CONTAINER:
  195.                 iType->type = ITEM_TYPE_CONTAINER;
  196.                 break;
  197.             case ITEM_GROUP_DOOR:
  198.                 //not used
  199.                 iType->type = ITEM_TYPE_DOOR;
  200.                 break;
  201.             case ITEM_GROUP_MAGICFIELD:
  202.                 //not used
  203.                 iType->type = ITEM_TYPE_MAGICFIELD;
  204.                 break;
  205.             case ITEM_GROUP_TELEPORT:
  206.                 //not used
  207.                 iType->type = ITEM_TYPE_TELEPORT;
  208.                 break;
  209.             case ITEM_GROUP_NONE:
  210.             case ITEM_GROUP_GROUND:
  211.             case ITEM_GROUP_SPLASH:
  212.             case ITEM_GROUP_FLUID:
  213.             case ITEM_GROUP_CHARGES:
  214.             case ITEM_GROUP_DEPRECATED:
  215.                 break;
  216.             default:
  217.                 return ERROR_INVALID_FORMAT;
  218.         }
  219.  
  220.         //read 4 byte flags
  221.         if(!props.GET_VALUE(flags))
  222.             return ERROR_INVALID_FORMAT;
  223.  
  224.         iType->blockSolid = hasBitSet(FLAG_BLOCK_SOLID, flags);
  225.         iType->blockProjectile = hasBitSet(FLAG_BLOCK_PROJECTILE, flags);
  226.         iType->blockPathFind = hasBitSet(FLAG_BLOCK_PATHFIND, flags);
  227.         iType->hasHeight = hasBitSet(FLAG_HAS_HEIGHT, flags);
  228.         iType->useable = hasBitSet(FLAG_USEABLE, flags);
  229.         iType->pickupable = hasBitSet(FLAG_PICKUPABLE, flags);
  230.         iType->moveable = hasBitSet(FLAG_MOVEABLE, flags);
  231.         iType->stackable = hasBitSet(FLAG_STACKABLE, flags);
  232.  
  233.         iType->alwaysOnTop = hasBitSet(FLAG_ALWAYSONTOP, flags);
  234.         iType->isVertical = hasBitSet(FLAG_VERTICAL, flags);
  235.         iType->isHorizontal = hasBitSet(FLAG_HORIZONTAL, flags);
  236.         iType->isHangable = hasBitSet(FLAG_HANGABLE, flags);
  237.         iType->allowDistRead = hasBitSet(FLAG_ALLOWDISTREAD, flags);
  238.         iType->rotable = hasBitSet(FLAG_ROTABLE, flags);
  239.         iType->canReadText = hasBitSet(FLAG_READABLE, flags);
  240.         iType->clientCharges = hasBitSet(FLAG_CLIENTCHARGES, flags);
  241.         iType->lookThrough = hasBitSet(FLAG_LOOKTHROUGH, flags);
  242.  
  243.         attribute_t attr;
  244.         while(props.GET_VALUE(attr))
  245.         {
  246.             //size of data
  247.             datasize_t length = 0;
  248.             if(!props.GET_VALUE(length))
  249.             {
  250.                 delete iType;
  251.                 return ERROR_INVALID_FORMAT;
  252.             }
  253.  
  254.             switch(attr)
  255.             {
  256.                 case ITEM_ATTR_SERVERID:
  257.                 {
  258.                     if(length != sizeof(uint16_t))
  259.                         return ERROR_INVALID_FORMAT;
  260.  
  261.                     uint16_t serverId;
  262.                     if(!props.GET_USHORT(serverId))
  263.                         return ERROR_INVALID_FORMAT;
  264.  
  265.                     if(serverId > 20000 && serverId < 20100)
  266.                         serverId = serverId - 20000;
  267.                     else if(lastId > 99 && lastId != serverId - 1)
  268.                     {
  269.                         static ItemType dummyItemType;
  270.                         while(lastId != serverId - 1)
  271.                         {
  272.                             dummyItemType.id = ++lastId;
  273.                             items.addElement(&dummyItemType, lastId);
  274.                         }
  275.                     }
  276.  
  277.                     iType->id = serverId;
  278.                     lastId = serverId;
  279.                     break;
  280.                 }
  281.                 case ITEM_ATTR_CLIENTID:
  282.                 {
  283.                     if(length != sizeof(uint16_t))
  284.                         return ERROR_INVALID_FORMAT;
  285.  
  286.                     uint16_t clientId;
  287.                     if(!props.GET_USHORT(clientId))
  288.                         return ERROR_INVALID_FORMAT;
  289.  
  290.                     iType->clientId = clientId;
  291.                     break;
  292.                 }
  293.                 case ITEM_ATTR_SPEED:
  294.                 {
  295.                     if(length != sizeof(uint16_t))
  296.                         return ERROR_INVALID_FORMAT;
  297.  
  298.                     uint16_t speed;
  299.                     if(!props.GET_USHORT(speed))
  300.                         return ERROR_INVALID_FORMAT;
  301.  
  302.                     iType->speed = speed;
  303.                     break;
  304.                 }
  305.                 case ITEM_ATTR_LIGHT2:
  306.                 {
  307.                     if(length != sizeof(lightBlock2))
  308.                         return ERROR_INVALID_FORMAT;
  309.  
  310.                     lightBlock2* block;
  311.                     if(!props.GET_STRUCT(block))
  312.                         return ERROR_INVALID_FORMAT;
  313.  
  314.                     iType->lightLevel = block->lightLevel;
  315.                     iType->lightColor = block->lightColor;
  316.                     break;
  317.                 }
  318.                 case ITEM_ATTR_TOPORDER:
  319.                 {
  320.                     if(length != sizeof(uint8_t))
  321.                         return ERROR_INVALID_FORMAT;
  322.  
  323.                     uint8_t topOrder;
  324.                     if(!props.GET_UCHAR(topOrder))
  325.                         return ERROR_INVALID_FORMAT;
  326.  
  327.                     iType->alwaysOnTopOrder = topOrder;
  328.                     break;
  329.                 }
  330.                 default:
  331.                 {
  332.                     //skip unknown attributes
  333.                     if(!props.SKIP_N(length))
  334.                         return ERROR_INVALID_FORMAT;
  335.  
  336.                     break;
  337.                 }
  338.             }
  339.         }
  340.  
  341.         // store the found item
  342.         items.addElement(iType, iType->id);
  343.         if(iType->clientId)
  344.             reverseItemMap[iType->clientId] = iType->id;
  345.     }
  346.  
  347.     return ERROR_NONE;
  348. }
  349.  
  350. // this struct is used to parse the lua table, sort of like a jump start for loading all of the numerous fields
  351. static struct i {
  352.     const char* name;
  353.     int type;
  354. } itemLua[] = {
  355.     { "itemid", LUA_TNUMBER },
  356.     { "name", LUA_TSTRING },
  357.     { "article", LUA_TSTRING },
  358.     { "plural", LUA_TSTRING },
  359.     { "attributes", LUA_TTABLE },
  360.     { NULL, 0 }
  361. }, attributesL[] = {
  362.     { "key", LUA_TSTRING },
  363.     { "value", LUA_TSTRING },
  364.     { NULL, 0 }
  365. };
  366.  
  367. bool Items::loadFromXml()
  368. {
  369.     // this will give the option to load vocations as xml or lua
  370.     bool useXML = g_config.getBool(ConfigManager::USE_XML);
  371.     // we don't always want to build a table of items in lua so this is why we have this setting
  372.     bool constructTable = g_config.getBool(ConfigManager::BUILD_TABLE);
  373.     if (!useXML && !constructTable) {
  374.  
  375.         lua_State *L = luaL_newstate();
  376.         std::string str;
  377.         uint16_t id = 1;
  378.  
  379.         if (!L) {
  380.             throw std::runtime_error("Failed to allocate memory in items");
  381.         }
  382.  
  383.         luaL_openlibs(L);
  384.  
  385.         if (luaL_dofile(L, "data/lua/items.lua")) {
  386.             std::cout << "[Error - Items] " << lua_tostring(L, -1) << std::endl;
  387.             lua_close(L);
  388.             return false;
  389.         }
  390.         lua_getglobal(L, "items");
  391.  
  392.         if (lua_istable(L, -1)) {
  393.             for (int i = 1; ; i++) {
  394.                 lua_rawgeti(L, -1, i);
  395.                 if (lua_isnil(L, -1)) {
  396.                     lua_pop(L, 1);
  397.                     break;
  398.                 }
  399.                 lua_getfield(L, -1, itemLua[0].name);
  400.                 str = itemLua[0].name;
  401.                 if (lua_isnumber(L, -1)) {
  402.                     if (str == "itemid") {
  403.                         id = (uint16_t)lua_tonumber(L, -1);
  404.                         lua_pop(L, 1);
  405.                         //std::cout << "item id " << id << std::endl;
  406.                         parseItemNodeLua(L, id);
  407.                     }
  408.                 }
  409.             }
  410.             lua_pop(L, 1);
  411.         }
  412.         lua_close(L);
  413.         return true;
  414.     }
  415.     else{
  416.        
  417.         std::ofstream out;
  418.        
  419.         if (constructTable) {
  420.            out.open("data/lua/items.lua");
  421.         }else{
  422.            out.open("data/lua/empty.lua");
  423.         }
  424.          
  425.        
  426.        
  427.         xmlDocPtr itemDoc = xmlParseFile(getFilePath(FILE_TYPE_OTHER, "items/items.xml").c_str());
  428.         if(!itemDoc)
  429.         {
  430.             std::cout << "[Warning - Items::loadFromXml] Cannot load items file." << std::endl;
  431.             std::cout << getLastXMLError() << std::endl;
  432.             return false;
  433.         }
  434.        
  435.         if (constructTable) {
  436.             out << "items = {" << std::endl;
  437.         }
  438.  
  439.         xmlNodePtr itemRoot = xmlDocGetRootElement(itemDoc);
  440.         if(xmlStrcmp(itemRoot->name,(const xmlChar*)"items"))
  441.         {
  442.             xmlFreeDoc(itemDoc);
  443.  
  444.             std::cout << "[Warning - Items::loadFromXml] Malformed items file." << std::endl;
  445.             return false;
  446.         }
  447.  
  448.         IntegerVec intVector, endVector;
  449.         std::string strValue, endValue;
  450.         StringVec strVector;
  451.  
  452.         int32_t intValue, id = 0, endId = 0, fromId = 0, toId = 0;
  453.         for(xmlNodePtr itemNode = itemRoot->children; itemNode; itemNode = itemNode->next)
  454.         {
  455.             if(xmlStrcmp(itemNode->name,(const xmlChar*)"item"))
  456.                 continue;
  457.  
  458.             if(readXMLInteger(itemNode, "id", intValue))
  459.                 parseItemNode(itemNode, intValue, out, constructTable);
  460.             else if(readXMLString(itemNode, "fromid", strValue) && readXMLString(itemNode, "toid", endValue))
  461.             {
  462.                 intVector = vectorAtoi(explodeString(strValue, ";"));
  463.                 endVector = vectorAtoi(explodeString(endValue, ";"));
  464.                 if(intVector[0] && endVector[0] && intVector.size() == endVector.size())
  465.                 {
  466.                     size_t size = intVector.size();
  467.                     for(size_t i = 0; i < size; ++i)
  468.                     {
  469.                         parseItemNode(itemNode, intVector[i], out, constructTable);
  470.                         while(intVector[i] < endVector[i])
  471.                             parseItemNode(itemNode, ++intVector[i], out, constructTable);
  472.                     }
  473.                 }
  474.                 else
  475.                     std::cout << "[Warning - Items::loadFromXml] Malformed entry (from: \"" << strValue << "\", to: \"" << endValue << "\")" << std::endl;
  476.             }
  477.             else
  478.                 std::cout << "[Warning - Items::loadFromXml] No itemid found" << std::endl;
  479.         }
  480.  
  481.         xmlFreeDoc(itemDoc);
  482.         for(uint32_t i = 0; i < Item::items.size(); ++i) //lets do some checks...
  483.         {
  484.             const ItemType* it = Item::items.getElement(i);
  485.             if(!it)
  486.                 continue;
  487.  
  488.             //check bed items
  489.             if((it->transformToFree || it->transformUseTo[PLAYERSEX_FEMALE] || it->transformUseTo[PLAYERSEX_MALE]) && it->type != ITEM_TYPE_BED)
  490.                 std::cout << "[Warning - Items::loadFromXml] Item " << it->id << " is not set as a bed-type." << std::endl;
  491.         }
  492.    
  493.         if (constructTable) {
  494.             out << "}" << std::endl;
  495.         }
  496.         out.close();
  497.     }
  498.     return true;
  499. }
  500.  
  501. void Items::parseItemNodeLua(lua_State *L, uint16_t id)
  502. {
  503.     CombatType_t combatType = COMBAT_NONE;
  504.    
  505.     int32_t intValue = 0;
  506.     int16_t value = 0;
  507.     std::string strValue = "";
  508.  
  509.     uint32_t ticks = 0;
  510.     int32_t damage = 0;
  511.     int32_t start = 0;
  512.     int32_t count = 1;
  513.  
  514.     std::string lstr, lkey, tmpStrValue;
  515.  
  516.     if(id > 20000 && id < 20100)
  517.     {
  518.         id = id - 20000;
  519.  
  520.         ItemType* iType = new ItemType();
  521.         iType->id = id;
  522.         items.addElement(iType, iType->id);
  523.     }
  524.    
  525.     ItemType& it = Item::items.getItemType(id);
  526.     if(!it.name.empty()){
  527.         std::cout << "[Warning - Items::loadFromXml] Duplicate registered item with id " << id << std::endl;
  528.     }
  529.  
  530.     for (int fields = 1; itemLua[fields].name != NULL; fields++) { // start outter loop
  531.         lua_getfield(L, -1, itemLua[fields].name);
  532.         lstr = itemLua[fields].name;
  533.         //std::cout << lstr << std::endl;
  534.         switch (lua_type(L, -1)) { // start outter switch
  535.         case LUA_TSTRING:
  536.             if (lstr == "name") {
  537.                 it.name = lua_tostring(L, -1);
  538.             }
  539.             else if (lstr == "article") {
  540.                 it.article = lua_tostring(L, -1);
  541.             }
  542.             else if (lstr == "plural") {
  543.                 it.pluralName = lua_tostring(L, -1);
  544.             }
  545.             break;
  546.         case LUA_TTABLE:
  547.             if (lstr == "attributes") {
  548.                 if (lua_objlen(L, -1) > 0) {
  549.                     for (int i = 1; ; i++) {
  550.                         lua_rawgeti(L, -1, i);
  551.                         if (lua_isnil(L, -1)) {
  552.                             lua_pop(L, 1);
  553.                             break;
  554.                         }
  555.                         for (int x = 0; attributesL[x].name != NULL; x++) { // start inner loop
  556.                             lua_getfield(L, -1, attributesL[x].name);
  557.                             lstr = attributesL[x].name;
  558.                             //testLua(L);
  559.                             if (lstr == "key") {
  560.                                 lkey = lua_tostring(L, -1);
  561.                                 if (!lkey.empty()) {
  562.                                     //std::cout << lkey << std::endl;
  563.                                 }
  564.                             }
  565.                             if (lstr == "value") {
  566.                                 if(lkey == "type")
  567.                                 {
  568.                                     strValue = lua_tostring(L, -1);
  569.                                     if(strValue == "container")
  570.                                     {
  571.                                         it.type = ITEM_TYPE_CONTAINER;
  572.                                         it.group = ITEM_GROUP_CONTAINER;
  573.                                     }
  574.                                     else if(strValue == "key")
  575.                                         it.type = ITEM_TYPE_KEY;
  576.                                     else if(strValue == "magicfield")
  577.                                         it.type = ITEM_TYPE_MAGICFIELD;
  578.                                     else if(strValue == "depot")
  579.                                         it.type = ITEM_TYPE_DEPOT;
  580.                                     else if(strValue == "mailbox")
  581.                                         it.type = ITEM_TYPE_MAILBOX;
  582.                                     else if(strValue == "trashholder")
  583.                                         it.type = ITEM_TYPE_TRASHHOLDER;
  584.                                     else if(strValue == "teleport")
  585.                                         it.type = ITEM_TYPE_TELEPORT;
  586.                                     else if(strValue == "door")
  587.                                         it.type = ITEM_TYPE_DOOR;
  588.                                     else if(strValue == "bed")
  589.                                         it.type = ITEM_TYPE_BED;
  590.                                     else
  591.                                         std::cout << "[Warning - Items::loadFromXml] Unknown type " << strValue << std::endl;
  592.                                 }
  593.                                 else if (lkey == "description") {
  594.                                     it.description = lua_tostring(L, -1);
  595.                                 }
  596.                                 else if (lkey == "name") {
  597.                                     it.name = lua_tostring(L, -1);
  598.                                 }
  599.                                 else if (lkey == "article") {
  600.                                     it.article = lua_tostring(L, -1);
  601.                                 }
  602.                                 else if (lkey == "plural") {
  603.                                     it.pluralName = lua_tostring(L, -1);
  604.                                 }
  605.                                 else if (lkey == "runespellname") {
  606.                                     it.runeSpellName = lua_tostring(L, -1);
  607.                                 }
  608.                                 else if (lkey == "weight") {
  609.                                     it.weight = (uint32_t)lua_tonumber(L, -1) / 100.f;
  610.                                 }// custom added
  611.                                 /*
  612.                                 else if (lkey == "tier") {
  613.                                     it.tier = (uint32_t)lua_tonumber(L, -1);
  614.                                 }
  615.                                 else if (lkey == "power") {
  616.                                     it.power = (uint32_t)lua_tonumber(L, -1);
  617.                                 }
  618.                                 else if (lkey == "heal") {
  619.                                     it.heal = (uint32_t)lua_tonumber(L, -1);
  620.                                 }*/
  621.                                 //--
  622.                                 else if (lkey == "showcount") {
  623.                                     it.showCount = (lua_tonumber(L, -1) != 0);
  624.                                 }
  625.                                 else if (lkey == "armor") {
  626.                                     it.armor = (int32_t)lua_tonumber(L, -1);
  627.                                 }
  628.                                 else if (lkey == "defense") {
  629.                                     it.defense = (int32_t)lua_tonumber(L, -1);
  630.                                 }
  631.                                 else if (lkey == "extradefense" || lkey == "extradef") {
  632.                                     it.extraDefense = (int32_t)lua_tonumber(L, -1);
  633.                                 }
  634.                                 else if (lkey == "attack") {
  635.                                     it.attack = (int32_t)lua_tonumber(L, -1);
  636.                                 }
  637.                                 else if (lkey == "extraattack" || lkey == "extraatk") {
  638.                                     it.attack = (int32_t)lua_tonumber(L, -1);
  639.                                 }
  640.                                 else if(lkey == "attackspeed"){
  641.                                     it.attackSpeed = (int32_t)lua_tonumber(L, -1);
  642.                                 }
  643.                                 else if (lkey == "rotateto") {
  644.                                     it.rotateTo = (int32_t)lua_tonumber(L, -1);
  645.                                 }
  646.                                 else if (lkey == "moveable" || lkey == "movable") {
  647.                                     it.moveable = (lua_tonumber(L, -1) != 0);
  648.                                 }
  649.                                 else if (lkey == "blockprojectile") {
  650.                                     it.blockProjectile = (lua_tonumber(L, -1) != 0);
  651.                                 }
  652.                                 else if (lkey == "allowpickupable" || lkey == "pickupable") {
  653.                                     it.allowPickupable = (lua_tonumber(L, -1) != 0);
  654.                                 }
  655.                                 else if(lkey == "floorchange")
  656.                                 {
  657.                                     strValue = lua_tostring(L, -1);
  658.                                     if(strValue == "down")
  659.                                         it.floorChange[CHANGE_DOWN] = true;
  660.                                     else if(strValue == "north")
  661.                                         it.floorChange[CHANGE_NORTH] = true;
  662.                                     else if(strValue == "south")
  663.                                         it.floorChange[CHANGE_SOUTH] = true;
  664.                                     else if(strValue == "west")
  665.                                         it.floorChange[CHANGE_WEST] = true;
  666.                                     else if(strValue == "east")
  667.                                         it.floorChange[CHANGE_EAST] = true;
  668.                                     else if(strValue == "northex")
  669.                                         it.floorChange[CHANGE_NORTH_EX] = true;
  670.                                     else if(strValue == "southex")
  671.                                         it.floorChange[CHANGE_SOUTH_EX] = true;
  672.                                     else if(strValue == "westex")
  673.                                         it.floorChange[CHANGE_WEST_EX] = true;
  674.                                     else if(strValue == "eastex")
  675.                                         it.floorChange[CHANGE_EAST_EX] = true;
  676.                                     else
  677.                                         std::cout << "[Warning - Items::parseItemNodeLua] Unknown floorchange " << strValue << std::endl;
  678.                                 }
  679.                                 else if(lkey == "corpsetype")
  680.                                 {
  681.                                     strValue = lua_tostring(L, -1);
  682.                                     if(strValue == "venom")
  683.                                         it.corpseType = RACE_VENOM;
  684.                                     else if(strValue == "blood")
  685.                                         it.corpseType = RACE_BLOOD;
  686.                                     else if(strValue == "undead")
  687.                                         it.corpseType = RACE_UNDEAD;
  688.                                     else if(strValue == "fire")
  689.                                         it.corpseType = RACE_FIRE;
  690.                                     else if(strValue == "energy")
  691.                                         it.corpseType = RACE_ENERGY;
  692.                                     else
  693.                                         std::cout << "[Warning - Items::parseItemNodeLua] Unknown corpseType " << strValue << std::endl;
  694.                                 }
  695.                                 else if (lkey == "containersize") {
  696.  
  697.                                     it.maxItems = (uint16_t)lua_tonumber(L, -1);
  698.                                 }
  699.                                 else if(lkey == "fluidsource")
  700.                                 {
  701.                                     strValue = lua_tostring(L, -1);
  702.                                     FluidTypes_t fluid = getFluidType(strValue);
  703.                                     if(fluid != FLUID_NONE)
  704.                                         it.fluidSource = fluid;
  705.                                     else
  706.                                         std::cout << "[Warning - Items::loadFromXml] Unknown fluidSource " << strValue << std::endl;
  707.                                 }
  708.                                 else if (lkey == "writeable" || lkey == "writable") {
  709.                                     it.canWriteText = (lua_tonumber(L, -1) != 0);
  710.                                     it.canReadText = it.canWriteText;
  711.                                 }
  712.                                 else if (lkey == "readable") {
  713.                                     it.canReadText = (lua_tonumber(L, -1) != 0);
  714.                                 }
  715.                                 else if (lkey == "maxtextlen" || lkey == "maxtextlength") {
  716.                                     it.maxTextLen = (uint16_t)lua_tonumber(L, -1);
  717.                                 }
  718.                                 else if (lkey == "writeonceitemid") {
  719.                                     it.writeOnceItemId = (uint16_t)lua_tonumber(L, -1);
  720.                                 }
  721.                                 else if (lkey == "worth") {
  722.                                     intValue = (int32_t)lua_tonumber(L, -1);
  723.                                     if(moneyMap.find(intValue) != moneyMap.end()){
  724.                         std::cout << "[Warning - Items::parseItemNodeLua] Duplicated money item " << id << " with worth " << intValue << "!" << std::endl;
  725.                                     }else{
  726.                                         moneyMap[intValue] = id;
  727.                                         it.worth = intValue;
  728.                                     }
  729.                                 }
  730.                                 else if(lkey == "forceserialize" || lkey == "forceserialization" || lkey == "forcesave"){
  731.                                     it.forceSerialize = (lua_tonumber(L, -1) != 0);
  732.                                 }
  733.                                 else if(lkey == "leveldoor"){
  734.                                     it.levelDoor = (uint32_t)lua_tonumber(L, -1);
  735.                                 }
  736.                                 else if(lkey == "weapontype")
  737.                                 {
  738.                                         strValue = lua_tostring(L, -1);
  739.                                         if(strValue == "sword")
  740.                                             it.weaponType = WEAPON_SWORD;
  741.                                         else if(strValue == "club")
  742.                                             it.weaponType = WEAPON_CLUB;
  743.                                         else if(strValue == "axe")
  744.                                             it.weaponType = WEAPON_AXE;
  745.                                         else if(strValue == "shield")
  746.                                             it.weaponType = WEAPON_SHIELD;
  747.                                         else if(strValue == "distance")
  748.                                             it.weaponType = WEAPON_DIST;
  749.                                         else if(strValue == "wand" || strValue == "rod")
  750.                                             it.weaponType = WEAPON_WAND;
  751.                                         else if(strValue == "ammunition")
  752.                                             it.weaponType = WEAPON_AMMO;
  753.                                         else if(strValue == "fist")
  754.                                             it.weaponType = WEAPON_FIST;
  755.                                         else
  756.                                             std::cout << "[Warning - Items::loadFromXml] Unknown weaponType " << strValue << std::endl;
  757.                                 }
  758.                                 else if (lkey == "slottype") {
  759.                                     strValue = lua_tostring(L, -1);
  760.                                     if(strValue == "head")
  761.                                     {
  762.                                         it.slotPosition |= SLOTP_HEAD;
  763.                                         it.wieldPosition = SLOT_HEAD;
  764.                                     }
  765.                                     else if(strValue == "body")
  766.                                     {
  767.                                         it.slotPosition |= SLOTP_ARMOR;
  768.                                         it.wieldPosition = SLOT_ARMOR;
  769.                                     }
  770.                                     else if(strValue == "legs")
  771.                                     {
  772.                                         it.slotPosition |= SLOTP_LEGS;
  773.                                         it.wieldPosition = SLOT_LEGS;
  774.                                     }
  775.                                     else if(strValue == "feet")
  776.                                     {
  777.                                         it.slotPosition |= SLOTP_FEET;
  778.                                         it.wieldPosition = SLOT_FEET;
  779.                                     }
  780.                                     else if(strValue == "backpack")
  781.                                     {
  782.                                         it.slotPosition |= SLOTP_BACKPACK;
  783.                                         it.wieldPosition = SLOT_BACKPACK;
  784.                                     }
  785.                                     else if(strValue == "two-handed")
  786.                                     {
  787.                                         it.slotPosition |= SLOTP_TWO_HAND;
  788.                                         it.wieldPosition = SLOT_TWO_HAND;
  789.                                     }
  790.                                     else if(strValue == "necklace")
  791.                                     {
  792.                                         it.slotPosition |= SLOTP_NECKLACE;
  793.                                         it.wieldPosition = SLOT_NECKLACE;
  794.                                     }
  795.                                     else if(strValue == "ring")
  796.                                     {
  797.                                         it.slotPosition |= SLOTP_RING;
  798.                                         it.wieldPosition = SLOT_RING;
  799.                                     }
  800.                                     else if(strValue == "ammo")
  801.                                         it.wieldPosition = SLOT_AMMO;
  802.                                     else if(strValue == "hand")
  803.                                         it.wieldPosition = SLOT_HAND;
  804.                                     else
  805.                                         std::cout << "[Warning - Items::loadFromXml] Unknown slotType " << strValue << std::endl;
  806.                                    
  807.                                 }
  808.                                 else if (lkey == "ammotype") {
  809.                                     strValue = lua_tostring(L, -1);
  810.                                     it.ammoType = getAmmoType(strValue);
  811.                                     if (it.ammoType == AMMO_NONE) {
  812.                                         std::cout << "[Warning - Items::parseItemNodeLua] Unknown ammoType: " << strValue << std::endl;
  813.                                     }
  814.                                 }
  815.                                 else if (lkey == "shoottype") {
  816.                                     strValue = lua_tostring(L, -1);
  817.                                     ShootEffect_t shoot = getShootType(strValue);
  818.                                     if (shoot != SHOOT_EFFECT_UNKNOWN) {
  819.                                         it.shootType = shoot;
  820.                                     }
  821.                                     else {
  822.                                         std::cout << "[Warning - Items::parseItemNodeLua] Unknown shootType: " << strValue << std::endl;
  823.                                     }
  824.                                 }
  825.                                 else if (lkey == "effect") {
  826.                                     strValue = lua_tostring(L, -1);
  827.                                     MagicEffect_t effect = getMagicEffect(strValue);
  828.                                     if(effect != MAGIC_EFFECT_UNKNOWN) {
  829.                                         it.magicEffect = effect;
  830.                                     }
  831.                                     else {
  832.                                         std::cout << "[Warning - Items::parseItemNodeLua] Unknown effect: " << strValue << std::endl;
  833.                                     }
  834.                                 }
  835.                                 else if (lkey == "range") {
  836.                                     it.shootRange = (uint16_t)lua_tonumber(L, -1);
  837.                                 }
  838.                                 else if (lkey == "stopduration") {
  839.                                     it.stopTime = (lua_tonumber(L, -1) != 0);
  840.                                 }
  841.                                 else if (lkey == "decayto") {
  842.                                     it.decayTo = (int32_t)lua_tonumber(L, -1);
  843.                                 }
  844.                                 else if (lkey == "transformequipto") {
  845.                                     it.transformEquipTo = (uint16_t)lua_tonumber(L, -1);
  846.                                 }
  847.                                 else if (lkey == "transformdeequipto") {
  848.                                     it.transformDeEquipTo = (uint16_t)lua_tonumber(L, -1);
  849.                                 }
  850.                                 else if (lkey == "duration") {
  851.                                     it.decayTime = std::max((int32_t)0, (int32_t)lua_tonumber(L, -1));
  852.                                 }
  853.                                 else if (lkey == "showduration") {
  854.                                     it.showDuration = (lua_tonumber(L, -1) != 0);
  855.                                 }
  856.                                 else if (lkey == "charges") {
  857.                                     it.charges = (uint32_t)lua_tonumber(L, -1);
  858.                                 }
  859.                                 else if (lkey == "showcharges") {
  860.                                     it.showCharges = (lua_tonumber(L, -1) != 0);
  861.                                 }
  862.                                 else if (lkey == "showattributes") {
  863.                                     it.showAttributes = (lua_tonumber(L, -1) != 0);
  864.                                 }
  865.                                 else if (lkey == "breakchance") {
  866.                                     intValue = (int32_t)lua_tonumber(L, -1);
  867.                                     it.breakChance = std::max(0, std::min(100, intValue));
  868.                                 }
  869.                                 else if(lkey == "ammoaction"){
  870.                                     strValue = lua_tostring(L, -1);
  871.                                     AmmoAction_t ammo = getAmmoAction(strValue);
  872.                                     if(ammo != AMMOACTION_NONE)
  873.                                         it.ammoAction = ammo;
  874.                                     else
  875.                                         std::cout << "[Warning - Items::loadFromXml] Unknown ammoAction " << strValue << std::endl;
  876.                                 }
  877.                                 else if (lkey == "hitchance") {
  878.                                     it.hitChance = std::max(0, std::min(100, (int)lua_tonumber(L, -1)));
  879.                                 }
  880.                                 else if (lkey == "maxhitchance") {
  881.                                     it.maxHitChance = std::max(0, std::min(100, (int)lua_tonumber(L, -1)));
  882.                                 }
  883.                                 else if(lkey == "preventloss"){
  884.                                     it.abilities.preventLoss = (lua_tonumber(L, -1) != 0);
  885.                                 }
  886.                                 else if(lkey == "preventdrop"){
  887.                                     it.abilities.preventDrop = (lua_tonumber(L, -1) != 0);
  888.                                 }
  889.                                 else if (lkey == "invisible") {
  890.                                     it.abilities.invisible = (lua_tonumber(L, -1) != 0);
  891.                                 }
  892.                                 else if (lkey == "speed") {
  893.                                     it.abilities.speed = (int32_t)lua_tonumber(L, -1);
  894.                                 }
  895.                                 else if (lkey == "healthgain") {
  896.                                     it.abilities.regeneration = true;
  897.                                     it.abilities.healthGain = (uint32_t)lua_tonumber(L, -1);
  898.                                 }
  899.                                 else if (lkey == "healthticks") {
  900.                                     it.abilities.regeneration = true;
  901.                                     it.abilities.healthTicks = (uint32_t)lua_tonumber(L, -1);
  902.                                 }
  903.                                 else if (lkey == "managain") {
  904.                                     it.abilities.regeneration = true;
  905.                                     it.abilities.manaGain = (uint32_t)lua_tonumber(L, -1);
  906.                                 }
  907.                                 else if (lkey == "manaticks") {
  908.                                     it.abilities.regeneration = true;
  909.                                     it.abilities.manaTicks = (uint32_t)lua_tonumber(L, -1);
  910.                                 }
  911.                                 else if (lkey == "manashield") {
  912.                                     it.abilities.manaShield = (lua_tonumber(L, -1) != 0);
  913.                                 }
  914.                                 else if (lkey == "skillsword") {
  915.                                     it.abilities.skills[SKILL_SWORD] = (int32_t)lua_tonumber(L, -1);
  916.                                 }
  917.                                 else if (lkey == "skillaxe") {
  918.                                     it.abilities.skills[SKILL_AXE] = (int32_t)lua_tonumber(L, -1);
  919.                                 }
  920.                                 else if (lkey == "skillclub") {
  921.                                     it.abilities.skills[SKILL_CLUB] = (int32_t)lua_tonumber(L, -1);
  922.                                 }
  923.                                 else if (lkey == "skilldist") {
  924.                                     it.abilities.skills[SKILL_DIST] = (int32_t)lua_tonumber(L, -1);
  925.                                 }
  926.                                 else if (lkey == "skillfish") {
  927.                                     it.abilities.skills[SKILL_FISH] = (int32_t)lua_tonumber(L, -1);
  928.                                 }
  929.                                 else if (lkey == "skillshield") {
  930.                                     it.abilities.skills[SKILL_SHIELD] = (int32_t)lua_tonumber(L, -1);
  931.                                 }
  932.                                 else if (lkey == "skillfist") {
  933.                                     it.abilities.skills[SKILL_FIST] = (int32_t)lua_tonumber(L, -1);
  934.                                 }/*
  935.                                 else if (lkey == "critchance") {
  936.                                     it.abilities.skills[SKILL_CRITICAL_HIT_CHANCE] = (int32_t)lua_tonumber(L, -1);
  937.                                 }
  938.                                 else if (lkey == "critdamage") {
  939.                                     it.abilities.skills[SKILL_CRITICAL_HIT_DAMAGE] = (int32_t)lua_tonumber(L, -1);
  940.                                 }
  941.                                 else if (lkey == "lifeleechchance") {
  942.                                     it.abilities.skills[SKILL_LIFE_LEECH_CHANCE] = (int32_t)lua_tonumber(L, -1);
  943.                                 }
  944.                                 else if (lkey == "lifeleechamount") {
  945.                                     it.abilities.skills[SKILL_LIFE_LEECH_AMOUNT] = (int32_t)lua_tonumber(L, -1);
  946.                                 }
  947.                                 else if (lkey == "manaleechchance") {
  948.                                     it.getAbilities().skills[SKILL_MANA_LEECH_CHANCE] = (int32_t)lua_tonumber(L, -1);
  949.                                 }
  950.                                 else if (lkey == "manaleechamount") {
  951.                                     it.getAbilities().skills[SKILL_MANA_LEECH_AMOUNT] = (int32_t)lua_tonumber(L, -1);
  952.                                 }*/
  953.                                 else if (lkey == "maxhealthpoints" || lkey == "maxhitpoints") {
  954.                                     it.abilities.stats[STAT_MAXHEALTH] = (int32_t)lua_tonumber(L, -1);
  955.                                 }
  956.                                 else if (lkey == "maxhealthpercent" || lkey == "maxhitpointspercent") {
  957.                                     it.abilities.statsPercent[STAT_MAXHEALTH] = (int32_t)lua_tonumber(L, -1);
  958.                                 }
  959.                                 else if (lkey == "maxmanapoints") {
  960.                                     it.abilities.stats[STAT_MAXMANA] = (int32_t)lua_tonumber(L, -1);
  961.                                 }
  962.                                 else if (lkey == "maxmanapercent" || lkey == "maxmanapointspercent") {
  963.                                     it.abilities.statsPercent[STAT_MAXMANA] = (int32_t)lua_tonumber(L, -1);
  964.                                 }
  965.                                 else if(lkey == "soulpoints"){
  966.                                     it.abilities.stats[STAT_SOUL] = (int32_t)lua_tonumber(L, -1);
  967.                                 }
  968.                                 else if(lkey == "soulpercent" || lkey == "soulpointspercent"){
  969.                                     it.abilities.statsPercent[STAT_SOUL] = (int32_t)lua_tonumber(L, -1);
  970.                                 }
  971.                                 else if (lkey == "magiclevelpoints" || lkey == "magicpoints") {
  972.                                     it.abilities.stats[STAT_MAGICLEVEL] = (int32_t)lua_tonumber(L, -1);
  973.                                 }
  974.                                 else if (lkey == "magiclevelpercent" || lkey == "magicpointspercent") {
  975.                                     it.abilities.statsPercent[STAT_MAGICLEVEL] = (int32_t)lua_tonumber(L, -1);
  976.                                 }
  977.                                 else if(lkey == "increasemagicvalue"){
  978.                                     it.abilities.increment[MAGIC_VALUE] = (int32_t)lua_tonumber(L, -1);
  979.                                 }
  980.                                 else if(lkey == "increasemagicpercent"){
  981.                                     it.abilities.increment[MAGIC_PERCENT] = (int32_t)lua_tonumber(L, -1);
  982.                                 }
  983.                                 else if(lkey == "increasehealingvalue"){
  984.                                     it.abilities.increment[HEALING_VALUE] = (int32_t)lua_tonumber(L, -1);
  985.                                 }
  986.                                 else if(lkey == "increasehealingpercent"){
  987.                                     it.abilities.increment[HEALING_PERCENT] = (int32_t)lua_tonumber(L, -1);
  988.                                 }
  989.                                 else if(lkey == "absorbpercentall")
  990.                                 {
  991.                                     intValue = (int32_t)lua_tonumber(L, -1);
  992.                                     for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
  993.                                         it.abilities.absorb[i] += intValue;
  994.                                     }
  995.                                 }
  996.                                 else if(lkey == "absorbpercentelements")
  997.                                 {
  998.                                     intValue = (int32_t)lua_tonumber(L, -1);
  999.                                     it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
  1000.                                     it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
  1001.                                     it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
  1002.                                     it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
  1003.                                 }
  1004.                                 else if(lkey == "absorbpercentmagic")
  1005.                                 {
  1006.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1007.                                     it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
  1008.                                     it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
  1009.                                     it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
  1010.                                     it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
  1011.                                     it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
  1012.                                     it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
  1013.                                 }
  1014.                                 else if(lkey == "absorbpercentenergy")
  1015.                                 {
  1016.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1017.                                     it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
  1018.                                 }
  1019.                                 else if(lkey == "absorbpercentfire")
  1020.                                 {
  1021.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1022.                                     it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
  1023.                                 }
  1024.                                 else if(lkey == "absorbpercentpoison" ||    lkey == "absorbpercentearth")
  1025.                                 {
  1026.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1027.                                     it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
  1028.                                 }
  1029.                                 else if(lkey == "absorbpercentice")
  1030.                                 {
  1031.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1032.                                     it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
  1033.                                 }
  1034.                                 else if(lkey == "absorbpercentholy")
  1035.                                 {
  1036.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1037.                                     it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
  1038.                                 }
  1039.                                 else if(lkey == "absorbpercentdeath")
  1040.                                 {
  1041.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1042.                                     it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
  1043.                                 }
  1044.                                 else if(lkey == "absorbpercentlifedrain")
  1045.                                 {
  1046.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1047.                                     it.abilities.absorb[COMBAT_LIFEDRAIN] += intValue;
  1048.                                 }
  1049.                                 else if(lkey == "absorbpercentmanadrain")
  1050.                                 {
  1051.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1052.                                     it.abilities.absorb[COMBAT_MANADRAIN] += intValue;
  1053.                                 }
  1054.                                 else if(lkey == "absorbpercentdrown")
  1055.                                 {
  1056.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1057.                                     it.abilities.absorb[COMBAT_DROWNDAMAGE] += intValue;
  1058.                                 }
  1059.                                 else if(lkey == "absorbpercentphysical")
  1060.                                 {
  1061.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1062.                                     it.abilities.absorb[COMBAT_PHYSICALDAMAGE] += intValue;
  1063.                                 }
  1064.                                 else if(lkey == "absorbpercenthealing")
  1065.                                 {
  1066.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1067.                                     it.abilities.absorb[COMBAT_HEALING] += intValue;
  1068.                                 }
  1069.                                 else if(lkey == "absorbpercentundefined")
  1070.                                 {
  1071.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1072.                                     it.abilities.absorb[COMBAT_UNDEFINEDDAMAGE] += intValue;
  1073.                                 }
  1074.                                 else if(lkey == "reflectpercentall")
  1075.                                 {
  1076.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1077.                                     for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++)
  1078.                                         it.abilities.reflect[REFLECT_PERCENT][i] += intValue;
  1079.                                 }
  1080.                                 else if(lkey == "reflectpercentelements")
  1081.                                 {
  1082.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1083.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
  1084.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
  1085.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
  1086.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
  1087.                                 }
  1088.                                 else if(lkey == "reflectpercentmagic")
  1089.                                 {
  1090.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1091.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
  1092.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
  1093.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
  1094.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
  1095.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
  1096.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
  1097.                                 }
  1098.                                 else if(lkey == "reflectpercentenergy")
  1099.                                 {
  1100.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1101.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
  1102.                                 }
  1103.                                 else if(lkey == "reflectpercentfire")
  1104.                                 {
  1105.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1106.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
  1107.                                 }
  1108.                                 else if(lkey == "reflectpercentpoison" ||   lkey == "reflectpercentearth")
  1109.                                 {
  1110.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1111.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
  1112.                                 }
  1113.                                 else if(lkey == "reflectpercentice")
  1114.                                 {
  1115.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1116.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
  1117.                                 }
  1118.                                 else if(lkey == "reflectpercentholy")
  1119.                                 {
  1120.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1121.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
  1122.                                 }
  1123.                                 else if(lkey == "reflectpercentdeath")
  1124.                                 {
  1125.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1126.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
  1127.                                 }
  1128.                                 else if(lkey == "reflectpercentlifedrain")
  1129.                                 {
  1130.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1131.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_LIFEDRAIN] += intValue;
  1132.                                 }
  1133.                                 else if(lkey == "reflectpercentmanadrain")
  1134.                                 {
  1135.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1136.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_MANADRAIN] += intValue;
  1137.                                 }
  1138.                                 else if(lkey == "reflectpercentdrown")
  1139.                                 {
  1140.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1141.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_DROWNDAMAGE] += intValue;
  1142.                                 }
  1143.                                 else if(lkey == "reflectpercentphysical")
  1144.                                 {
  1145.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1146.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_PHYSICALDAMAGE] += intValue;
  1147.                                 }
  1148.                                 else if(lkey == "reflectpercenthealing")
  1149.                                 {
  1150.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1151.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_HEALING] += intValue;
  1152.                                 }
  1153.                                 else if(lkey == "reflectpercentundefined")
  1154.                                 {
  1155.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1156.                                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_UNDEFINEDDAMAGE] += intValue;
  1157.                                 }
  1158.                                 else if(lkey == "reflectchanceall")
  1159.                                 {
  1160.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1161.                                     for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++)
  1162.                                         it.abilities.reflect[REFLECT_CHANCE][i] += intValue;
  1163.                                 }
  1164.                                 else if(lkey == "reflectchanceelements")
  1165.                                 {
  1166.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1167.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
  1168.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
  1169.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
  1170.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
  1171.                                 }
  1172.                                 else if(lkey == "reflectchancemagic")
  1173.                                 {
  1174.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1175.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
  1176.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
  1177.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
  1178.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
  1179.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
  1180.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
  1181.                                 }
  1182.                                 else if(lkey == "reflectchanceenergy")
  1183.                                 {
  1184.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1185.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
  1186.                                 }
  1187.                                 else if(lkey == "reflectchancefire")
  1188.                                 {
  1189.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1190.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
  1191.                                 }
  1192.                                 else if(lkey == "reflectchancepoison" ||    lkey == "reflectchanceearth")
  1193.                                 {
  1194.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1195.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
  1196.                                 }
  1197.                                 else if(lkey == "reflectchanceice")
  1198.                                 {
  1199.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1200.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
  1201.                                 }
  1202.                                 else if(lkey == "reflectchanceholy")
  1203.                                 {
  1204.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1205.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
  1206.                                 }
  1207.                                 else if(lkey == "reflectchancedeath")
  1208.                                 {
  1209.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1210.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
  1211.                                 }
  1212.                                 else if(lkey == "reflectchancelifedrain")
  1213.                                 {
  1214.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1215.                                         it.abilities.reflect[REFLECT_CHANCE][COMBAT_LIFEDRAIN] += intValue;
  1216.                                 }
  1217.                                 else if(lkey == "reflectchancemanadrain")
  1218.                                 {
  1219.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1220.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_MANADRAIN] += intValue;
  1221.                                 }
  1222.                                 else if(lkey == "reflectchancedrown")
  1223.                                 {
  1224.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1225.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_DROWNDAMAGE] += intValue;
  1226.                                 }
  1227.                                 else if(lkey == "reflectchancephysical")
  1228.                                 {
  1229.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1230.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_PHYSICALDAMAGE] += intValue;
  1231.                                 }
  1232.                                 else if(lkey == "reflectchancehealing")
  1233.                                 {
  1234.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1235.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_HEALING] += intValue;
  1236.                                 }
  1237.                                 else if(lkey == "reflectchanceundefined")
  1238.                                 {
  1239.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1240.                                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_UNDEFINEDDAMAGE] += intValue;
  1241.                                 }
  1242.                                 else if(lkey == "suppressshock" || lkey == "suppressenergy")
  1243.                                 {
  1244.                                     if(lua_tonumber(L, -1) != 0)
  1245.                                         it.abilities.conditionSuppressions |= CONDITION_ENERGY;
  1246.                                 }
  1247.                                 else if(lkey == "suppressburn" || lkey == "suppressfire")
  1248.                                 {
  1249.                                     if(lua_tonumber(L, -1) != 0)
  1250.                                         it.abilities.conditionSuppressions |= CONDITION_FIRE;
  1251.                                 }
  1252.                                 else if(lkey == "suppresspoison" || lkey == "suppressearth")
  1253.                                 {
  1254.                                     if(lua_tonumber(L, -1) != 0)
  1255.                                         it.abilities.conditionSuppressions |= CONDITION_POISON;
  1256.                                 }
  1257.                                 else if(lkey == "suppressfreeze" || lkey == "suppressice")
  1258.                                 {
  1259.                                     if(lua_tonumber(L, -1) != 0)
  1260.                                         it.abilities.conditionSuppressions |= CONDITION_FREEZING;
  1261.                                 }
  1262.                                 else if(lkey == "suppressdazzle" || lkey == "suppressholy")
  1263.                                 {
  1264.                                     if(lua_tonumber(L, -1) != 0)
  1265.                                         it.abilities.conditionSuppressions |= CONDITION_DAZZLED;
  1266.                                 }
  1267.                                 else if(lkey == "suppresscurse" || lkey == "suppressdeath")
  1268.                                 {
  1269.                                     if(lua_tonumber(L, -1) != 0)
  1270.                                         it.abilities.conditionSuppressions |= CONDITION_CURSED;
  1271.                                 }
  1272.                                 else if(lkey == "suppressdrown")
  1273.                                 {
  1274.                                     if(lua_tonumber(L, -1) != 0)
  1275.                                         it.abilities.conditionSuppressions |= CONDITION_DROWN;
  1276.                                 }
  1277.                                 else if(lkey == "suppressphysical")
  1278.                                 {
  1279.                                     if(lua_tonumber(L, -1) != 0)
  1280.                                         it.abilities.conditionSuppressions |= CONDITION_PHYSICAL;
  1281.                                 }
  1282.                                 else if(lkey == "suppresshaste")
  1283.                                 {
  1284.                                     if(lua_tonumber(L, -1) != 0)
  1285.                                         it.abilities.conditionSuppressions |= CONDITION_HASTE;
  1286.                                 }
  1287.                                 else if(lkey == "suppressparalyze")
  1288.                                 {
  1289.                                     if(lua_tonumber(L, -1) != 0)
  1290.                                         it.abilities.conditionSuppressions |= CONDITION_PARALYZE;
  1291.                                 }
  1292.                                 else if(lkey == "suppressdrunk")
  1293.                                 {
  1294.                                     if(lua_tonumber(L, -1) != 0)
  1295.                                         it.abilities.conditionSuppressions |= CONDITION_DRUNK;
  1296.                                 }
  1297.                                 else if(lkey == "suppressregeneration")
  1298.                                 {
  1299.                                     if(lua_tonumber(L, -1) != 0)
  1300.                                         it.abilities.conditionSuppressions |= CONDITION_REGENERATION;
  1301.                                 }
  1302.                                 else if(lkey == "suppresssoul")
  1303.                                 {
  1304.                                     if(lua_tonumber(L, -1) != 0)
  1305.                                         it.abilities.conditionSuppressions |= CONDITION_SOUL;
  1306.                                 }
  1307.                                 else if(lkey == "suppressoutfit")
  1308.                                 {
  1309.                                     if(lua_tonumber(L, -1) != 0)
  1310.                                         it.abilities.conditionSuppressions |= CONDITION_OUTFIT;
  1311.                                 }
  1312.                                 else if(lkey == "suppressinvisible")
  1313.                                 {
  1314.                                     if(lua_tonumber(L, -1) != 0)
  1315.                                         it.abilities.conditionSuppressions |= CONDITION_INVISIBLE;
  1316.                                 }
  1317.                                 else if(lkey == "suppressinfight")
  1318.                                 {
  1319.                                     if(lua_tonumber(L, -1) != 0)
  1320.                                         it.abilities.conditionSuppressions |= CONDITION_INFIGHT;
  1321.                                 }
  1322.                                 else if(lkey == "suppressexhaust")
  1323.                                 {
  1324.                                     if(lua_tonumber(L, -1) != 0)
  1325.                                         it.abilities.conditionSuppressions |= CONDITION_EXHAUST;
  1326.                                 }
  1327.                                 else if(lkey == "suppressmuted")
  1328.                                 {
  1329.                                     if(lua_tonumber(L, -1) != 0)
  1330.                                         it.abilities.conditionSuppressions |= CONDITION_MUTED;
  1331.                                 }
  1332.                                 else if(lkey == "suppresspacified")
  1333.                                 {
  1334.                                     if(lua_tonumber(L, -1) != 0)
  1335.                                         it.abilities.conditionSuppressions |= CONDITION_PACIFIED;
  1336.                                 }
  1337.                                 else if(lkey == "suppresslight")
  1338.                                 {
  1339.                                     if(lua_tonumber(L, -1) != 0)
  1340.                                         it.abilities.conditionSuppressions |= CONDITION_LIGHT;
  1341.                                 }
  1342.                                 else if(lkey == "suppressattributes")
  1343.                                 {
  1344.                                     if(lua_tonumber(L, -1) != 0)
  1345.                                         it.abilities.conditionSuppressions |= CONDITION_ATTRIBUTES;
  1346.                                 }
  1347.                                 else if(lkey == "suppressmanashield")
  1348.                                 {
  1349.                                     if(lua_tonumber(L, -1) != 0)
  1350.                                         it.abilities.conditionSuppressions |= CONDITION_MANASHIELD;
  1351.                                 }
  1352.                                 else if(lkey == "elementphysical")
  1353.                                 {
  1354.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1355.                                     it.abilities.elementDamage = intValue;
  1356.                                     it.abilities.elementType = COMBAT_PHYSICALDAMAGE;
  1357.                                 }
  1358.                                 else if(lkey == "elementfire")
  1359.                                 {
  1360.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1361.                                     it.abilities.elementDamage = intValue;
  1362.                                     it.abilities.elementType = COMBAT_FIREDAMAGE;
  1363.                                 }
  1364.                                 else if(lkey == "elementenergy")
  1365.                                 {
  1366.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1367.                                     it.abilities.elementDamage = intValue;
  1368.                                     it.abilities.elementType = COMBAT_ENERGYDAMAGE;
  1369.                                 }
  1370.                                 else if(lkey == "elementearth")
  1371.                                 {
  1372.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1373.                                     it.abilities.elementDamage = intValue;
  1374.                                     it.abilities.elementType = COMBAT_EARTHDAMAGE;
  1375.                                 }
  1376.                                 else if(lkey == "elementice")
  1377.                                 {
  1378.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1379.                                     it.abilities.elementDamage = intValue;
  1380.                                     it.abilities.elementType = COMBAT_ICEDAMAGE;
  1381.                                 }
  1382.                                 else if(lkey == "elementholy")
  1383.                                 {
  1384.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1385.                                     it.abilities.elementDamage = intValue;
  1386.                                     it.abilities.elementType = COMBAT_HOLYDAMAGE;
  1387.                                 }
  1388.                                 else if(lkey == "elementdeath")
  1389.                                 {
  1390.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1391.                                     it.abilities.elementDamage = intValue;
  1392.                                     it.abilities.elementType = COMBAT_DEATHDAMAGE;
  1393.                                 }
  1394.                                 else if(lkey == "elementlifedrain")
  1395.                                 {
  1396.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1397.                                     it.abilities.elementDamage = intValue;
  1398.                                     it.abilities.elementType = COMBAT_LIFEDRAIN;
  1399.                                 }
  1400.                                 else if(lkey == "elementmanadrain")
  1401.                                 {
  1402.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1403.                                     it.abilities.elementDamage = intValue;
  1404.                                     it.abilities.elementType = COMBAT_MANADRAIN;
  1405.                                 }
  1406.                                 else if(lkey == "elementhealing")
  1407.                                 {
  1408.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1409.                                     it.abilities.elementDamage = intValue;
  1410.                                     it.abilities.elementType = COMBAT_HEALING;
  1411.                                 }
  1412.                                 else if(lkey == "elementundefined")
  1413.                                 {
  1414.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1415.                                     it.abilities.elementDamage = intValue;
  1416.                                     it.abilities.elementType = COMBAT_UNDEFINEDDAMAGE;
  1417.                                 }
  1418.                                 else if(lkey == "replaceable" || lkey == "replacable")
  1419.                                 {
  1420.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1421.                                     it.replaceable = (intValue != 0);
  1422.                                 }
  1423.                                 else if(lkey == "partnerdirection")
  1424.                                 {
  1425.                                     std::string strValue = lua_tostring(L, -1);
  1426.                                     it.bedPartnerDir = getDirection(strValue);
  1427.                                 }
  1428.                                 else if(lkey == "maletransformto")
  1429.                                 {
  1430.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1431.                                     it.transformUseTo[PLAYERSEX_MALE] = intValue;
  1432.                                     ItemType& ot = getItemType(intValue);
  1433.                                     if(!ot.transformToFree)
  1434.                                         ot.transformToFree = it.id;
  1435.  
  1436.                                     if(!it.transformUseTo[PLAYERSEX_FEMALE])
  1437.                                         it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
  1438.                                 }
  1439.                                 else if(lkey == "femaletransformto")
  1440.                                 {
  1441.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1442.                                     it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
  1443.                                     ItemType& ot = getItemType(intValue);
  1444.                                     if(!ot.transformToFree)
  1445.                                         ot.transformToFree = it.id;
  1446.  
  1447.                                     if(!it.transformUseTo[PLAYERSEX_MALE])
  1448.                                         it.transformUseTo[PLAYERSEX_MALE] = intValue;
  1449.                                 }
  1450.                                 else if(lkey == "transformto")
  1451.                                 {
  1452.                                     intValue = (int32_t)lua_tonumber(L, -1);
  1453.                                     it.transformToFree = intValue;
  1454.                                 }
  1455.                                
  1456.                                 else {
  1457.                                     std::cout << "[Warning - Items::parseItemNodeLua] Unknown key value: " << lkey << std::endl;
  1458.                                 }
  1459.  
  1460.                             }// end of value
  1461.  
  1462.                              //check bed items
  1463.                             //if ((it.transformToFree != 0 || it.transformToOnUse[PLAYERSEX_FEMALE] != 0 || it.transformToOnUse[PLAYERSEX_MALE] != 0) && it.type != ITEM_TYPE_BED) {
  1464.                                 //std::cout << "[Warning - Items::parseItemNodeLua] Item " << it.id << " is not set as a bed-type" << std::endl;
  1465.                         //  }//
  1466.                             lua_pop(L, 1);
  1467.                         }// end of inner for loop  
  1468.                         lua_pop(L, 1);
  1469.                     }
  1470.  
  1471.                 }// end of objlen
  1472.             }// end of attributes
  1473.             lua_pop(L, 1);
  1474.             break;
  1475.         } // end of outter switch
  1476.         lua_pop(L, 1);
  1477.     }//end of outter loop
  1478. }
  1479.  
  1480.  
  1481.  
  1482. // this function not only parses the items.xml but it also can construct items.xml in a lua table
  1483. void Items::parseItemNode(xmlNodePtr itemNode, uint32_t id, std::ofstream& out, bool constructTable)
  1484. {
  1485.     int32_t intValue;
  1486.     std::string strValue;
  1487.    
  1488.     bool description = false, field = false;
  1489.     std::string parser, pattribute, desc, key, pfield = "";
  1490.     if (constructTable) {
  1491.         parser = "\t{\n\t\titemid = " + boost::lexical_cast<std::string>(id) + ", ";
  1492.     }
  1493.  
  1494.     if(id > 20000 && id < 20100)
  1495.     {
  1496.         id = id - 20000;
  1497.  
  1498.         ItemType* iType = new ItemType();
  1499.         iType->id = id;
  1500.         items.addElement(iType, iType->id);
  1501.     }
  1502.  
  1503.     ItemType& it = Item::items.getItemType(id);
  1504.     if(!it.name.empty() && (!readXMLString(itemNode, "override", strValue) || !booleanString(strValue))){
  1505.         std::cout << "[Warning - Items::loadFromXml] Duplicate registered item with id " << id << std::endl;
  1506.     }
  1507.  
  1508.     if(readXMLString(itemNode, "name", strValue)){
  1509.         it.name = strValue;
  1510.         if (constructTable) {
  1511.             if (!it.name.empty()) {
  1512.                 parser += "name = \"" + it.name + "\", ";
  1513.             }
  1514.         }
  1515.     }
  1516.    
  1517.     if(readXMLString(itemNode, "article", strValue)){
  1518.         it.article = strValue;
  1519.         if (constructTable) {
  1520.             if (!it.article.empty()) {
  1521.                 parser += "article = \"" + it.article + "\", ";
  1522.             }
  1523.         }
  1524.     }
  1525.  
  1526.     if(readXMLString(itemNode, "plural", strValue)){
  1527.         it.pluralName = strValue;
  1528.         if (constructTable) {
  1529.             if (!it.pluralName.empty()) {
  1530.                 parser += "plural = \"" + it.pluralName + "\", ";
  1531.             }
  1532.         }
  1533.     }
  1534.    
  1535.     xmlNodePtr itemAttributesNode = itemNode->children;
  1536.     while(itemAttributesNode)
  1537.     {
  1538.         if(readXMLString(itemAttributesNode, "key", strValue))
  1539.         {
  1540.             if (constructTable) {
  1541.                 std::string key = asLowerCaseString(strValue);
  1542.                 pattribute += "\t\t\t{ key = \"" + key + "\", ";
  1543.             }
  1544.             std::string tmpStrValue = asLowerCaseString(strValue);
  1545.             if(tmpStrValue == "type")
  1546.             {
  1547.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1548.                 {
  1549.                     tmpStrValue = asLowerCaseString(strValue);
  1550.                     if(tmpStrValue == "container")
  1551.                     {
  1552.                         it.type = ITEM_TYPE_CONTAINER;
  1553.                         it.group = ITEM_GROUP_CONTAINER;
  1554.                     }
  1555.                     else if(tmpStrValue == "key")
  1556.                         it.type = ITEM_TYPE_KEY;
  1557.                     else if(tmpStrValue == "magicfield")
  1558.                         it.type = ITEM_TYPE_MAGICFIELD;
  1559.                     else if(tmpStrValue == "depot")
  1560.                         it.type = ITEM_TYPE_DEPOT;
  1561.                     else if(tmpStrValue == "mailbox")
  1562.                         it.type = ITEM_TYPE_MAILBOX;
  1563.                     else if(tmpStrValue == "trashholder")
  1564.                         it.type = ITEM_TYPE_TRASHHOLDER;
  1565.                     else if(tmpStrValue == "teleport")
  1566.                         it.type = ITEM_TYPE_TELEPORT;
  1567.                     else if(tmpStrValue == "door")
  1568.                         it.type = ITEM_TYPE_DOOR;
  1569.                     else if(tmpStrValue == "bed")
  1570.                         it.type = ITEM_TYPE_BED;
  1571.                     else
  1572.                         std::cout << "[Warning - Items::loadFromXml] Unknown type " << strValue << std::endl;
  1573.                        
  1574.                     if (constructTable) {
  1575.                         if (!tmpStrValue.empty()) {
  1576.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  1577.                         }  
  1578.                     }
  1579.                 }
  1580.             }
  1581.             else if(tmpStrValue == "name")
  1582.             {
  1583.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1584.                     it.name = strValue;
  1585.                
  1586.                     if (constructTable) {
  1587.                         if (!strValue.empty()) {
  1588.                             pattribute += "value = \"" + strValue + "\" },\n";
  1589.                         }  
  1590.                     }
  1591.             }
  1592.             else if(tmpStrValue == "article")
  1593.             {
  1594.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1595.                     it.article = strValue;
  1596.                     if (constructTable) {
  1597.                         if (!strValue.empty()) {
  1598.                             pattribute += "value = \"" + strValue + "\" },\n";
  1599.                         }  
  1600.                     }
  1601.             }
  1602.             else if(tmpStrValue == "plural")
  1603.             {
  1604.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1605.                     it.pluralName = strValue;
  1606.                     if (constructTable) {
  1607.                         if (!strValue.empty()) {
  1608.                             pattribute += "value = \"" + strValue + "\" },\n";
  1609.                         }  
  1610.                     }
  1611.             }
  1612.             else if(tmpStrValue == "description")
  1613.             {
  1614.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1615.                     it.description = strValue;
  1616.                     if (constructTable) {
  1617.                         if (!strValue.empty()) {
  1618.                             pattribute += "value = \"" + strValue + "\" },\n";
  1619.                         }  
  1620.                     }
  1621.             }
  1622.             else if(tmpStrValue == "runespellname")
  1623.             {
  1624.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1625.                     it.runeSpellName = strValue;
  1626.                     if (constructTable) {
  1627.                         if (!strValue.empty()) {
  1628.                             pattribute += "value = \"" + strValue + "\" },\n";
  1629.                         }  
  1630.                     }
  1631.             }
  1632.             else if(tmpStrValue == "weight")
  1633.             {
  1634.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1635.                     it.weight = intValue / 100.f;
  1636.                     if (constructTable) {
  1637.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1638.                     }
  1639.             }
  1640.             else if(tmpStrValue == "showcount")
  1641.             {
  1642.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1643.                     it.showCount = (intValue != 0);
  1644.                     if (constructTable) {
  1645.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1646.                     }
  1647.             }
  1648.             else if(tmpStrValue == "armor")
  1649.             {
  1650.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1651.                     it.armor = intValue;
  1652.                     if (constructTable) {
  1653.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1654.                     }
  1655.             }
  1656.             else if(tmpStrValue == "defense")
  1657.             {
  1658.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1659.                     it.defense = intValue;
  1660.                     if (constructTable) {
  1661.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1662.                     }
  1663.             }
  1664.             else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef")
  1665.             {
  1666.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1667.                     it.extraDefense = intValue;
  1668.                     if (constructTable) {
  1669.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1670.                     }
  1671.             }
  1672.             else if(tmpStrValue == "attack")
  1673.             {
  1674.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1675.                     it.attack = intValue;
  1676.                     if (constructTable) {
  1677.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1678.                     }
  1679.             }
  1680.             else if(tmpStrValue == "extraattack" || tmpStrValue == "extraatk")
  1681.             {
  1682.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1683.                     it.extraAttack = intValue;
  1684.                     if (constructTable) {
  1685.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1686.                     }
  1687.             }
  1688.             else if(tmpStrValue == "attackspeed")
  1689.             {
  1690.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1691.                     it.attackSpeed = intValue;
  1692.                     if (constructTable) {
  1693.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1694.                     }
  1695.             }
  1696.             else if(tmpStrValue == "rotateto")
  1697.             {
  1698.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1699.                     it.rotateTo = intValue;
  1700.                     if (constructTable) {
  1701.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1702.                     }
  1703.             }
  1704.             else if(tmpStrValue == "moveable" || tmpStrValue == "movable")
  1705.             {
  1706.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1707.                     it.moveable = (intValue != 0);
  1708.                     if (constructTable) {
  1709.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1710.                     }
  1711.             }
  1712.             else if(tmpStrValue == "blockprojectile")
  1713.             {
  1714.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1715.                     it.blockProjectile = (intValue != 0);
  1716.                     if (constructTable) {
  1717.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1718.                     }
  1719.             }
  1720.             else if(tmpStrValue == "allowpickupable")
  1721.             {
  1722.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1723.                     it.allowPickupable = (intValue != 0);
  1724.                     if (constructTable) {
  1725.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1726.                     }
  1727.             }
  1728.             else if(tmpStrValue == "floorchange")
  1729.             {
  1730.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1731.                 {
  1732.                     tmpStrValue = asLowerCaseString(strValue);
  1733.                     if(tmpStrValue == "down")
  1734.                         it.floorChange[CHANGE_DOWN] = true;
  1735.                     else if(tmpStrValue == "north")
  1736.                         it.floorChange[CHANGE_NORTH] = true;
  1737.                     else if(tmpStrValue == "south")
  1738.                         it.floorChange[CHANGE_SOUTH] = true;
  1739.                     else if(tmpStrValue == "west")
  1740.                         it.floorChange[CHANGE_WEST] = true;
  1741.                     else if(tmpStrValue == "east")
  1742.                         it.floorChange[CHANGE_EAST] = true;
  1743.                     else if(tmpStrValue == "northex")
  1744.                         it.floorChange[CHANGE_NORTH_EX] = true;
  1745.                     else if(tmpStrValue == "southex")
  1746.                         it.floorChange[CHANGE_SOUTH_EX] = true;
  1747.                     else if(tmpStrValue == "westex")
  1748.                         it.floorChange[CHANGE_WEST_EX] = true;
  1749.                     else if(tmpStrValue == "eastex")
  1750.                         it.floorChange[CHANGE_EAST_EX] = true;
  1751.                     if (constructTable) {
  1752.                         if (!tmpStrValue.empty()) {
  1753.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  1754.                         }  
  1755.                     }
  1756.                 }
  1757.             }
  1758.             else if(tmpStrValue == "corpsetype")
  1759.             {
  1760.                 tmpStrValue = asLowerCaseString(strValue);
  1761.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1762.                 {
  1763.                     tmpStrValue = asLowerCaseString(strValue);
  1764.                     if(tmpStrValue == "venom")
  1765.                         it.corpseType = RACE_VENOM;
  1766.                     else if(tmpStrValue == "blood")
  1767.                         it.corpseType = RACE_BLOOD;
  1768.                     else if(tmpStrValue == "undead")
  1769.                         it.corpseType = RACE_UNDEAD;
  1770.                     else if(tmpStrValue == "fire")
  1771.                         it.corpseType = RACE_FIRE;
  1772.                     else if(tmpStrValue == "energy")
  1773.                         it.corpseType = RACE_ENERGY;
  1774.                     else
  1775.                         std::cout << "[Warning - Items::loadFromXml] Unknown corpseType " << strValue << std::endl;
  1776.                    
  1777.                     if (constructTable) {
  1778.                         if (!tmpStrValue.empty()) {
  1779.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  1780.                         }  
  1781.                     }
  1782.                 }
  1783.             }
  1784.             else if(tmpStrValue == "containersize")
  1785.             {
  1786.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1787.                     it.maxItems = intValue;
  1788.                     if (constructTable) {
  1789.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1790.                     }
  1791.             }
  1792.             else if(tmpStrValue == "fluidsource")
  1793.             {
  1794.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1795.                 {
  1796.                     tmpStrValue = asLowerCaseString(strValue);
  1797.                     FluidTypes_t fluid = getFluidType(tmpStrValue);
  1798.                     if(fluid != FLUID_NONE)
  1799.                         it.fluidSource = fluid;
  1800.                     else
  1801.                         std::cout << "[Warning - Items::loadFromXml] Unknown fluidSource " << strValue << std::endl;
  1802.                        
  1803.                     if (constructTable) {
  1804.                         if (!tmpStrValue.empty()) {
  1805.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  1806.                         }  
  1807.                     }
  1808.                 }
  1809.             }
  1810.             else if(tmpStrValue == "writeable" || tmpStrValue == "writable")
  1811.             {
  1812.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1813.                 {
  1814.                     it.canWriteText = (intValue != 0);
  1815.                     it.canReadText = (intValue != 0);
  1816.                     if (constructTable) {
  1817.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1818.                     }
  1819.                 }
  1820.             }
  1821.             else if(tmpStrValue == "readable")
  1822.             {
  1823.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1824.                     it.canReadText = (intValue != 0);
  1825.                     if (constructTable) {
  1826.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1827.                     }
  1828.             }
  1829.             else if(tmpStrValue == "maxtextlen" || tmpStrValue == "maxtextlength")
  1830.             {
  1831.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1832.                     it.maxTextLen = intValue;
  1833.                     if (constructTable) {
  1834.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1835.                     }
  1836.             }
  1837.             else if(tmpStrValue == "writeonceitemid")
  1838.             {
  1839.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1840.                     it.writeOnceItemId = intValue;
  1841.                     if (constructTable) {
  1842.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1843.                     }
  1844.             }
  1845.             else if(tmpStrValue == "worth")
  1846.             {
  1847.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1848.                 {
  1849.                     if(moneyMap.find(intValue) != moneyMap.end() && (!readXMLString(itemNode, "override", strValue) || !booleanString(strValue)))
  1850.                         std::cout << "[Warning - Items::loadFromXml] Duplicated money item " << id << " with worth " << intValue << "!" << std::endl;
  1851.                     else
  1852.                     {
  1853.                         moneyMap[intValue] = id;
  1854.                         it.worth = intValue;
  1855.                         if (constructTable) {
  1856.                             pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1857.                         }
  1858.                     }
  1859.                 }
  1860.             }
  1861.             else if(tmpStrValue == "forceserialize" || tmpStrValue == "forceserialization" || tmpStrValue == "forcesave")
  1862.             {
  1863.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1864.                     it.forceSerialize = (intValue != 0);
  1865.                     if (constructTable) {
  1866.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1867.                     }
  1868.             }
  1869.             else if(tmpStrValue == "leveldoor")
  1870.             {
  1871.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  1872.                     it.levelDoor = intValue;
  1873.                     if (constructTable) {
  1874.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  1875.                     }
  1876.             }
  1877.             else if(tmpStrValue == "weapontype")
  1878.             {
  1879.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1880.                 {
  1881.                     tmpStrValue = asLowerCaseString(strValue);
  1882.                     if(tmpStrValue == "sword")
  1883.                         it.weaponType = WEAPON_SWORD;
  1884.                     else if(tmpStrValue == "club")
  1885.                         it.weaponType = WEAPON_CLUB;
  1886.                     else if(tmpStrValue == "axe")
  1887.                         it.weaponType = WEAPON_AXE;
  1888.                     else if(tmpStrValue == "shield")
  1889.                         it.weaponType = WEAPON_SHIELD;
  1890.                     else if(tmpStrValue == "distance")
  1891.                         it.weaponType = WEAPON_DIST;
  1892.                     else if(tmpStrValue == "wand" || tmpStrValue == "rod")
  1893.                         it.weaponType = WEAPON_WAND;
  1894.                     else if(tmpStrValue == "ammunition")
  1895.                         it.weaponType = WEAPON_AMMO;
  1896.                     else if(tmpStrValue == "fist")
  1897.                         it.weaponType = WEAPON_FIST;
  1898.                     else
  1899.                         std::cout << "[Warning - Items::loadFromXml] Unknown weaponType " << strValue << std::endl;
  1900.                        
  1901.                     if (constructTable) {
  1902.                         if (!tmpStrValue.empty()) {
  1903.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  1904.                         }  
  1905.                     }
  1906.                 }
  1907.             }
  1908.             else if(tmpStrValue == "slottype")
  1909.             {
  1910.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1911.                 {
  1912.                     tmpStrValue = asLowerCaseString(strValue);
  1913.                     if(tmpStrValue == "head")
  1914.                     {
  1915.                         it.slotPosition |= SLOTP_HEAD;
  1916.                         it.wieldPosition = SLOT_HEAD;
  1917.                     }
  1918.                     else if(tmpStrValue == "body")
  1919.                     {
  1920.                         it.slotPosition |= SLOTP_ARMOR;
  1921.                         it.wieldPosition = SLOT_ARMOR;
  1922.                     }
  1923.                     else if(tmpStrValue == "legs")
  1924.                     {
  1925.                         it.slotPosition |= SLOTP_LEGS;
  1926.                         it.wieldPosition = SLOT_LEGS;
  1927.                     }
  1928.                     else if(tmpStrValue == "feet")
  1929.                     {
  1930.                         it.slotPosition |= SLOTP_FEET;
  1931.                         it.wieldPosition = SLOT_FEET;
  1932.                     }
  1933.                     else if(tmpStrValue == "backpack")
  1934.                     {
  1935.                         it.slotPosition |= SLOTP_BACKPACK;
  1936.                         it.wieldPosition = SLOT_BACKPACK;
  1937.                     }
  1938.                     else if(tmpStrValue == "two-handed")
  1939.                     {
  1940.                         it.slotPosition |= SLOTP_TWO_HAND;
  1941.                         it.wieldPosition = SLOT_TWO_HAND;
  1942.                     }
  1943.                     else if(tmpStrValue == "necklace")
  1944.                     {
  1945.                         it.slotPosition |= SLOTP_NECKLACE;
  1946.                         it.wieldPosition = SLOT_NECKLACE;
  1947.                     }
  1948.                     else if(tmpStrValue == "ring")
  1949.                     {
  1950.                         it.slotPosition |= SLOTP_RING;
  1951.                         it.wieldPosition = SLOT_RING;
  1952.                     }
  1953.                     else if(tmpStrValue == "ammo")
  1954.                         it.wieldPosition = SLOT_AMMO;
  1955.                     else if(tmpStrValue == "hand")
  1956.                         it.wieldPosition = SLOT_HAND;
  1957.                     else
  1958.                         std::cout << "[Warning - Items::loadFromXml] Unknown slotType " << strValue << std::endl;
  1959.                        
  1960.                     if (constructTable) {
  1961.                         if (!tmpStrValue.empty()) {
  1962.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  1963.                         }  
  1964.                     }
  1965.                 }
  1966.             }
  1967.             else if(tmpStrValue == "ammotype")
  1968.             {
  1969.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1970.                 {
  1971.                     it.ammoType = getAmmoType(strValue);
  1972.                     if(it.ammoType == AMMO_NONE)
  1973.                         std::cout << "[Warning - Items::loadFromXml] Unknown ammoType " << strValue << std::endl;
  1974.                        
  1975.                     if (constructTable) {
  1976.                         if (!strValue.empty()) {
  1977.                             pattribute += "value = \"" + strValue + "\" },\n";
  1978.                         }  
  1979.                     }
  1980.                 }
  1981.             }
  1982.             else if(tmpStrValue == "shoottype")
  1983.             {
  1984.                 if(readXMLString(itemAttributesNode, "value", strValue))
  1985.                 {
  1986.                     ShootEffect_t shoot = getShootType(strValue);
  1987.                     if(shoot != SHOOT_EFFECT_UNKNOWN)
  1988.                         it.shootType = shoot;
  1989.                     else
  1990.                         std::cout << "[Warning - Items::loadFromXml] Unknown shootType " << strValue << std::endl;
  1991.                        
  1992.                     if (constructTable) {
  1993.                         if (!strValue.empty()) {
  1994.                             pattribute += "value = \"" + strValue + "\" },\n";
  1995.                         }  
  1996.                     }
  1997.                 }
  1998.             }
  1999.             else if(tmpStrValue == "effect")
  2000.             {
  2001.                 if(readXMLString(itemAttributesNode, "value", strValue))
  2002.                 {
  2003.                     MagicEffect_t effect = getMagicEffect(strValue);
  2004.                     if(effect != MAGIC_EFFECT_UNKNOWN)
  2005.                         it.magicEffect = effect;
  2006.                     else
  2007.                         std::cout << "[Warning - Items::loadFromXml] Unknown effect " << strValue << std::endl;
  2008.                        
  2009.                     if (constructTable) {
  2010.                         if (!strValue.empty()) {
  2011.                             pattribute += "value = \"" + strValue + "\" },\n";
  2012.                         }  
  2013.                     }
  2014.                 }
  2015.             }
  2016.             else if(tmpStrValue == "range")
  2017.             {
  2018.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2019.                     it.shootRange = intValue;
  2020.                     if (constructTable) {
  2021.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2022.                     }
  2023.             }
  2024.             else if(tmpStrValue == "stopduration")
  2025.             {
  2026.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2027.                     it.stopTime = (intValue != 0);
  2028.                     if (constructTable) {
  2029.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2030.                     }
  2031.             }
  2032.             else if(tmpStrValue == "decayto")
  2033.             {
  2034.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2035.                     it.decayTo = intValue;
  2036.                     if (constructTable) {
  2037.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2038.                     }
  2039.             }
  2040.             else if(tmpStrValue == "transformequipto")
  2041.             {
  2042.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2043.                     it.transformEquipTo = intValue;
  2044.                     if (constructTable) {
  2045.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2046.                     }
  2047.             }
  2048.             else if(tmpStrValue == "transformdeequipto")
  2049.             {
  2050.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2051.                     it.transformDeEquipTo = intValue;
  2052.                     if (constructTable) {
  2053.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2054.                     }
  2055.             }
  2056.             else if(tmpStrValue == "duration")
  2057.             {
  2058.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2059.                     it.decayTime = std::max((int32_t)0, intValue);
  2060.                     if (constructTable) {
  2061.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2062.                     }
  2063.             }
  2064.             else if(tmpStrValue == "showduration")
  2065.             {
  2066.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2067.                     it.showDuration = (intValue != 0);
  2068.                     if (constructTable) {
  2069.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2070.                     }
  2071.             }
  2072.             else if(tmpStrValue == "charges")
  2073.             {
  2074.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2075.                     it.charges = intValue;
  2076.                     if (constructTable) {
  2077.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2078.                     }
  2079.             }
  2080.             else if(tmpStrValue == "showcharges")
  2081.             {
  2082.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2083.                     it.showCharges = (intValue != 0);
  2084.                     if (constructTable) {
  2085.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2086.                     }
  2087.             }
  2088.             else if(tmpStrValue == "showattributes")
  2089.             {
  2090.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2091.                     it.showAttributes = (intValue != 0);
  2092.                     if (constructTable) {
  2093.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2094.                     }
  2095.             }
  2096.             else if(tmpStrValue == "breakchance")
  2097.             {
  2098.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2099.                     it.breakChance = std::max(0, std::min(100, intValue));
  2100.                     if (constructTable) {
  2101.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2102.                     }
  2103.             }
  2104.             else if(tmpStrValue == "ammoaction")
  2105.             {
  2106.                 if(readXMLString(itemAttributesNode, "value", strValue))
  2107.                 {
  2108.                     AmmoAction_t ammo = getAmmoAction(strValue);
  2109.                     if(ammo != AMMOACTION_NONE)
  2110.                         it.ammoAction = ammo;
  2111.                     else
  2112.                         std::cout << "[Warning - Items::loadFromXml] Unknown ammoAction " << strValue << std::endl;
  2113.                        
  2114.                     if (constructTable) {
  2115.                         if (!strValue.empty()) {
  2116.                             pattribute += "value = \"" + strValue + "\" },\n";
  2117.                         }  
  2118.                     }
  2119.                 }
  2120.             }
  2121.             else if(tmpStrValue == "hitchance")
  2122.             {
  2123.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2124.                     it.hitChance = std::max(0, std::min(100, intValue));
  2125.                     if (constructTable) {
  2126.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2127.                     }
  2128.             }
  2129.             else if(tmpStrValue == "maxhitchance")
  2130.             {
  2131.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2132.                     it.maxHitChance = std::max(0, std::min(100, intValue));
  2133.                     if (constructTable) {
  2134.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2135.                     }
  2136.             }
  2137.             else if(tmpStrValue == "preventloss")
  2138.             {
  2139.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2140.                     it.abilities.preventLoss = (intValue != 0);
  2141.                     if (constructTable) {
  2142.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2143.                     }
  2144.             }
  2145.             else if(tmpStrValue == "preventdrop")
  2146.             {
  2147.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2148.                     it.abilities.preventDrop = (intValue != 0);
  2149.                     if (constructTable) {
  2150.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2151.                     }
  2152.             }
  2153.             else if(tmpStrValue == "invisible")
  2154.             {
  2155.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2156.                     it.abilities.invisible = (intValue != 0);
  2157.                     if (constructTable) {
  2158.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2159.                     }
  2160.             }
  2161.             else if(tmpStrValue == "speed")
  2162.             {
  2163.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2164.                     it.abilities.speed = intValue;
  2165.                     if (constructTable) {
  2166.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2167.                     }
  2168.             }
  2169.             else if(tmpStrValue == "healthgain")
  2170.             {
  2171.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2172.                 {
  2173.                     it.abilities.regeneration = true;
  2174.                     it.abilities.healthGain = intValue;
  2175.                     if (constructTable) {
  2176.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2177.                     }
  2178.                 }
  2179.             }
  2180.             else if(tmpStrValue == "healthticks")
  2181.             {
  2182.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2183.                 {
  2184.                     it.abilities.regeneration = true;
  2185.                     it.abilities.healthTicks = intValue;
  2186.                     if (constructTable) {
  2187.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2188.                     }
  2189.                 }
  2190.             }
  2191.             else if(tmpStrValue == "managain")
  2192.             {
  2193.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2194.                 {
  2195.                     it.abilities.regeneration = true;
  2196.                     it.abilities.manaGain = intValue;
  2197.                     if (constructTable) {
  2198.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2199.                     }
  2200.                 }
  2201.             }
  2202.             else if(tmpStrValue == "manaticks")
  2203.             {
  2204.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2205.                 {
  2206.                     it.abilities.regeneration = true;
  2207.                     it.abilities.manaTicks = intValue;
  2208.                     if (constructTable) {
  2209.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2210.                     }
  2211.                 }
  2212.             }
  2213.             else if(tmpStrValue == "manashield")
  2214.             {
  2215.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2216.                     it.abilities.manaShield = (intValue != 0);
  2217.                     if (constructTable) {
  2218.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2219.                     }
  2220.             }
  2221.             else if(tmpStrValue == "skillsword")
  2222.             {
  2223.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2224.                     it.abilities.skills[SKILL_SWORD] = intValue;
  2225.                     if (constructTable) {
  2226.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2227.                     }
  2228.             }
  2229.             else if(tmpStrValue == "skillaxe")
  2230.             {
  2231.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2232.                     it.abilities.skills[SKILL_AXE] = intValue;
  2233.                     if (constructTable) {
  2234.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2235.                     }
  2236.             }
  2237.             else if(tmpStrValue == "skillclub")
  2238.             {
  2239.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2240.                     it.abilities.skills[SKILL_CLUB] = intValue;
  2241.                     if (constructTable) {
  2242.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2243.                     }
  2244.             }
  2245.             else if(tmpStrValue == "skilldist")
  2246.             {
  2247.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2248.                     it.abilities.skills[SKILL_DIST] = intValue;
  2249.                     if (constructTable) {
  2250.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2251.                     }
  2252.             }
  2253.             else if(tmpStrValue == "skillfish")
  2254.             {
  2255.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2256.                     it.abilities.skills[SKILL_FISH] = intValue;
  2257.                     if (constructTable) {
  2258.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2259.                     }
  2260.             }
  2261.             else if(tmpStrValue == "skillshield")
  2262.             {
  2263.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2264.                     it.abilities.skills[SKILL_SHIELD] = intValue;
  2265.                     if (constructTable) {
  2266.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2267.                     }
  2268.             }
  2269.             else if(tmpStrValue == "skillfist")
  2270.             {
  2271.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2272.                     it.abilities.skills[SKILL_FIST] = intValue;
  2273.                     if (constructTable) {
  2274.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2275.                     }
  2276.             }
  2277.             else if(tmpStrValue == "maxhealthpoints" || tmpStrValue == "maxhitpoints")
  2278.             {
  2279.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2280.                     it.abilities.stats[STAT_MAXHEALTH] = intValue;
  2281.                     if (constructTable) {
  2282.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2283.                     }
  2284.             }
  2285.             else if(tmpStrValue == "maxhealthpercent" || tmpStrValue == "maxhitpointspercent")
  2286.             {
  2287.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2288.                     it.abilities.statsPercent[STAT_MAXHEALTH] = intValue;
  2289.                     if (constructTable) {
  2290.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2291.                     }
  2292.             }
  2293.             else if(tmpStrValue == "maxmanapoints")
  2294.             {
  2295.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2296.                     it.abilities.stats[STAT_MAXMANA] = intValue;
  2297.                     if (constructTable) {
  2298.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2299.                     }
  2300.             }
  2301.             else if(tmpStrValue == "maxmanapercent" || tmpStrValue == "maxmanapointspercent")
  2302.             {
  2303.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2304.                     it.abilities.statsPercent[STAT_MAXMANA] = intValue;
  2305.                     if (constructTable) {
  2306.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2307.                     }
  2308.             }
  2309.             else if(tmpStrValue == "soulpoints")
  2310.             {
  2311.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2312.                     it.abilities.stats[STAT_SOUL] = intValue;
  2313.                     if (constructTable) {
  2314.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2315.                     }
  2316.             }
  2317.             else if(tmpStrValue == "soulpercent" || tmpStrValue == "soulpointspercent")
  2318.             {
  2319.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2320.                     it.abilities.statsPercent[STAT_SOUL] = intValue;
  2321.                     if (constructTable) {
  2322.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2323.                     }
  2324.             }
  2325.             else if(tmpStrValue == "magiclevelpoints" || tmpStrValue == "magicpoints")
  2326.             {
  2327.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2328.                     it.abilities.stats[STAT_MAGICLEVEL] = intValue;
  2329.                     if (constructTable) {
  2330.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2331.                     }
  2332.             }
  2333.             else if(tmpStrValue == "magiclevelpercent" || tmpStrValue == "magicpointspercent")
  2334.             {
  2335.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2336.                     it.abilities.statsPercent[STAT_MAGICLEVEL] = intValue;
  2337.                     if (constructTable) {
  2338.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2339.                     }
  2340.             }
  2341.             else if(tmpStrValue == "increasemagicvalue")
  2342.             {
  2343.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2344.                     it.abilities.increment[MAGIC_VALUE] = intValue;
  2345.                     if (constructTable) {
  2346.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2347.                     }
  2348.             }
  2349.             else if(tmpStrValue == "increasemagicpercent")
  2350.             {
  2351.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2352.                     it.abilities.increment[MAGIC_PERCENT] = intValue;
  2353.                     if (constructTable) {
  2354.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2355.                     }
  2356.             }
  2357.             else if(tmpStrValue == "increasehealingvalue")
  2358.             {
  2359.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2360.                     it.abilities.increment[HEALING_VALUE] = intValue;
  2361.                     if (constructTable) {
  2362.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2363.                     }
  2364.             }
  2365.             else if(tmpStrValue == "increasehealingpercent")
  2366.             {
  2367.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2368.                     it.abilities.increment[HEALING_PERCENT] = intValue;
  2369.                     if (constructTable) {
  2370.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2371.                     }
  2372.             }
  2373.             else if(tmpStrValue == "absorbpercentall")
  2374.             {
  2375.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2376.                 {
  2377.                     for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
  2378.                         it.abilities.absorb[i] += intValue;
  2379.                     }
  2380.                     if (constructTable) {
  2381.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2382.                     }
  2383.                 }
  2384.             }
  2385.             else if(tmpStrValue == "absorbpercentelements")
  2386.             {
  2387.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2388.                 {
  2389.                     it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
  2390.                     it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
  2391.                     it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
  2392.                     it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
  2393.                     if (constructTable) {
  2394.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2395.                     }
  2396.                 }
  2397.             }
  2398.             else if(tmpStrValue == "absorbpercentmagic")
  2399.             {
  2400.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2401.                 {
  2402.                     it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
  2403.                     it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
  2404.                     it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
  2405.                     it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
  2406.                     it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
  2407.                     it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
  2408.                     if (constructTable) {
  2409.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2410.                     }
  2411.                 }
  2412.             }
  2413.             else if(tmpStrValue == "absorbpercentenergy")
  2414.             {
  2415.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2416.                     it.abilities.absorb[COMBAT_ENERGYDAMAGE] += intValue;
  2417.                     if (constructTable) {
  2418.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2419.                     }
  2420.             }
  2421.             else if(tmpStrValue == "absorbpercentfire")
  2422.             {
  2423.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2424.                     it.abilities.absorb[COMBAT_FIREDAMAGE] += intValue;
  2425.                     if (constructTable) {
  2426.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2427.                     }
  2428.             }
  2429.             else if(tmpStrValue == "absorbpercentpoison" || tmpStrValue == "absorbpercentearth")
  2430.             {
  2431.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2432.                     it.abilities.absorb[COMBAT_EARTHDAMAGE] += intValue;
  2433.                     if (constructTable) {
  2434.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2435.                     }
  2436.             }
  2437.             else if(tmpStrValue == "absorbpercentice")
  2438.             {
  2439.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2440.                     it.abilities.absorb[COMBAT_ICEDAMAGE] += intValue;
  2441.                     if (constructTable) {
  2442.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2443.                     }
  2444.             }
  2445.             else if(tmpStrValue == "absorbpercentholy")
  2446.             {
  2447.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2448.                     it.abilities.absorb[COMBAT_HOLYDAMAGE] += intValue;
  2449.                     if (constructTable) {
  2450.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2451.                     }
  2452.             }
  2453.             else if(tmpStrValue == "absorbpercentdeath")
  2454.             {
  2455.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2456.                     it.abilities.absorb[COMBAT_DEATHDAMAGE] += intValue;
  2457.                     if (constructTable) {
  2458.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2459.                     }
  2460.             }
  2461.             else if(tmpStrValue == "absorbpercentlifedrain")
  2462.             {
  2463.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2464.                     it.abilities.absorb[COMBAT_LIFEDRAIN] += intValue;
  2465.                     if (constructTable) {
  2466.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2467.                     }
  2468.             }
  2469.             else if(tmpStrValue == "absorbpercentmanadrain")
  2470.             {
  2471.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2472.                     it.abilities.absorb[COMBAT_MANADRAIN] += intValue;
  2473.                     if (constructTable) {
  2474.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2475.                     }
  2476.             }
  2477.             else if(tmpStrValue == "absorbpercentdrown")
  2478.             {
  2479.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2480.                     it.abilities.absorb[COMBAT_DROWNDAMAGE] += intValue;
  2481.                     if (constructTable) {
  2482.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2483.                     }
  2484.             }
  2485.             else if(tmpStrValue == "absorbpercentphysical")
  2486.             {
  2487.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2488.                     it.abilities.absorb[COMBAT_PHYSICALDAMAGE] += intValue;
  2489.                     if (constructTable) {
  2490.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2491.                     }
  2492.             }
  2493.             else if(tmpStrValue == "absorbpercenthealing")
  2494.             {
  2495.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2496.                     it.abilities.absorb[COMBAT_HEALING] += intValue;
  2497.                     if (constructTable) {
  2498.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2499.                     }
  2500.             }
  2501.             else if(tmpStrValue == "absorbpercentundefined")
  2502.             {
  2503.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2504.                     it.abilities.absorb[COMBAT_UNDEFINEDDAMAGE] += intValue;
  2505.                     if (constructTable) {
  2506.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2507.                     }
  2508.             }
  2509.             else if(tmpStrValue == "reflectpercentall")
  2510.             {
  2511.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2512.                 {
  2513.                     for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
  2514.                         it.abilities.reflect[REFLECT_PERCENT][i] += intValue;
  2515.                     }
  2516.                     if (constructTable) {
  2517.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2518.                     }
  2519.                 }
  2520.             }
  2521.             else if(tmpStrValue == "reflectpercentelements")
  2522.             {
  2523.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2524.                 {
  2525.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
  2526.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
  2527.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
  2528.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
  2529.                     if (constructTable) {
  2530.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2531.                     }
  2532.                 }
  2533.             }
  2534.             else if(tmpStrValue == "reflectpercentmagic")
  2535.             {
  2536.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2537.                 {
  2538.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
  2539.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
  2540.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
  2541.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
  2542.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
  2543.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
  2544.                     if (constructTable) {
  2545.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2546.                     }
  2547.                 }
  2548.             }
  2549.             else if(tmpStrValue == "reflectpercentenergy")
  2550.             {
  2551.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2552.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ENERGYDAMAGE] += intValue;
  2553.                     if (constructTable) {
  2554.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2555.                     }
  2556.             }
  2557.             else if(tmpStrValue == "reflectpercentfire")
  2558.             {
  2559.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2560.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_FIREDAMAGE] += intValue;
  2561.                     if (constructTable) {
  2562.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2563.                     }
  2564.             }
  2565.             else if(tmpStrValue == "reflectpercentpoison" ||    tmpStrValue == "reflectpercentearth")
  2566.             {
  2567.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2568.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_EARTHDAMAGE] += intValue;
  2569.                     if (constructTable) {
  2570.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2571.                     }
  2572.             }
  2573.             else if(tmpStrValue == "reflectpercentice")
  2574.             {
  2575.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2576.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_ICEDAMAGE] += intValue;
  2577.                     if (constructTable) {
  2578.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2579.                     }
  2580.             }
  2581.             else if(tmpStrValue == "reflectpercentholy")
  2582.             {
  2583.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2584.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_HOLYDAMAGE] += intValue;
  2585.                     if (constructTable) {
  2586.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2587.                     }
  2588.             }
  2589.             else if(tmpStrValue == "reflectpercentdeath")
  2590.             {
  2591.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2592.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_DEATHDAMAGE] += intValue;
  2593.                     if (constructTable) {
  2594.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2595.                     }
  2596.             }
  2597.             else if(tmpStrValue == "reflectpercentlifedrain")
  2598.             {
  2599.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2600.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_LIFEDRAIN] += intValue;
  2601.                     if (constructTable) {
  2602.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2603.                     }
  2604.             }
  2605.             else if(tmpStrValue == "reflectpercentmanadrain")
  2606.             {
  2607.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2608.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_MANADRAIN] += intValue;
  2609.                     if (constructTable) {
  2610.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2611.                     }
  2612.             }
  2613.             else if(tmpStrValue == "reflectpercentdrown")
  2614.             {
  2615.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2616.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_DROWNDAMAGE] += intValue;
  2617.                     if (constructTable) {
  2618.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2619.                     }
  2620.             }
  2621.             else if(tmpStrValue == "reflectpercentphysical")
  2622.             {
  2623.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2624.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_PHYSICALDAMAGE] += intValue;
  2625.                     if (constructTable) {
  2626.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2627.                     }
  2628.             }
  2629.             else if(tmpStrValue == "reflectpercenthealing")
  2630.             {
  2631.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2632.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_HEALING] += intValue;
  2633.                     if (constructTable) {
  2634.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2635.                     }
  2636.             }
  2637.             else if(tmpStrValue == "reflectpercentundefined")
  2638.             {
  2639.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2640.                     it.abilities.reflect[REFLECT_PERCENT][COMBAT_UNDEFINEDDAMAGE] += intValue;
  2641.                     if (constructTable) {
  2642.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2643.                     }
  2644.             }
  2645.             else if(tmpStrValue == "reflectchanceall")
  2646.             {
  2647.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2648.                 {
  2649.                     for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++){
  2650.                         it.abilities.reflect[REFLECT_CHANCE][i] += intValue;
  2651.                     }
  2652.                     if (constructTable) {
  2653.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2654.                     }
  2655.                 }
  2656.             }
  2657.             else if(tmpStrValue == "reflectchanceelements")
  2658.             {
  2659.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2660.                 {
  2661.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
  2662.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
  2663.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
  2664.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
  2665.                     if (constructTable) {
  2666.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2667.                     }
  2668.                 }
  2669.             }
  2670.             else if(tmpStrValue == "reflectchancemagic")
  2671.             {
  2672.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2673.                 {
  2674.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
  2675.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
  2676.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
  2677.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
  2678.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
  2679.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
  2680.                     if (constructTable) {
  2681.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2682.                     }
  2683.                 }
  2684.             }
  2685.             else if(tmpStrValue == "reflectchanceenergy")
  2686.             {
  2687.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2688.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ENERGYDAMAGE] += intValue;
  2689.                     if (constructTable) {
  2690.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2691.                     }
  2692.             }
  2693.             else if(tmpStrValue == "reflectchancefire")
  2694.             {
  2695.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2696.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_FIREDAMAGE] += intValue;
  2697.                     if (constructTable) {
  2698.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2699.                     }
  2700.             }
  2701.             else if(tmpStrValue == "reflectchancepoison" || tmpStrValue == "reflectchanceearth")
  2702.             {
  2703.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2704.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_EARTHDAMAGE] += intValue;
  2705.                     if (constructTable) {
  2706.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2707.                     }
  2708.             }
  2709.             else if(tmpStrValue == "reflectchanceice")
  2710.             {
  2711.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2712.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_ICEDAMAGE] += intValue;
  2713.                     if (constructTable) {
  2714.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2715.                     }
  2716.             }
  2717.             else if(tmpStrValue == "reflectchanceholy")
  2718.             {
  2719.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2720.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_HOLYDAMAGE] += intValue;
  2721.                     if (constructTable) {
  2722.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2723.                     }
  2724.             }
  2725.             else if(tmpStrValue == "reflectchancedeath")
  2726.             {
  2727.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2728.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_DEATHDAMAGE] += intValue;
  2729.                     if (constructTable) {
  2730.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2731.                     }
  2732.             }
  2733.             else if(tmpStrValue == "reflectchancelifedrain")
  2734.             {
  2735.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2736.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_LIFEDRAIN] += intValue;
  2737.                     if (constructTable) {
  2738.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2739.                     }
  2740.             }
  2741.             else if(tmpStrValue == "reflectchancemanadrain")
  2742.             {
  2743.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2744.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_MANADRAIN] += intValue;
  2745.                     if (constructTable) {
  2746.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2747.                     }
  2748.             }
  2749.             else if(tmpStrValue == "reflectchancedrown")
  2750.             {
  2751.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2752.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_DROWNDAMAGE] += intValue;
  2753.                     if (constructTable) {
  2754.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2755.                     }
  2756.             }
  2757.             else if(tmpStrValue == "reflectchancephysical")
  2758.             {
  2759.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2760.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_PHYSICALDAMAGE] += intValue;
  2761.                     if (constructTable) {
  2762.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2763.                     }
  2764.             }
  2765.             else if(tmpStrValue == "reflectchancehealing")
  2766.             {
  2767.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2768.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_HEALING] += intValue;
  2769.                     if (constructTable) {
  2770.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2771.                     }
  2772.             }
  2773.             else if(tmpStrValue == "reflectchanceundefined")
  2774.             {
  2775.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  2776.                     it.abilities.reflect[REFLECT_CHANCE][COMBAT_UNDEFINEDDAMAGE] += intValue;
  2777.                     if (constructTable) {
  2778.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2779.                     }
  2780.             }
  2781.             else if(tmpStrValue == "suppressshock" || tmpStrValue == "suppressenergy")
  2782.             {
  2783.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2784.                     it.abilities.conditionSuppressions |= CONDITION_ENERGY;
  2785.                     if (constructTable) {
  2786.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2787.                     }
  2788.             }
  2789.             else if(tmpStrValue == "suppressburn" || tmpStrValue == "suppressfire")
  2790.             {
  2791.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2792.                     it.abilities.conditionSuppressions |= CONDITION_FIRE;
  2793.                     if (constructTable) {
  2794.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2795.                     }
  2796.             }
  2797.             else if(tmpStrValue == "suppresspoison" || tmpStrValue == "suppressearth")
  2798.             {
  2799.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2800.                     it.abilities.conditionSuppressions |= CONDITION_POISON;
  2801.                     if (constructTable) {
  2802.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2803.                     }
  2804.             }
  2805.             else if(tmpStrValue == "suppressfreeze" || tmpStrValue == "suppressice")
  2806.             {
  2807.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2808.                     it.abilities.conditionSuppressions |= CONDITION_FREEZING;
  2809.                     if (constructTable) {
  2810.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2811.                     }
  2812.             }
  2813.             else if(tmpStrValue == "suppressdazzle" || tmpStrValue == "suppressholy")
  2814.             {
  2815.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2816.                     it.abilities.conditionSuppressions |= CONDITION_DAZZLED;
  2817.                     if (constructTable) {
  2818.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2819.                     }
  2820.             }
  2821.             else if(tmpStrValue == "suppresscurse" || tmpStrValue == "suppressdeath")
  2822.             {
  2823.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2824.                     it.abilities.conditionSuppressions |= CONDITION_CURSED;
  2825.                     if (constructTable) {
  2826.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2827.                     }
  2828.             }
  2829.             else if(tmpStrValue == "suppressdrown")
  2830.             {
  2831.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2832.                     it.abilities.conditionSuppressions |= CONDITION_DROWN;
  2833.                     if (constructTable) {
  2834.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2835.                     }
  2836.             }
  2837.             else if(tmpStrValue == "suppressphysical")
  2838.             {
  2839.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2840.                     it.abilities.conditionSuppressions |= CONDITION_PHYSICAL;
  2841.                     if (constructTable) {
  2842.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2843.                     }
  2844.             }
  2845.             else if(tmpStrValue == "suppresshaste")
  2846.             {
  2847.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2848.                     it.abilities.conditionSuppressions |= CONDITION_HASTE;
  2849.                     if (constructTable) {
  2850.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2851.                     }
  2852.             }
  2853.             else if(tmpStrValue == "suppressparalyze")
  2854.             {
  2855.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2856.                     it.abilities.conditionSuppressions |= CONDITION_PARALYZE;
  2857.                     if (constructTable) {
  2858.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2859.                     }
  2860.             }
  2861.             else if(tmpStrValue == "suppressdrunk")
  2862.             {
  2863.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2864.                     it.abilities.conditionSuppressions |= CONDITION_DRUNK;
  2865.                     if (constructTable) {
  2866.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2867.                     }
  2868.             }
  2869.             else if(tmpStrValue == "suppressregeneration")
  2870.             {
  2871.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2872.                     it.abilities.conditionSuppressions |= CONDITION_REGENERATION;
  2873.                     if (constructTable) {
  2874.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2875.                     }
  2876.             }
  2877.             else if(tmpStrValue == "suppresssoul")
  2878.             {
  2879.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2880.                     it.abilities.conditionSuppressions |= CONDITION_SOUL;
  2881.                     if (constructTable) {
  2882.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2883.                     }
  2884.             }
  2885.             else if(tmpStrValue == "suppressoutfit")
  2886.             {
  2887.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2888.                     it.abilities.conditionSuppressions |= CONDITION_OUTFIT;
  2889.                     if (constructTable) {
  2890.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2891.                     }
  2892.             }
  2893.             else if(tmpStrValue == "suppressinvisible")
  2894.             {
  2895.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2896.                     it.abilities.conditionSuppressions |= CONDITION_INVISIBLE;
  2897.                     if (constructTable) {
  2898.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2899.                     }
  2900.             }
  2901.             else if(tmpStrValue == "suppressinfight")
  2902.             {
  2903.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2904.                     it.abilities.conditionSuppressions |= CONDITION_INFIGHT;
  2905.                     if (constructTable) {
  2906.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2907.                     }
  2908.             }
  2909.             else if(tmpStrValue == "suppressexhaust")
  2910.             {
  2911.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2912.                     it.abilities.conditionSuppressions |= CONDITION_EXHAUST;
  2913.                     if (constructTable) {
  2914.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2915.                     }
  2916.             }
  2917.             else if(tmpStrValue == "suppressmuted")
  2918.             {
  2919.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2920.                     it.abilities.conditionSuppressions |= CONDITION_MUTED;
  2921.                     if (constructTable) {
  2922.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2923.                     }
  2924.             }
  2925.             else if(tmpStrValue == "suppresspacified")
  2926.             {
  2927.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2928.                     it.abilities.conditionSuppressions |= CONDITION_PACIFIED;
  2929.                     if (constructTable) {
  2930.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2931.                     }
  2932.             }
  2933.             else if(tmpStrValue == "suppresslight")
  2934.             {
  2935.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2936.                     it.abilities.conditionSuppressions |= CONDITION_LIGHT;
  2937.                     if (constructTable) {
  2938.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2939.                     }
  2940.             }
  2941.             else if(tmpStrValue == "suppressattributes")
  2942.             {
  2943.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2944.                     it.abilities.conditionSuppressions |= CONDITION_ATTRIBUTES;
  2945.                     if (constructTable) {
  2946.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2947.                     }
  2948.             }
  2949.             else if(tmpStrValue == "suppressmanashield")
  2950.             {
  2951.                 if(readXMLInteger(itemAttributesNode, "value", intValue) && intValue != 0)
  2952.                     it.abilities.conditionSuppressions |= CONDITION_MANASHIELD;
  2953.                     if (constructTable) {
  2954.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  2955.                     }
  2956.             }
  2957.             else if(tmpStrValue == "field")
  2958.             {
  2959.                 it.group = ITEM_GROUP_MAGICFIELD;
  2960.                 it.type = ITEM_TYPE_MAGICFIELD;
  2961.                 CombatType_t combatType = COMBAT_NONE;
  2962.                 ConditionDamage* conditionDamage = NULL;
  2963.  
  2964.                 if(readXMLString(itemAttributesNode, "value", strValue))
  2965.                 {
  2966.                     tmpStrValue = asLowerCaseString(strValue);
  2967.                     if(tmpStrValue == "fire")
  2968.                     {
  2969.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_FIRE, false, 0);
  2970.                         combatType = COMBAT_FIREDAMAGE;
  2971.                     }
  2972.                     else if(tmpStrValue == "energy")
  2973.                     {
  2974.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_ENERGY, false, 0);
  2975.                         combatType = COMBAT_ENERGYDAMAGE;
  2976.                     }
  2977.                     else if(tmpStrValue == "earth" || tmpStrValue == "poison")
  2978.                     {
  2979.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_POISON, false, 0);
  2980.                         combatType = COMBAT_EARTHDAMAGE;
  2981.                     }
  2982.                     else if(tmpStrValue == "ice" || tmpStrValue == "freezing")
  2983.                     {
  2984.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_FREEZING, false, 0);
  2985.                         combatType = COMBAT_ICEDAMAGE;
  2986.                     }
  2987.                     else if(tmpStrValue == "holy" || tmpStrValue == "dazzled")
  2988.                     {
  2989.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_DAZZLED, false, 0);
  2990.                         combatType = COMBAT_HOLYDAMAGE;
  2991.                     }
  2992.                     else if(tmpStrValue == "death" || tmpStrValue == "cursed")
  2993.                     {
  2994.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_CURSED, false, 0);
  2995.                         combatType = COMBAT_DEATHDAMAGE;
  2996.                     }
  2997.                     else if(tmpStrValue == "drown")
  2998.                     {
  2999.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_DROWN, false, 0);
  3000.                         combatType = COMBAT_DROWNDAMAGE;
  3001.                     }
  3002.                     else if(tmpStrValue == "physical")
  3003.                     {
  3004.                         conditionDamage = new ConditionDamage(CONDITIONID_COMBAT, CONDITION_PHYSICAL, false, 0);
  3005.                         combatType = COMBAT_PHYSICALDAMAGE;
  3006.                     }
  3007.                     else
  3008.                         std::cout << "[Warning - Items::loadFromXml] Unknown field value " << strValue << std::endl;
  3009.                        
  3010.                     if (constructTable) {
  3011.                         if (!tmpStrValue.empty()) {
  3012.                             pattribute += "value = \"" + tmpStrValue + "\" },\n";
  3013.                         }  
  3014.                     }
  3015.  
  3016.                     if(combatType != COMBAT_NONE)
  3017.                     {
  3018.                         it.combatType = combatType;
  3019.                         it.condition = conditionDamage;
  3020.                         uint32_t ticks = 0;
  3021.                         int32_t damage = 0, start = 0, count = 1;
  3022.  
  3023.                         xmlNodePtr fieldAttributesNode = itemAttributesNode->children;
  3024.                         while(fieldAttributesNode)
  3025.                         {
  3026.                             if(readXMLString(fieldAttributesNode, "key", strValue))
  3027.                             {
  3028.                                 tmpStrValue = asLowerCaseString(strValue);
  3029.                                 if(tmpStrValue == "ticks")
  3030.                                 {
  3031.                                     if(readXMLInteger(fieldAttributesNode, "value", intValue))
  3032.                                         ticks = std::max(0, intValue);
  3033.                                 }
  3034.  
  3035.                                 if(tmpStrValue == "count")
  3036.                                 {
  3037.                                     if(readXMLInteger(fieldAttributesNode, "value", intValue))
  3038.                                         count = std::max(1, intValue);
  3039.                                 }
  3040.  
  3041.                                 if(tmpStrValue == "start")
  3042.                                 {
  3043.                                     if(readXMLInteger(fieldAttributesNode, "value", intValue))
  3044.                                         start = std::max(0, intValue);
  3045.                                 }
  3046.  
  3047.                                 if(tmpStrValue == "damage")
  3048.                                 {
  3049.                                     if(readXMLInteger(fieldAttributesNode, "value", intValue))
  3050.                                     {
  3051.                                         damage = -intValue;
  3052.                                         if(start > 0)
  3053.                                         {
  3054.                                             std::list<int32_t> damageList;
  3055.                                             ConditionDamage::generateDamageList(damage, start, damageList);
  3056.  
  3057.                                             for(std::list<int32_t>::iterator it = damageList.begin(); it != damageList.end(); ++it)
  3058.                                                 conditionDamage->addDamage(1, ticks, -*it);
  3059.  
  3060.                                             start = 0;
  3061.                                         }
  3062.                                         else
  3063.                                             conditionDamage->addDamage(count, ticks, damage);
  3064.                                     }
  3065.                                 }
  3066.                             }
  3067.  
  3068.                             fieldAttributesNode = fieldAttributesNode->next;
  3069.                         }
  3070.  
  3071.                         if(conditionDamage->getTotalDamage() > 0)
  3072.                             it.condition->setParam(CONDITIONPARAM_FORCEUPDATE, true);
  3073.                     }
  3074.                 }
  3075.             }
  3076.             else if(tmpStrValue == "elementphysical")
  3077.             {
  3078.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3079.                 {
  3080.                     it.abilities.elementDamage = intValue;
  3081.                     it.abilities.elementType = COMBAT_PHYSICALDAMAGE;
  3082.                     if (constructTable) {
  3083.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3084.                     }
  3085.                 }
  3086.             }
  3087.             else if(tmpStrValue == "elementfire")
  3088.             {
  3089.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3090.                 {
  3091.                     it.abilities.elementDamage = intValue;
  3092.                     it.abilities.elementType = COMBAT_FIREDAMAGE;
  3093.                     if (constructTable) {
  3094.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3095.                     }
  3096.                 }
  3097.             }
  3098.             else if(tmpStrValue == "elementenergy")
  3099.             {
  3100.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3101.                 {
  3102.                     it.abilities.elementDamage = intValue;
  3103.                     it.abilities.elementType = COMBAT_ENERGYDAMAGE;
  3104.                     if (constructTable) {
  3105.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3106.                     }
  3107.                 }
  3108.             }
  3109.             else if(tmpStrValue == "elementearth")
  3110.             {
  3111.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3112.                 {
  3113.                     it.abilities.elementDamage = intValue;
  3114.                     it.abilities.elementType = COMBAT_EARTHDAMAGE;
  3115.                     if (constructTable) {
  3116.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3117.                     }
  3118.                 }
  3119.             }
  3120.             else if(tmpStrValue == "elementice")
  3121.             {
  3122.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3123.                 {
  3124.                     it.abilities.elementDamage = intValue;
  3125.                     it.abilities.elementType = COMBAT_ICEDAMAGE;
  3126.                     if (constructTable) {
  3127.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3128.                     }
  3129.                 }
  3130.             }
  3131.             else if(tmpStrValue == "elementholy")
  3132.             {
  3133.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3134.                 {
  3135.                     it.abilities.elementDamage = intValue;
  3136.                     it.abilities.elementType = COMBAT_HOLYDAMAGE;
  3137.                     if (constructTable) {
  3138.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3139.                     }
  3140.                 }
  3141.             }
  3142.             else if(tmpStrValue == "elementdeath")
  3143.             {
  3144.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3145.                 {
  3146.                     it.abilities.elementDamage = intValue;
  3147.                     it.abilities.elementType = COMBAT_DEATHDAMAGE;
  3148.                     if (constructTable) {
  3149.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3150.                     }
  3151.                 }
  3152.             }
  3153.             else if(tmpStrValue == "elementlifedrain")
  3154.             {
  3155.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3156.                 {
  3157.                     it.abilities.elementDamage = intValue;
  3158.                     it.abilities.elementType = COMBAT_LIFEDRAIN;
  3159.                     if (constructTable) {
  3160.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3161.                     }
  3162.                 }
  3163.             }
  3164.             else if(tmpStrValue == "elementmanadrain")
  3165.             {
  3166.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3167.                 {
  3168.                     it.abilities.elementDamage = intValue;
  3169.                     it.abilities.elementType = COMBAT_MANADRAIN;
  3170.                     if (constructTable) {
  3171.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3172.                     }
  3173.                 }
  3174.             }
  3175.             else if(tmpStrValue == "elementhealing")
  3176.             {
  3177.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3178.                 {
  3179.                     it.abilities.elementDamage = intValue;
  3180.                     it.abilities.elementType = COMBAT_HEALING;
  3181.                     if (constructTable) {
  3182.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3183.                     }
  3184.                 }
  3185.             }
  3186.             else if(tmpStrValue == "elementundefined")
  3187.             {
  3188.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3189.                 {
  3190.                     it.abilities.elementDamage = intValue;
  3191.                     it.abilities.elementType = COMBAT_UNDEFINEDDAMAGE;
  3192.                     if (constructTable) {
  3193.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3194.                     }
  3195.                 }
  3196.             }
  3197.             else if(tmpStrValue == "replaceable" || tmpStrValue == "replacable")
  3198.             {
  3199.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3200.                     it.replaceable = (intValue != 0);
  3201.                     if (constructTable) {
  3202.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3203.                     }
  3204.             }
  3205.             else if(tmpStrValue == "partnerdirection")
  3206.             {
  3207.                 if(readXMLString(itemAttributesNode, "value", strValue))
  3208.                     it.bedPartnerDir = getDirection(strValue);
  3209.                     if (constructTable) {
  3210.                         if (!strValue.empty()) {
  3211.                             pattribute += "value = \"" + strValue + "\" },\n";
  3212.                         }  
  3213.                     }
  3214.             }
  3215.             else if(tmpStrValue == "maletransformto")
  3216.             {
  3217.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3218.                 {
  3219.                     it.transformUseTo[PLAYERSEX_MALE] = intValue;
  3220.                     ItemType& ot = getItemType(intValue);
  3221.                     if(!ot.transformToFree)
  3222.                         ot.transformToFree = it.id;
  3223.  
  3224.                     if(!it.transformUseTo[PLAYERSEX_FEMALE])
  3225.                         it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
  3226.                    
  3227.                     if (constructTable) {
  3228.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3229.                     }
  3230.                 }
  3231.             }
  3232.             else if(tmpStrValue == "femaletransformto")
  3233.             {
  3234.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3235.                 {
  3236.                     it.transformUseTo[PLAYERSEX_FEMALE] = intValue;
  3237.                     ItemType& ot = getItemType(intValue);
  3238.                     if(!ot.transformToFree)
  3239.                         ot.transformToFree = it.id;
  3240.  
  3241.                     if(!it.transformUseTo[PLAYERSEX_MALE])
  3242.                         it.transformUseTo[PLAYERSEX_MALE] = intValue;
  3243.                    
  3244.                     if (constructTable) {
  3245.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3246.                     }
  3247.                 }
  3248.             }
  3249.             else if(tmpStrValue == "transformto")
  3250.             {
  3251.                 if(readXMLInteger(itemAttributesNode, "value", intValue))
  3252.                     it.transformToFree = intValue;
  3253.                     if (constructTable) {
  3254.                        pattribute += "value = \"" + boost::lexical_cast<std::string>(intValue) + "\" },\n";
  3255.                     }
  3256.             }
  3257.             else
  3258.                 std::cout << "[Warning - Items::loadFromXml] Unknown key value " << strValue << std::endl;
  3259.         }
  3260.  
  3261.         itemAttributesNode = itemAttributesNode->next;
  3262.     }
  3263.  
  3264.     if(it.pluralName.empty() && !it.name.empty())
  3265.     {
  3266.         it.pluralName = it.name;
  3267.         if(it.showCount)
  3268.             it.pluralName += "s";
  3269.     }
  3270.    
  3271.     if (constructTable) {
  3272.         //if (!pattribute.empty()){
  3273.             parser += "\n\t\tattributes = {\n" + pattribute + "\t\t}\n\t},\n";
  3274.         //}else{
  3275.             //parser += "\n\t},\n";
  3276.         //}
  3277.         out << parser;
  3278.     }
  3279. }
  3280.  
  3281. void Items::parseRandomizationBlock(int32_t id, int32_t fromId, int32_t toId, int32_t chance)
  3282. {
  3283.     RandomizationMap::iterator it = randomizationMap.find(id);
  3284.     if(it != randomizationMap.end())
  3285.     {
  3286.         std::cout << "[Warning - Items::parseRandomizationBlock] Duplicated item with id: " << id << std::endl;
  3287.         return;
  3288.     }
  3289.  
  3290.     RandomizationBlock rand;
  3291.     rand.chance = chance;
  3292.     rand.fromRange = fromId;
  3293.     rand.toRange = toId;
  3294.  
  3295.     randomizationMap[id] = rand;
  3296. }
  3297.  
  3298. uint16_t Items::getRandomizedItem(uint16_t id)
  3299. {
  3300.     if(!g_config.getBool(ConfigManager::RANDOMIZE_TILES))
  3301.         return id;
  3302.  
  3303.     RandomizationBlock randomize = getRandomization(id);
  3304.     if(randomize.chance > 0 && random_range(0, 100) <= randomize.chance)
  3305.         id = random_range(randomize.fromRange, randomize.toRange);
  3306.  
  3307.     return id;
  3308. }
  3309.  
  3310. ItemType& Items::getItemType(int32_t id)
  3311. {
  3312.     ItemType* iType = items.getElement(id);
  3313.     if(iType)
  3314.         return *iType;
  3315.  
  3316.     #ifdef __DEBUG__
  3317.     std::cout << "[Warning - Items::getItemType] Unknown itemtype with id " << id << ", using defaults." << std::endl;
  3318.     #endif
  3319.     static ItemType dummyItemType; // use this for invalid ids
  3320.     return dummyItemType;
  3321. }
  3322.  
  3323. const ItemType& Items::getItemType(int32_t id) const
  3324. {
  3325.     if(ItemType* iType = items.getElement(id))
  3326.         return *iType;
  3327.  
  3328.     static ItemType dummyItemType; // use this for invalid ids
  3329.     return dummyItemType;
  3330. }
  3331.  
  3332. const ItemType& Items::getItemIdByClientId(int32_t spriteId) const
  3333. {
  3334.     uint32_t i = 100;
  3335.     ItemType* iType;
  3336.     do
  3337.     {
  3338.         if((iType = items.getElement(i)) && iType->clientId == spriteId)
  3339.             return *iType;
  3340.  
  3341.         i++;
  3342.     }
  3343.     while(iType);
  3344.     static ItemType dummyItemType; // use this for invalid ids
  3345.     return dummyItemType;
  3346. }
  3347.  
  3348. int32_t Items::getItemIdByName(const std::string& name)
  3349. {
  3350.     if(!name.empty())
  3351.     {
  3352.         uint32_t i = 100;
  3353.         ItemType* iType = NULL;
  3354.         do
  3355.         {
  3356.             if((iType = items.getElement(i)) && !strcasecmp(name.c_str(), iType->name.c_str()))
  3357.                 return i;
  3358.  
  3359.             i++;
  3360.         }
  3361.         while(iType);
  3362.     }
  3363.  
  3364.     return -1;
  3365. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement