addremove vip and look improvements

This commit is contained in:
Henrique Santiago
2012-01-04 12:30:28 -02:00
parent f16318e80a
commit a73908fbbe
11 changed files with 66 additions and 9 deletions

View File

@@ -235,10 +235,32 @@ void Game::talkPrivate(int channelType, const std::string& receiver, const std::
void Game::openOutfitWindow()
{
if(!m_online)
return;
m_protocolGame->sendGetOutfit();
}
void Game::setOutfit(const Outfit& outfit)
{
if(!m_online)
return;
m_protocolGame->sendSetOutfit(outfit);
}
void Game::addVip(const std::string& name)
{
if(!m_online || name.empty())
return;
m_protocolGame->sendAddVip(name);
}
void Game::removeVip(int playerId)
{
if(!m_online)
return;
m_protocolGame->sendRemoveVip(playerId);
}

View File

@@ -57,6 +57,8 @@ public:
void talkPrivate(int channelType, const std::string& receiver, const std::string& message);
void openOutfitWindow();
void setOutfit(const Outfit& outfit);
void addVip(const std::string& name);
void removeVip(int playerId);
int getThingStackpos(const ThingPtr& thing);
bool isOnline() { return m_online; }

View File

@@ -288,6 +288,24 @@ bool Tile::isLookPossible()
return true;
}
bool Tile::isClickable()
{
bool hasGround = false, hasOnBottom = false, hasIgnoreLook = false;
for(const ThingPtr& thing : m_things) {
ThingType *type = thing->getType();
if(type->properties[ThingType::IsGround])
hasGround = true;
if(type->properties[ThingType::IsOnBottom])
hasOnBottom = true;
if(type->properties[ThingType::IgnoreLook])
hasIgnoreLook = true;
if((hasGround || hasOnBottom) && !hasIgnoreLook)
return true;
}
return false;
}
bool Tile::hasCreature()
{
for(const ThingPtr& thing : m_things)

View File

@@ -59,8 +59,7 @@ public:
bool isLookPossible();
bool hasCreature();
bool isEmpty();
void useItem();
bool isClickable();
TilePtr asTile() { return std::static_pointer_cast<Tile>(shared_from_this()); }

View File

@@ -69,6 +69,8 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("attack", std::bind(&Game::attack, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("follow", std::bind(&Game::follow, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("rotate", std::bind(&Game::rotate, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("addVip", std::bind(&Game::addVip, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("removeVip", std::bind(&Game::removeVip, &g_game, _1));
g_lua.registerClass<UIItem, UIWidget>();
g_lua.bindClassStaticFunction<UIItem>("create", &UIItem::create<UIItem>);

View File

@@ -96,7 +96,7 @@ public:
void sendGetOutfit();
void sendSetOutfit(const Outfit& outfit);
void sendAddVip(const std::string& name);
void sendRemoveVip(int id);
void sendRemoveVip(int playerId);
void sendGetQuestLog();
void sendGetQuestLine(int questId);

View File

@@ -555,11 +555,11 @@ void ProtocolGame::sendAddVip(const std::string& name)
send(oMsg);
}
void ProtocolGame::sendRemoveVip(int id)
void ProtocolGame::sendRemoveVip(int playerId)
{
OutputMessage oMsg;
oMsg.addU8(Otc::ClientRemoveBuddy);
oMsg.addU32(id);
oMsg.addU32(playerId);
send(oMsg);
}

View File

@@ -74,17 +74,19 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
// Get tile
TilePtr tile = nullptr;
// We must check every floor, from top to bottom
// We must check every floor, from top to bottom to check for a clickable tile
int firstFloor = g_map.getFirstVisibleFloor();
tilePos.perspectiveUp(tilePos.z - firstFloor);
for(int i = firstFloor; i <= Map::MAX_Z; i++) {
tile = g_map.getTile(tilePos);
if(tile && !tile->isEmpty() && tile->getGround())
if(tile && tile->isClickable())
break;
tilePos.coveredDown();
}
if(!tile || tile->isEmpty())
// todo: get creature, using walkOffset etc.
if(!tile || !tile->isClickable())
return true;
if(button == Fw::MouseLeftButton) {