skulls, shields and emblems are now rendered, thanks to joao

This commit is contained in:
Henrique Santiago 2012-01-06 21:54:17 -02:00
parent cd0d2cb642
commit 14c517d7a6
23 changed files with 166 additions and 6 deletions

75
modules/game/creature.lua Normal file
View File

@ -0,0 +1,75 @@
SkullNone = 0
SkullYellow = 1
SkullGreen = 2
SkullWhite = 3
SkullRed = 4
SkullBlack = 5
SkullOrange = 6
ShieldNone = 0
ShieldWhiteYellow = 1
ShieldWhiteBlue = 2
ShieldBlue = 3
ShieldYellow = 4
ShieldBlueSharedExp = 5
ShieldYellowSharedExp = 6
ShieldBlueNoSharedExpBlink = 7
ShieldYellowNoSharedExpBlink = 8
ShieldBlueNoSharedExp = 9
ShieldYellowNoSharedExp = 10
EmblemNone = 0
EmblemGreen = 1
EmblemRed = 2
EmblemBlue = 3
function Creature:onSkullChange(skullId)
if skullId == SkullYellow then
self:setSkullTexture(resolvepath('images/skull_yellow.png'))
elseif skullId == SkullGreen then
self:setSkullTexture(resolvepath('images/skull_green.png'))
elseif skullId == SkullWhite then
self:setSkullTexture(resolvepath('images/skull_white.png'))
elseif skullId == SkullRed then
self:setSkullTexture(resolvepath('images/skull_red.png'))
elseif skullId == SkullBlack then
self:setSkullTexture(resolvepath('images/skull_black.png'))
elseif skullId == SkullOrange then
self:setSkullTexture(resolvepath('images/skull_orange.png'))
end
end
function Creature:onShieldChange(shieldId)
if shieldId == ShieldWhiteYellow then
self:setShieldTexture(resolvepath('images/shield_yellow_white.png'))
elseif shieldId == ShieldWhiteBlue then
self:setShieldTexture(resolvepath('images/shield_blue_white.png'))
elseif shieldId == ShieldBlue then
self:setShieldTexture(resolvepath('images/shield_blue.png'))
elseif shieldId == ShieldYellow then
self:setShieldTexture(resolvepath('images/shield_yellow.png'))
elseif shieldId == ShieldBlueSharedExp then
self:setShieldTexture(resolvepath('images/shield_blue_shared.png'))
elseif shieldId == ShieldYellowSharedExp then
self:setSkullTexture(resolvepath('images/shield_yellow_shared.png'))
elseif shieldId == ShieldBlueNoSharedExpBlink then
self:setSkullTexture(resolvepath('images/shield_blue_not_shared.png'))
elseif shieldId == ShieldYellowNoSharedExpBlink then
self:setSkullTexture(resolvepath('images/shield_yellow_not_shared.png'))
elseif shieldId == ShieldBlueNoSharedExp then
self:setSkullTexture(resolvepath('images/shield_blue_not_shared.png'))
elseif shieldId == ShieldYellowNoSharedExp then
self:setSkullTexture(resolvepath('images/shield_yellow_not_shared.png'))
end
end
function Creature:onEmblemChange(emblemId)
if emblemId == EmblemGreen then
self:setEmblemTexture(resolvepath('images/emblem_green.png'))
elseif emblemId == EmblemRed then
self:setEmblemTexture(resolvepath('images/emblem_red.png'))
elseif emblemId == EmblemBlue then
self:setEmblemTexture(resolvepath('images/emblem_blue.png'))
end
end

View File

@ -16,3 +16,4 @@ Module
onLoad: | onLoad: |
require 'game' require 'game'
require 'thing' require 'thing'
require 'creature'

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

View File

@ -368,6 +368,37 @@ namespace Otc
StandWhileFighting = 0, StandWhileFighting = 0,
ChaseOpponent = 1 ChaseOpponent = 1
}; };
enum PlayerSkulls {
SkullNone = 0,
SkullYellow = 1,
SkullGreen = 2,
SkullWhite = 3,
SkullRed = 4,
SkullBlack = 5,
SkullOrange = 6
};
enum PlayerShields {
ShieldNone = 0,
ShieldWhiteYellow = 1,
ShieldWhiteBlue = 2,
ShieldBlue = 3,
ShieldYellow = 4,
ShieldBlueSharedExp = 5,
ShieldYellowSharedExp = 6,
ShieldBlueNoSharedExpBlink = 7,
ShieldYellowNoSharedExpBlink = 8,
ShieldBlueNoSharedExp = 9,
ShieldYellowNoSharedExp = 10
};
enum PlayerEmblems {
EmblemNone = 0,
EmblemGreen = 1,
EmblemRed = 2,
EmblemBlue = 3
};
} }
#endif #endif

View File

