Fix for creature lights.

* Will now load the dat values for creature lights (ed if you know a more conventional way for this please let me know).
* No need to draw light for the outfit the creature draw will handle it.
Note: not sure if the from8bit method should limit at 256 or not, but tibia dat contains colors 216+.
master
BeniS 12 years ago
parent b806b57628
commit 617e6b302b

@ -50,7 +50,7 @@ function g_game.getSupportedProtocols()
return { return {
810, 853, 854, 860, 861, 862, 870, 810, 853, 854, 860, 861, 862, 870,
910, 940, 944, 953, 954, 960, 961, 910, 940, 944, 953, 954, 960, 961,
963, 970 963, 970, 971
} }
end end

@ -71,7 +71,7 @@ public:
bool operator!=(const Color& other) const { return other.rgba() != rgba(); } bool operator!=(const Color& other) const { return other.rgba() != rgba(); }
static Color from8bit(int color) { static Color from8bit(int color) {
if(color >= 216 || color <= 0) if(color >= 256 || color <= 0)
return Color(0, 0, 0); return Color(0, 0, 0);
int r = int(color / 36) % 6 * 51; int r = int(color / 36) % 6 * 51;

@ -78,7 +78,7 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate, LightVie
g_painter->setColor(Color::white); g_painter->setColor(Color::white);
} }
internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction, lightView); internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction);
m_footStepDrawn = true; m_footStepDrawn = true;
if(lightView) { if(lightView) {

@ -30,11 +30,11 @@
LightView::LightView() LightView::LightView()
{ {
m_lightbuffer = g_framebuffers.createFrameBuffer(); m_lightbuffer = g_framebuffers.createFrameBuffer();
generateLightBuble(); generateLightBubble();
reset(); reset();
} }
void LightView::generateLightBuble() void LightView::generateLightBubble()
{ {
m_lightRadius = 128; m_lightRadius = 128;
int circleDiameter = m_lightRadius * 2; int circleDiameter = m_lightRadius * 2;

@ -47,7 +47,7 @@ public:
private: private:
void drawGlobalLight(const Light& light); void drawGlobalLight(const Light& light);
void drawLightSource(const Point& center, const Color& color, int radius); void drawLightSource(const Point& center, const Color& color, int radius);
void generateLightBuble(); void generateLightBubble();
TexturePtr m_lightTexture; TexturePtr m_lightTexture;
int m_lightRadius; int m_lightRadius;

@ -1638,13 +1638,23 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
creature->setHealthPercent(healthPercent); creature->setHealthPercent(healthPercent);
creature->setDirection(direction); creature->setDirection(direction);
creature->setOutfit(outfit); creature->setOutfit(outfit);
creature->setLight(light);
creature->setSpeed(speed); creature->setSpeed(speed);
creature->setSkull(skull); creature->setSkull(skull);
creature->setShield(shield); creature->setShield(shield);
creature->setPassable(!unpass);
if(emblem != -1) if(emblem != -1)
creature->setEmblem(emblem); creature->setEmblem(emblem);
creature->setPassable(!unpass);
ThingTypePtr thing = creature->getThingType();
if(thing) {
Light newLight = thing->getLight();
if(light.color > 0 && light.color != 215)
newLight.color = light.color;
if(light.intensity > 0)
newLight.intensity = light.intensity;
creature->setLight(newLight);
}
if(creature == m_localPlayer && !m_localPlayer->isKnown()) if(creature == m_localPlayer && !m_localPlayer->isKnown())
m_localPlayer->setKnown(true); m_localPlayer->setKnown(true);

Loading…
Cancel
Save