Wesquel

Untitled

Feb 16th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 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 __MONSTER__
  19. #define __MONSTER__
  20.  
  21. #include "monsters.h"
  22. #include "raids.h"
  23. #include "tile.h"
  24.  
  25. class Creature;
  26. class Game;
  27. class Spawn;
  28.  
  29. enum TargetSearchType_t
  30. {
  31. TARGETSEARCH_DEFAULT,
  32. TARGETSEARCH_RANDOM,
  33. TARGETSEARCH_ATTACKRANGE,
  34. TARGETSEARCH_NEAREST
  35. };
  36.  
  37. typedef std::list<Creature*> CreatureList;
  38. class Monster : public Creature
  39. {
  40. private:
  41. Monster(MonsterType* _mType);
  42.  
  43. public:
  44. #ifdef __ENABLE_SERVER_DIAGNOSTIC__
  45. static uint32_t monsterCount;
  46. #endif
  47. virtual ~Monster();
  48.  
  49. static Monster* createMonster(MonsterType* mType);
  50. static Monster* createMonster(const std::string& name);
  51.  
  52. virtual Monster* getMonster() {return this;}
  53. virtual const Monster* getMonster() const {return this;}
  54.  
  55. virtual uint32_t rangeId() {return 0x40000000;}
  56. static AutoList<Monster> autoList;
  57.  
  58. void addList() {autoList[id] = this;}
  59. void removeList() {autoList.erase(id);}
  60.  
  61. virtual const std::string& getName() const {return mType->name;}
  62. virtual const std::string& getNameDescription() const {return mType->nameDescription;}
  63. virtual std::string getDescription(int32_t lookDistance) const {return mType->nameDescription + ".";}
  64.  
  65. virtual RaceType_t getRace() const {return mType->race;}
  66. virtual int32_t getArmor() const {return mType->armor;}
  67. virtual int32_t getDefense() const {return mType->defense;}
  68. virtual MonsterType* getMonsterType() const {return mType;}
  69. virtual bool isPushable() const {return mType->pushable && (baseSpeed > 0);}
  70. virtual bool isAttackable() const {return mType->isAttackable;}
  71. virtual bool isImmune(CombatType_t type) const;
  72.  
  73. bool canPushItems() const {return mType->canPushItems;}
  74. bool canPushCreatures() const {return mType->canPushCreatures;}
  75. bool isHostile() const {return mType->isHostile;}
  76. virtual bool isWalkable() const {return mType->isWalkable;}
  77. virtual bool canSeeInvisibility() const {return Creature::isImmune(CONDITION_INVISIBLE);}
  78. uint32_t getManaCost() const {return mType->manaCost;}
  79.  
  80. void setSpawn(Spawn* _spawn) {spawn = _spawn;}
  81. void setRaid(Raid* _raid) {raid = _raid;}
  82.  
  83. virtual void onAttackedCreature(Creature* target);
  84. virtual void onAttackedCreatureDisappear(bool isLogout);
  85. virtual void onAttackedCreatureDrain(Creature* target, int32_t points);
  86.  
  87. virtual void onCreatureAppear(const Creature* creature);
  88. virtual void onCreatureDisappear(const Creature* creature, bool isLogout);
  89. virtual void onCreatureMove(const Creature* creature, const Tile* newTile, const Position& newPos,
  90. const Tile* oldTile, const Position& oldPos, bool teleport);
  91.  
  92. virtual void drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage);
  93. virtual void changeHealth(int32_t healthChange);
  94. virtual bool getNextStep(Direction& dir, uint32_t& flags);
  95. virtual void onFollowCreatureComplete(const Creature* creature);
  96.  
  97. virtual void onThink(uint32_t interval);
  98.  
  99. virtual bool challengeCreature(Creature* creature);
  100. virtual bool convinceCreature(Creature* creature);
  101.  
  102. virtual void setNormalCreatureLight();
  103. virtual bool getCombatValues(int32_t& min, int32_t& max);
  104.  
  105. virtual void doAttacking(uint32_t interval);
  106. virtual bool hasExtraSwing() {return extraMeleeAttack;}
  107.  
  108. bool searchTarget(TargetSearchType_t searchType = TARGETSEARCH_DEFAULT);
  109. bool selectTarget(Creature* creature);
  110.  
  111. const CreatureList& getTargetList() {return targetList;}
  112. const CreatureList& getFriendList() {return friendList;}
  113.  
  114. bool isTarget(Creature* creature);
  115. bool isFleeing() const {return getHealth() <= mType->runAwayHealth;}
  116.  
  117. virtual BlockType_t blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
  118. bool checkDefense = false, bool checkArmor = false);
  119.  
  120. private:
  121. CreatureList targetList;
  122. CreatureList friendList;
  123.  
  124. MonsterType* mType;
  125.  
  126. int32_t minCombatValue;
  127. int32_t maxCombatValue;
  128. uint32_t attackTicks;
  129. uint32_t targetTicks;
  130. uint32_t targetChangeTicks;
  131. uint32_t defenseTicks;
  132. uint32_t yellTicks;
  133. int32_t targetChangeCooldown;
  134. bool resetTicks;
  135. bool isIdle;
  136. bool extraMeleeAttack;
  137.  
  138. Spawn* spawn;
  139. Raid* raid;
  140.  
  141. bool isMasterInRange;
  142. bool teleportToMaster;
  143.  
  144. virtual void onCreatureEnter(Creature* creature);
  145. virtual void onCreatureLeave(Creature* creature);
  146. void onCreatureFound(Creature* creature, bool pushFront = false);
  147.  
  148. bool doTeleportToMaster();
  149. void updateLookDirection();
  150.  
  151. void updateTargetList();
  152. void clearTargetList();
  153. void clearFriendList();
  154.  
  155. virtual bool onDeath();
  156. virtual Item* createCorpse(DeathList deathList);
  157. bool despawn();
  158. bool inDespawnRange(const Position& pos);
  159.  
  160. void setIdle(bool _idle);
  161. void updateIdleStatus();
  162. bool getIdleStatus() const {return isIdle;}
  163.  
  164. virtual void onAddCondition(ConditionType_t type, bool hadCondition);
  165. virtual void onEndCondition(ConditionType_t type);
  166. virtual void onCreatureConvinced(const Creature* convincer, const Creature* creature);
  167.  
  168. bool canUseAttack(const Position& pos, const Creature* target) const;
  169. bool canUseSpell(const Position& pos, const Position& targetPos,
  170. const spellBlock_t& sb, uint32_t interval, bool& inRange);
  171. bool getRandomStep(const Position& creaturePos, Direction& dir);
  172. bool getDanceStep(const Position& creaturePos, Direction& dir,
  173. bool keepAttack = true, bool keepDistance = true);
  174. bool isInSpawnRange(const Position& toPos);
  175. bool canWalkTo(Position pos, Direction dir);
  176.  
  177. bool pushItem(Item* item, int32_t radius);
  178. void pushItems(Tile* tile);
  179. bool pushCreature(Creature* creature);
  180. void pushCreatures(Tile* tile);
  181.  
  182. void onThinkTarget(uint32_t interval);
  183. void onThinkYell(uint32_t interval);
  184. void onThinkDefense(uint32_t interval);
  185.  
  186. bool isFriend(const Creature* creature);
  187. bool isOpponent(const Creature* creature);
  188.  
  189. virtual uint64_t getLostExperience() const {return ((skillLoss ? mType->experience : 0));}
  190. virtual void dropLoot(Container* corpse);
  191. virtual uint32_t getDamageImmunities() const {return mType->damageImmunities;}
  192. virtual uint32_t getConditionImmunities() const {return mType->conditionImmunities;}
  193. virtual uint16_t getLookCorpse() {return mType->lookCorpse;}
  194. virtual uint16_t getLookCorpse() const {return mType->lookCorpse;}
  195. virtual void getPathSearchParams(const Creature* creature, FindPathParams& fpp) const;
  196. virtual bool useCacheMap() const {return true;}
  197. };
  198. #endif
Add Comment
Please, Sign In to add comment