Hi.I Am New to C++ and learned few basics and started to go in programming in open tibia.i want to release my first system that i made it.
Warning:If You are Using 0.3.6 add all this except the one with * And Then Add This
http://otland.net/threads/durability-system.202358/#post-1945197
-----
Open items.h
Find
Replace
Open item.h
find:
Add After It(Don't Forget The Comma)
Find
Add After It
Find
Add After It
*******
If You are Using 0.3.6 Don't Add This
Open Item.cpp
Find
Add After It
******
If You are Using 0.3.6 Don't Add This
Find
Add After It
Open items.cpp
Find
Add After It
Find
Add After It
Luascript.cpp
Find
Add This After It
*******
If You are Using 0.3.6 Don't Add This
Find
add This After It
********
If You are Using 0.3.6 Don't Add This
luascript.h
Find
Add This After It
ScreenShot:
Compile and Done.Tested on 0.3.7 if you are using 0.4 you will have to change few things
Next System will be Price:x$
How It Work
You Add This Code in items.xml
Durability Can't Be Higher Than 100
And Use the Lua Script Here
You Add This Code in items.xml
Code:
<attribute key="durability" value="100"/>
And Use the Lua Script Here
Warning:If You are Using 0.3.6 add all this except the one with * And Then Add This
http://otland.net/threads/durability-system.202358/#post-1945197
-----
Open items.h
Find
Code:
int32_t attack, criticalHitChance, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder;
Replace
Code:
int32_t attack, criticalHitChance, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder, durability;
Open item.h
find:
Code:
ATTR_SCRIPTPROTECTED = 42,
Add After It(Don't Forget The Comma)
Code:
ATTR_DURABILITY = 43
Find
Code:
int32_t getAttack() const;
Add After It
Code:
int32_t getDurability() const;
Find
Code:
inline int32_t Item::getExtraAttack() const
{
bool ok;
int32_t v = getIntegerAttribute("extraattack", ok);
if(ok)
return v;
return items[id].extraAttack;
}
Add After It
*******
If You are Using 0.3.6 Don't Add This
Code:
inline int32_t Item::getDurability() const
{
bool ok;
int32_t v = getIntegerAttribute("durability", ok);
if(ok)
return v;
return items[id].durability;
}
Open Item.cpp
Find
Code:
case ATTR_EXTRAATTACK:
{
int32_t attack;
if(!propStream.getLong((uint32_t&)attack))
return ATTR_READ_ERROR;
setAttribute("extraattack", attack);
break;
}
Add After It
******
If You are Using 0.3.6 Don't Add This
Code:
case ATTR_DURABILITY:
{
int32_t durability;
if(!propStream.getLong((uint32_t&)durability))
return ATTR_READ_ERROR;
setAttribute("durability", durability);
break;
}
Find
Code:
if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense())))
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "Def:" << int32_t(item ? item->getDefense() : it.defense);
if(it.extraDefense || (item && item->getExtraDefense()))
s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos;
}
}
Add After It
Code:
if(it.durability || (item && item->getDurability()))
{
if(begin)
{
begin = false;
s << " (";
}
else
s << ", ";
s << "Durability:" << int32_t(item ? item->getDurability() : it.durability) << "/100"<< std::noshowpos;
}
Find
Code:
Armor = 0;
Code:
durability = 0;
Find
Code:
else if(tmpStrValue == "weight")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.weight = intValue / 100.f;
}
Add After It
Code:
else if(tmpStrValue == "durability")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.durability = intValue;
}
Luascript.cpp
Find
Code:
int32_t LuaInterface::luaDoCleanHouse(lua_State* L)
{
//doCleanHouse(houseId)
uint32_t houseId = popNumber(L);
if(House* house = Houses::getInstance()->getHouse(houseId))
{
house->clean();
lua_pushboolean(L, true);
}
else
lua_pushboolean(L, false);
return 1;
}
Add This After It
*******
If You are Using 0.3.6 Don't Add This
Code:
int32_t LuaInterface::luaGetItemDurability(lua_State* L)
{
ScriptEnviroment* env = getEnv();
Item* item = env->getItemByUID(popNumber(L));
if(!item)
{
lua_pushboolean(L, false);
errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
return 1;
}
lua_pushnumber(L, item->getDurability());
return 1;
}
Find
Code:
//getTownId(townName)
lua_register(m_luaState, "getTownId", LuaInterface::luaGetTownId);
add This After It
********
If You are Using 0.3.6 Don't Add This
Code:
//getItemDurability(uid, durability)
lua_register(m_luaState, "getItemDurability", LuaInterface::luaGetItemDurability);
luascript.h
Find
Code:
static int32_t luaDoCreatureSetSpeakType(lua_State* L);
Add This After It
Code:
static int32_t luaGetItemDurability(lua_State* L);
ScreenShot:
Compile and Done.Tested on 0.3.7 if you are using 0.4 you will have to change few things
Next System will be Price:x$
Last edited: