implement more chat...

This commit is contained in:
Eduardo Bart
2012-01-14 03:54:20 -02:00
parent 61aa710d1c
commit c6013dfeda
4 changed files with 81 additions and 47 deletions

View File

@@ -153,7 +153,7 @@ void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldP
}
*/
if(!m_walkFeedback && creature == m_localPlayer) {
updatePing();
updateWalkPing();
m_walkFeedback = true;
}
creature->walk(newPos);
@@ -168,7 +168,7 @@ void Game::processAttackCancel()
void Game::processWalkCancel(Otc::Direction direction)
{
if(!m_walkFeedback) {
updatePing();
updateWalkPing();
m_walkFeedback = true;
}
m_localPlayer->cancelWalk(direction, true);
@@ -280,6 +280,14 @@ void Game::useWith(const ThingPtr& fromThing, const ThingPtr& toThing)
m_protocolGame->sendUseItemEx(fromThing->getPos(), fromThing->getId(), fromStackpos, toThing->getPos(), toThing->getId(), toStackpos);
}
void Game::useHotkey(int itemId, const ThingPtr& toThing)
{
if(!m_online || !toThing || !checkBotProtection())
return;
m_protocolGame->sendUseItemEx(Position(0xFFFF, 0, 0), itemId, 0, toThing->getPos(), toThing->getId(), getThingStackpos(toThing));
}
void Game::attack(const CreaturePtr& creature)
{
if(!m_online || !creature || !checkBotProtection())
@@ -347,7 +355,6 @@ void Game::talkChannel(const std::string& speakTypeDesc, int channelId, const st
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendTalk(speakTypeDesc, channelId, "", message);
}
@@ -355,15 +362,42 @@ void Game::talkPrivate(const std::string& speakTypeDesc, const std::string& rece
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendTalk(speakTypeDesc, 0, receiver, message);
}
void Game::requestChannels()
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendGetChannels();
}
void Game::joinChannel(int channelId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendJoinChannel(channelId);
}
void Game::leaveChannel(int channelId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendLeaveChannel(channelId);
}
void Game::closeNpcChannel()
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendCloseNpcChannel();
}
void Game::partyInvite(int creatureId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendInviteToParty(creatureId);
}
@@ -371,7 +405,6 @@ void Game::partyJoin(int creatureId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendJoinParty(creatureId);
}
@@ -379,7 +412,6 @@ void Game::partyRevokeInvitation(int creatureId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendRevokeInvitation(creatureId);
}
@@ -388,7 +420,6 @@ void Game::partyPassLeadership(int creatureId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendPassLeadership(creatureId);
}
@@ -396,7 +427,6 @@ void Game::partyLeave()
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendLeaveParty();
}
@@ -404,7 +434,6 @@ void Game::partyShareExperience(bool active)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendShareExperience(active, 0);
}
@@ -412,31 +441,13 @@ void Game::requestOutfit()
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendGetOutfit();
}
void Game::requestChannels()
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendGetChannels();
}
void Game::openChannel(int channelId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendOpenChannel(channelId);
}
void Game::setOutfit(const Outfit& outfit)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendSetOutfit(outfit);
}
@@ -444,7 +455,6 @@ void Game::addVip(const std::string& name)
{
if(!m_online || name.empty() || !checkBotProtection())
return;
m_protocolGame->sendAddVip(name);
}
@@ -452,7 +462,6 @@ void Game::removeVip(int playerId)
{
if(!m_online || !checkBotProtection())
return;
m_protocolGame->sendRemoveVip(playerId);
}
@@ -467,7 +476,7 @@ bool Game::checkBotProtection()
return true;
}
void Game::updatePing()
void Game::updateWalkPing()
{
m_walkPing = m_walkPingTimer.ticksElapsed();
g_lua.callGlobalField("Game", "onWalkPingUpdate", m_walkPing);

View File

@@ -54,32 +54,49 @@ public:
void processAttackCancel();
void processWalkCancel(Otc::Direction direction);
// walk related
void walk(Otc::Direction direction);
void turn(Otc::Direction direction);
// item related
void look(const ThingPtr& thing);
void open(const ThingPtr& thing, int containerId);
void use(const ThingPtr& thing);
void useWith(const ThingPtr& fromThing, const ThingPtr& toThing);
void useHotkey(int itemId, const ThingPtr& toThing);
// attack/follow related
void attack(const CreaturePtr& creature);
void cancelAttack();
void follow(const CreaturePtr& creature);
void cancelFollow();
void rotate(const ThingPtr& thing);
// talk related
void talk(const std::string& message);
void talkChannel(const std::string& speakTypeDesc, int channelId, const std::string& message);
void talkPrivate(const std::string& speakTypeDesc, const std::string& receiver, const std::string& message);
void requestChannels();
void joinChannel(int channelId);
void leaveChannel(int channelId);
void closeNpcChannel();
// party related
void partyInvite(int creatureId);
void partyJoin(int creatureId);
void partyRevokeInvitation(int creatureId);
void partyPassLeadership(int creatureId);
void partyLeave();
void partyShareExperience(bool active);
// outfit related
void requestOutfit();
void requestChannels();
void openChannel(int channelId);
void setOutfit(const Outfit& outfit);
// vip related
void addVip(const std::string& name);
void removeVip(int playerId);
int getThingStackpos(const ThingPtr& thing);
bool checkBotProtection();
@@ -99,7 +116,7 @@ public:
int getWalkPing() { return m_walkPing; }
private:
void updatePing();
void updateWalkPing();
LocalPlayerPtr m_localPlayer;
ProtocolGamePtr m_protocolGame;

View File

@@ -180,7 +180,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("isOnline", std::bind(&Game::isOnline, &g_game));
g_lua.bindClassStaticFunction<Game>("requestOutfit", std::bind(&Game::requestOutfit, &g_game));
g_lua.bindClassStaticFunction<Game>("requestChannels", std::bind(&Game::requestChannels, &g_game));
g_lua.bindClassStaticFunction<Game>("openChannel", std::bind(&Game::openChannel, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("joinChannel", std::bind(&Game::joinChannel, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("setOutfit", std::bind(&Game::setOutfit, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("look", std::bind(&Game::look, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("open", std::bind(&Game::open, &g_game, _1, _2));