Yamaken
Pro OpenTibia Developer
- Joined
- Jul 27, 2013
- Messages
- 534
- Solutions
- 4
- Reaction score
- 432
Well i have only dedicated few hours to this and i'm not willing to spend more to make it more performance wise.
Inside map.cpp:
replace
with this:
on item.h:
after:
add:
after:
add:
inside item.cpp:
replace this:
with this:
find Item::draw, inside Item::draw:
After this:
add:
add at the item.cpp file end:
change 2128 to magic wall client id.
As said, its a hack but at least it works.
Result:
Inside map.cpp:
replace
Code:
void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
{
if(!thing)
return;
if(thing->isItem() || thing->isCreature() || thing->isEffect()) {
const TilePtr& tile = getOrCreateTile(pos);
if(tile)
tile->addThing(thing, stackPos);
Code:
void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
{
if(!thing)
return;
if(thing->isItem() || thing->isCreature() || thing->isEffect()) {
const TilePtr& tile = getOrCreateTile(pos);
if (tile) {
tile->addThing(thing, stackPos);
if (thing->isItem()) {
thing->static_self_cast<Item>()->mwTimer();
}
}
on item.h:
after:
Code:
ThingType *rawGetThingType();
Code:
void mwTimer();
after:
Code:
ticks_t m_lastPhase;
Code:
Timer m_mwAnimationTimer;
uint16_t m_mwTime;
BitmapFontPtr m_mwFont;
bool m_isMW;
inside item.cpp:
replace this:
Code:
Item::Item() :
m_clientId(0),
m_serverId(0),
m_countOrSubType(1),
m_color(Color::alpha),
m_async(true),
m_phase(0),
m_lastPhase(0)
with this:
Code:
Item::Item() :
m_clientId(0),
m_serverId(0),
m_countOrSubType(1),
m_color(Color::alpha),
m_async(true),
m_phase(0),
m_lastPhase(0),
m_isMW(false)
find Item::draw, inside Item::draw:
After this:
Code:
rawGetThingType()->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase, lightView);
add:
Code:
if (m_isMW) {
std::string text = stdext::to_string(static_cast<float>(m_mwTime - m_mwAnimationTimer.ticksElapsed()) / 1000);
g_painter->setColor(Color::white);
m_mwFont->drawText(text, Rect(dest.x - 20, dest.y - 12, 20, 20));
}
add at the item.cpp file end:
Code:
void Item::mwTimer()
{
if (m_clientId == 2128) {
m_mwAnimationTimer.restart();
m_mwTime = 20000;
m_isMW = true;
m_mwFont = g_fonts.getFont("verdana-11px-rounded");
}
}
change 2128 to magic wall client id.
As said, its a hack but at least it works.
Result:
Last edited: