Advertisement
Guest User

player.h

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