Advertisement
Guest User

player.h

a guest
Feb 8th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.23 KB | None | 0 0
  1. /**
  2. * The Forgotten Server - a free and open-source MMORPG server emulator
  3. * Copyright (C) 2017 Mark Samman <mark.samman@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19.  
  20. #ifndef FS_PLAYER_H_4083D3D3A05B4EDE891B31BB720CD06F
  21. #define FS_PLAYER_H_4083D3D3A05B4EDE891B31BB720CD06F
  22.  
  23. #include "creature.h"
  24. #include "container.h"
  25. #include "cylinder.h"
  26. #include "outfit.h"
  27. #include "enums.h"
  28. #include "vocation.h"
  29. #include "protocolgame.h"
  30. #include "ioguild.h"
  31. #include "party.h"
  32. #include "inbox.h"
  33. #include "depotchest.h"
  34. #include "depotlocker.h"
  35. #include "guild.h"
  36. #include "groups.h"
  37. #include "town.h"
  38. #include "mounts.h"
  39. #include "reward.h"
  40. #include "rewardchest.h"
  41. #include "gamestore.h"
  42. #include <set>
  43.  
  44. class House;
  45. class NetworkMessage;
  46. class Weapon;
  47. class ProtocolGame;
  48. class Npc;
  49. class Party;
  50. class SchedulerTask;
  51. class Bed;
  52. class Guild;
  53.  
  54. enum skillsid_t {
  55. SKILLVALUE_LEVEL = 0,
  56. SKILLVALUE_TRIES = 1,
  57. SKILLVALUE_PERCENT = 2,
  58. };
  59.  
  60. enum fightMode_t : uint8_t {
  61. FIGHTMODE_ATTACK = 1,
  62. FIGHTMODE_BALANCED = 2,
  63. FIGHTMODE_DEFENSE = 3,
  64. };
  65.  
  66. enum pvpMode_t : uint8_t {
  67. PVP_MODE_DOVE = 0,
  68. PVP_MODE_WHITE_HAND = 1,
  69. PVP_MODE_YELLOW_HAND = 2,
  70. PVP_MODE_RED_FIST = 3,
  71. };
  72.  
  73. enum tradestate_t : uint8_t {
  74. TRADE_NONE,
  75. TRADE_INITIATED,
  76. TRADE_ACCEPT,
  77. TRADE_ACKNOWLEDGE,
  78. TRADE_TRANSFER,
  79. };
  80.  
  81. static int luaPlayerAddAutoLootItem(lua_State* L);
  82. static int luaPlayerRemoveAutoLootItem(lua_State* L);
  83. static int luaPlayerGetAutoLootItem(lua_State* L);
  84. static int luaPlayerGetAutoLootList(lua_State* L);
  85.  
  86. struct VIPEntry {
  87. VIPEntry(uint32_t guid, std::string name, std::string description, uint32_t icon, bool notify) :
  88. guid(guid), name(std::move(name)), description(std::move(description)), icon(icon), notify(notify) {}
  89.  
  90. uint32_t guid;
  91. std::string name;
  92. std::string description;
  93. uint32_t icon;
  94. bool notify;
  95. };
  96.  
  97. struct OpenContainer {
  98. Container* container;
  99. uint16_t index;
  100. };
  101.  
  102. struct OutfitEntry {
  103. constexpr OutfitEntry(uint16_t lookType, uint8_t addons) : lookType(lookType), addons(addons) {}
  104.  
  105. uint16_t lookType;
  106. uint8_t addons;
  107. };
  108.  
  109. struct Skill {
  110. uint64_t tries = 0;
  111. uint16_t level = 10;
  112. uint8_t percent = 0;
  113. };
  114.  
  115. struct Kill {
  116. uint32_t target;
  117. time_t time;
  118. bool unavenged;
  119.  
  120. Kill(uint32_t _target, time_t _time, bool _unavenged) : target(_target), time(_time), unavenged(_unavenged) {}
  121. };
  122.  
  123. using MuteCountMap = std::map<uint32_t, uint32_t>;
  124.  
  125. static constexpr int32_t PLAYER_MAX_SPEED = 4500;
  126. static constexpr int32_t PLAYER_MIN_SPEED = 10;
  127.  
  128. class Player final : public Creature, public Cylinder
  129. {
  130. public:
  131. explicit Player(ProtocolGame_ptr p);
  132. ~Player();
  133.  
  134. // non-copyable
  135. Player(const Player&) = delete;
  136. Player& operator=(const Player&) = delete;
  137.  
  138. Player* getPlayer() final {
  139. return this;
  140. }
  141. const Player* getPlayer() const final {
  142. return this;
  143. }
  144.  
  145. void setID() final {
  146. if (id == 0) {
  147. id = playerAutoID++;
  148. }
  149. }
  150.  
  151. static MuteCountMap muteCountMap;
  152.  
  153. const std::string& getName() const final {
  154. return name;
  155. }
  156. void setName(std::string name) {
  157. this->name = std::move(name);
  158. }
  159. const std::string& getNameDescription() const final {
  160. return name;
  161. }
  162. std::string getDescription(int32_t lookDistance) const final;
  163.  
  164. CreatureType_t getType() const final {
  165. return CREATURETYPE_PLAYER;
  166. }
  167.  
  168. uint8_t getCurrentMount() const;
  169. void setCurrentMount(uint8_t mountId);
  170. bool isMounted() const {
  171. return defaultOutfit.lookMount != 0;
  172. }
  173. bool toggleMount(bool mount);
  174. bool tameMount(uint8_t mountId);
  175. bool untameMount(uint8_t mountId);
  176. bool hasMount(const Mount* mount) const;
  177. void dismount();
  178.  
  179. void sendFYIBox(const std::string& message) {
  180. if (client) {
  181. client->sendFYIBox(message);
  182. }
  183. }
  184.  
  185. void setGUID(uint32_t guid) {
  186. this->guid = guid;
  187. }
  188. uint32_t getGUID() const {
  189. return guid;
  190. }
  191. bool canSeeInvisibility() const final {
  192. return hasFlag(PlayerFlag_CanSenseInvisibility) || group->access;
  193. }
  194.  
  195. void removeList() final;
  196. void addList() final;
  197. void kickPlayer(bool displayEffect);
  198.  
  199. static uint64_t getExpForLevel(int32_t lv) {
  200. lv--;
  201. return ((50ULL * lv * lv * lv) - (150ULL * lv * lv) + (400ULL * lv)) / 3ULL;
  202. }
  203.  
  204. uint16_t getStaminaMinutes() const {
  205. return staminaMinutes;
  206. }
  207.  
  208. uint16_t getPreyStamina(uint16_t index) const {
  209. return preyStaminaMinutes[index];
  210. }
  211. uint16_t getPreyType(uint16_t index) const {
  212. return preyBonusType[index];
  213. }
  214. uint16_t getPreyValue(uint16_t index) const {
  215. return preyBonusValue[index];
  216. }
  217. std::string getPreyName(uint16_t index) const {
  218. return preyBonusName[index];
  219. }
  220.  
  221. bool addOfflineTrainingTries(skills_t skill, uint64_t tries);
  222.  
  223. void addOfflineTrainingTime(int32_t addTime) {
  224. offlineTrainingTime = std::min<int32_t>(12 * 3600 * 1000, offlineTrainingTime + addTime);
  225. }
  226. void removeOfflineTrainingTime(int32_t removeTime) {
  227. offlineTrainingTime = std::max<int32_t>(0, offlineTrainingTime - removeTime);
  228. }
  229. int32_t getOfflineTrainingTime() const {
  230. return offlineTrainingTime;
  231. }
  232.  
  233. int32_t getOfflineTrainingSkill() const {
  234. return offlineTrainingSkill;
  235. }
  236. void setOfflineTrainingSkill(int32_t skill) {
  237. offlineTrainingSkill = skill;
  238. }
  239.  
  240. uint64_t getBankBalance() const {
  241. return bankBalance;
  242. }
  243. void setBankBalance(uint64_t balance) {
  244. bankBalance = balance;
  245. }
  246.  
  247. Guild* getGuild() const {
  248. return guild;
  249. }
  250. void setGuild(Guild* guild);
  251.  
  252. const GuildRank* getGuildRank() const {
  253. return guildRank;
  254. }
  255. void setGuildRank(const GuildRank* newGuildRank) {
  256. guildRank = newGuildRank;
  257. }
  258.  
  259. bool isGuildMate(const Player* player) const;
  260.  
  261. const std::string& getGuildNick() const {
  262. return guildNick;
  263. }
  264. void setGuildNick(std::string nick) {
  265. guildNick = nick;
  266. }
  267.  
  268. bool isInWar(const Player* player) const;
  269. bool isInWarList(uint32_t guild_id) const;
  270.  
  271. void setLastWalkthroughAttempt(int64_t walkthroughAttempt) {
  272. lastWalkthroughAttempt = walkthroughAttempt;
  273. }
  274. void setLastWalkthroughPosition(Position walkthroughPosition) {
  275. lastWalkthroughPosition = walkthroughPosition;
  276. }
  277.  
  278. Inbox* getInbox() const {
  279. return inbox;
  280. }
  281.  
  282. uint16_t getClientIcons() const;
  283.  
  284. const GuildWarVector& getGuildWarVector() const {
  285. return guildWarVector;
  286. }
  287.  
  288. Vocation* getVocation() const {
  289. return vocation;
  290. }
  291.  
  292. OperatingSystem_t getOperatingSystem() const {
  293. return operatingSystem;
  294. }
  295. void setOperatingSystem(OperatingSystem_t clientos) {
  296. operatingSystem = clientos;
  297. }
  298.  
  299. uint16_t getProtocolVersion() const {
  300. if (!client) {
  301. return 0;
  302. }
  303.  
  304. return client->getVersion();
  305. }
  306.  
  307. bool hasSecureMode() const {
  308. return secureMode;
  309. }
  310.  
  311. void setParty(Party* party) {
  312. this->party = party;
  313. }
  314. Party* getParty() const {
  315. return party;
  316. }
  317. PartyShields_t getPartyShield(const Player* player) const;
  318. bool isInviting(const Player* player) const;
  319. bool isPartner(const Player* player) const;
  320. void sendPlayerPartyIcons(Player* player);
  321. bool addPartyInvitation(Party* party);
  322. void removePartyInvitation(Party* party);
  323. void clearPartyInvitations();
  324.  
  325. void sendUnjustifiedPoints();
  326.  
  327. GuildEmblems_t getGuildEmblem(const Player* player) const;
  328.  
  329. uint64_t getSpentMana() const {
  330. return manaSpent;
  331. }
  332.  
  333. bool hasFlag(PlayerFlags value) const {
  334. return (group->flags & value) != 0;
  335. }
  336.  
  337. BedItem* getBedItem() {
  338. return bedItem;
  339. }
  340. void setBedItem(BedItem* b) {
  341. bedItem = b;
  342. }
  343.  
  344. void addBlessing(uint8_t index, uint8_t count) {
  345. if (blessings[index - 1] == 255) {
  346. return;
  347. }
  348.  
  349. blessings[index-1] += count;
  350. }
  351. void removeBlessing(uint8_t index, uint8_t count) {
  352. if (blessings[index - 1] == 0) {
  353. return;
  354. }
  355.  
  356. blessings[index-1] -= count;
  357. }
  358. bool hasBlessing(uint8_t index) const {
  359. return blessings[index - 1] != 0;
  360. }
  361. uint8_t getBlessingCount(uint8_t index) const {
  362. return blessings[index - 1];
  363. }
  364.  
  365. bool isOffline() const {
  366. return (getID() == 0);
  367. }
  368. void disconnect() {
  369. if (client) {
  370. client->disconnect();
  371. }
  372. }
  373. uint32_t getIP() const;
  374.  
  375. void addContainer(uint8_t cid, Container* container);
  376. void closeContainer(uint8_t cid);
  377. void setContainerIndex(uint8_t cid, uint16_t index);
  378.  
  379. Container* getContainerByID(uint8_t cid);
  380. int8_t getContainerID(const Container* container) const;
  381. uint16_t getContainerIndex(uint8_t cid) const;
  382.  
  383. bool canOpenCorpse(uint32_t ownerId) const;
  384.  
  385. void addStorageValue(const uint32_t key, const int32_t value, const bool isLogin = false);
  386. bool getStorageValue(const uint32_t key, int32_t& value) const;
  387. void genReservedStorageRange();
  388.  
  389. void setGroup(Group* newGroup) {
  390. group = newGroup;
  391. }
  392. Group* getGroup() const {
  393. return group;
  394. }
  395.  
  396. void setInMarket(bool value) {
  397. inMarket = value;
  398. }
  399. bool isInMarket() const {
  400. return inMarket;
  401. }
  402.  
  403. void setLastDepotId(int16_t newId) {
  404. lastDepotId = newId;
  405. }
  406. int16_t getLastDepotId() const {
  407. return lastDepotId;
  408. }
  409.  
  410. void resetIdleTime() {
  411. idleTime = 0;
  412. }
  413.  
  414. bool isInGhostMode() const {
  415. return ghostMode;
  416. }
  417. void switchGhostMode() {
  418. ghostMode = !ghostMode;
  419. }
  420.  
  421. uint32_t getAccount() const {
  422. return accountNumber;
  423. }
  424. AccountType_t getAccountType() const {
  425. return accountType;
  426. }
  427. uint32_t getLevel() const {
  428. return level;
  429. }
  430. uint8_t getLevelPercent() const {
  431. return levelPercent;
  432. }
  433. uint32_t getMagicLevel() const {
  434. return std::max<int32_t>(0, magLevel + varStats[STAT_MAGICPOINTS]);
  435. }
  436. uint32_t getBaseMagicLevel() const {
  437. return magLevel;
  438. }
  439. uint8_t getMagicLevelPercent() const {
  440. return magLevelPercent;
  441. }
  442. uint8_t getSoul() const {
  443. return soul;
  444. }
  445. bool isAccessPlayer() const {
  446. return group->access;
  447. }
  448. bool isPremium() const;
  449. void setPremiumDays(int32_t v);
  450.  
  451. void setTibiaCoins(int32_t v);
  452.  
  453. uint16_t getHelpers() const;
  454.  
  455. bool setVocation(uint16_t vocId);
  456. uint16_t getVocationId() const {
  457. return vocation->getId();
  458. }
  459.  
  460. PlayerSex_t getSex() const {
  461. return sex;
  462. }
  463. void setSex(PlayerSex_t);
  464. uint64_t getExperience() const {
  465. return experience;
  466. }
  467.  
  468. time_t getLastLoginSaved() const {
  469. return lastLoginSaved;
  470. }
  471.  
  472. time_t getLastLogout() const {
  473. return lastLogout;
  474. }
  475.  
  476. const Position& getLoginPosition() const {
  477. return loginPosition;
  478. }
  479. const Position& getTemplePosition() const {
  480. return town->getTemplePosition();
  481. }
  482. Town* getTown() const {
  483. return town;
  484. }
  485. void setTown(Town* town) {
  486. this->town = town;
  487. }
  488.  
  489. void clearModalWindows();
  490. bool hasModalWindowOpen(uint32_t modalWindowId) const;
  491. void onModalWindowHandled(uint32_t modalWindowId);
  492.  
  493. bool isPushable() const final;
  494. uint32_t isMuted() const;
  495. void addMessageBuffer();
  496. void removeMessageBuffer();
  497.  
  498. bool removeItemOfType(uint16_t itemId, uint32_t amount, int32_t subType, bool ignoreEquipped = false) const;
  499.  
  500. uint32_t getCapacity() const {
  501. if (hasFlag(PlayerFlag_CannotPickupItem)) {
  502. return 0;
  503. } else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
  504. return std::numeric_limits<uint32_t>::max();
  505. }
  506. return capacity;
  507. }
  508.  
  509. uint32_t getFreeCapacity() const {
  510. if (hasFlag(PlayerFlag_CannotPickupItem)) {
  511. return 0;
  512. } else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
  513. return std::numeric_limits<uint32_t>::max();
  514. } else {
  515. return std::max<int32_t>(0, capacity - inventoryWeight);
  516. }
  517. }
  518.  
  519. int32_t getMaxHealth() const final {
  520. return std::max<int32_t>(1, healthMax + varStats[STAT_MAXHITPOINTS]);
  521. }
  522. uint32_t getMaxMana() const {
  523. return std::max<int32_t>(0, manaMax + varStats[STAT_MAXMANAPOINTS]);
  524. }
  525.  
  526. Item* getInventoryItem(slots_t slot) const;
  527.  
  528. bool isItemAbilityEnabled(slots_t slot) const {
  529. return inventoryAbilities[slot];
  530. }
  531. void setItemAbility(slots_t slot, bool enabled) {
  532. inventoryAbilities[slot] = enabled;
  533. }
  534.  
  535. void setVarSkill(skills_t skill, int32_t modifier) {
  536. varSkills[skill] += modifier;
  537. }
  538.  
  539. void setVarStats(stats_t stat, int32_t modifier);
  540. int32_t getDefaultStats(stats_t stat) const;
  541.  
  542. void addConditionSuppressions(uint32_t conditions);
  543. void removeConditionSuppressions(uint32_t conditions);
  544.  
  545. Reward* getReward(uint32_t rewardId, bool autoCreate);
  546. void removeReward(uint32_t rewardId);
  547. void getRewardList(std::vector<uint32_t>& rewards);
  548. RewardChest* getRewardChest();
  549.  
  550. DepotChest* getDepotBox();
  551. DepotChest* getDepotChest(uint32_t depotId, bool autoCreate);
  552. DepotLocker* getDepotLocker(uint32_t depotId);
  553. void onReceiveMail() const;
  554. bool isNearDepotBox() const;
  555.  
  556. bool canSee(const Position& pos) const final;
  557. bool canSeeCreature(const Creature* creature) const final;
  558.  
  559. bool canWalkthrough(const Creature* creature) const;
  560. bool canWalkthroughEx(const Creature* creature) const;
  561.  
  562. RaceType_t getRace() const final {
  563. return RACE_BLOOD;
  564. }
  565.  
  566. uint64_t getMoney() const;
  567.  
  568. //safe-trade functions
  569. void setTradeState(tradestate_t state) {
  570. tradeState = state;
  571. }
  572. tradestate_t getTradeState() const {
  573. return tradeState;
  574. }
  575. Item* getTradeItem() {
  576. return tradeItem;
  577. }
  578.  
  579. //shop functions
  580. void setShopOwner(Npc* owner, int32_t onBuy, int32_t onSell) {
  581. shopOwner = owner;
  582. purchaseCallback = onBuy;
  583. saleCallback = onSell;
  584. }
  585.  
  586. Npc* getShopOwner(int32_t& onBuy, int32_t& onSell) {
  587. onBuy = purchaseCallback;
  588. onSell = saleCallback;
  589. return shopOwner;
  590. }
  591.  
  592. const Npc* getShopOwner(int32_t& onBuy, int32_t& onSell) const {
  593. onBuy = purchaseCallback;
  594. onSell = saleCallback;
  595. return shopOwner;
  596. }
  597.  
  598. //V.I.P. functions
  599. void notifyStatusChange(Player* player, VipStatus_t status);
  600. bool removeVIP(uint32_t vipGuid);
  601. bool addVIP(uint32_t vipGuid, const std::string& vipName, VipStatus_t status);
  602. bool addVIPInternal(uint32_t vipGuid);
  603. bool editVIP(uint32_t vipGuid, const std::string& description, uint32_t icon, bool notify);
  604.  
  605. //follow functions
  606. bool setFollowCreature(Creature* creature) final;
  607. void goToFollowCreature() final;
  608.  
  609. //follow events
  610. void onFollowCreature(const Creature* creature) final;
  611.  
  612. //walk events
  613. void onWalk(Direction& dir) final;
  614. void onWalkAborted() final;
  615. void onWalkComplete() final;
  616.  
  617. void stopWalk();
  618. void openShopWindow(Npc* npc, const std::list<ShopInfo>& shop);
  619. bool closeShopWindow(bool sendCloseShopWindow = true);
  620. bool updateSaleShopList(const Item* item);
  621. bool hasShopItemForSale(uint32_t itemId, uint8_t subType) const;
  622.  
  623. void setChaseMode(bool mode);
  624. void setFightMode(fightMode_t mode) {
  625. fightMode = mode;
  626. }
  627. void setSecureMode(bool mode) {
  628. secureMode = mode;
  629. }
  630.  
  631. //combat functions
  632. bool setAttackedCreature(Creature* creature) final;
  633. bool isImmune(CombatType_t type) const final;
  634. bool isImmune(ConditionType_t type) const final;
  635. bool hasShield() const;
  636. bool isAttackable() const final;
  637. static bool lastHitIsPlayer(Creature* lastHitCreature);
  638.  
  639. void changeHealth(int32_t healthChange, bool sendHealthChange = true) final;
  640. void changeMana(int32_t manaChange) final;
  641. void changeSoul(int32_t soulChange);
  642.  
  643. bool isPzLocked() const {
  644. return pzLocked;
  645. }
  646. BlockType_t blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
  647. bool checkDefense = false, bool checkArmor = false, bool field = false) final;
  648. void doAttacking(uint32_t interval) final;
  649. bool hasExtraSwing() final {
  650. return lastAttack > 0 && ((OTSYS_TIME() - lastAttack) >= getAttackSpeed());
  651. }
  652.  
  653. uint16_t getSkillLevel(uint8_t skill) const {
  654. return std::max<int32_t>(0, skills[skill].level + varSkills[skill]);
  655. }
  656. uint16_t getBaseSkill(uint8_t skill) const {
  657. return skills[skill].level;
  658. }
  659. uint8_t getSkillPercent(uint8_t skill) const {
  660. return skills[skill].percent;
  661. }
  662.  
  663. bool getAddAttackSkill() const {
  664. return addAttackSkillPoint;
  665. }
  666. BlockType_t getLastAttackBlockType() const {
  667. return lastAttackBlockType;
  668. }
  669.  
  670. Item* getWeapon(slots_t slot, bool ignoreAmmo) const;
  671. Item* getWeapon(bool ignoreAmmo = false) const;
  672. WeaponType_t getWeaponType() const;
  673. int32_t getWeaponSkill(const Item* item) const;
  674. void getShieldAndWeapon(const Item*& shield, const Item*& weapon) const;
  675.  
  676. void drainHealth(Creature* attacker, int32_t damage) final;
  677. void drainMana(Creature* attacker, int32_t manaLoss) final;
  678. void addManaSpent(uint64_t amount);
  679. void addSkillAdvance(skills_t skill, uint64_t count);
  680.  
  681. int32_t getArmor() const final;
  682. int32_t getDefense() const final;
  683. float getAttackFactor() const final;
  684. float getDefenseFactor() const final;
  685.  
  686. void addInFightTicks(bool pzlock = false);
  687.  
  688. uint64_t getGainedExperience(Creature* attacker) const final;
  689.  
  690. //combat event functions
  691. void onAddCondition(ConditionType_t type) final;
  692. void onAddCombatCondition(ConditionType_t type) final;
  693. void onEndCondition(ConditionType_t type) final;
  694. void onCombatRemoveCondition(Condition* condition) final;
  695. void onAttackedCreature(Creature* target) final;
  696. void onAttacked() final;
  697. void onAttackedCreatureDrainHealth(Creature* target, int32_t points) final;
  698. void onTargetCreatureGainHealth(Creature* target, int32_t points) final;
  699. bool onKilledCreature(Creature* target, bool lastHit = true) final;
  700. void onGainExperience(uint64_t gainExp, Creature* target) final;
  701. void onGainSharedExperience(uint64_t gainExp, Creature* source);
  702. void onAttackedCreatureBlockHit(BlockType_t blockType) final;
  703. void onBlockHit() final;
  704. void onChangeZone(ZoneType_t zone) final;
  705. void onAttackedCreatureChangeZone(ZoneType_t zone) final;
  706. void onIdleStatus() final;
  707. void onPlacedCreature() final;
  708.  
  709. void getCreatureLight(LightInfo& light) const final;
  710.  
  711. Skulls_t getSkull() const final;
  712. Skulls_t getSkullClient(const Creature* creature) const final;
  713. int64_t getSkullTicks() const { return skullTicks; }
  714. void setSkullTicks(int64_t ticks) { skullTicks = ticks; }
  715.  
  716. bool hasKilled(const Player* player) const;
  717. bool hasAttacked(const Player* attacked) const;
  718. void addAttacked(const Player* attacked);
  719. void removeAttacked(const Player* attacked);
  720. void clearAttacked();
  721. void addUnjustifiedDead(const Player* attacked);
  722. void sendCreatureSkull(const Creature* creature) const {
  723. if (client) {
  724. client->sendCreatureSkull(creature);
  725. }
  726. }
  727. void checkSkullTicks(int64_t ticks);
  728.  
  729. bool canWear(uint32_t lookType, uint8_t addons) const;
  730. void addOutfit(uint16_t lookType, uint8_t addons);
  731. bool removeOutfit(uint16_t lookType);
  732. bool removeOutfitAddon(uint16_t lookType, uint8_t addons);
  733. bool getOutfitAddons(const Outfit& outfit, uint8_t& addons) const;
  734.  
  735. bool canLogout();
  736.  
  737. size_t getMaxVIPEntries() const;
  738. size_t getMaxDepotItems() const;
  739.  
  740. //tile
  741. //send methods
  742. void sendAddTileItem(const Tile* tile, const Position& pos, const Item* item) {
  743. if (client) {
  744. int32_t stackpos = tile->getStackposOfItem(this, item);
  745. if (stackpos != -1) {
  746. client->sendAddTileItem(pos, stackpos, item);
  747. }
  748. }
  749. }
  750. void sendUpdateTileItem(const Tile* tile, const Position& pos, const Item* item) {
  751. if (client) {
  752. int32_t stackpos = tile->getStackposOfItem(this, item);
  753. if (stackpos != -1) {
  754. client->sendUpdateTileItem(pos, stackpos, item);
  755. }
  756. }
  757. }
  758. void sendRemoveTileThing(const Position& pos, int32_t stackpos) {
  759. if (stackpos != -1 && client) {
  760. client->sendRemoveTileThing(pos, stackpos);
  761. }
  762. }
  763. void sendUpdateTile(const Tile* tile, const Position& pos) {
  764. if (client) {
  765. client->sendUpdateTile(tile, pos);
  766. }
  767. }
  768.  
  769. void sendChannelMessage(const std::string& author, const std::string& text, SpeakClasses type, uint16_t channel) {
  770. if (client) {
  771. client->sendChannelMessage(author, text, type, channel);
  772. }
  773. }
  774. void sendChannelEvent(uint16_t channelId, const std::string& playerName, ChannelEvent_t channelEvent) {
  775. if (client) {
  776. client->sendChannelEvent(channelId, playerName, channelEvent);
  777. }
  778. }
  779. void sendCreatureAppear(const Creature* creature, const Position& pos, bool isLogin) {
  780. if (client) {
  781. client->sendAddCreature(creature, pos, creature->getTile()->getStackposOfCreature(this, creature), isLogin);
  782. }
  783. }
  784. void sendCreatureMove(const Creature* creature, const Position& newPos, int32_t newStackPos, const Position& oldPos, int32_t oldStackPos, bool teleport) {
  785. if (client) {
  786. client->sendMoveCreature(creature, newPos, newStackPos, oldPos, oldStackPos, teleport);
  787. }
  788. }
  789. void sendCreatureTurn(const Creature* creature) {
  790. if (client && canSeeCreature(creature)) {
  791. int32_t stackpos = creature->getTile()->getStackposOfCreature(this, creature);
  792. if (stackpos != -1) {
  793. client->sendCreatureTurn(creature, stackpos);
  794. }
  795. }
  796. }
  797. void sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text, const Position* pos = nullptr) {
  798. if (client) {
  799. client->sendCreatureSay(creature, type, text, pos);
  800. }
  801. }
  802. void sendPrivateMessage(const Player* speaker, SpeakClasses type, const std::string& text) {
  803. if (client) {
  804. client->sendPrivateMessage(speaker, type, text);
  805. }
  806. }
  807. void sendCreatureSquare(const Creature* creature, SquareColor_t color) {
  808. if (client) {
  809. client->sendCreatureSquare(creature, color);
  810. }
  811. }
  812. void sendCreatureChangeOutfit(const Creature* creature, const Outfit_t& outfit) {
  813. if (client) {
  814. client->sendCreatureOutfit(creature, outfit);
  815. }
  816. }
  817. void sendCreatureChangeVisible(const Creature* creature, bool visible) {
  818. if (!client) {
  819. return;
  820. }
  821.  
  822. if (creature->getPlayer()) {
  823. if (visible) {
  824. client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
  825. } else {
  826. static Outfit_t outfit;
  827. client->sendCreatureOutfit(creature, outfit);
  828. }
  829. } else if (canSeeInvisibility()) {
  830. client->sendCreatureOutfit(creature, creature->getCurrentOutfit());
  831. } else {
  832. int32_t stackpos = creature->getTile()->getStackposOfCreature(this, creature);
  833. if (stackpos == -1) {
  834. return;
  835. }
  836.  
  837. if (visible) {
  838. client->sendAddCreature(creature, creature->getPosition(), stackpos, false);
  839. } else {
  840. client->sendRemoveTileThing(creature->getPosition(), stackpos);
  841. }
  842. }
  843. }
  844. void sendCreatureLight(const Creature* creature) {
  845. if (client) {
  846. client->sendCreatureLight(creature);
  847. }
  848. }
  849. void sendCreatureWalkthrough(const Creature* creature, bool walkthrough) {
  850. if (client) {
  851. client->sendCreatureWalkthrough(creature, walkthrough);
  852. }
  853. }
  854. void sendCreatureShield(const Creature* creature) {
  855. if (client) {
  856. client->sendCreatureShield(creature);
  857. }
  858. }
  859. void sendCreatureType(const Creature* creature, uint8_t creatureType) {
  860. if (client) {
  861. client->sendCreatureType(creature, creatureType);
  862. }
  863. }
  864. void sendCreatureHelpers(uint32_t creatureId, uint16_t helpers) {
  865. if (client) {
  866. client->sendCreatureHelpers(creatureId, helpers);
  867. }
  868. }
  869. void sendSpellCooldown(uint8_t spellId, uint32_t time) {
  870. if (client) {
  871. client->sendSpellCooldown(spellId, time);
  872. }
  873. }
  874. void sendSpellGroupCooldown(SpellGroup_t groupId, uint32_t time) {
  875. if (client) {
  876. client->sendSpellGroupCooldown(groupId, time);
  877. }
  878. }
  879. void sendModalWindow(const ModalWindow& modalWindow);
  880.  
  881. //container
  882. void sendAddContainerItem(const Container* container, const Item* item);
  883. void sendUpdateContainerItem(const Container* container, uint16_t slot, const Item* newItem);
  884. void sendRemoveContainerItem(const Container* container, uint16_t slot);
  885. void sendContainer(uint8_t cid, const Container* container, bool hasParent, uint16_t firstIndex) {
  886. if (client) {
  887. client->sendContainer(cid, container, hasParent, firstIndex);
  888. }
  889. }
  890.  
  891. //inventory
  892. void sendInventoryItem(slots_t slot, const Item* item) {
  893. if (client) {
  894. client->sendInventoryItem(slot, item);
  895. }
  896. }
  897.  
  898. void sendInventoryClientIds() {
  899. if (client) {
  900. client->sendInventoryClientIds();
  901. }
  902. }
  903.  
  904. //store
  905. void sendOpenStore(uint8_t serviceType) {
  906. if(client) {
  907. client->sendOpenStore(serviceType);
  908. }
  909. }
  910.  
  911. void sendShowStoreCategoryOffers(StoreCategory* category) {
  912. if(client) {
  913. client->sendStoreCategoryOffers(category);
  914. }
  915. }
  916.  
  917. void sendStoreError(GameStoreError_t error, const std::string& errorMessage) {
  918. if(client) {
  919. client->sendStoreError(error, errorMessage);
  920. }
  921. }
  922.  
  923. void sendStorePurchaseSuccessful(const std::string& message, const uint32_t coinBalance) {
  924. if(client)
  925. {
  926. client->sendStorePurchaseSuccessful(message, coinBalance);
  927. }
  928. }
  929.  
  930. void sendStoreRequestAdditionalInfo(uint32_t offerId, ClientOffer_t clientOfferType) {
  931. if(client) {
  932. client->sendStoreRequestAdditionalInfo(offerId, clientOfferType);
  933. }
  934. }
  935.  
  936. void sendStoreTrasactionHistory(HistoryStoreOfferList& list, uint32_t page, uint8_t entriesPerPage) {
  937. if(client) {
  938. client->sendStoreTrasactionHistory(list, page, entriesPerPage);
  939. }
  940. }
  941.  
  942. //event methods
  943. void onUpdateTileItem(const Tile* tile, const Position& pos, const Item* oldItem,
  944. const ItemType& oldType, const Item* newItem, const ItemType& newType) final;
  945. void onRemoveTileItem(const Tile* tile, const Position& pos, const ItemType& iType,
  946. const Item* item) final;
  947.  
  948. void onCreatureAppear(Creature* creature, bool isLogin) final;
  949. void onRemoveCreature(Creature* creature, bool isLogout) final;
  950. void onCreatureMove(Creature* creature, const Tile* newTile, const Position& newPos,
  951. const Tile* oldTile, const Position& oldPos, bool teleport) final;
  952.  
  953. void onAttackedCreatureDisappear(bool isLogout) final;
  954. void onFollowCreatureDisappear(bool isLogout) final;
  955.  
  956. //container
  957. void onAddContainerItem(const Item* item);
  958. void onUpdateContainerItem(const Container* container, const Item* oldItem, const Item* newItem);
  959. void onRemoveContainerItem(const Container* container, const Item* item);
  960.  
  961. void onCloseContainer(const Container* container);
  962. void onSendContainer(const Container* container);
  963. void autoCloseContainers(const Container* container);
  964.  
  965. //inventory
  966. void onUpdateInventoryItem(Item* oldItem, Item* newItem);
  967. void onRemoveInventoryItem(Item* item);
  968.  
  969. void sendCancelMessage(const std::string& msg) const {
  970. if (client) {
  971. client->sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, msg));
  972. }
  973. }
  974. void sendCancelMessage(ReturnValue message) const;
  975. void sendCancelTarget() const {
  976. if (client) {
  977. client->sendCancelTarget();
  978. }
  979. }
  980. void sendCancelWalk() const {
  981. if (client) {
  982. client->sendCancelWalk();
  983. }
  984. }
  985. void sendChangeSpeed(const Creature* creature, uint32_t newSpeed) const {
  986. if (client) {
  987. client->sendChangeSpeed(creature, newSpeed);
  988. }
  989. }
  990. void sendCreatureHealth(const Creature* creature) const {
  991. if (client) {
  992. client->sendCreatureHealth(creature);
  993. }
  994. }
  995. void sendDistanceShoot(const Position& from, const Position& to, unsigned char type) const {
  996. if (client) {
  997. client->sendDistanceShoot(from, to, type);
  998. }
  999. }
  1000. void sendHouseWindow(House* house, uint32_t listId) const;
  1001. void sendCreatePrivateChannel(uint16_t channelId, const std::string& channelName) {
  1002. if (client) {
  1003. client->sendCreatePrivateChannel(channelId, channelName);
  1004. }
  1005. }
  1006. void sendClosePrivate(uint16_t channelId);
  1007. void sendIcons() const {
  1008. if (client) {
  1009. client->sendIcons(getClientIcons());
  1010. }
  1011. }
  1012. void sendClientCheck() const {
  1013. if (client) {
  1014. client->sendClientCheck();
  1015. }
  1016. }
  1017. void sendGameNews() const {
  1018. if (client) {
  1019. client->sendGameNews();
  1020. }
  1021. }
  1022. void sendMagicEffect(const Position& pos, uint8_t type) const {
  1023. if (client) {
  1024. client->sendMagicEffect(pos, type);
  1025. }
  1026. }
  1027. void sendPing();
  1028. void sendPingBack() const {
  1029. if (client) {
  1030. client->sendPingBack();
  1031. }
  1032. }
  1033. void sendStats();
  1034. void sendBasicData() const {
  1035. if (client) {
  1036. client->sendBasicData();
  1037. }
  1038. }
  1039. void sendBlessStatus() const {
  1040. if (client) {
  1041. client->sendBlessStatus();
  1042. }
  1043. }
  1044. void sendSkills() const {
  1045. if (client) {
  1046. client->sendSkills();
  1047. }
  1048. }
  1049. void sendTextMessage(MessageClasses mclass, const std::string& message) const {
  1050. if (client) {
  1051. client->sendTextMessage(TextMessage(mclass, message));
  1052. }
  1053. }
  1054. void sendTextMessage(const TextMessage& message) const {
  1055. if (client) {
  1056. client->sendTextMessage(message);
  1057. }
  1058. }
  1059. void sendReLoginWindow(uint8_t unfairFightReduction) const {
  1060. if (client) {
  1061. client->sendReLoginWindow(unfairFightReduction);
  1062. }
  1063. }
  1064. void sendTextWindow(Item* item, uint16_t maxlen, bool canWrite) const {
  1065. if (client) {
  1066. client->sendTextWindow(windowTextId, item, maxlen, canWrite);
  1067. }
  1068. }
  1069. void sendTextWindow(uint32_t itemId, const std::string& text) const {
  1070. if (client) {
  1071. client->sendTextWindow(windowTextId, itemId, text);
  1072. }
  1073. }
  1074. void sendToChannel(const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId) const {
  1075. if (client) {
  1076. client->sendToChannel(creature, type, text, channelId);
  1077. }
  1078. }
  1079. void sendShop(Npc* npc) const {
  1080. if (client) {
  1081. client->sendShop(npc, shopItemList);
  1082. }
  1083. }
  1084. void sendSaleItemList() const {
  1085. if (client) {
  1086. client->sendSaleItemList(shopItemList);
  1087. }
  1088. }
  1089. void sendCloseShop() const {
  1090. if (client) {
  1091. client->sendCloseShop();
  1092. }
  1093. }
  1094. void sendMarketEnter(uint32_t depotId) const {
  1095. if (client) {
  1096. client->sendMarketEnter(depotId);
  1097. }
  1098. }
  1099. void sendMarketLeave() {
  1100. inMarket = false;
  1101. if (client) {
  1102. client->sendMarketLeave();
  1103. }
  1104. }
  1105. void sendMarketBrowseItem(uint16_t itemId, const MarketOfferList& buyOffers, const MarketOfferList& sellOffers) const {
  1106. if (client) {
  1107. client->sendMarketBrowseItem(itemId, buyOffers, sellOffers);
  1108. }
  1109. }
  1110. void sendMarketBrowseOwnOffers(const MarketOfferList& buyOffers, const MarketOfferList& sellOffers) const {
  1111. if (client) {
  1112. client->sendMarketBrowseOwnOffers(buyOffers, sellOffers);
  1113. }
  1114. }
  1115. void sendMarketBrowseOwnHistory(const HistoryMarketOfferList& buyOffers, const HistoryMarketOfferList& sellOffers) const {
  1116. if (client) {
  1117. client->sendMarketBrowseOwnHistory(buyOffers, sellOffers);
  1118. }
  1119. }
  1120. void sendMarketDetail(uint16_t itemId) const {
  1121. if (client) {
  1122. client->sendMarketDetail(itemId);
  1123. }
  1124. }
  1125. void sendMarketAcceptOffer(const MarketOfferEx& offer) const {
  1126. if (client) {
  1127. client->sendMarketAcceptOffer(offer);
  1128. }
  1129. }
  1130. void sendMarketCancelOffer(const MarketOfferEx& offer) const {
  1131. if (client) {
  1132. client->sendMarketCancelOffer(offer);
  1133. }
  1134. }
  1135. void sendTradeItemRequest(const std::string& traderName, const Item* item, bool ack) const {
  1136. if (client) {
  1137. client->sendTradeItemRequest(traderName, item, ack);
  1138. }
  1139. }
  1140. void sendTradeClose() const {
  1141. if (client) {
  1142. client->sendCloseTrade();
  1143. }
  1144. }
  1145. void sendWorldLight(const LightInfo& lightInfo) {
  1146. if (client) {
  1147. client->sendWorldLight(lightInfo);
  1148. }
  1149. }
  1150. void sendChannelsDialog() {
  1151. if (client) {
  1152. client->sendChannelsDialog();
  1153. }
  1154. }
  1155. void sendOpenPrivateChannel(const std::string& receiver) {
  1156. if (client) {
  1157. client->sendOpenPrivateChannel(receiver);
  1158. }
  1159. }
  1160. void sendOutfitWindow() {
  1161. if (client) {
  1162. client->sendOutfitWindow();
  1163. }
  1164. }
  1165. void sendCloseContainer(uint8_t cid) {
  1166. if (client) {
  1167. client->sendCloseContainer(cid);
  1168. }
  1169. }
  1170.  
  1171. void sendChannel(uint16_t channelId, const std::string& channelName, const UsersMap* channelUsers, const InvitedMap* invitedUsers) {
  1172. if (client) {
  1173. client->sendChannel(channelId, channelName, channelUsers, invitedUsers);
  1174. }
  1175. }
  1176. void sendTutorial(uint8_t tutorialId) {
  1177. if (client) {
  1178. client->sendTutorial(tutorialId);
  1179. }
  1180. }
  1181. void sendAddMarker(const Position& pos, uint8_t markType, const std::string& desc) {
  1182. if (client) {
  1183. client->sendAddMarker(pos, markType, desc);
  1184. }
  1185. }
  1186. void sendQuestLog() {
  1187. if (client) {
  1188. client->sendQuestLog();
  1189. }
  1190. }
  1191. void sendQuestLine(const Quest* quest) {
  1192. if (client) {
  1193. client->sendQuestLine(quest);
  1194. }
  1195. }
  1196. void sendEnterWorld() {
  1197. if (client) {
  1198. client->sendEnterWorld();
  1199. }
  1200. }
  1201. void sendFightModes() {
  1202. if (client) {
  1203. client->sendFightModes();
  1204. }
  1205. }
  1206. void sendNetworkMessage(const NetworkMessage& message, bool broadcast = true) {
  1207. if (client) {
  1208. client->writeToOutputBuffer(message, broadcast);
  1209. }
  1210. }
  1211.  
  1212. void sendCoinBalanceUpdating(bool updating) {
  1213. if(client) {
  1214. client->sendCoinBalanceUpdating(updating);
  1215. }
  1216. }
  1217.  
  1218. void sendStoreOpen(uint8_t serviceType) {
  1219. if(client)
  1220. client->sendOpenStore(serviceType);
  1221. }
  1222.  
  1223.  
  1224.  
  1225. void receivePing() {
  1226. lastPong = OTSYS_TIME();
  1227. }
  1228.  
  1229. void onThink(uint32_t interval) final;
  1230.  
  1231. void postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t link = LINK_OWNER) final;
  1232. void postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, cylinderlink_t link = LINK_OWNER) final;
  1233.  
  1234. void setNextAction(int64_t time) {
  1235. if (time > nextAction) {
  1236. nextAction = time;
  1237. }
  1238. }
  1239. bool canDoAction() const {
  1240. return nextAction <= OTSYS_TIME();
  1241. }
  1242.  
  1243. void setModuleDelay(uint8_t byteortype, int16_t delay) {
  1244. moduleDelayMap[byteortype] = OTSYS_TIME() + delay;
  1245. }
  1246.  
  1247. bool canRunModule(uint8_t byteortype) {
  1248. if (!moduleDelayMap[byteortype]) {
  1249. return true;
  1250. }
  1251. return moduleDelayMap[byteortype] <= OTSYS_TIME();
  1252. }
  1253.  
  1254. uint32_t getNextActionTime() const;
  1255.  
  1256. Item* getWriteItem(uint32_t& windowTextId, uint16_t& maxWriteLen);
  1257. void setWriteItem(Item* item, uint16_t maxWriteLen = 0);
  1258.  
  1259. House* getEditHouse(uint32_t& windowTextId, uint32_t& listId);
  1260. void setEditHouse(House* house, uint32_t listId = 0);
  1261.  
  1262. void learnInstantSpell(const std::string& spellName);
  1263. void forgetInstantSpell(const std::string& spellName);
  1264. bool hasLearnedInstantSpell(const std::string& spellName) const;
  1265. void addAutoLootItem(uint16_t itemId);
  1266. void removeAutoLootItem(uint16_t itemId);
  1267. bool getAutoLootItem(uint16_t itemId);
  1268.  
  1269. bool startLiveCast(const std::string& password) {
  1270. return client && client->startLiveCast(password);
  1271. }
  1272. bool stopLiveCast() {
  1273. return client && client->stopLiveCast();
  1274. }
  1275. bool isLiveCaster() const {
  1276. return client && client->isLiveCaster();
  1277. }
  1278. bool getSpectators(std::vector<ProtocolSpectator_ptr>& spectators) const {
  1279. if (!isLiveCaster()) {
  1280. return false;
  1281. }
  1282. spectators = client->spectators;
  1283. return true;
  1284. }
  1285.  
  1286. const std::map<uint8_t, OpenContainer>& getOpenContainers() const {
  1287. return openContainers;
  1288. }
  1289.  
  1290. uint16_t getBaseXpGain() const {
  1291. return baseXpGain;
  1292. }
  1293. void setBaseXpGain(uint16_t value) {
  1294.  
  1295. baseXpGain = std::min<uint16_t>(std::numeric_limits<uint16_t>::max(), value);
  1296. }
  1297. uint16_t getVoucherXpBoost() const {
  1298. return voucherXpBoost;
  1299. }
  1300. void setVoucherXpBoost(uint16_t value) {
  1301. voucherXpBoost = std::min<uint16_t>(std::numeric_limits<uint16_t>::max(), value);
  1302. }
  1303. uint16_t getGrindingXpBoost() const {
  1304. return grindingXpBoost;
  1305. }
  1306. void setGrindingXpBoost(uint16_t value) {
  1307. grindingXpBoost = std::min<uint16_t>(std::numeric_limits<uint16_t>::max(), value);
  1308. }
  1309. uint16_t getStoreXpBoost() const {
  1310. return storeXpBoost;
  1311. }
  1312. void setStoreXpBoost(uint16_t exp) {
  1313. storeXpBoost = exp;
  1314. }
  1315. uint16_t getStaminaXpBoost() const {
  1316. return staminaXpBoost;
  1317. }
  1318. void setStaminaXpBoost(uint16_t value) {
  1319. staminaXpBoost = std::min<uint16_t>(std::numeric_limits<uint16_t>::max(), value);
  1320. }
  1321.  
  1322. void setExpBoostStamina(uint16_t stamina) {
  1323. expBoostStamina = stamina;
  1324. }
  1325.  
  1326. uint16_t getExpBoostStamina() {
  1327. return expBoostStamina;
  1328. }
  1329.  
  1330. int32_t getIdleTime() const {
  1331. return idleTime;
  1332. }
  1333.  
  1334. void doCriticalDamage(CombatDamage& damage) const;
  1335. protected:
  1336. std::forward_list<Condition*> getMuteConditions() const;
  1337.  
  1338. void checkTradeState(const Item* item);
  1339. bool hasCapacity(const Item* item, uint32_t count) const;
  1340.  
  1341. void gainExperience(uint64_t exp, Creature* source);
  1342. void addExperience(Creature* source, uint64_t exp, bool sendText = false);
  1343. void removeExperience(uint64_t exp, bool sendText = false);
  1344.  
  1345. void updateInventoryWeight();
  1346.  
  1347. void setNextWalkActionTask(SchedulerTask* task);
  1348. void setNextWalkTask(SchedulerTask* task);
  1349. void setNextActionTask(SchedulerTask* task);
  1350.  
  1351. void death(Creature* lastHitCreature) final;
  1352. bool dropCorpse(Creature* lastHitCreature, Creature* mostDamageCreature, bool lastHitUnjustified, bool mostDamageUnjustified) final;
  1353. Item* getCorpse(Creature* lastHitCreature, Creature* mostDamageCreature) final;
  1354.  
  1355. //cylinder implementations
  1356. ReturnValue queryAdd(int32_t index, const Thing& thing, uint32_t count,
  1357. uint32_t flags, Creature* actor = nullptr) const final;
  1358. ReturnValue queryMaxCount(int32_t index, const Thing& thing, uint32_t count, uint32_t& maxQueryCount,
  1359. uint32_t flags) const final;
  1360. ReturnValue queryRemove(const Thing& thing, uint32_t count, uint32_t flags) const final;
  1361. Cylinder* queryDestination(int32_t& index, const Thing& thing, Item** destItem,
  1362. uint32_t& flags) final;
  1363.  
  1364. void addThing(Thing*) final {}
  1365. void addThing(int32_t index, Thing* thing) final;
  1366.  
  1367. void updateThing(Thing* thing, uint16_t itemId, uint32_t count) final;
  1368. void replaceThing(uint32_t index, Thing* thing) final;
  1369.  
  1370. void removeThing(Thing* thing, uint32_t count) final;
  1371.  
  1372. int32_t getThingIndex(const Thing* thing) const final;
  1373. size_t getFirstIndex() const final;
  1374. size_t getLastIndex() const final;
  1375. uint32_t getItemTypeCount(uint16_t itemId, int32_t subType = -1) const final;
  1376. std::map<uint32_t, uint32_t>& getAllItemTypeCount(std::map<uint32_t, uint32_t>& countMap) const final;
  1377. Item* getItemByClientId(uint16_t clientId) const;
  1378. std::map<uint16_t, uint16_t> getInventoryClientIds() const;
  1379. Thing* getThing(size_t index) const final;
  1380.  
  1381. void internalAddThing(Thing* thing) final;
  1382. void internalAddThing(uint32_t index, Thing* thing) final;
  1383.  
  1384. std::unordered_set<uint32_t> attackedSet;
  1385. std::set<uint32_t> autoLootList;
  1386. std::unordered_set<uint32_t> VIPList;
  1387.  
  1388. std::map<uint8_t, OpenContainer> openContainers;
  1389. std::map<uint32_t, DepotLocker*> depotLockerMap;
  1390. std::map<uint32_t, DepotChest*> depotChests;
  1391. std::map<uint32_t, int32_t> storageMap;
  1392. std::map<uint8_t, int64_t> moduleDelayMap;
  1393.  
  1394. std::map<uint32_t, Reward*> rewardMap;
  1395.  
  1396. std::vector<OutfitEntry> outfits;
  1397. GuildWarVector guildWarVector;
  1398.  
  1399. std::list<ShopInfo> shopItemList;
  1400.  
  1401. std::forward_list<Party*> invitePartyList;
  1402. std::forward_list<uint32_t> modalWindows;
  1403. std::forward_list<std::string> learnedInstantSpellList;
  1404. std::forward_list<Condition*> storedConditionList; // TODO: This variable is only temporarily used when logging in, get rid of it somehow
  1405.  
  1406. std::string name;
  1407. std::string guildNick;
  1408.  
  1409. Skill skills[SKILL_LAST + 1];
  1410. LightInfo itemsLight;
  1411. Position loginPosition;
  1412. Position lastWalkthroughPosition;
  1413.  
  1414. time_t lastLoginSaved = 0;
  1415. time_t lastLogout = 0;
  1416.  
  1417. uint64_t experience = 0;
  1418. uint64_t manaSpent = 0;
  1419. uint64_t lastAttack = 0;
  1420. uint64_t bankBalance = 0;
  1421. uint64_t lastQuestlogUpdate = 0;
  1422. int64_t lastFailedFollow = 0;
  1423. int64_t skullTicks = 0;
  1424. int64_t lastWalkthroughAttempt = 0;
  1425. int64_t lastToggleMount = 0;
  1426. int64_t lastPing;
  1427. int64_t lastPong;
  1428. int64_t nextAction = 0;
  1429.  
  1430. std::vector<Kill> unjustifiedKills;
  1431.  
  1432. BedItem* bedItem = nullptr;
  1433. Guild* guild = nullptr;
  1434. const GuildRank* guildRank = nullptr;
  1435. Group* group = nullptr;
  1436. Inbox* inbox;
  1437. Item* tradeItem = nullptr;
  1438. Item* inventory[CONST_SLOT_LAST + 1] = {};
  1439. Item* writeItem = nullptr;
  1440. House* editHouse = nullptr;
  1441. Npc* shopOwner = nullptr;
  1442. Party* party = nullptr;
  1443. Player* tradePartner = nullptr;
  1444. ProtocolGame_ptr client;
  1445. SchedulerTask* walkTask = nullptr;
  1446. Town* town = nullptr;
  1447. Vocation* vocation = nullptr;
  1448. RewardChest* rewardChest = nullptr;
  1449.  
  1450. uint32_t inventoryWeight = 0;
  1451. uint32_t capacity = 40000;
  1452. uint32_t damageImmunities = 0;
  1453. uint32_t conditionImmunities = 0;
  1454. uint32_t conditionSuppressions = 0;
  1455. uint32_t level = 1;
  1456. uint32_t magLevel = 0;
  1457. uint32_t actionTaskEvent = 0;
  1458. uint32_t nextStepEvent = 0;
  1459. uint32_t walkTaskEvent = 0;
  1460. uint32_t MessageBufferTicks = 0;
  1461. uint32_t lastIP = 0;
  1462. uint32_t accountNumber = 0;
  1463. uint32_t guid = 0;
  1464. uint32_t windowTextId = 0;
  1465. uint32_t editListId = 0;
  1466. uint32_t manaMax = 0;
  1467. int32_t varSkills[SKILL_LAST + 1] = {};
  1468. int32_t varStats[STAT_LAST + 1] = {};
  1469. int32_t purchaseCallback = -1;
  1470. int32_t saleCallback = -1;
  1471. int32_t MessageBufferCount = 0;
  1472. int32_t premiumDays = 0;
  1473. int32_t tibiaCoins = 0;
  1474. int32_t bloodHitCount = 0;
  1475. int32_t shieldBlockCount = 0;
  1476. int32_t offlineTrainingSkill = -1;
  1477. int32_t offlineTrainingTime = 0;
  1478. int32_t idleTime = 0;
  1479. uint16_t expBoostStamina = 0;
  1480.  
  1481. uint16_t lastStatsTrainingTime = 0;
  1482. uint16_t staminaMinutes = 2520;
  1483. std::vector<uint16_t> preyStaminaMinutes = {7200, 7200, 7200};
  1484. std::vector<uint16_t> preyBonusType = {0, 0, 0};
  1485. std::vector<uint16_t> preyBonusValue = {0, 0, 0};
  1486. std::vector<std::string> preyBonusName = {"", "", ""};
  1487. std::vector<uint8_t> blessings = { 0, 0, 0, 0, 0, 0, 0, 0 };
  1488. uint16_t maxWriteLen = 0;
  1489. uint16_t baseXpGain = 100;
  1490. uint16_t voucherXpBoost = 0;
  1491. uint16_t grindingXpBoost = 0;
  1492. uint16_t storeXpBoost = 0;
  1493. uint16_t staminaXpBoost = 100;
  1494. int16_t lastDepotId = -1;
  1495.  
  1496. uint8_t soul = 0;
  1497. uint8_t levelPercent = 0;
  1498. uint8_t magLevelPercent = 0;
  1499.  
  1500. PlayerSex_t sex = PLAYERSEX_FEMALE;
  1501. OperatingSystem_t operatingSystem = CLIENTOS_NONE;
  1502. BlockType_t lastAttackBlockType = BLOCK_NONE;
  1503. tradestate_t tradeState = TRADE_NONE;
  1504. fightMode_t fightMode = FIGHTMODE_ATTACK;
  1505. AccountType_t accountType = ACCOUNT_TYPE_NORMAL;
  1506.  
  1507. bool chaseMode = false;
  1508. bool secureMode = false;
  1509. bool inMarket = false;
  1510. bool wasMounted = false;
  1511. bool ghostMode = false;
  1512. bool pzLocked = false;
  1513. bool isConnecting = false;
  1514. bool addAttackSkillPoint = false;
  1515. bool inventoryAbilities[CONST_SLOT_LAST + 1] = {};
  1516.  
  1517. static uint32_t playerAutoID;
  1518.  
  1519. void updateItemsLight(bool internal = false);
  1520. int32_t getStepSpeed() const final {
  1521. return std::max<int32_t>(PLAYER_MIN_SPEED, std::min<int32_t>(PLAYER_MAX_SPEED, getSpeed()));
  1522. }
  1523. void updateBaseSpeed() {
  1524. if (!hasFlag(PlayerFlag_SetMaxSpeed)) {
  1525. baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));
  1526. } else {
  1527. baseSpeed = PLAYER_MAX_SPEED;
  1528. }
  1529. }
  1530.  
  1531. bool isPromoted() const;
  1532.  
  1533. uint32_t getAttackSpeed() const {
  1534. return vocation->getAttackSpeed();
  1535. }
  1536.  
  1537. static uint8_t getPercentLevel(uint64_t count, uint64_t nextLevelCount);
  1538. double getLostPercent() const;
  1539. uint64_t getLostExperience() const final {
  1540. return skillLoss ? static_cast<uint64_t>(experience * getLostPercent()) : 0;
  1541. }
  1542. uint32_t getDamageImmunities() const final {
  1543. return damageImmunities;
  1544. }
  1545. uint32_t getConditionImmunities() const final {
  1546. return conditionImmunities;
  1547. }
  1548. uint32_t getConditionSuppressions() const final {
  1549. return conditionSuppressions;
  1550. }
  1551. uint16_t getLookCorpse() const final;
  1552. void getPathSearchParams(const Creature* creature, FindPathParams& fpp) const final;
  1553.  
  1554. friend class Game;
  1555. friend class Npc;
  1556. friend class LuaScriptInterface;
  1557. friend class Map;
  1558. friend class Actions;
  1559. friend class IOLoginData;
  1560. friend class ProtocolGame;
  1561. friend class ProtocolGameBase;
  1562. };
  1563.  
  1564. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement