Advertisement
Guest User

player.h

a guest
Jun 11th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 46.35 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////
  2. // OpenTibia - an opensource roleplaying game
  3. ////////////////////////////////////////////////////////////////////////
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. ////////////////////////////////////////////////////////////////////////
  17.  
  18. #ifndef __PLAYER__
  19. #define __PLAYER__
  20. #include "otsystem.h"
  21. #include "enums.h"
  22.  
  23. #include "creature.h"
  24. #include "cylinder.h"
  25.  
  26. #include "container.h"
  27. #include "depot.h"
  28.  
  29. #include "outfit.h"
  30. #include "vocation.h"
  31. #include "group.h"
  32.  
  33. #include "protocolgame.h"
  34. #include "ioguild.h"
  35. #include "party.h"
  36. #include "npc.h"
  37.  
  38. class House;
  39. class NetworkMessage;
  40. class Weapon;
  41. class ProtocolGame;
  42. class Npc;
  43. class Party;
  44. class SchedulerTask;
  45. class Quest;
  46.  
  47. struct CastBan
  48. {
  49.     std::string name;
  50.     uint32_t ip;
  51.  
  52.     CastBan(std::string n, uint32_t _ip)
  53.     {
  54.         name = n;
  55.         ip = _ip;
  56.     }
  57. };
  58.  
  59. struct PlayerCast
  60. {
  61.     uint16_t curId;
  62.     bool isCasting;
  63.     std::string password;
  64.     std::string description;
  65.  
  66.     std::list<CastBan> muted;
  67.     std::list<CastBan> bans;
  68.  
  69.     PlayerCast()
  70.     {
  71.         isCasting = false;
  72.         curId = 1;
  73.     }
  74. };
  75.  
  76. enum skillsid_t
  77. {
  78.     SKILL_LEVEL = 0,
  79.     SKILL_TRIES = 1,
  80.     SKILL_PERCENT = 2
  81. };
  82.  
  83. enum playerinfo_t
  84. {
  85.     PLAYERINFO_LEVEL,
  86.     PLAYERINFO_LEVELPERCENT,
  87.     PLAYERINFO_HEALTH,
  88.     PLAYERINFO_MAXHEALTH,
  89.     PLAYERINFO_MANA,
  90.     PLAYERINFO_MAXMANA,
  91.     PLAYERINFO_MAGICLEVEL,
  92.     PLAYERINFO_MAGICLEVELPERCENT,
  93.     PLAYERINFO_SOUL,
  94. };
  95.  
  96. enum freeslot_t
  97. {
  98.     SLOT_TYPE_NONE,
  99.     SLOT_TYPE_INVENTORY,
  100.     SLOT_TYPE_CONTAINER
  101. };
  102.  
  103. enum chaseMode_t
  104. {
  105.     CHASEMODE_STANDSTILL,
  106.     CHASEMODE_FOLLOW,
  107. };
  108.  
  109. enum fightMode_t
  110. {
  111.     FIGHTMODE_ATTACK,
  112.     FIGHTMODE_BALANCED,
  113.     FIGHTMODE_DEFENSE
  114. };
  115.  
  116. enum secureMode_t
  117. {
  118.     SECUREMODE_ON,
  119.     SECUREMODE_OFF
  120. };
  121.  
  122. enum tradestate_t
  123. {
  124.     TRADE_NONE,
  125.     TRADE_INITIATED,
  126.     TRADE_ACCEPT,
  127.     TRADE_ACKNOWLEDGE,
  128.     TRADE_TRANSFER
  129. };
  130.  
  131. enum AccountManager_t
  132. {
  133.     MANAGER_NONE,
  134.     MANAGER_NEW,
  135.     MANAGER_ACCOUNT,
  136.     MANAGER_NAMELOCK
  137. };
  138.  
  139. enum GamemasterCondition_t
  140. {
  141.     GAMEMASTER_INVISIBLE = 0,
  142.     GAMEMASTER_IGNORE = 1,
  143.     GAMEMASTER_TELEPORT = 2
  144. };
  145.  
  146. enum Exhaust_t
  147. {
  148.     EXHAUST_COMBAT = 1,
  149.     EXHAUST_HEALING = 2,
  150.     EXHAUST_NPC = 3,
  151.     EXHAUST_OUTFIT = 4
  152. };
  153.  
  154. typedef std::set<uint32_t> VIPSet;
  155. typedef std::vector<std::pair<uint32_t, Container*> > ContainerVector;
  156. typedef std::map<uint32_t, std::pair<Depot*, bool> > DepotMap;
  157. typedef std::map<uint32_t, uint32_t> MuteCountMap;
  158. typedef std::list<std::string> LearnedInstantSpellList;
  159. typedef std::list<uint32_t> InvitedToGuildsList;
  160. typedef std::list<Party*> PartyList;
  161. typedef std::map<uint32_t, War_t> WarMap;
  162.  
  163. #define SPEED_MAX 1500
  164. #define SPEED_MIN 10
  165. #define STAMINA_MAX (56 * 60 * 60 * 1000)
  166. #define STAMINA_MULTIPLIER (60 * 1000)
  167.  
  168. class Player : public Creature, public Cylinder
  169. {
  170.     public:
  171. #ifdef __ENABLE_SERVER_DIAGNOSTIC__
  172.         static uint32_t playerCount;
  173. #endif
  174.         Player(const std::string& name, ProtocolGame* p);
  175.         virtual ~Player();
  176.  
  177.         virtual Player* getPlayer() {return this;}
  178.         virtual const Player* getPlayer() const {return this;}
  179.  
  180.         static MuteCountMap muteCountMap;
  181.        
  182.         bool getCastingState() const {return cast.isCasting;};
  183.         virtual const std::string& getCastingPassword() const {return cast.password;};
  184.  
  185.         PlayerCast getCast() {return cast;}
  186.  
  187.         void setCasting(bool c);
  188.         void setCastPassword(std::string p) {cast.password = p;};
  189.  
  190.         void setCastDescription(std::string desc) {cast.description = desc;}
  191.  
  192.         virtual const std::string& getCastDescription() const {return cast.description;}
  193.  
  194.         void addCastViewer(ProtocolGame* pg)
  195.         {
  196.             cSpectators[nextSpectator] = pg;
  197.             nextSpectator++;
  198.  
  199.             std::stringstream ss;
  200.             ss << "Viewer " << cast.curId;
  201.             pg->viewerName = ss.str().c_str();
  202.             cast.curId++;
  203.         }
  204.  
  205.         void removeCastViewer(uint32_t id) {cSpectators.erase(id);}
  206.  
  207.         uint32_t getCastIpByName(std::string n)
  208.         {
  209.             for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it)
  210.             {
  211.                 if(it->second->getViewerName() == n && it->second->getPlayer() == this)
  212.                     return it->second->getIP();
  213.             }
  214.             return false;
  215.         }
  216.  
  217.         uint32_t getCastViewerCount()
  218.         {
  219.             uint32_t count = 0;
  220.             for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it)
  221.                     if(it->second->getPlayer() == this)
  222.                         count++;
  223.  
  224.             return count;
  225.         }
  226.  
  227.         void kickCastViewers()
  228.         {
  229.             for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it)
  230.             {
  231.                 if(it->second->getPlayer() == this)
  232.                 {
  233.                     it->second->disconnect();
  234.                     it->second->unRef();
  235.                     removeCastViewer(it->first);
  236.                 }
  237.             }
  238.             cast = PlayerCast();
  239.         }
  240.  
  241.         void kickCastViewerByName(std::string n)
  242.         {
  243.             for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  244.                 if(it->second->getViewerName() == n && it->second->getPlayer() == this)
  245.                 {
  246.                     it->second->disconnect();
  247.                     it->second->unRef();
  248.                     removeCastViewer(it->first);
  249.                 }
  250.         }
  251.  
  252.         bool addCastBan(std::string n)
  253.         {
  254.             uint32_t ip = getCastIpByName(n);
  255.             if(!ip)
  256.                 return false;
  257.  
  258.             cast.bans.push_back(CastBan(n, ip));
  259.             kickCastViewerByName(n);
  260.             return true;
  261.         }
  262.  
  263.         bool removeCastBan(std::string n)
  264.         {
  265.             for(std::list<CastBan>::iterator it = cast.bans.begin(); it != cast.bans.end(); ++it)
  266.                 if(it->name == n)
  267.                 {
  268.                     cast.bans.erase(it);
  269.                     return true;
  270.                 }
  271.  
  272.             return false;
  273.         }
  274.  
  275.  
  276.         bool addCastMute(std::string n)
  277.         {
  278.             uint32_t ip = getCastIpByName(n);
  279.             if(!ip)
  280.                 return false;
  281.  
  282.             cast.muted.push_back(CastBan(n, ip));
  283.             return true;
  284.         }
  285.  
  286.         bool removeCastMute(std::string n)
  287.         {
  288.             for(std::list<CastBan>::iterator it = cast.muted.begin(); it != cast.muted.end(); ++it)
  289.                 if(it->name == n)
  290.                 {
  291.                     cast.muted.erase(it);
  292.                     return true;
  293.                 }
  294.  
  295.             return false;
  296.         }
  297.  
  298.         virtual const std::string& getName() const {return name;}
  299.         virtual const std::string& getNameDescription() const {return nameDescription;}
  300.         virtual std::string getDescription(int32_t lookDistance) const;
  301.  
  302.         const std::string& getSpecialDescription() const {return specialDescription;}
  303.         void setSpecialDescription(const std::string& desc) {specialDescription = desc;}
  304.  
  305.         void manageAccount(const std::string& text);
  306.         bool isAccountManager() const {return (accountManager != MANAGER_NONE);}
  307.         void kickPlayer(bool displayEffect, bool forceLogout);
  308.  
  309.         void setGUID(uint32_t _guid) {guid = _guid;}
  310.         uint32_t getGUID() const {return guid;}
  311.  
  312.         static AutoList<Player> autoList;
  313.        
  314.         static AutoList<Player> castAutoList;
  315.         static AutoList<ProtocolGame> cSpectators;
  316.         static uint32_t nextSpectator;
  317.        
  318.         virtual uint32_t rangeId() {return 0x10000000;}
  319.  
  320.         void addList();
  321.         void removeList();
  322.  
  323.         static uint64_t getExpForLevel(uint32_t lv)
  324.         {
  325.             lv--;
  326.             return ((50ULL * lv * lv * lv) - (150ULL * lv * lv) + (400ULL * lv)) / 3ULL;
  327.         }
  328.  
  329.         uint32_t getPromotionLevel() const {return promotionLevel;}
  330.         void setPromotionLevel(uint32_t pLevel);
  331.  
  332.         bool changeOutfit(Outfit_t outfit, bool checkList);
  333.         void hasRequestedOutfit(bool v) {requestedOutfit = v;}
  334.  
  335.         Vocation* getVocation() const {return vocation;}
  336.         int32_t getPlayerInfo(playerinfo_t playerinfo) const;
  337.  
  338.         void setParty(Party* _party) {party = _party;}
  339.         Party* getParty() const {return party;}
  340.  
  341.         bool isInviting(const Player* player) const;
  342.         bool isPartner(const Player* player) const;
  343.  
  344.         bool getHideHealth() const;
  345.  
  346.         bool addPartyInvitation(Party* party);
  347.         bool removePartyInvitation(Party* party);
  348.         void clearPartyInvitations();
  349.  
  350.         uint32_t getGuildId() const {return guildId;}
  351.         void setGuildId(uint32_t newId) {guildId = newId;}
  352.         uint32_t getRankId() const {return rankId;}
  353.         void setRankId(uint32_t newId) {rankId = newId;}
  354.  
  355.         GuildLevel_t getGuildLevel() const {return guildLevel;}
  356.         bool setGuildLevel(GuildLevel_t newLevel, uint32_t rank = 0);
  357.  
  358.         const std::string& getGuildName() const {return guildName;}
  359.         void setGuildName(const std::string& newName) {guildName = newName;}
  360.         const std::string& getRankName() const {return rankName;}
  361.         void setRankName(const std::string& newName) {rankName = newName;}
  362.  
  363.         const std::string& getGuildNick() const {return guildNick;}
  364.         void setGuildNick(const std::string& newNick) {guildNick = newNick;}
  365.  
  366.         bool isGuildInvited(uint32_t guildId) const;
  367.         void leaveGuild();
  368.  
  369.         void setFlags(uint64_t flags) {if(group) group->setFlags(flags);}
  370.         bool hasFlag(PlayerFlags value) const {return group != NULL && group->hasFlag(value);}
  371.         void setCustomFlags(uint64_t flags) {if(group) group->setCustomFlags(flags);}
  372.         bool hasCustomFlag(PlayerCustomFlags value) const {return group != NULL && group->hasCustomFlag(value);}
  373.  
  374.         void addBlessing(int16_t blessing) {blessings += blessing;}
  375.         void removeBlessing(int16_t blessing) {blessings -= blessing;}
  376.         bool hasBlessing(int16_t blessing) const {return ((blessings & ((int16_t)1 << blessing)) != 0);}
  377.         uint16_t getBlessings() const;
  378.  
  379.         OperatingSystem_t getOperatingSystem() const {return operatingSystem;}
  380.         void setOperatingSystem(OperatingSystem_t clientOs) {operatingSystem = clientOs;}
  381.         uint32_t getClientVersion() const {return clientVersion;}
  382.         void setClientVersion(uint32_t version) {clientVersion = version;}
  383.  
  384.         bool hasClient() const {return client;}
  385.         bool isVirtual() const {return (getID() == 0);}
  386.         void disconnect() {
  387.             if(client) {
  388.                 client->disconnect();
  389.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  390.                     it->second->disconnect();
  391.             }
  392.         }
  393.         uint32_t getIP() const;
  394.         bool canOpenCorpse(uint32_t ownerId);
  395.  
  396.         Container* getContainer(uint32_t cid);
  397.         int32_t getContainerID(const Container* container) const;
  398.  
  399.         void addContainer(uint32_t cid, Container* container);
  400.         void closeContainer(uint32_t cid);
  401.  
  402.         virtual bool setStorage(const uint32_t key, const std::string& value);
  403.         virtual void eraseStorage(const uint32_t key);
  404.  
  405.         void generateReservedStorage();
  406.         bool transferMoneyTo(const std::string& name, uint64_t amount);
  407.         void increaseCombatValues(int32_t& min, int32_t& max, bool useCharges, bool countWeapon);
  408.  
  409.         void setGroupId(int32_t newId);
  410.         int32_t getGroupId() const {return groupId;}
  411.         void setGroup(Group* newGroup);
  412.         Group* getGroup() const {return group;}
  413.  
  414.         virtual bool isGhost() const {return hasCondition(CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE) || hasFlag(PlayerFlag_CannotBeSeen);}
  415.         virtual bool isWalkable() const {return hasCustomFlag(PlayerCustomFlag_IsWalkable);}
  416.  
  417.         void switchSaving() {saving = !saving;}
  418.         bool isSaving() const {return saving;}
  419.  
  420.         uint32_t getIdleTime() const {return idleTime;}
  421.         void setIdleTime(uint32_t amount) {idleTime = amount;}
  422.  
  423.         bool checkLoginDelay(uint32_t playerId) const;
  424.         bool isTrading() const {return tradePartner;}
  425.  
  426.         uint32_t getAccount() const {return accountId;}
  427.         std::string getAccountName() const {return account;}
  428.         uint16_t getAccess() const {return group ? group->getAccess() : 0;}
  429.         uint16_t getGhostAccess() const {return group ? group->getGhostAccess() : 0;}
  430.  
  431.         uint32_t getLevel() const {return level;}
  432.         uint64_t getExperience() const {return experience;}
  433.         uint32_t getMagicLevel() const {return getPlayerInfo(PLAYERINFO_MAGICLEVEL);}
  434.         uint64_t getSpentMana() const {return manaSpent;}
  435.  
  436.         bool isPremium() const;
  437.         int32_t getPremiumDays() const {return premiumDays;}
  438.  
  439.         bool hasEnemy() const {return !warMap.empty();}
  440.         bool getEnemy(const Player* player, War_t& data) const;
  441.  
  442.         bool isEnemy(const Player* player, bool allies) const;
  443.         bool isAlly(const Player* player) const;
  444.  
  445.         void addEnemy(uint32_t guild, War_t war)
  446.             {warMap[guild] = war;}
  447.         void removeEnemy(uint32_t guild) {warMap.erase(guild);}
  448.  
  449.         uint32_t getVocationId() const {return vocationId;}
  450.         void setVocation(uint32_t id);
  451.         uint16_t getSex(bool full) const {return full ? sex : sex % 2;}
  452.         void setSex(uint16_t);
  453.  
  454.         uint32_t getBaseVoc();
  455.         double getPartyBonus();
  456.  
  457.         uint64_t getStamina() const {return hasFlag(PlayerFlag_HasInfiniteStamina) ? STAMINA_MAX : stamina;}
  458.         void setStamina(uint64_t value) {stamina = std::min((uint64_t)STAMINA_MAX, (uint64_t)std::max((uint64_t)0, value));}
  459.         uint32_t getStaminaMinutes() const {return (uint32_t)(getStamina() / (uint64_t)STAMINA_MULTIPLIER);}
  460.         void setStaminaMinutes(uint32_t value) {setStamina((uint64_t)(value * STAMINA_MULTIPLIER));}
  461.         void useStamina(int64_t value) {stamina = std::min((int64_t)STAMINA_MAX, (int64_t)std::max((int64_t)0, ((int64_t)stamina + value)));}
  462.         uint64_t getSpentStamina() {return (uint64_t)STAMINA_MAX - stamina;}
  463.  
  464.         int64_t getLastLoad() const {return lastLoad;}
  465.         time_t getLastLogin() const {return lastLogin;}
  466.         time_t getLastLogout() const {return lastLogout;}
  467.  
  468.         Position getLoginPosition() const {return loginPosition;}
  469.  
  470.         uint32_t getTown() const {return town;}
  471.         void setTown(uint32_t _town) {town = _town;}
  472.  
  473.         virtual bool isPushable() const;
  474.         virtual int32_t getThrowRange() const {return 1;}
  475.         virtual double getGainedExperience(Creature* attacker) const;
  476.  
  477.         bool isMuted(uint16_t channelId, SpeakClasses type, uint32_t& time);
  478.         void addMessageBuffer();
  479.         void removeMessageBuffer();
  480.  
  481.         double getCapacity() const {return capacity;}
  482.         void setCapacity(double newCapacity) {capacity = newCapacity;}
  483.  
  484.         double getFreeCapacity() const
  485.         {
  486.             if(hasFlag(PlayerFlag_CannotPickupItem))
  487.                 return 0.00;
  488.             else if(hasFlag(PlayerFlag_HasInfiniteCapacity))
  489.                 return 10000.00;
  490.  
  491.             return std::max(0.00, capacity - inventoryWeight);
  492.         }
  493.  
  494.         virtual int32_t getSoul() const {return getPlayerInfo(PLAYERINFO_SOUL);}
  495.         virtual int32_t getMaxHealth() const {return getPlayerInfo(PLAYERINFO_MAXHEALTH);}
  496.         virtual int32_t getMaxMana() const {return getPlayerInfo(PLAYERINFO_MAXMANA);}
  497.         int32_t getSoulMax() const {return soulMax;}
  498.  
  499.         Item* getInventoryItem(slots_t slot) const;
  500.         Item* getEquippedItem(slots_t slot) const;
  501.  
  502.         bool isItemAbilityEnabled(slots_t slot) const {return inventoryAbilities[slot];}
  503.         void setItemAbility(slots_t slot, bool enabled) {inventoryAbilities[slot] = enabled;}
  504.  
  505.         int32_t getVarSkill(skills_t skill) const {return varSkills[skill];}
  506.         void setVarSkill(skills_t skill, int32_t modifier) {varSkills[skill] += modifier;}
  507.  
  508.         int32_t getVarStats(stats_t stat) const {return varStats[stat];}
  509.         void setVarStats(stats_t stat, int32_t modifier);
  510.         int32_t getDefaultStats(stats_t stat);
  511.  
  512.         void setConditionSuppressions(uint32_t conditions, bool remove);
  513.  
  514.         uint32_t getLossPercent(lossTypes_t lossType) const {return lossPercent[lossType];}
  515.         void setLossPercent(lossTypes_t lossType, uint32_t newPercent) {lossPercent[lossType] = newPercent;}
  516.  
  517.         Depot* getDepot(uint32_t depotId, bool autoCreateDepot);
  518.         bool addDepot(Depot* depot, uint32_t depotId);
  519.         void useDepot(uint32_t depotId, bool value);
  520.  
  521.         virtual bool canSee(const Position& pos) const;
  522.         virtual bool canSeeCreature(const Creature* creature) const;
  523.         virtual bool canWalkthrough(const Creature* creature) const;
  524.  
  525.         virtual bool canSeeInvisibility() const {return hasFlag(PlayerFlag_CanSenseInvisibility);}
  526.  
  527.         virtual RaceType_t getRace() const {return RACE_BLOOD;}
  528.  
  529.         //safe-trade functions
  530.         void setTradeState(tradestate_t state) {tradeState = state;}
  531.         tradestate_t getTradeState() {return tradeState;}
  532.         Item* getTradeItem() {return tradeItem;}
  533.  
  534.         //shop functions
  535.         void setShopOwner(Npc* owner, int32_t onBuy, int32_t onSell, ShopInfoList offer)
  536.         {
  537.             shopOwner = owner;
  538.             purchaseCallback = onBuy;
  539.             saleCallback = onSell;
  540.             shopOffer = offer;
  541.         }
  542.  
  543.         Npc* getShopOwner(int32_t& onBuy, int32_t& onSell)
  544.         {
  545.             onBuy = purchaseCallback;
  546.             onSell = saleCallback;
  547.             return shopOwner;
  548.         }
  549.  
  550.         const Npc* getShopOwner(int32_t& onBuy, int32_t& onSell) const
  551.         {
  552.             onBuy = purchaseCallback;
  553.             onSell = saleCallback;
  554.             return shopOwner;
  555.         }
  556.  
  557.         //V.I.P. functions
  558.         void notifyLogIn(Player* loginPlayer);
  559.         void notifyLogOut(Player* logoutPlayer);
  560.         bool removeVIP(uint32_t guid);
  561.         bool addVIP(uint32_t guid, std::string& name, bool isOnline, bool internal = false);
  562.  
  563.         //follow functions
  564.         virtual bool setFollowCreature(Creature* creature, bool fullPathSearch = false);
  565.         virtual void goToFollowCreature();
  566.  
  567.         //follow events
  568.         virtual void onFollowCreature(const Creature* creature);
  569.  
  570.         //walk events
  571.         virtual void onWalk(Direction& dir);
  572.         virtual void onWalkAborted();
  573.         virtual void onWalkComplete();
  574.  
  575.         void stopWalk() {cancelNextWalk = true;}
  576.         void openShopWindow();
  577.         void closeShopWindow(bool send = true, Npc* npc = NULL, int32_t onBuy = -1, int32_t onSell = -1);
  578.         bool canShopItem(uint16_t itemId, uint8_t subType, ShopEvent_t event);
  579.  
  580.         chaseMode_t getChaseMode() const {return chaseMode;}
  581.         void setChaseMode(chaseMode_t mode);
  582.         fightMode_t getFightMode() const {return fightMode;}
  583.         void setFightMode(fightMode_t mode) {fightMode = mode;}
  584.         secureMode_t getSecureMode() const {return secureMode;}
  585.         void setSecureMode(secureMode_t mode) {secureMode = mode;}
  586.  
  587.         //combat functions
  588.         virtual bool setAttackedCreature(Creature* creature);
  589.         bool isImmune(CombatType_t type) const;
  590.         bool isImmune(ConditionType_t type) const;
  591.         bool hasShield() const;
  592.         virtual bool isAttackable() const;
  593.  
  594.         virtual void changeHealth(int32_t healthChange);
  595.         virtual void changeMana(int32_t manaChange);
  596.         void changeSoul(int32_t soulChange);
  597.  
  598.         bool isPzLocked() const {return pzLocked;}
  599.         void setPzLocked(bool v) {pzLocked = v;}
  600.  
  601.         virtual BlockType_t blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
  602.             bool checkDefense = false, bool checkArmor = false, bool reflect = true);
  603.         virtual void doAttacking(uint32_t interval);
  604.         virtual bool hasExtraSwing() {return lastAttack > 0 && ((OTSYS_TIME() - lastAttack) >= getAttackSpeed());}
  605.         int32_t getShootRange() const {return shootRange;}
  606.  
  607.         int32_t getSkill(skills_t skilltype, skillsid_t skillinfo) const;
  608.         bool getAddAttackSkill() const {return addAttackSkillPoint;}
  609.         BlockType_t getLastAttackBlockType() const {return lastAttackBlockType;}
  610.  
  611.         Item* getWeapon(bool ignoreAmmo);
  612.         ItemVector getWeapons() const;
  613.  
  614.         virtual WeaponType_t getWeaponType();
  615.         int32_t getWeaponSkill(const Item* item) const;
  616.         void getShieldAndWeapon(const Item* &_shield, const Item* &_weapon) const;
  617.  
  618.         virtual void drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage);
  619.         virtual void drainMana(Creature* attacker, CombatType_t combatType, int32_t damage);
  620.  
  621.         void addExperience(uint64_t exp);
  622.         void removeExperience(uint64_t exp, bool updateStats = true);
  623.         void addManaSpent(uint64_t amount, bool useMultiplier = true);
  624.         void addSkillAdvance(skills_t skill, uint32_t count, bool useMultiplier = true);
  625.         bool addUnjustifiedKill(const Player* attacked, bool countNow);
  626.  
  627.         virtual int32_t getArmor() const;
  628.         virtual int32_t getDefense() const;
  629.         virtual float getAttackFactor() const;
  630.         virtual float getDefenseFactor() const;
  631.  
  632.         void setMagicLevel(uint64_t value);
  633.         void setSkillLevel(skills_t skill, uint32_t value);
  634.  
  635.         void addExhaust(uint32_t ticks, Exhaust_t type);
  636.         void addInFightTicks(bool pzLock, int32_t ticks = 0);
  637.         void addDefaultRegeneration(uint32_t addTicks);
  638.  
  639.         //combat event functions
  640.         virtual void onAddCondition(ConditionType_t type, bool hadCondition);
  641.         virtual void onAddCombatCondition(ConditionType_t type, bool hadCondition);
  642.         virtual void onEndCondition(ConditionType_t type);
  643.         virtual void onCombatRemoveCondition(const Creature* attacker, Condition* condition);
  644.         virtual void onTickCondition(ConditionType_t type, int32_t interval, bool& _remove);
  645.         virtual void onAttackedCreature(Creature* target);
  646.         virtual void onSummonAttackedCreature(Creature* summon, Creature* target);
  647.         virtual void onAttacked();
  648.         virtual void onAttackedCreatureDrain(Creature* target, int32_t points);
  649.         virtual void onSummonAttackedCreatureDrain(Creature* summon, Creature* target, int32_t points);
  650.         virtual void onTargetCreatureGainHealth(Creature* target, int32_t points);
  651.         virtual bool onKilledCreature(Creature* target, DeathEntry& entry);
  652.         virtual void onGainExperience(double& gainExp, bool fromMonster, bool multiplied);
  653.         virtual void onGainSharedExperience(double& gainExp, bool fromMonster, bool multiplied);
  654.         virtual void onAttackedCreatureBlockHit(Creature* target, BlockType_t blockType);
  655.         virtual void onBlockHit(BlockType_t blockType);
  656.         virtual void onChangeZone(ZoneType_t zone);
  657.         virtual void onAttackedCreatureChangeZone(ZoneType_t zone);
  658.         virtual void onIdleStatus();
  659.         virtual void onPlacedCreature();
  660.  
  661.         virtual void getCreatureLight(LightInfo& light) const;
  662.         Skulls_t getSkull() const;
  663.  
  664.         Skulls_t getSkullType(const Creature* creature) const;
  665.         PartyShields_t getPartyShield(const Creature* creature) const;
  666.         GuildEmblems_t getGuildEmblem(const Creature* creature) const;
  667.  
  668.         bool hasAttacked(const Player* attacked) const;
  669.         void addAttacked(const Player* attacked);
  670.         void clearAttacked() {attackedSet.clear();}
  671.  
  672.         time_t getSkullEnd() const {return skullEnd;}
  673.         void setSkullEnd(time_t _time, bool login, Skulls_t _skull);
  674.  
  675.         bool addOutfit(uint32_t outfitId, uint32_t addons);
  676.         bool removeOutfit(uint32_t outfitId, uint32_t addons);
  677.  
  678.         bool canWearOutfit(uint32_t outfitId, uint32_t addons);
  679.  
  680.         //tile
  681.         //send methods
  682.         void sendAddTileItem(const Tile* tile, const Position& pos, const Item* item)
  683.             {if(client) {client->sendAddTileItem(tile, pos, tile->getClientIndexOfThing(this, item), item);
  684.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  685.                     it->second->sendAddTileItem(tile, pos, tile->getClientIndexOfThing(this, item), item);
  686.             }
  687.         }
  688.  
  689.         void sendUpdateTileItem(const Tile* tile, const Position& pos, const Item* oldItem, const Item* newItem)
  690.             {if(client) {client->sendUpdateTileItem(tile, pos, tile->getClientIndexOfThing(this, oldItem), newItem);
  691.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  692.                     it->second->sendUpdateTileItem(tile, pos, tile->getClientIndexOfThing(this, oldItem), newItem);
  693.             }
  694.         }
  695.         void sendRemoveTileItem(const Tile* tile, const Position& pos, uint32_t stackpos, const Item*)
  696.             {if(client) {client->sendRemoveTileItem(tile, pos, stackpos);
  697.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  698.                     it->second->sendRemoveTileItem(tile, pos, stackpos);
  699.             }
  700.         }
  701.         void sendUpdateTile(const Tile* tile, const Position& pos)
  702.             {if(client) {client->sendUpdateTile(tile, pos);
  703.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  704.                     it->second->sendUpdateTile(tile, pos);
  705.             }  
  706.         }
  707.  
  708.         void sendChannelMessage(std::string author, std::string text, SpeakClasses type, uint8_t channel)
  709.             {if(client) {client->sendChannelMessage(author, text, type, channel);
  710.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  711.                     it->second->sendChannelMessage(author, text, type, channel);
  712.             }
  713.         }
  714.  
  715.         void sendCreatureAppear(const Creature* creature)
  716.             {if(client) {client->sendAddCreature(creature, creature->getPosition(), creature->getTile()->getClientIndexOfThing(this, creature));
  717.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  718.                     it->second->sendAddCreature(creature, creature->getPosition(), creature->getTile()->getClientIndexOfThing(this, creature));
  719.             }
  720.         }
  721.         void sendCreatureDisappear(const Creature* creature, uint32_t stackpos)
  722.             {if(client) {client->sendRemoveCreature(creature, creature->getPosition(), stackpos);
  723.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  724.                     it->second->sendRemoveCreature(creature, creature->getPosition(), stackpos);
  725.             }
  726.         }
  727.         void sendCreatureMove(const Creature* creature, const Tile* newTile, const Position& newPos,
  728.             const Tile* oldTile, const Position& oldPos, uint32_t oldStackpos, bool teleport)
  729.             {if(client) {client->sendMoveCreature(creature, newTile, newPos, newTile->getClientIndexOfThing(this, creature), oldTile, oldPos, oldStackpos, teleport);
  730.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  731.                     it->second->sendMoveCreature(creature, newTile, newPos, newTile->getClientIndexOfThing(this, creature), oldTile, oldPos, oldStackpos, teleport);
  732.             }
  733.         }
  734.  
  735.         void sendCreatureTurn(const Creature* creature)
  736.             {if(client) {client->sendCreatureTurn(creature, creature->getTile()->getClientIndexOfThing(this, creature));
  737.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  738.                     it->second->sendCreatureTurn(creature, creature->getTile()->getClientIndexOfThing(this, creature));
  739.             }
  740.         }
  741.         void sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text, Position* pos = NULL)
  742.             {if(client) {client->sendCreatureSay(creature, type, text, pos);
  743.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  744.                     it->second->sendCreatureSay(creature, type, text, pos);
  745.             }
  746.         }
  747.  
  748.         void sendCreatureSquare(const Creature* creature, uint8_t color)
  749.             {if(client) {client->sendCreatureSquare(creature, color);
  750.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  751.                     it->second->sendCreatureSquare(creature, color);
  752.             }
  753.         }
  754.         void sendCreatureChangeOutfit(const Creature* creature, const Outfit_t& outfit)
  755.             {if(client) {client->sendCreatureOutfit(creature, outfit);
  756.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  757.                     it->second->sendCreatureOutfit(creature, outfit);
  758.             }
  759.         }
  760.         void sendCreatureChangeVisible(const Creature* creature, Visible_t visible);
  761.         void sendCreatureLight(const Creature* creature)
  762.             {if(client) {client->sendCreatureLight(creature);
  763.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  764.                     it->second->sendCreatureLight(creature);
  765.             }
  766.         }
  767.         void sendCreatureShield(const Creature* creature)
  768.             {if(client) {client->sendCreatureShield(creature);
  769.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  770.                     it->second->sendCreatureShield(creature);
  771.             }
  772.         }
  773.         void sendCreatureEmblem(const Creature* creature)
  774.             {if(client) {client->sendCreatureEmblem(creature);
  775.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  776.                     it->second->sendCreatureEmblem(creature);
  777.             }
  778.         }
  779.         void sendCreatureImpassable(const Creature* creature)
  780.             {if(client) {client->sendCreatureImpassable(creature);
  781.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  782.                     it->second->sendCreatureEmblem(creature);
  783.            }
  784.         }
  785.         //container
  786.         void sendAddContainerItem(const Container* container, const Item* item);
  787.         void sendUpdateContainerItem(const Container* container, uint8_t slot, const Item* oldItem, const Item* newItem);
  788.         void sendRemoveContainerItem(const Container* container, uint8_t slot, const Item* item);
  789.         void sendContainer(uint32_t cid, const Container* container, bool hasParent)
  790.             {if(client) client->sendContainer(cid, container, hasParent);}
  791.  
  792.         //inventory
  793.         void sendAddInventoryItem(slots_t slot, const Item* item)
  794.             {if(client) {client->sendAddInventoryItem(slot, item);
  795.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  796.                     it->second->sendAddInventoryItem(slot, item);
  797.             }
  798.         }
  799.         void sendUpdateInventoryItem(slots_t slot, const Item*, const Item* newItem)
  800.             {if(client) {client->sendUpdateInventoryItem(slot, newItem);
  801.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  802.                     it->second->sendUpdateInventoryItem(slot, newItem);
  803.             }
  804.         }
  805.         void sendRemoveInventoryItem(slots_t slot, const Item*)
  806.             {if(client) {client->sendRemoveInventoryItem(slot);
  807.                 for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  808.                     it->second->sendRemoveInventoryItem(slot);
  809.             }
  810.         }
  811.  
  812.         //event methods
  813.         virtual void onUpdateTileItem(const Tile* tile, const Position& pos, const Item* oldItem,
  814.             const ItemType& oldType, const Item* newItem, const ItemType& newType);
  815.         virtual void onRemoveTileItem(const Tile* tile, const Position& pos,
  816.             const ItemType& iType, const Item* item);
  817.  
  818.         virtual void onCreatureAppear(const Creature* creature);
  819.         virtual void onCreatureDisappear(const Creature* creature, bool isLogout);
  820.         virtual void onCreatureMove(const Creature* creature, const Tile* newTile, const Position& newPos,
  821.             const Tile* oldTile, const Position& oldPos, bool teleport);
  822.  
  823.         virtual void onAttackedCreatureDisappear(bool isLogout);
  824.         virtual void onFollowCreatureDisappear(bool isLogout);
  825.  
  826.         //cylinder implementations
  827.         virtual Cylinder* getParent() {return Creature::getParent();}
  828.         virtual const Cylinder* getParent() const {return Creature::getParent();}
  829.         virtual bool isRemoved() const {return Creature::isRemoved();}
  830.         virtual Position getPosition() const {return Creature::getPosition();}
  831.         virtual Tile* getTile() {return Creature::getTile();}
  832.         virtual const Tile* getTile() const {return Creature::getTile();}
  833.         virtual Item* getItem() {return NULL;}
  834.         virtual const Item* getItem() const {return NULL;}
  835.         virtual Creature* getCreature() {return this;}
  836.         virtual const Creature* getCreature() const {return this;}
  837.  
  838.         //container
  839.         void onAddContainerItem(const Container* container, const Item* item);
  840.         void onUpdateContainerItem(const Container* container, uint8_t slot,
  841.             const Item* oldItem, const ItemType& oldType, const Item* newItem, const ItemType& newType);
  842.         void onRemoveContainerItem(const Container* container, uint8_t slot, const Item* item);
  843.  
  844.         void onCloseContainer(const Container* container);
  845.         void onSendContainer(const Container* container);
  846.         void autoCloseContainers(const Container* container);
  847.  
  848.         //inventory
  849.         void onAddInventoryItem(slots_t, Item*) {}
  850.         void onUpdateInventoryItem(slots_t slot, Item* oldItem, const ItemType& oldType,
  851.             Item* newItem, const ItemType& newType);
  852.         void onRemoveInventoryItem(slots_t slot, Item* item);
  853.  
  854.         void sendAnimatedText(const Position& pos, uint8_t color, std::string text) const
  855.             {if(client) {client->sendAnimatedText(pos,color,text);
  856.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  857.                     it->second->sendAnimatedText(pos,color,text);
  858.             }
  859.         }
  860.         void sendCancel(const std::string& msg) const
  861.             {if(client) {client->sendCancel(msg);
  862.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  863.                     it->second->sendCancel(msg);
  864.             }
  865.         }
  866.         void sendCancelMessage(ReturnValue message) const;
  867.         void sendCancelTarget() const
  868.             {if(client) {client->sendCancelTarget();
  869.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  870.                     it->second->sendCancelTarget();
  871.             }
  872.         }
  873.         void sendCancelWalk() const
  874.             {if(client) {client->sendCancelWalk();
  875.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  876.                     it->second->sendCancelWalk();
  877.             }
  878.         }
  879.         void sendChangeSpeed(const Creature* creature, uint32_t newSpeed) const
  880.             {if(client) {client->sendChangeSpeed(creature, newSpeed);
  881.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  882.                     it->second->sendChangeSpeed(creature, newSpeed);
  883.             }
  884.         }
  885.         void sendCreatureHealth(const Creature* creature) const
  886.             {if(client) {client->sendCreatureHealth(creature);
  887.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  888.                     it->second->sendCreatureHealth(creature);
  889.             }
  890.         }
  891.         void sendDistanceShoot(const Position& from, const Position& to, uint8_t type) const
  892.             {if(client) {client->sendDistanceShoot(from, to, type);
  893.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  894.                     it->second->sendDistanceShoot(from, to, type);
  895.             }
  896.         }
  897.        
  898.         void sendHouseWindow(House* house, uint32_t listId) const;
  899.         void sendOutfitWindow() const {if(client) client->sendOutfitWindow();}
  900.         void sendQuests() const {if(client) client->sendQuests();}
  901.         void sendQuestInfo(Quest* quest) const {if(client) client->sendQuestInfo(quest);}
  902.         void sendCreatureSkull(const Creature* creature) const
  903.             {if(client) {client->sendCreatureSkull(creature);
  904.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  905.                     it->second->sendCreatureSkull(creature);
  906.             }
  907.         }
  908.         void sendFYIBox(std::string message)
  909.             {if(client) client->sendFYIBox(message);}
  910.         void sendCreatePrivateChannel(uint16_t channelId, const std::string& channelName)
  911.             {if(client) {client->sendCreatePrivateChannel(channelId, channelName);
  912.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  913.                     it->second->sendCreatePrivateChannel(channelId, channelName);
  914.             }
  915.         }
  916.         void sendClosePrivate(uint16_t channelId) const
  917.             {if(client) {client->sendClosePrivate(channelId);
  918.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  919.                     it->second->sendClosePrivate(channelId);
  920.             }
  921.         }
  922.         void sendIcons() const;
  923.         void sendMagicEffect(const Position& pos, uint8_t type) const
  924.             {if(client) {client->sendMagicEffect(pos, type);
  925.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  926.                     it->second->sendMagicEffect(pos, type);
  927.             }
  928.         }
  929.         void sendStats() const
  930.             {if(client) {client->sendStats();
  931.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  932.                     it->second->sendStats();
  933.             }
  934.         }
  935.         void sendSkills() const
  936.             {if(client) {client->sendSkills();
  937.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  938.                     it->second->sendSkills();
  939.             }
  940.         }
  941.         void sendTextMessage(MessageClasses type, const std::string& message) const
  942.             {if(client) {client->sendTextMessage(type, message);
  943.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  944.                     it->second->sendTextMessage(type, message);
  945.             }
  946.         }
  947.  
  948.         void sendReLoginWindow() const
  949.             {if(client) client->sendReLoginWindow();}
  950.         void sendTextWindow(Item* item, uint16_t maxLen, bool canWrite) const
  951.             {if(client) client->sendTextWindow(windowTextId, item, maxLen, canWrite);}
  952.         void sendTextWindow(uint32_t itemId, const std::string& text) const
  953.             {if(client) client->sendTextWindow(windowTextId, itemId, text);}
  954.         void sendToChannel(Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId, uint32_t time = 0, ProtocolGame* pg = NULL) const
  955.             {if(client) {client->sendToChannel(creature, type, text, channelId, time, pg);
  956.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  957.                     it->second->sendToChannel(creature, type, text, channelId, time, pg);
  958.             }
  959.         }
  960.         void sendShop() const
  961.             {if(client) client->sendShop(shopOffer);}
  962.         void sendGoods() const
  963.             {if(client) client->sendGoods(shopOffer);}
  964.         void sendCloseShop() const
  965.             {if(client) client->sendCloseShop();}
  966.         void sendTradeItemRequest(const Player* player, const Item* item, bool ack) const
  967.             {if(client) client->sendTradeItemRequest(player, item, ack);}
  968.         void sendTradeClose() const
  969.             {if(client) client->sendCloseTrade();}
  970.         void sendWorldLight(LightInfo& lightInfo)
  971.             {if(client) {client->sendWorldLight(lightInfo);
  972.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  973.                     it->second->sendWorldLight(lightInfo);
  974.             }
  975.         }
  976.         void sendChannelsDialog()
  977.             {if(client) client->sendChannelsDialog();}
  978.         void sendOpenPrivateChannel(const std::string& receiver)
  979.             {if(client) client->sendOpenPrivateChannel(receiver);}
  980.         void sendOutfitWindow()
  981.             {if(client) client->sendOutfitWindow();}
  982.         void sendCloseContainer(uint32_t cid)
  983.             {if(client) {client->sendCloseContainer(cid);
  984.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  985.                     it->second->sendCloseContainer(cid);
  986.             }
  987.         }
  988.         void sendChannel(uint16_t channelId, const std::string& channelName)
  989.             {if(client) {client->sendChannel(channelId, channelName);
  990.                 for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) if(it->second->getPlayer() == this)
  991.                     it->second->sendChannel(channelId, channelName);
  992.             }
  993.         }
  994.         void sendRuleViolationsChannel(uint16_t channelId)
  995.             {if(client) client->sendRuleViolationsChannel(channelId);}
  996.         void sendRemoveReport(const std::string& name)
  997.             {if(client) client->sendRemoveReport(name);}
  998.         void sendLockRuleViolation()
  999.             {if(client) client->sendLockRuleViolation();}
  1000.         void sendRuleViolationCancel(const std::string& name)
  1001.             {if(client) client->sendRuleViolationCancel(name);}
  1002.         void sendTutorial(uint8_t tutorialId)
  1003.             {if(client) client->sendTutorial(tutorialId);}
  1004.         void sendAddMarker(const Position& pos, MapMarks_t markType, const std::string& desc)
  1005.             {if (client) client->sendAddMarker(pos, markType, desc);}
  1006.         void sendCritical() const;
  1007.         void sendPlayerIcons(Player* player);
  1008.  
  1009.         void receivePing() {lastPong = OTSYS_TIME();}
  1010.         virtual void onThink(uint32_t interval);
  1011.         uint32_t getAttackSpeed() const;
  1012.  
  1013.         virtual void postAddNotification(Creature* actor, Thing* thing, const Cylinder* oldParent,
  1014.             int32_t index, cylinderlink_t link = LINK_OWNER);
  1015.         virtual void postRemoveNotification(Creature* actor, Thing* thing, const Cylinder* newParent,
  1016.             int32_t index, bool isCompleteRemoval, cylinderlink_t link = LINK_OWNER);
  1017.  
  1018.         void setNextAction(int64_t time) {if(time > nextAction) {nextAction = time;}}
  1019.         bool canDoAction() const {return nextAction <= OTSYS_TIME();}
  1020.         uint32_t getNextActionTime() const;
  1021.  
  1022.         Item* getWriteItem(uint32_t& _windowTextId, uint16_t& _maxWriteLen);
  1023.         void setWriteItem(Item* item, uint16_t _maxWriteLen = 0);
  1024.  
  1025.         House* getEditHouse(uint32_t& _windowTextId, uint32_t& _listId);
  1026.         void setEditHouse(House* house, uint32_t listId = 0);
  1027.  
  1028.         void learnInstantSpell(const std::string& name);
  1029.         void unlearnInstantSpell(const std::string& name);
  1030.         bool hasLearnedInstantSpell(const std::string& name) const;
  1031.  
  1032.         VIPSet VIPList;
  1033.         ContainerVector containerVec;
  1034.         InvitedToGuildsList invitedToGuildsList;
  1035.         ConditionList storedConditionList;
  1036.         DepotMap depots;
  1037.  
  1038.         uint32_t marriage;
  1039.         uint64_t balance;
  1040.         double rates[SKILL__LAST + 1];
  1041.         Container transferContainer;
  1042.  
  1043.     protected:
  1044.         PlayerCast cast;
  1045.  
  1046.         void checkTradeState(const Item* item);
  1047.  
  1048.         bool gainExperience(double& gainExp, bool fromMonster);
  1049.         bool rateExperience(double& gainExp, bool fromMonster);
  1050.         void updateBaseSpeed()
  1051.         {
  1052.             if(!hasFlag(PlayerFlag_SetMaxSpeed))
  1053.                 baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));
  1054.             else
  1055.                 baseSpeed = SPEED_MAX;
  1056.         }
  1057.  
  1058.         void updateInventoryWeight();
  1059.         void updateInventoryGoods(uint32_t itemId);
  1060.         void updateItemsLight(bool internal = false);
  1061.         void updateWeapon();
  1062.  
  1063.         void setNextWalkActionTask(SchedulerTask* task);
  1064.         void setNextWalkTask(SchedulerTask* task);
  1065.         void setNextActionTask(SchedulerTask* task);
  1066.  
  1067.         virtual bool onDeath();
  1068.         virtual Item* createCorpse(DeathList deathList);
  1069.  
  1070.         virtual void dropCorpse(DeathList deathList);
  1071.         virtual void dropLoot(Container* corpse);
  1072.  
  1073.         //cylinder implementations
  1074.         virtual ReturnValue __queryAdd(int32_t index, const Thing* thing, uint32_t count,
  1075.             uint32_t flags) const;
  1076.         virtual ReturnValue __queryMaxCount(int32_t index, const Thing* thing, uint32_t count, uint32_t& maxQueryCount,
  1077.             uint32_t flags) const;
  1078.         virtual ReturnValue __queryRemove(const Thing* thing, uint32_t count, uint32_t flags) const;
  1079.         virtual Cylinder* __queryDestination(int32_t& index, const Thing* thing, Item** destItem,
  1080.             uint32_t& flags);
  1081.  
  1082.         virtual void __addThing(Creature* actor, Thing* thing);
  1083.         virtual void __addThing(Creature* actor, int32_t index, Thing* thing);
  1084.  
  1085.         virtual void __updateThing(Thing* thing, uint16_t itemId, uint32_t count);
  1086.         virtual void __replaceThing(uint32_t index, Thing* thing);
  1087.  
  1088.         virtual void __removeThing(Thing* thing, uint32_t count);
  1089.  
  1090.         virtual Thing* __getThing(uint32_t index) const;
  1091.         virtual int32_t __getIndexOfThing(const Thing* thing) const;
  1092.         virtual int32_t __getFirstIndex() const;
  1093.         virtual int32_t __getLastIndex() const;
  1094.         virtual uint32_t __getItemTypeCount(uint16_t itemId, int32_t subType = -1) const;
  1095.         virtual std::map<uint32_t, uint32_t>& __getAllItemTypeCount(std::map<uint32_t, uint32_t>& countMap) const;
  1096.  
  1097.         virtual void __internalAddThing(Thing* thing);
  1098.         virtual void __internalAddThing(uint32_t index, Thing* thing);
  1099.  
  1100.         uint32_t getVocAttackSpeed() const {return vocation->getAttackSpeed();}
  1101.         virtual int32_t getStepSpeed() const
  1102.         {
  1103.             if(getSpeed() > SPEED_MAX)
  1104.                 return SPEED_MAX;
  1105.  
  1106.             if(getSpeed() < SPEED_MIN)
  1107.                 return SPEED_MIN;
  1108.  
  1109.             return getSpeed();
  1110.         }
  1111.  
  1112.         virtual uint32_t getDamageImmunities() const {return damageImmunities;}
  1113.         virtual uint32_t getConditionImmunities() const {return conditionImmunities;}
  1114.         virtual uint32_t getConditionSuppressions() const {return conditionSuppressions;}
  1115.  
  1116.         virtual uint16_t getLookCorpse() const;
  1117.         virtual uint64_t getLostExperience() const;
  1118.  
  1119.         virtual void getPathSearchParams(const Creature* creature, FindPathParams& fpp) const;
  1120.         static uint32_t getPercentLevel(uint64_t count, uint64_t nextLevelCount);
  1121.  
  1122.         bool isPromoted(uint32_t pLevel = 1) const {return promotionLevel >= pLevel;}
  1123.         bool hasCapacity(const Item* item, uint32_t count) const;
  1124.  
  1125.     private:
  1126.         bool talkState[13];
  1127.         bool inventoryAbilities[11];
  1128.         bool pzLocked;
  1129.         bool saving;
  1130.         bool isConnecting;
  1131.         bool requestedOutfit;
  1132.         bool outfitAttributes;
  1133.         bool addAttackSkillPoint;
  1134.  
  1135.         OperatingSystem_t operatingSystem;
  1136.         AccountManager_t accountManager;
  1137.         PlayerSex_t managerSex;
  1138.         BlockType_t lastAttackBlockType;
  1139.         chaseMode_t chaseMode;
  1140.         fightMode_t fightMode;
  1141.         secureMode_t secureMode;
  1142.         tradestate_t tradeState;
  1143.         GuildLevel_t guildLevel;
  1144.  
  1145.         int16_t blessings;
  1146.         uint16_t maxWriteLen;
  1147.         uint16_t sex;
  1148.  
  1149.         int32_t premiumDays;
  1150.         int32_t soul;
  1151.         int32_t soulMax;
  1152.         int32_t vocationId;
  1153.         int32_t groupId;
  1154.         int32_t managerNumber, managerNumber2, managerNumber3;
  1155.         int32_t purchaseCallback;
  1156.         int32_t saleCallback;
  1157.         int32_t varSkills[SKILL_LAST + 1];
  1158.         int32_t varStats[STAT_LAST + 1];
  1159.         int32_t messageBuffer;
  1160.         int32_t bloodHitCount;
  1161.         int32_t shieldBlockCount;
  1162.         int32_t shootRange;
  1163.  
  1164.         uint32_t clientVersion;
  1165.         uint32_t messageTicks;
  1166.         uint32_t idleTime;
  1167.         uint32_t accountId;
  1168.         uint32_t lastIP;
  1169.         uint32_t level;
  1170.         uint32_t levelPercent;
  1171.         uint32_t magLevel;
  1172.         uint32_t magLevelPercent;
  1173.         uint32_t damageImmunities;
  1174.         uint32_t conditionImmunities;
  1175.         uint32_t conditionSuppressions;
  1176.         uint32_t condition; //?
  1177.         uint32_t nextStepEvent;
  1178.         uint32_t actionTaskEvent;
  1179.         uint32_t walkTaskEvent;
  1180.         uint32_t lossPercent[LOSS_LAST + 1];
  1181.         uint32_t skills[SKILL_LAST + 1][3];
  1182.         uint32_t guid;
  1183.         uint32_t editListId;
  1184.         uint32_t windowTextId;
  1185.         uint32_t guildId;
  1186.         uint32_t rankId;
  1187.         uint32_t promotionLevel;
  1188.         uint32_t town;
  1189.  
  1190.         time_t skullEnd;
  1191.         time_t lastLogin;
  1192.         time_t lastLogout;
  1193.         int64_t lastLoad;
  1194.         int64_t lastPong;
  1195.         int64_t lastPing;
  1196.         int64_t nextAction;
  1197.         uint64_t stamina;
  1198.         uint64_t experience;
  1199.         uint64_t manaSpent;
  1200.         uint64_t lastAttack;
  1201.  
  1202.         double inventoryWeight;
  1203.         double capacity;
  1204.         char managerChar[100];
  1205.  
  1206.         std::string managerString, managerString2;
  1207.         std::string account, password;
  1208.         std::string name, nameDescription, specialDescription;
  1209.         std::string guildName, rankName, guildNick;
  1210.  
  1211.         Position loginPosition;
  1212.         LightInfo itemsLight;
  1213.  
  1214.         Vocation* vocation;
  1215.         ProtocolGame* client;
  1216.         SchedulerTask* walkTask;
  1217.         Party* party;
  1218.         Group* group;
  1219.         Item* inventory[11];
  1220.         Player* tradePartner;
  1221.         Item* tradeItem;
  1222.         Item* writeItem;
  1223.         House* editHouse;
  1224.         Npc* shopOwner;
  1225.         Item* weapon;
  1226.  
  1227.         typedef std::set<uint32_t> AttackedSet;
  1228.         AttackedSet attackedSet;
  1229.         ShopInfoList shopOffer;
  1230.         PartyList invitePartyList;
  1231.         OutfitMap outfits;
  1232.         LearnedInstantSpellList learnedInstantSpellList;
  1233.  
  1234.         WarMap warMap;
  1235.  
  1236.         friend class Game;
  1237.         friend class LuaInterface;
  1238.         friend class Npc;
  1239.         friend class Map;
  1240.         friend class Actions;
  1241.         friend class IOLoginData;
  1242.         friend class ProtocolGame;
  1243. };
  1244. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement