tibia-client/src/otclient/core/item.cpp

72 lines
1.7 KiB
C++
Raw Normal View History

2011-08-15 16:11:24 +02:00
#include "item.h"
2011-08-15 21:15:49 +02:00
#include "datmanager.h"
#include "spritemanager.h"
2011-08-15 16:11:24 +02:00
#include "thing.h"
2011-08-25 15:30:46 +02:00
#include <framework/platform/platform.h>
2011-08-15 16:11:24 +02:00
2011-08-15 23:02:52 +02:00
Item::Item() : Thing(THING_ITEM)
2011-08-15 16:11:24 +02:00
{
2011-08-15 23:02:52 +02:00
m_count = 0;
2011-08-25 15:30:46 +02:00
m_lastTicks = g_platform.getTicks();
m_animation = 0;
2011-08-15 16:11:24 +02:00
}
void Item::draw(int x, int y)
{
2011-08-15 23:02:52 +02:00
const ThingAttributes& attributes = g_dat.getItemAttributes(m_id);
2011-08-25 15:30:46 +02:00
int xdiv = 0, ydiv = 0, zdiv = 0;
2011-08-15 16:11:24 +02:00
2011-08-25 15:30:46 +02:00
if(attributes.animcount > 1) {
if(g_platform.getTicks() - m_lastTicks > 500) {
if(m_animation+1 == attributes.animcount)
m_animation = 0;
else
m_animation++;
m_lastTicks = g_platform.getTicks();
}
}
2011-08-15 16:11:24 +02:00
2011-08-24 05:58:23 +02:00
if(attributes.group == THING_GROUP_SPLASH || attributes.group == THING_GROUP_FLUID) {
//xdiv = m_count % attributes.xdiv;
//ydiv = m_count / attributes.ydiv;
}
else if(attributes.stackable) {
if(m_count < 5) {
xdiv = m_count-1;
ydiv = 0;
}
else if(m_count < 10) {
xdiv = 0;
ydiv = 1;
}
else if(m_count < 25) {
xdiv = 1;
ydiv = 1;
}
else if(m_count < 50) {
xdiv = 2;
ydiv = 1;
}
else if(m_count <= 100) {
xdiv = 3;
ydiv = 1;
}
2011-08-15 16:11:24 +02:00
}
2011-08-15 21:15:49 +02:00
else if(!attributes.moveable) {
xdiv = m_position.x % attributes.xdiv;
ydiv = m_position.y % attributes.ydiv;
zdiv = m_position.z % attributes.zdiv;
2011-08-15 16:11:24 +02:00
}
2011-08-15 21:15:49 +02:00
for(int b = 0; b < attributes.blendframes; b++)
2011-08-25 15:30:46 +02:00
internalDraw(x, y, b, xdiv, ydiv, zdiv, m_animation);
2011-08-15 16:11:24 +02:00
}
2011-08-15 23:02:52 +02:00
const ThingAttributes& Item::getAttributes()
{
return g_dat.getItemAttributes(m_id);
}