Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,419
- Solutions
- 68
- Reaction score
- 1,074
So I have increased the amount of attributes I can use. One of which is bindtype of the item. The issue is it isn't changing when I try to use setAttribute on it. There are no errors indicating a problem it is just persisting anyway. Maybe there is a size limit somewhere I need to figure out. Here is the main parts of the code:
item.h
item.cpp
items.h
items.cpp
not really important but tools.cpp
enums.h
luascript.cpp
All other attributes work as normal. One thing I noticed is the bindType is not included in the attributes section in items.xml. So this is probably where the problem is surfacing. I think I should still be able to modify it though?

UPDATE: Even moving it into the attributes area and adding bindtype to the proper places to do so everywhere else still results in setAttribute not changing it.


EDIT SOLVED:
The problem was in item.h
item.h
C++:
enum AttrTypes_t
{
// ATTR_DESCRIPTION = 1,
// ATTR_EXT_FILE = 2,
ATTR_TILE_FLAGS = 3,
ATTR_ACTION_ID = 4,
ATTR_UNIQUE_ID = 5,
ATTR_TEXT = 6,
ATTR_DESC = 7,
ATTR_TELE_DEST = 8,
...
ATTR_BINDTYPE = 57,
// version 12.x
ATTR_OPENCONTAINER = 58,
ATTR_PODIUMOUTFIT = 59,
ATTR_TIER = 60,
};
const static uint64_t intAttributeTypes =
ITEM_ATTRIBUTE_ACTIONID | ITEM_ATTRIBUTE_UNIQUEID | ITEM_ATTRIBUTE_DATE | ITEM_ATTRIBUTE_WEIGHT |
ITEM_ATTRIBUTE_HITCHANCE | ITEM_ATTRIBUTE_SHOOTRANGE | ITEM_ATTRIBUTE_OWNER | ITEM_ATTRIBUTE_DURATION |
ITEM_ATTRIBUTE_DECAYSTATE | ITEM_ATTRIBUTE_CORPSEOWNER | ITEM_ATTRIBUTE_CHARGES | ITEM_ATTRIBUTE_FLUIDTYPE |
ITEM_ATTRIBUTE_DOORID | ITEM_ATTRIBUTE_DECAYTO | ITEM_ATTRIBUTE_WRAPID | ITEM_ATTRIBUTE_STOREITEM |
ITEM_ATTRIBUTE_ATTACK_SPEED | ITEM_ATTRIBUTE_EQUIPMENT | ITEM_ATTRIBUTE_RARITY | ITEM_ATTRIBUTE_DODGE |
ITEM_ATTRIBUTE_BLOCK | ITEM_ATTRIBUTE_CRITICAL | ITEM_ATTRIBUTE_HASTE | ITEM_ATTRIBUTE_LUCK |
ITEM_ATTRIBUTE_SPEED | ITEM_ATTRIBUTE_ATTACK_MIN | ITEM_ATTRIBUTE_ATTACK_MAX | ITEM_ATTRIBUTE_ARMOR | ITEM_ATTRIBUTE_DEFENSE |
ITEM_ATTRIBUTE_CONSTITUTION | ITEM_ATTRIBUTE_SPIRIT | ITEM_ATTRIBUTE_STRENGTH | ITEM_ATTRIBUTE_DEXTERITY |
ITEM_ATTRIBUTE_INTELLECT | ITEM_ATTRIBUTE_BINDTYPE;
uint32_t getBindType() const
{
if (hasAttribute(ITEM_ATTRIBUTE_BINDTYPE)) return getIntAttr(ITEM_ATTRIBUTE_BINDTYPE);
return items[id].bindType;
}
item.cpp
C++:
case ATTR_BINDTYPE: {
uint32_t bindType;
if (!propStream.read<uint32_t>(bindType)) { return ATTR_READ_ERROR; }
setIntAttr(ITEM_ATTRIBUTE_BINDTYPE, bindType);
break;
}
items.h
C++:
uint32_t bindType = 0;
items.cpp
C++:
pugi::xml_attribute bindType = itemNode.attribute("bindType");
if (bindType) {
it.bindType = pugi::cast<uint32_t>(bindType.value());
}
not really important but tools.cpp
C++:
} else if (str == "bindtype" || str == "bindType") {
return ITEM_ATTRIBUTE_BINDTYPE;
enums.h
C++:
enum itemAttrTypes : uint64_t
{
ITEM_ATTRIBUTE_NONE,
ITEM_ATTRIBUTE_ACTIONID = 1ULL << 0,
ITEM_ATTRIBUTE_UNIQUEID = 1ULL << 1,
ITEM_ATTRIBUTE_DESCRIPTION = 1ULL << 2,
ITEM_ATTRIBUTE_TEXT = 1ULL << 3,
ITEM_ATTRIBUTE_DATE = 1ULL << 4,
...
ITEM_ATTRIBUTE_BINDTYPE = 1ULL << 41,
// ITEM_ATTRIBUTE_ = 1ULL << 41,
// Max 63
};
luascript.cpp
C++:
registerEnum(ITEM_ATTRIBUTE_BINDTYPE);
All other attributes work as normal. One thing I noticed is the bindType is not included in the attributes section in items.xml. So this is probably where the problem is surfacing. I think I should still be able to modify it though?

UPDATE: Even moving it into the attributes area and adding bindtype to the proper places to do so everywhere else still results in setAttribute not changing it.


Post automatically merged:
EDIT SOLVED:
The problem was in item.h
C++:
uint32_t attributeBits = 0; -> uint64_t attributeBits = 0;
Last edited: