Advertisement
Guest User

creature.h

a guest
Jun 12th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.98 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 __CREATURE__
  19. #define __CREATURE__
  20. #include "otsystem.h"
  21.  
  22. #include "templates.h"
  23. #include <boost/any.hpp>
  24.  
  25. #include "const.h"
  26. #include "enums.h"
  27.  
  28. #include "map.h"
  29. #include "condition.h"
  30. #include "creatureevent.h"
  31.  
  32. enum slots_t
  33. {
  34.     SLOT_PRE_FIRST = 0,
  35.     SLOT_WHEREEVER = SLOT_PRE_FIRST,
  36.     SLOT_FIRST = 1,
  37.     SLOT_HEAD = SLOT_FIRST,
  38.     SLOT_NECKLACE = 2,
  39.     SLOT_BACKPACK = 3,
  40.     SLOT_ARMOR = 4,
  41.     SLOT_RIGHT = 5,
  42.     SLOT_LEFT = 6,
  43.     SLOT_LEGS = 7,
  44.     SLOT_FEET = 8,
  45.     SLOT_RING = 9,
  46.     SLOT_AMMO = 10,
  47.     SLOT_DEPOT = 11,
  48.     SLOT_LAST = SLOT_DEPOT,
  49.     SLOT_HAND = 12,
  50.     SLOT_TWO_HAND = SLOT_HAND
  51. };
  52.  
  53. enum lootDrop_t
  54. {
  55.     LOOT_DROP_FULL = 0,
  56.     LOOT_DROP_PREVENT,
  57.     LOOT_DROP_NONE
  58. };
  59.  
  60. enum Visible_t
  61. {
  62.     VISIBLE_NONE = 0,
  63.     VISIBLE_APPEAR = 1,
  64.     VISIBLE_DISAPPEAR = 2,
  65.     VISIBLE_GHOST_APPEAR = 3,
  66.     VISIBLE_GHOST_DISAPPEAR = 4
  67. };
  68.  
  69. struct FindPathParams
  70. {
  71.     bool fullPathSearch, clearSight, allowDiagonal, keepDistance;
  72.     int32_t maxSearchDist, minTargetDist, maxTargetDist;
  73.     FindPathParams()
  74.     {
  75.         fullPathSearch = clearSight = allowDiagonal = true;
  76.         maxSearchDist = minTargetDist = maxTargetDist = -1;
  77.         keepDistance = false;
  78.     }
  79. };
  80.  
  81. struct DeathLessThan;
  82. struct DeathEntry
  83. {
  84.         DeathEntry(std::string name, int32_t dmg):
  85.             data(name), damage(dmg), last(false), justify(false), unjustified(false) {}
  86.         DeathEntry(Creature* killer, int32_t dmg):
  87.             data(killer), damage(dmg), last(false), justify(false), unjustified(false) {}
  88.  
  89.         bool isCreatureKill() const {return data.type() == typeid(Creature*);}
  90.         bool isNameKill() const {return !isCreatureKill();}
  91.  
  92.         void setWar(War_t v) {war = v;}
  93.         War_t getWar() const {return war;}
  94.  
  95.         void setLast() {last = true;}
  96.         bool isLast() const {return last;}
  97.  
  98.         void setJustify() {justify = true;}
  99.         bool isJustify() const {return justify;}
  100.  
  101.         void setUnjustified() {unjustified = true;}
  102.         bool isUnjustified() const {return unjustified;}
  103.  
  104.         const std::type_info& getKillerType() const {return data.type();}
  105.         int32_t getDamage() const {return damage;}
  106.  
  107.         Creature* getKillerCreature() const {return boost::any_cast<Creature*>(data);}
  108.         std::string getKillerName() const {return boost::any_cast<std::string>(data);}
  109.  
  110.     protected:
  111.         friend struct DeathLessThan;
  112.  
  113.         boost::any data;
  114.         int32_t damage;
  115.         War_t war;
  116.  
  117.         bool last;
  118.         bool justify;
  119.         bool unjustified;
  120. };
  121.  
  122. struct DeathLessThan
  123. {
  124.     bool operator()(const DeathEntry& d1, const DeathEntry& d2) {return d1.damage > d2.damage;}
  125. };
  126.  
  127. typedef std::vector<DeathEntry> DeathList;
  128. typedef std::list<CreatureEvent*> CreatureEventList;
  129. typedef std::list<Condition*> ConditionList;
  130. typedef std::map<uint32_t, std::string> StorageMap;
  131.  
  132. class Map;
  133. class Tile;
  134. class Thing;
  135.  
  136. class Player;
  137. class Monster;
  138. class Npc;
  139.  
  140. class Item;
  141. class Container;
  142.  
  143. #define EVENT_CREATURECOUNT 10
  144. #define EVENT_CREATURE_THINK_INTERVAL 500
  145. #define EVENT_CHECK_CREATURE_INTERVAL (EVENT_CREATURE_THINK_INTERVAL / EVENT_CREATURECOUNT)
  146.  
  147. class FrozenPathingConditionCall
  148. {
  149.     public:
  150.         FrozenPathingConditionCall(const Position& _targetPos);
  151.         virtual ~FrozenPathingConditionCall() {}
  152.  
  153.         virtual bool operator()(const Position& startPos, const Position& testPos,
  154.             const FindPathParams& fpp, int32_t& bestMatchDist) const;
  155.  
  156.         bool isInRange(const Position& startPos, const Position& testPos,
  157.             const FindPathParams& fpp) const;
  158.  
  159.     protected:
  160.         Position targetPos;
  161. };
  162.  
  163. class Creature : public AutoId, virtual public Thing
  164. {
  165.     protected:
  166.         Creature();
  167.  
  168.     public:
  169.         virtual ~Creature();
  170.  
  171.         virtual Creature* getCreature() {return this;}
  172.         virtual const Creature* getCreature()const {return this;}
  173.         virtual Player* getPlayer() {return NULL;}
  174.         virtual const Player* getPlayer() const {return NULL;}
  175.         virtual Npc* getNpc() {return NULL;}
  176.         virtual const Npc* getNpc() const {return NULL;}
  177.         virtual Monster* getMonster() {return NULL;}
  178.         virtual const Monster* getMonster() const {return NULL;}
  179.  
  180.         virtual const std::string& getName() const = 0;
  181.         virtual const std::string& getNameDescription() const = 0;
  182.         virtual std::string getDescription(int32_t lookDistance) const;
  183.  
  184.         uint32_t getID() const {return id;}
  185.         void setID()
  186.         {
  187.             /*
  188.              * 0x10000000 - Player
  189.              * 0x40000000 - Monster
  190.              * 0x80000000 - NPC
  191.              */
  192.             if(!id)
  193.                 id = autoId | rangeId();
  194.         }
  195.  
  196.         void setRemoved() {removed = true;}
  197.         virtual bool isRemoved() const {return removed;}
  198.  
  199.         virtual uint32_t rangeId() = 0;
  200.         virtual void removeList() = 0;
  201.         virtual void addList() = 0;
  202.  
  203.         virtual bool canSee(const Position& pos) const;
  204.         virtual bool canSeeCreature(const Creature* creature) const;
  205.         virtual bool canWalkthrough(const Creature* creature) const;
  206.  
  207.         Direction getDirection() const {return direction;}
  208.         void setDirection(Direction dir) {direction = dir;}
  209.  
  210.         bool getHideName() const {return hideName;}
  211.         void setHideName(bool v) {hideName = v;}
  212.  
  213.         bool getHideHealth() const {return hideHealth;}
  214.         void setHideHealth(bool v) {hideHealth = v;}
  215.  
  216.         SpeakClasses getSpeakType() const {return speakType;}
  217.         void setSpeakType(SpeakClasses type) {speakType = type;}
  218.  
  219.         Position getMasterPosition() const {return masterPosition;}
  220.         void setMasterPosition(const Position& pos, uint32_t radius = 1) {masterPosition = pos; masterRadius = radius;}
  221.  
  222.         virtual int32_t getThrowRange() const {return 1;}
  223.         virtual RaceType_t getRace() const {return RACE_NONE;}
  224.  
  225.         virtual bool isPushable() const {return getWalkDelay() <= 0;}
  226.         virtual bool canSeeInvisibility() const {return false;}
  227.  
  228.         int32_t getWalkDelay(Direction dir) const;
  229.         int32_t getWalkDelay() const;
  230.         int32_t getStepDuration(Direction dir) const;
  231.         int32_t getStepDuration() const;
  232.  
  233.         int64_t getEventStepTicks(bool onlyDelay = false) const;
  234.         int64_t getTimeSinceLastMove() const;
  235.         virtual int32_t getStepSpeed() const {return getSpeed();}
  236.  
  237.         int32_t getSpeed() const {return baseSpeed + varSpeed;}
  238.         void setSpeed(int32_t varSpeedDelta)
  239.         {
  240.             int32_t oldSpeed = getSpeed();
  241.             varSpeed = varSpeedDelta;
  242.             if(getSpeed() <= 0)
  243.             {
  244.                 stopEventWalk();
  245.                 cancelNextWalk = true;
  246.             }
  247.             else if(oldSpeed <= 0 && !listWalkDir.empty())
  248.                 addEventWalk();
  249.         }
  250.  
  251.         void setBaseSpeed(uint32_t newBaseSpeed) {baseSpeed = newBaseSpeed;}
  252.         int32_t getBaseSpeed() {return baseSpeed;}
  253.  
  254.         virtual int32_t getHealth() const {return health;}
  255.         virtual int32_t getMaxHealth() const {return healthMax;}
  256.         virtual int32_t getMana() const {return mana;}
  257.         virtual int32_t getMaxMana() const {return manaMax;}
  258.  
  259.         const Outfit_t getCurrentOutfit() const {return currentOutfit;}
  260.         void setCurrentOutfit(Outfit_t outfit) {currentOutfit = outfit;}
  261.         const Outfit_t getDefaultOutfit() const {return defaultOutfit;}
  262.  
  263.         bool isInvisible() const {return hasCondition(CONDITION_INVISIBLE, -1, false);}
  264.         virtual bool isGhost() const {return false;}
  265.         virtual bool isWalkable() const {return false;}
  266.  
  267.         ZoneType_t getZone() const {return getTile()->getZone();}
  268.  
  269.         //walk functions
  270.         bool startAutoWalk(std::list<Direction>& listDir);
  271.         void addEventWalk(bool firstStep = false);
  272.         void stopEventWalk();
  273.         void goToFollowCreature();
  274.  
  275.         //walk events
  276.         virtual void onWalk(Direction& dir);
  277.         virtual void onWalkAborted() {}
  278.         virtual void onWalkComplete() {}
  279.  
  280.         //follow functions
  281.         virtual Creature* getFollowCreature() const {return followCreature;}
  282.         virtual bool setFollowCreature(Creature* creature, bool fullPathSearch = false);
  283.  
  284.         //follow events
  285.         virtual void onFollowCreature(const Creature*) {}
  286.         virtual void onFollowCreatureComplete(const Creature*) {}
  287.  
  288.         //combat functions
  289.         Creature* getAttackedCreature() {return attackedCreature;}
  290.         virtual bool setAttackedCreature(Creature* creature);
  291.         virtual BlockType_t blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
  292.             bool checkDefense = false, bool checkArmor = false, bool reflect = true);
  293.  
  294.         void setMaster(Creature* creature) {master = creature;}
  295.         Creature* getMaster() {return master;}
  296.         const Creature* getMaster() const {return master;}
  297.         Player* getPlayerMaster() const {return isPlayerSummon() ? master->getPlayer() : NULL;}
  298.         bool isSummon() const {return master != NULL;}
  299.         bool isPlayerSummon() const {return master && master->getPlayer();}
  300.  
  301.         virtual void addSummon(Creature* creature);
  302.         virtual void removeSummon(const Creature* creature);
  303.         const std::list<Creature*>& getSummons() {return summons;}
  304.         void destroySummons();
  305.         uint32_t getSummonCount() const {return summons.size();}
  306.  
  307.         virtual int32_t getArmor() const {return 0;}
  308.         virtual int32_t getDefense() const {return 0;}
  309.         virtual float getAttackFactor() const {return 1.0f;}
  310.         virtual float getDefenseFactor() const {return 1.0f;}
  311.  
  312.         bool addCondition(Condition* condition);
  313.         bool addCombatCondition(Condition* condition);
  314.         void removeCondition(ConditionType_t type);
  315.         void removeCondition(ConditionType_t type, ConditionId_t id);
  316.         void removeCondition(Condition* condition);
  317.         void removeCondition(const Creature* attacker, ConditionType_t type);
  318.         void removeConditions(ConditionEnd_t reason, bool onlyPersistent = true);
  319.         Condition* getCondition(ConditionType_t type, ConditionId_t id, uint32_t subId = 0) const;
  320.         void executeConditions(uint32_t interval);
  321.         bool hasCondition(ConditionType_t type, int32_t subId = 0, bool checkTime = true) const;
  322.         virtual bool isImmune(ConditionType_t type) const;
  323.         virtual bool isImmune(CombatType_t type) const;
  324.         virtual bool isSuppress(ConditionType_t type) const;
  325.         virtual uint32_t getDamageImmunities() const {return 0;}
  326.         virtual uint32_t getConditionImmunities() const {return 0;}
  327.         virtual uint32_t getConditionSuppressions() const {return 0;}
  328.         virtual bool isAttackable() const {return true;}
  329.         virtual bool isAccountManager() const {return false;}
  330.  
  331.         virtual void changeHealth(int32_t healthChange);
  332.         void changeMaxHealth(uint32_t healthChange) {healthMax = healthChange;}
  333.         virtual void changeMana(int32_t manaChange);
  334.         void changeMaxMana(uint32_t manaChange) {manaMax = manaChange;}
  335.  
  336.         virtual bool getStorage(const uint32_t key, std::string& value) const;
  337.         virtual bool setStorage(const uint32_t key, const std::string& value);
  338.         virtual void eraseStorage(const uint32_t key) {storageMap.erase(key);}
  339.  
  340.         inline StorageMap::const_iterator getStorageBegin() const {return storageMap.begin();}
  341.         inline StorageMap::const_iterator getStorageEnd() const {return storageMap.end();}
  342.  
  343.         virtual void gainHealth(Creature* caster, int32_t amount);
  344.         virtual void drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage);
  345.         virtual void drainMana(Creature* attacker, CombatType_t combatType, int32_t damage);
  346.  
  347.         virtual bool challengeCreature(Creature*) {return false;}
  348.         virtual bool convinceCreature(Creature*) {return false;}
  349.  
  350.         virtual bool onDeath();
  351.  
  352.         uint32_t getBaseVoc();
  353.         double getPartyBonus();
  354.         virtual double getGainedExperience(Creature* attacker) {
  355.             double bonus = 1;
  356.             if(Player* player = attacker->getPlayer()) {
  357.                 bonus = player->getPartyBonus();
  358.             }
  359.             return getDamageRatio(attacker) * (double)getLostExperience() * bonus;
  360.         }
  361.  
  362.  
  363.         void addDamagePoints(Creature* attacker, int32_t damagePoints);
  364.         void addHealPoints(Creature* caster, int32_t healthPoints);
  365.         bool hasBeenAttacked(uint32_t attackerId) const;
  366.  
  367.         //combat event functions
  368.         virtual void onAddCondition(ConditionType_t type, bool hadCondition);
  369.         virtual void onAddCombatCondition(ConditionType_t, bool) {}
  370.         virtual void onEndCondition(ConditionType_t type);
  371.         virtual void onTickCondition(ConditionType_t type, int32_t interval, bool& _remove);
  372.         virtual void onCombatRemoveCondition(const Creature* attacker, Condition* condition);
  373.         virtual void onAttackedCreature(Creature*) {}
  374.         virtual void onSummonAttackedCreature(Creature*, Creature*) {}
  375.         virtual void onAttacked() {}
  376.         virtual void onAttackedCreatureDrainHealth(Creature* target, int32_t points);
  377.         virtual void onSummonAttackedCreatureDrainHealth(Creature*, Creature*, int32_t) {}
  378.         virtual void onAttackedCreatureDrainMana(Creature* target, int32_t points);
  379.         virtual void onSummonAttackedCreatureDrainMana(Creature*, Creature*, int32_t) {}
  380.         virtual void onAttackedCreatureDrain(Creature* target, int32_t points);
  381.         virtual void onSummonAttackedCreatureDrain(Creature*, Creature*, int32_t) {}
  382.         virtual void onTargetCreatureGainHealth(Creature* target, int32_t points);
  383.         virtual void onAttackedCreatureKilled(Creature* target);
  384.         virtual bool onKilledCreature(Creature* target, DeathEntry& entry);
  385.         virtual void onGainExperience(double& gainExp, bool fromMonster, bool multiplied);
  386.         virtual void onGainSharedExperience(double& gainExp, bool fromMonster, bool multiplied);
  387.         virtual void onAttackedCreatureBlockHit(Creature*, BlockType_t) {}
  388.         virtual void onBlockHit(BlockType_t) {}
  389.         virtual void onChangeZone(ZoneType_t zone);
  390.         virtual void onAttackedCreatureChangeZone(ZoneType_t zone);
  391.         virtual void onIdleStatus();
  392.  
  393.         virtual void getCreatureLight(LightInfo& light) const;
  394.         virtual void setNormalCreatureLight();
  395.         void setCreatureLight(LightInfo& light) {internalLight = light;}
  396.  
  397.         virtual void onThink(uint32_t interval);
  398.         virtual void onAttacking(uint32_t interval);
  399.         virtual void onWalk();
  400.         virtual bool getNextStep(Direction& dir, uint32_t& flags);
  401.  
  402.         virtual void onAddTileItem(const Tile* tile, const Position& pos, const Item* item);
  403.         virtual void onUpdateTileItem(const Tile* tile, const Position& pos, const Item* oldItem,
  404.             const ItemType& oldType, const Item* newItem, const ItemType& newType);
  405.         virtual void onRemoveTileItem(const Tile* tile, const Position& pos, const ItemType& iType, const Item* item);
  406.         virtual void onUpdateTile(const Tile*, const Position&) {}
  407.  
  408.         virtual void onCreatureAppear(const Creature* creature);
  409.         virtual void onCreatureDisappear(const Creature* creature, bool isLogout);
  410.         virtual void onCreatureMove(const Creature* creature, const Tile* newTile, const Position& newPos,
  411.             const Tile* oldTile, const Position& oldPos, bool teleport);
  412.  
  413.         virtual void onAttackedCreatureDisappear(bool) {}
  414.         virtual void onFollowCreatureDisappear(bool) {}
  415.  
  416.         virtual void onCreatureTurn(const Creature*) {}
  417.         virtual void onCreatureSay(const Creature*, SpeakClasses, const std::string&,
  418.             Position* = NULL) {}
  419.  
  420.         virtual void onCreatureChangeOutfit(const Creature*, const Outfit_t&) {}
  421.         virtual void onCreatureConvinced(const Creature*, const Creature*) {}
  422.         virtual void onCreatureChangeVisible(const Creature*, Visible_t) {}
  423.         virtual void onPlacedCreature() {}
  424.         virtual void onRemovedCreature();
  425.  
  426.         virtual WeaponType_t getWeaponType() {return WEAPON_NONE;}
  427.         virtual bool getCombatValues(int32_t&, int32_t&) {return false;}
  428.  
  429.         virtual void setSkull(Skulls_t newSkull) {skull = newSkull;}
  430.         virtual Skulls_t getSkull() const {return skull;}
  431.         virtual Skulls_t getSkullType(const Creature* creature) const {return creature->getSkull();}
  432.  
  433.         virtual void setShield(PartyShields_t newPartyShield) {partyShield = newPartyShield;}
  434.         virtual PartyShields_t getShield() const {return partyShield;}
  435.         virtual PartyShields_t getPartyShield(const Creature* creature) const {return creature->getShield();}
  436.  
  437.         virtual void setEmblem(GuildEmblems_t newGuildEmblem) {guildEmblem = newGuildEmblem;}
  438.         virtual GuildEmblems_t getEmblem() const {return guildEmblem;}
  439.         virtual GuildEmblems_t getGuildEmblem(const Creature* creature) const {return creature->getEmblem();}
  440.  
  441.         void setDropLoot(lootDrop_t _lootDrop) {lootDrop = _lootDrop;}
  442.         void setLossSkill(bool _skillLoss) {skillLoss = _skillLoss;}
  443.         bool getLossSkill() const {return skillLoss;}
  444.         void setNoMove(bool _cannotMove)
  445.         {
  446.             cannotMove = _cannotMove;
  447.             cancelNextWalk = true;
  448.         }
  449.         bool getNoMove() const {return cannotMove;}
  450.  
  451.         //creature script events
  452.         bool registerCreatureEvent(const std::string& name);
  453.         bool unregisterCreatureEvent(const std::string& name);
  454.         CreatureEventList getCreatureEvents(CreatureEventType_t type);
  455.  
  456.         virtual void setParent(Cylinder* cylinder)
  457.         {
  458.             _tile = dynamic_cast<Tile*>(cylinder);
  459.             Thing::setParent(cylinder);
  460.         }
  461.  
  462.         virtual Position getPosition() const {return _tile->getPosition();}
  463.         virtual Tile* getTile() {return _tile;}
  464.         virtual const Tile* getTile() const {return _tile;}
  465.         int32_t getWalkCache(const Position& pos) const;
  466.  
  467.         const Position& getLastPosition() {return lastPosition;}
  468.         void setLastPosition(Position newLastPos) {lastPosition = newLastPos;}
  469.         static bool canSee(const Position& myPos, const Position& pos, uint32_t viewRangeX, uint32_t viewRangeY);
  470.  
  471.     protected:
  472.         static const int32_t mapWalkWidth = Map::maxViewportX * 2 + 1;
  473.         static const int32_t mapWalkHeight = Map::maxViewportY * 2 + 1;
  474.         bool localMapCache[mapWalkHeight][mapWalkWidth];
  475.  
  476.         virtual bool useCacheMap() const {return false;}
  477.  
  478.         Tile* _tile;
  479.         uint32_t id;
  480.         bool removed;
  481.         bool isMapLoaded;
  482.         bool isUpdatingPath;
  483.         bool checked;
  484.         StorageMap storageMap;
  485.  
  486.         int32_t checkVector;
  487.         int32_t health, healthMax;
  488.         int32_t mana, manaMax;
  489.  
  490.         bool hideName, hideHealth, cannotMove;
  491.         SpeakClasses speakType;
  492.  
  493.         Outfit_t currentOutfit;
  494.         Outfit_t defaultOutfit;
  495.  
  496.         Position masterPosition;
  497.         Position lastPosition;
  498.         int32_t masterRadius;
  499.         uint64_t lastStep;
  500.         uint32_t lastStepCost;
  501.         uint32_t baseSpeed;
  502.         int32_t varSpeed;
  503.         bool skillLoss;
  504.         lootDrop_t lootDrop;
  505.         Skulls_t skull;
  506.         PartyShields_t partyShield;
  507.         GuildEmblems_t guildEmblem;
  508.         Direction direction;
  509.         ConditionList conditions;
  510.         LightInfo internalLight;
  511.  
  512.         //summon variables
  513.         Creature* master;
  514.         std::list<Creature*> summons;
  515.  
  516.         //follow variables
  517.         Creature* followCreature;
  518.         uint32_t eventWalk;
  519.         bool cancelNextWalk;
  520.         std::list<Direction> listWalkDir;
  521.         uint32_t walkUpdateTicks;
  522.         bool hasFollowPath;
  523.         bool forceUpdateFollowPath;
  524.  
  525.         //combat variables
  526.         Creature* attackedCreature;
  527.         struct CountBlock_t
  528.         {
  529.             uint32_t total;
  530.             int64_t ticks, start;
  531.  
  532.             CountBlock_t(uint32_t points)
  533.             {
  534.                 start = ticks = OTSYS_TIME();
  535.                 total = points;
  536.             }
  537.  
  538.             CountBlock_t() {start = ticks = total = 0;}
  539.         };
  540.  
  541.         typedef std::map<uint32_t, CountBlock_t> CountMap;
  542.         CountMap damageMap;
  543.         CountMap healMap;
  544.  
  545.         CreatureEventList eventsList;
  546.         uint32_t blockCount, blockTicks, lastHitCreature;
  547.         CombatType_t lastDamageSource;
  548.  
  549.         #ifdef __DEBUG__
  550.         void validateMapCache();
  551.         #endif
  552.         void updateMapCache();
  553.  
  554.         void updateTileCache(const Tile* tile);
  555.         void updateTileCache(const Tile* tile, int32_t dx, int32_t dy);
  556.         void updateTileCache(const Tile* tile, const Position& pos);
  557.  
  558.         virtual bool hasExtraSwing() {return false;}
  559.  
  560.         virtual uint16_t getLookCorpse() const {return 0;}
  561.         virtual uint64_t getLostExperience() const {return 0;}
  562.  
  563.         virtual double getDamageRatio(Creature* attacker) const;
  564.         virtual void getPathSearchParams(const Creature* creature, FindPathParams& fpp) const;
  565.         DeathList getKillers();
  566.  
  567.         virtual Item* createCorpse(DeathList deathList);
  568.         virtual void dropLoot(Container*) {}
  569.         virtual void dropCorpse(DeathList deathList);
  570.  
  571.         virtual void doAttacking(uint32_t) {}
  572.         void internalCreatureDisappear(const Creature* creature, bool isLogout);
  573.  
  574.         friend class Game;
  575.         friend class Map;
  576.         friend class LuaInterface;
  577. };
  578. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement