Add creature type icons for summons

This commit is contained in:
Kamil Chojnowski 2017-11-19 02:37:41 +01:00
parent 81a705096a
commit 3b23b787f3
8 changed files with 65 additions and 6 deletions

View File

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 283 B

View File

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 283 B

View File

@ -33,6 +33,12 @@ NpcIconTrade = 2
NpcIconQuest = 3
NpcIconTradeQuest = 4
CreatureTypePlayer = 0
CreatureTypeMonster = 1
CreatureTypeNpc = 2
CreatureTypeSummonOwn = 3
CreatureTypeSummonOther = 4
-- @}
function getNextSkullId(skullId)
@ -104,6 +110,16 @@ function getEmblemImagePath(emblemId)
return path
end
function getTypeImagePath(creatureType)
local path
if creatureType == CreatureTypeSummonOwn then
path = '/images/game/creaturetype/summon_own'
elseif creatureType == CreatureTypeSummonOther then
path = '/images/game/creaturetype/summon_other'
end
return path
end
function getIconImagePath(iconId)
local path
if iconId == NpcIconChat then
@ -139,9 +155,16 @@ function Creature:onEmblemChange(emblemId)
end
end
function Creature:onTypeChange(typeId)
local imagePath = getTypeImagePath(typeId)
if imagePath then
self:setTypeTexture(imagePath)
end
end
function Creature:onIconChange(iconId)
local imagePath = getIconImagePath(iconId)
if imagePath then
self:setIconTexture(imagePath)
end
end
end

View File

@ -53,6 +53,7 @@ Creature::Creature() : Thing()
m_skull = Otc::SkullNone;
m_shield = Otc::ShieldNone;
m_emblem = Otc::EmblemNone;
m_type = Proto::CreatureTypeUnknown;
m_icon = Otc::NpcIconNone;
m_lastStepDirection = Otc::InvalidDirection;
m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
@ -309,6 +310,11 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
}
if(m_type != Proto::CreatureTypeUnknown && m_typeTexture) {
g_painter->setColor(Color::white);
Rect typeRect = Rect(backgroundRect.x() + 13.5 + 12 + 12, backgroundRect.y() + 16, m_typeTexture->getSize());
g_painter->drawTexturedRect(typeRect, m_typeTexture);
}
if(m_icon != Otc::NpcIconNone && m_iconTexture) {
g_painter->setColor(Color::white);
Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
@ -745,6 +751,12 @@ void Creature::setEmblem(uint8 emblem)
callLuaField("onEmblemChange", m_emblem);
}
void Creature::setType(uint8 type)
{
m_type = type;
callLuaField("onTypeChange", m_type);
}
void Creature::setIcon(uint8 icon)
{
m_icon = icon;
@ -776,12 +788,16 @@ void Creature::setEmblemTexture(const std::string& filename)
m_emblemTexture = g_textures.getTexture(filename);
}
void Creature::setTypeTexture(const std::string& filename)
{
m_typeTexture = g_textures.getTexture(filename);
}
void Creature::setIconTexture(const std::string& filename)
{
m_iconTexture = g_textures.getTexture(filename);
}
void Creature::setSpeedFormula(double speedA, double speedB, double speedC)
{
m_speedFormula[Otc::SpeedFormulaA] = speedA;

View File

@ -62,10 +62,12 @@ public:
void setSkull(uint8 skull);
void setShield(uint8 shield);
void setEmblem(uint8 emblem);
void setType(uint8 type);
void setIcon(uint8 icon);
void setSkullTexture(const std::string& filename);
void setShieldTexture(const std::string& filename, bool blink);
void setEmblemTexture(const std::string& filename);
void setTypeTexture(const std::string& filename);
void setIconTexture(const std::string& filename);
void setPassable(bool passable) { m_passable = passable; }
void setSpeedFormula(double speedA, double speedB, double speedC);
@ -87,6 +89,7 @@ public:
uint8 getSkull() { return m_skull; }
uint8 getShield() { return m_shield; }
uint8 getEmblem() { return m_emblem; }
uint8 getType() { return m_type; }
uint8 getIcon() { return m_icon; }
bool isPassable() { return m_passable; }
Point getDrawOffset();
@ -153,10 +156,12 @@ protected:
uint8 m_skull;
uint8 m_shield;
uint8 m_emblem;
uint8 m_type;
uint8 m_icon;
TexturePtr m_skullTexture;
TexturePtr m_shieldTexture;
TexturePtr m_emblemTexture;
TexturePtr m_typeTexture;
TexturePtr m_iconTexture;
stdext::boolean<true> m_showShieldTexture;
stdext::boolean<false> m_shieldBlink;

View File

@ -456,6 +456,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("getSkull", &Creature::getSkull);
g_lua.bindClassMemberFunction<Creature>("getShield", &Creature::getShield);
g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem);
g_lua.bindClassMemberFunction<Creature>("getType", &Creature::getType);
g_lua.bindClassMemberFunction<Creature>("getIcon", &Creature::getIcon);
g_lua.bindClassMemberFunction<Creature>("setOutfit", &Creature::setOutfit);
g_lua.bindClassMemberFunction<Creature>("getOutfit", &Creature::getOutfit);
@ -469,6 +470,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("setSkullTexture", &Creature::setSkullTexture);
g_lua.bindClassMemberFunction<Creature>("setShieldTexture", &Creature::setShieldTexture);
g_lua.bindClassMemberFunction<Creature>("setEmblemTexture", &Creature::setEmblemTexture);
g_lua.bindClassMemberFunction<Creature>("setTypeTexture", &Creature::setTypeTexture);
g_lua.bindClassMemberFunction<Creature>("setIconTexture", &Creature::setIconTexture);
g_lua.bindClassMemberFunction<Creature>("showStaticSquare", &Creature::showStaticSquare);
g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare);

View File

@ -278,7 +278,8 @@ namespace Proto {
CreatureTypeMonster,
CreatureTypeNpc,
CreatureTypeSummonOwn,
CreatureTypeSummonOther
CreatureTypeSummonOther,
CreatureTypeUnknown = 0xFF
};
enum CreaturesIdRange {

View File

@ -2031,6 +2031,12 @@ void ProtocolGame::parseCreatureType(const InputMessagePtr& msg)
{
uint32 id = msg->getU32();
uint8 type = msg->getU8();
CreaturePtr creature = g_map.getCreatureById(id);
if(creature)
creature->setType(type);
else
g_logger.traceError("could not get creature");
}
void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height)
@ -2262,8 +2268,9 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
int shield = msg->getU8();
// emblem is sent only when the creature is not known
int emblem = -1;
int icon = -1;
int8 emblem = -1;
int8 creatureType = -1;
int8 icon = -1;
bool unpass = true;
uint8 mark;
@ -2271,7 +2278,7 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
emblem = msg->getU8();
if(g_game.getFeature(Otc::GameThingMarks)) {
msg->getU8(); // creature type for summons
creatureType = msg->getU8();
}
if(g_game.getFeature(Otc::GameCreatureIcons)) {
@ -2302,8 +2309,13 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
creature->setShield(shield);
creature->setPassable(!unpass);
creature->setLight(light);
if(emblem != -1)
creature->setEmblem(emblem);
if(creatureType != -1)
creature->setType(creatureType);
if(icon != -1)
creature->setIcon(icon);