No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

game.h 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. #ifndef GAME_H
  23. #define GAME_H
  24. #include "declarations.h"
  25. #include <otclient/net/declarations.h>
  26. #include <otclient/core/item.h>
  27. #include <otclient/core/outfit.h>
  28. #include <framework/core/timer.h>
  29. class Game
  30. {
  31. public:
  32. void loginWorld(const std::string& account,
  33. const std::string& password,
  34. const std::string& worldHost, int worldPort,
  35. const std::string& characterName);
  36. void cancelLogin();
  37. void logout(bool force);
  38. void forceLogout() { logout(true); }
  39. void cleanLogout() { logout(false); }
  40. void processLoginError(const std::string& error);
  41. void processConnectionError(const boost::system::error_code& error);
  42. void processGameStart(const LocalPlayerPtr& localPlayer, int serverBeat);
  43. void processLogin();
  44. void processLogout();
  45. void processDeath();
  46. void processPlayerStats(double health, double maxHealth,
  47. double freeCapacity, double experience,
  48. double level, double levelPercent,
  49. double mana, double maxMana,
  50. double magicLevel, double magicLevelPercent,
  51. double soul, double stamina);
  52. void processTextMessage(const std::string& type, const std::string& message);
  53. void processCreatureSpeak(const std::string& name, int level, Otc::SpeakType type, const std::string& message, int channelId, const Position& creaturePos);
  54. void processContainerAddItem(int containerId, const ItemPtr& item);
  55. void processInventoryChange(int slot, const ItemPtr& item);
  56. void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
  57. void processCreatureTeleport(const CreaturePtr& creature);
  58. void processAttackCancel();
  59. void processWalkCancel(Otc::Direction direction);
  60. // walk related
  61. void walk(Otc::Direction direction);
  62. void forceWalk(Otc::Direction direction);
  63. void turn(Otc::Direction direction);
  64. // item related
  65. void look(const ThingPtr& thing);
  66. void open(const ItemPtr& item, int containerId);
  67. void use(const ThingPtr& thing);
  68. void useWith(const ItemPtr& fromThing, const ThingPtr& toThing);
  69. void useInventoryItem(int itemId);
  70. void useInventoryItemWith(int itemId, const ThingPtr& toThing);
  71. void move(const ThingPtr &thing, const Position& toPos, int count);
  72. // fight tatics related
  73. void setChaseMode(Otc::ChaseModes chaseMode);
  74. void setFightMode(Otc::FightModes fightMode);
  75. void setSafeFight(bool on);
  76. Otc::ChaseModes getChaseMode() { return m_chaseMode; }
  77. Otc::FightModes getFightMode() { return m_fightMode; }
  78. bool isSafeFight() { return m_safeFight; }
  79. // attack/follow related
  80. void attack(const CreaturePtr& creature);
  81. void cancelAttack();
  82. void follow(const CreaturePtr& creature);
  83. void cancelFollow();
  84. void rotate(const ThingPtr& thing);
  85. // talk related
  86. void talk(const std::string& message);
  87. void talkChannel(Otc::SpeakType speakType, int channelId, const std::string& message);
  88. void talkPrivate(Otc::SpeakType speakType, const std::string& receiver, const std::string& message);
  89. void openPrivateChannel(const std::string& receiver);
  90. void requestChannels();
  91. void joinChannel(int channelId);
  92. void leaveChannel(int channelId);
  93. void closeNpcChannel();
  94. // party related
  95. void partyInvite(int creatureId);
  96. void partyJoin(int creatureId);
  97. void partyRevokeInvitation(int creatureId);
  98. void partyPassLeadership(int creatureId);
  99. void partyLeave();
  100. void partyShareExperience(bool active);
  101. // outfit related
  102. void requestOutfit();
  103. void setOutfit(const Outfit& outfit);
  104. // vip related
  105. void addVip(const std::string& name);
  106. void removeVip(int playerId);
  107. bool checkBotProtection();
  108. bool isOnline() { return !!m_localPlayer; }
  109. bool isDead() { return m_dead; }
  110. void setServerBeat(int serverBeat) { m_serverBeat = serverBeat; }
  111. int getServerBeat() { return m_serverBeat; }
  112. LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
  113. ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
  114. int getProtocolVersion() { return PROTOCOL; }
  115. private:
  116. LocalPlayerPtr m_localPlayer;
  117. ProtocolGamePtr m_protocolGame;
  118. bool m_dead;
  119. int m_serverBeat;
  120. Otc::FightModes m_fightMode;
  121. Otc::ChaseModes m_chaseMode;
  122. bool m_safeFight;
  123. };
  124. extern Game g_game;
  125. #endif