1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#ifndef TIBIA_OBJECTS_HH_
#define TIBIA_OBJECTS_HH_ 1
#include "common.hh"
#include "enums.hh"
enum : int{
TYPEID_MAP_CONTAINER = 0,
TYPEID_HEAD_CONTAINER = 1,
TYPEID_NECK_CONTAINER = 2,
TYPEID_BAG_CONTAINER = 3,
TYPEID_TORSO_CONTAINER = 4,
TYPEID_RIGHTHAND_CONTAINER = 5,
TYPEID_LEFTHAND_CONTAINER = 6,
TYPEID_LEGS_CONTAINER = 7,
TYPEID_FEET_CONTAINER = 8,
TYPEID_FINGER_CONTAINER = 9,
TYPEID_AMMO_CONTAINER = 10,
TYPEID_CREATURE_CONTAINER = 99,
};
struct ObjectType {
ObjectType(void) { this->setTypeID(0); }
ObjectType(int TypeID) { this->setTypeID(TypeID); }
void setTypeID(int TypeID);
bool getFlag(FLAG Flag);
uint32 getAttribute(TYPEATTRIBUTE Attribute);
int getAttributeOffset(INSTANCEATTRIBUTE Attribute);
const char *getName(int Count);
const char *getDescription(void);
bool isMapContainer(void){
return this->TypeID == TYPEID_MAP_CONTAINER;
}
bool isBodyContainer(void){
return this->TypeID == TYPEID_HEAD_CONTAINER
|| this->TypeID == TYPEID_NECK_CONTAINER
|| this->TypeID == TYPEID_BAG_CONTAINER
|| this->TypeID == TYPEID_TORSO_CONTAINER
|| this->TypeID == TYPEID_RIGHTHAND_CONTAINER
|| this->TypeID == TYPEID_LEFTHAND_CONTAINER
|| this->TypeID == TYPEID_LEGS_CONTAINER
|| this->TypeID == TYPEID_FEET_CONTAINER
|| this->TypeID == TYPEID_FINGER_CONTAINER
|| this->TypeID == TYPEID_AMMO_CONTAINER;
}
bool isCreatureContainer(void){
return this->TypeID == TYPEID_CREATURE_CONTAINER;
}
bool isTwoHanded(void){
return this->getFlag(CLOTHES)
&& this->getAttribute(BODYPOSITION) == 0;
}
bool isWeapon(void){
return this->getFlag(WEAPON)
|| this->getFlag(BOW)
|| this->getFlag(THROW)
|| this->getFlag(WAND);
}
bool isCloseWeapon(void){
if(!this->getFlag(WEAPON)){
return false;
}
int WeaponType = this->getAttribute(WEAPONTYPE);
return WeaponType == WEAPON_SWORD
|| WeaponType == WEAPON_CLUB
|| WeaponType == WEAPON_AXE;
}
ObjectType getDisguise(void){
if(this->getFlag(DISGUISE)){
return (int)this->getAttribute(DISGUISETARGET);
}else{
return *this;
}
}
bool operator==(const ObjectType &Other) const {
return this->TypeID == Other.TypeID;
}
bool operator!=(const ObjectType &Other) const {
return this->TypeID != Other.TypeID;
}
// DATA
// =================
int TypeID;
};
struct TObjectType {
const char *Name;
const char *Description;
uint8 Flags[9];
uint32 Attributes[62];
int AttributeOffsets[18];
};
int GetFlagByName(const char *Name);
int GetTypeAttributeByName(const char *Name);
int GetInstanceAttributeByName(const char *Name);
const char *GetFlagName(int Flag);
const char *GetTypeAttributeName(int Attribute);
const char *GetInstanceAttributeName(int Attribute);
bool ObjectTypeExists(int TypeID);
bool ObjectTypeExists(uint8 Group, uint8 Number);
ObjectType GetNewObjectType(uint8 Group, uint8 Number);
void GetOldObjectType(ObjectType Type, uint8 *Group, uint8 *Number);
ObjectType GetSpecialObject(SPECIALMEANING Meaning);
ObjectType GetObjectTypeByName(const char *SearchName, bool Movable);
void InitObjects(void);
void ExitObjects(void);
#endif //TIBIA_OBJECTS_HH_
|