creature distinction, look, remove textmessage bug
This commit is contained in:
parent
88f36b0455
commit
1ca825a4b6
|
@ -30,8 +30,9 @@ function TextMessage.create()
|
|||
end
|
||||
|
||||
-- hooked events
|
||||
function Game.onTextMessage(type, message)
|
||||
function TextMessage.onTextMessage(type, message)
|
||||
local messageType = messageTypes[type - messageTypes.first]
|
||||
print(messageType.color)
|
||||
|
||||
if messageType.showOnConsole then
|
||||
-- TODO
|
||||
|
@ -46,9 +47,9 @@ function Game.onTextMessage(type, message)
|
|||
end
|
||||
|
||||
label:setVisible(true)
|
||||
label:setForegroundColor(messageType.color)
|
||||
label:setText(message)
|
||||
label:setStyle(messageType.windowLocation)
|
||||
label:setForegroundColor(messageType.color)
|
||||
|
||||
time = #message * 75
|
||||
removeEvent(hideEvent)
|
||||
|
@ -60,4 +61,5 @@ end
|
|||
|
||||
|
||||
connect(Game, { onLogin = TextMessage.create,
|
||||
onLogout = TextMessage.destroy })
|
||||
onLogout = TextMessage.destroy,
|
||||
onTextMessage = TextMessage.onTextMessage })
|
||||
|
|
|
@ -349,6 +349,14 @@ namespace Otc
|
|||
SpeakMonsterYell = 0x0E //Yell orange
|
||||
};
|
||||
|
||||
enum CreaturesIdRange {
|
||||
PlayerStartId = 0x10000000,
|
||||
PlayerEndId = 0x40000000,
|
||||
MonsterStartId = 0x40000000,
|
||||
MonsterEndId = 0x80000000,
|
||||
NpcStartId = 0x80000000,
|
||||
NpcEndId = 0xffffffff
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "game.h"
|
||||
#include "localplayer.h"
|
||||
#include "map.h"
|
||||
#include "tile.h"
|
||||
#include <otclient/net/protocolgame.h>
|
||||
#include <framework/core/eventdispatcher.h>
|
||||
|
||||
|
@ -154,6 +156,17 @@ void Game::turn(Otc::Direction direction)
|
|||
}
|
||||
}
|
||||
|
||||
void Game::look(const Position& position)
|
||||
{
|
||||
const TilePtr& tile = g_map.getTile(position);
|
||||
if(tile) {
|
||||
int stackpos = tile->getLookStackpos();
|
||||
ThingPtr thing = tile->getThing(stackpos);
|
||||
if(thing)
|
||||
m_protocolGame->sendLookAt(position, thing->getId(), stackpos);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::talkChannel(int channelType, int channelId, const std::string& message)
|
||||
{
|
||||
if(!m_online)
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
void walk(Otc::Direction direction);
|
||||
void turn(Otc::Direction direction);
|
||||
void look(const Position& position);
|
||||
void talkChannel(int channelType, int channelId, const std::string& message);
|
||||
void talkPrivate(int channelType, const std::string& receiver, const std::string& message);
|
||||
void openOutfitWindow();
|
||||
|
|
|
@ -181,6 +181,14 @@ ItemPtr Tile::getGround()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int Tile::getLookStackpos()
|
||||
{
|
||||
// TODO: this needs to be improved
|
||||
// check if thing has look property.
|
||||
// check other floors
|
||||
return m_things.size() - 1;
|
||||
}
|
||||
|
||||
bool Tile::isWalkable()
|
||||
{
|
||||
if(!getGround())
|
||||
|
@ -257,11 +265,6 @@ bool Tile::canCopyName()
|
|||
// TODO:
|
||||
/*
|
||||
|
||||
//Ranges for ID Creatures
|
||||
#define PLAYER_ID_RANGE 0x10000000
|
||||
#define MONSTER_ID_RANGE 0x40000000
|
||||
#define NPC_ID_RANGE 0x80000000
|
||||
|
||||
Get menu options
|
||||
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
int getDrawElevation() { return m_drawElevation; }
|
||||
std::vector<CreaturePtr> getCreatures();
|
||||
ItemPtr getGround();
|
||||
int getLookStackpos();
|
||||
bool isWalkable();
|
||||
bool isFullGround();
|
||||
bool isFullyOpaque();
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
void sendTurnSouth();
|
||||
void sendTurnWest();
|
||||
void sendUseItem(const Position& position, int itemId, int stackpos, int index);
|
||||
void sendLookAt(const Position& position, int thingId, int stackpos);
|
||||
void sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message);
|
||||
void sendGetOutfit();
|
||||
void sendSetOutfit(const Outfit& outfit);
|
||||
|
|
|
@ -1062,7 +1062,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
|||
|
||||
uint16 thingId = msg.getU16();
|
||||
if(thingId == 0x0061 || thingId == 0x0062) { // add new creature
|
||||
CreaturePtr creature = CreaturePtr(new Creature);
|
||||
CreaturePtr creature;
|
||||
|
||||
if(thingId == 0x0062) { //creature is known
|
||||
uint32 id = msg.getU32();
|
||||
|
@ -1070,19 +1070,29 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
|||
CreaturePtr knownCreature = g_map.getCreatureById(id);
|
||||
if(knownCreature)
|
||||
creature = knownCreature;
|
||||
else
|
||||
logFatal("Server says creature is known, but its not on creatures list.");
|
||||
}
|
||||
else if(thingId == 0x0061) { //creature is not known
|
||||
uint32 removeId = msg.getU32();
|
||||
uint32 id = msg.getU32();
|
||||
std::string name = msg.getString();
|
||||
|
||||
if(name.length() > 0) // every creature name must have a capital letter
|
||||
if(name.length() > 0) // every creature name must start with a capital letter
|
||||
name[0] = toupper(name[0]);
|
||||
|
||||
g_map.removeCreatureById(removeId);
|
||||
|
||||
if(m_localPlayer->getId() == id)
|
||||
if(id == m_localPlayer->getId())
|
||||
creature = m_localPlayer->asCreature();
|
||||
else if(id >= Otc::PlayerStartId && id < Otc::PlayerEndId)
|
||||
creature = PlayerPtr(new Player)->asCreature();
|
||||
else if(id >= Otc::MonsterStartId && id < Otc::MonsterEndId)
|
||||
creature = CreaturePtr(new Creature);
|
||||
else if(id >= Otc::NpcStartId && id < Otc::NpcEndId)
|
||||
creature = CreaturePtr(new Creature);
|
||||
else
|
||||
logFatal("creature id is invalid");
|
||||
|
||||
creature->setId(id);
|
||||
creature->setName(name);
|
||||
|
|
|
@ -168,6 +168,16 @@ void ProtocolGame::sendUseItem(const Position& position, int itemId, int stackpo
|
|||
send(oMsg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendLookAt(const Position& position, int thingId, int stackpos)
|
||||
{
|
||||
OutputMessage oMsg;
|
||||
oMsg.addU8(Otc::ClientLook);
|
||||
addPosition(oMsg, position);
|
||||
oMsg.addU16(thingId);
|
||||
oMsg.addU8(stackpos);
|
||||
send(oMsg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& receiver, const std::string& message)
|
||||
{
|
||||
if(message.length() > 255 || message.length() <= 0)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "uimap.h"
|
||||
#include <otclient/core/game.h>
|
||||
#include <otclient/core/map.h>
|
||||
#include <framework/otml/otml.h>
|
||||
#include <framework/graphics/graphics.h>
|
||||
|
@ -95,6 +96,8 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
|||
animatedText->setColor(12);
|
||||
animatedText->setText("8");
|
||||
g_map.addThing(animatedText, g_map.getCentralPosition());
|
||||
|
||||
g_game.look(tilePos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue