2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2012-01-02 17:58:37 +01:00
|
|
|
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#ifndef GAME_H
|
|
|
|
#define GAME_H
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#include "declarations.h"
|
|
|
|
#include <otclient/net/declarations.h>
|
2011-11-10 06:29:25 +01:00
|
|
|
#include <otclient/core/item.h>
|
2011-11-16 18:33:43 +01:00
|
|
|
#include <otclient/core/outfit.h>
|
2012-01-09 06:23:39 +01:00
|
|
|
#include <framework/core/timer.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
class Game
|
|
|
|
{
|
|
|
|
public:
|
2011-08-16 02:30:31 +02:00
|
|
|
void loginWorld(const std::string& account,
|
|
|
|
const std::string& password,
|
2011-08-26 20:00:22 +02:00
|
|
|
const std::string& worldHost, int worldPort,
|
2011-08-16 02:30:31 +02:00
|
|
|
const std::string& characterName);
|
2011-08-29 16:14:21 +02:00
|
|
|
void cancelLogin();
|
2011-08-30 01:20:30 +02:00
|
|
|
void logout(bool force);
|
2012-01-07 06:10:02 +01:00
|
|
|
void forceLogout() { logout(true); }
|
|
|
|
void cleanLogout() { logout(false); }
|
2011-08-30 01:20:30 +02:00
|
|
|
void processLoginError(const std::string& error);
|
2011-08-29 20:38:01 +02:00
|
|
|
void processConnectionError(const boost::system::error_code& error);
|
2012-01-09 06:23:39 +01:00
|
|
|
void processLogin(const LocalPlayerPtr& localPlayer, int serverBeat);
|
2011-08-29 16:14:21 +02:00
|
|
|
void processLogout();
|
2012-01-07 06:10:02 +01:00
|
|
|
void processDeath();
|
2011-08-15 23:02:52 +02:00
|
|
|
|
2012-01-08 19:29:41 +01:00
|
|
|
void processTextMessage(const std::string& type, const std::string& message);
|
|
|
|
void processCreatureSpeak(const std::string& name, int level, const std::string& type, const std::string& message, int channelId, const Position& creaturePos);
|
2012-01-12 20:25:58 +01:00
|
|
|
void processContainerAddItem(int containerId, const ItemPtr& item);
|
2011-11-10 06:29:25 +01:00
|
|
|
void processInventoryChange(int slot, const ItemPtr& item);
|
2012-01-09 06:23:39 +01:00
|
|
|
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
|
2012-01-07 06:10:02 +01:00
|
|
|
void processAttackCancel();
|
2012-01-09 06:23:39 +01:00
|
|
|
void processWalkCancel(Otc::Direction direction);
|
2011-08-30 17:12:57 +02:00
|
|
|
|
2012-01-14 06:54:20 +01:00
|
|
|
// walk related
|
2011-08-28 18:02:26 +02:00
|
|
|
void walk(Otc::Direction direction);
|
2012-01-15 22:19:52 +01:00
|
|
|
void forceWalk(Otc::Direction direction);
|
2011-08-28 18:02:26 +02:00
|
|
|
void turn(Otc::Direction direction);
|
2012-01-14 06:54:20 +01:00
|
|
|
|
|
|
|
// item related
|
2012-01-03 21:41:00 +01:00
|
|
|
void look(const ThingPtr& thing);
|
2012-01-13 01:31:39 +01:00
|
|
|
void open(const ThingPtr& thing, int containerId);
|
2012-01-03 23:27:31 +01:00
|
|
|
void use(const ThingPtr& thing);
|
2012-01-12 00:10:44 +01:00
|
|
|
void useWith(const ThingPtr& fromThing, const ThingPtr& toThing);
|
2012-01-17 23:53:06 +01:00
|
|
|
void useInventoryItem(int itemId, const ThingPtr& toThing);
|
2012-01-14 06:54:20 +01:00
|
|
|
|
|
|
|
// attack/follow related
|
2012-01-04 14:02:35 +01:00
|
|
|
void attack(const CreaturePtr& creature);
|
2012-01-05 15:24:38 +01:00
|
|
|
void cancelAttack();
|
2012-01-04 14:02:35 +01:00
|
|
|
void follow(const CreaturePtr& creature);
|
2012-01-05 15:24:38 +01:00
|
|
|
void cancelFollow();
|
2012-01-04 14:02:35 +01:00
|
|
|
void rotate(const ThingPtr& thing);
|
2012-01-14 06:54:20 +01:00
|
|
|
|
|
|
|
// talk related
|
2012-01-07 22:10:06 +01:00
|
|
|
void talk(const std::string& message);
|
2012-01-14 02:37:15 +01:00
|
|
|
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);
|
2012-01-14 06:54:20 +01:00
|
|
|
void requestChannels();
|
|
|
|
void joinChannel(int channelId);
|
|
|
|
void leaveChannel(int channelId);
|
|
|
|
void closeNpcChannel();
|
|
|
|
|
|
|
|
// party related
|
2012-01-11 00:38:32 +01:00
|
|
|
void partyInvite(int creatureId);
|
|
|
|
void partyJoin(int creatureId);
|
|
|
|
void partyRevokeInvitation(int creatureId);
|
|
|
|
void partyPassLeadership(int creatureId);
|
|
|
|
void partyLeave();
|
|
|
|
void partyShareExperience(bool active);
|
2012-01-14 06:54:20 +01:00
|
|
|
|
|
|
|
// outfit related
|
2012-01-14 02:37:15 +01:00
|
|
|
void requestOutfit();
|
2011-11-16 18:33:43 +01:00
|
|
|
void setOutfit(const Outfit& outfit);
|
2012-01-14 06:54:20 +01:00
|
|
|
|
|
|
|
// vip related
|
2012-01-04 15:30:28 +01:00
|
|
|
void addVip(const std::string& name);
|
|
|
|
void removeVip(int playerId);
|
2012-01-14 06:54:20 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
int getThingStackpos(const ThingPtr& thing);
|
2012-01-05 15:24:38 +01:00
|
|
|
|
2012-01-06 20:25:27 +01:00
|
|
|
bool checkBotProtection();
|
|
|
|
|
2012-01-19 05:12:53 +01:00
|
|
|
bool isOnline() { return !!m_localPlayer; }
|
2012-01-07 06:10:02 +01:00
|
|
|
bool isDead() { return m_dead; }
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-01-12 00:10:44 +01:00
|
|
|
void setSelectedThing(const ThingPtr& thing) { m_selectedThing = thing; }
|
|
|
|
ThingPtr getSelectedThing() { return m_selectedThing; }
|
|
|
|
|
2011-12-28 12:26:52 +01:00
|
|
|
void setServerBeat(int serverBeat) { m_serverBeat = serverBeat; }
|
|
|
|
int getServerBeat() { return m_serverBeat; }
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
|
2011-08-16 02:30:31 +02:00
|
|
|
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
|
2012-01-08 16:42:23 +01:00
|
|
|
int getProtocolVersion() { return PROTOCOL; }
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
private:
|
2011-08-15 23:02:52 +02:00
|
|
|
LocalPlayerPtr m_localPlayer;
|
2011-08-15 16:11:24 +02:00
|
|
|
ProtocolGamePtr m_protocolGame;
|
2012-01-07 06:10:02 +01:00
|
|
|
bool m_dead;
|
2011-12-28 12:26:52 +01:00
|
|
|
int m_serverBeat;
|
2012-01-12 00:10:44 +01:00
|
|
|
ThingPtr m_selectedThing;
|
2011-08-15 16:11:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Game g_game;
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#endif
|