@ -34,6 +34,7 @@
#include <framework/graphics/paintershaderprogram.h> #include <framework/graphics/paintershaderprogram.h>
#include <framework/graphics/paintershadersources.h> #include <framework/graphics/paintershadersources.h>
#include <framework/graphics/texturemanager.h>
#include "spritemanager.h" #include "spritemanager.h"
Creature::Creature() : Thing() Creature::Creature() : Thing()
@ -158,6 +159,19 @@ void Creature::drawInformation(int x, int y, bool useGray, const Rect& visibleRe
if(m_informationFont) if(m_informationFont)
m_informationFont->renderText(m_name, textRect, Fw::AlignTopCenter, fillColor); m_informationFont->renderText(m_name, textRect, Fw::AlignTopCenter, fillColor);
if(m_skull != Otc::SkullNone && m_skullTexture) {
g_painter.setColor(Fw::white);
g_painter.drawTexturedRect(Rect(x + 12, y + 5, m_skullTexture->getSize()), m_skullTexture);
}
if(m_shield != Otc::ShieldNone && m_shieldTexture) {
g_painter.setColor(Fw::white);
g_painter.drawTexturedRect(Rect(x, y + 5, m_shieldTexture->getSize()), m_shieldTexture);
}
if(m_emblem != Otc::EmblemNone && m_emblemTexture) {
g_painter.setColor(Fw::white);
g_painter.drawTexturedRect(Rect(x + 12, y + 16, m_emblemTexture->getSize()), m_emblemTexture);
}
} }
void Creature::walk(const Position& position, bool inverse) void Creature::walk(const Position& position, bool inverse)
@ -325,6 +339,40 @@ void Creature::setOutfit(const Outfit& outfit)
m_outfit.resetClothes(); m_outfit.resetClothes();
} }
void Creature::setSkull(uint8 skull)
{
m_skull = skull;
g_lua.callGlobalField("Creature","onSkullChange", asCreature(), m_skull);
}
void Creature::setShield(uint8 shield)
{
m_shield = shield;
g_lua.callGlobalField("Creature","onShieldChange", asCreature(), m_shield);
}
void Creature::setEmblem(uint8 emblem)
{
m_emblem = emblem;
g_lua.callGlobalField("Creature","onEmblemChange", asCreature(), m_emblem);
}
void Creature::setSkullTexture(const std::string& filename)
{
m_skullTexture = g_textures.getTexture(filename);
}
void Creature::setShieldTexture(const std::string& filename)
{
m_shieldTexture = g_textures.getTexture(filename);
}
void Creature::setEmblemTexture(const std::string& filename)
{
m_emblemTexture = g_textures.getTexture(filename);
}
void Creature::addVolatileSquare(uint8 color) void Creature::addVolatileSquare(uint8 color)
{ {
m_showVolatileSquare = true; m_showVolatileSquare = true;

View File

@ -46,9 +46,12 @@ public:
void setOutfit(const Outfit& outfit); void setOutfit(const Outfit& outfit);
void setLight(const Light& light) { m_light = light; } void setLight(const Light& light) { m_light = light; }
void setSpeed(uint16 speed) { m_speed = speed; } void setSpeed(uint16 speed) { m_speed = speed; }
void setSkull(uint8 skull) { m_skull = skull; } void setSkull(uint8 skull);
void setShield(uint8 shield) { m_shield = shield; } void setShield(uint8 shield);
void setEmblem(uint8 emblem) { m_emblem = emblem; } void setEmblem(uint8 emblem);
void setSkullTexture(const std::string& filename);
void setShieldTexture(const std::string& filename);
void setEmblemTexture(const std::string& filename);
void setPassable(bool passable) { m_passable = passable; } void setPassable(bool passable) { m_passable = passable; }
void addVolatileSquare(uint8 color); void addVolatileSquare(uint8 color);
@ -88,9 +91,8 @@ protected:
Outfit m_outfit; Outfit m_outfit;
Light m_light; Light m_light;
uint16 m_speed; uint16 m_speed;
uint8 m_skull; uint8 m_skull, m_shield, m_emblem;
uint8 m_shield; TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture;
uint8 m_emblem;
bool m_passable; bool m_passable;
Color m_volatileSquareColor, m_staticSquareColor; Color m_volatileSquareColor, m_staticSquareColor;
bool m_showVolatileSquare, m_showStaticSquare; bool m_showVolatileSquare, m_showStaticSquare;

View File

@ -80,6 +80,9 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName); g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
g_lua.bindClassMemberFunction<Creature>("setOutfit", &Creature::setOutfit); g_lua.bindClassMemberFunction<Creature>("setOutfit", &Creature::setOutfit);
g_lua.bindClassMemberFunction<Creature>("getOutfit", &Creature::getOutfit); g_lua.bindClassMemberFunction<Creature>("getOutfit", &Creature::getOutfit);
g_lua.bindClassMemberFunction<Creature>("setSkullTexture", &Creature::setSkullTexture);
g_lua.bindClassMemberFunction<Creature>("setShieldTexture", &Creature::setShieldTexture);
g_lua.bindClassMemberFunction<Creature>("setEmblemTexture", &Creature::setEmblemTexture);
g_lua.registerClass<Player, Creature>(); g_lua.registerClass<Player, Creature>();
g_lua.registerClass<LocalPlayer, Player>(); g_lua.registerClass<LocalPlayer, Player>();