Advertisement
Guest User

player.h

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