Advertisement
MaR0

Untitled

May 30th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////
  2. // OpenTibia - an opensource roleplaying game
  3. //////////////////////////////////////////////////////////////////////
  4. //
  5. //////////////////////////////////////////////////////////////////////
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU General Public License
  8. // as published by the Free Software Foundation; either version 2
  9. // of the License, or (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software Foundation,
  18. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. //////////////////////////////////////////////////////////////////////
  20.  
  21. #ifndef __OTSERV_MONSTERS_H__
  22. #define __OTSERV_MONSTERS_H__
  23.  
  24. #include <string>
  25. #include "creature.h"
  26.  
  27. #define MAX_LOOTCHANCE 100000
  28. #define MAX_STATICWALK 100
  29.  
  30. struct LootBlock{
  31. unsigned short id;
  32. unsigned short countmax;
  33. uint32_t chance;
  34.  
  35. //optional
  36. int subType;
  37. int actionId;
  38. std::string text;
  39.  
  40. typedef std::list<LootBlock> LootItems;
  41. LootItems childLoot;
  42. LootBlock(){
  43. id = 0;
  44. countmax = 0;
  45. chance = 0;
  46.  
  47. subType = -1;
  48. actionId = -1;
  49. text = "";
  50. }
  51. };
  52.  
  53. struct summonBlock_t{
  54. std::string name;
  55. uint32_t chance;
  56. uint32_t speed;
  57. };
  58.  
  59. class BaseSpell;
  60.  
  61. struct spellBlock_t{
  62. BaseSpell* spell;
  63. uint32_t chance;
  64. uint32_t speed;
  65. uint32_t range;
  66. int32_t minCombatValue;
  67. int32_t maxCombatValue;
  68. bool combatSpell;
  69. };
  70.  
  71. struct voiceBlock_t{
  72. std::string text;
  73. bool yellText;
  74. };
  75.  
  76. typedef std::list<LootBlock> LootItems;
  77. typedef std::list<summonBlock_t> SummonList;
  78. typedef std::list<spellBlock_t> SpellList;
  79. typedef std::vector<voiceBlock_t> VoiceVector;
  80. typedef std::list<std::string> MonsterScriptList;
  81.  
  82. class MonsterType{
  83. public:
  84. MonsterType();
  85. ~MonsterType();
  86.  
  87. void reset();
  88.  
  89. std::string name;
  90. std::string nameDescription;
  91. int experience;
  92.  
  93. int defense;
  94. int armor;
  95.  
  96. bool canPushItems;
  97. bool canPushCreatures;
  98. uint32_t staticAttackChance;
  99. int maxSummons;
  100. int targetDistance;
  101. int runAwayHealth;
  102. bool pushable;
  103. int base_speed;
  104. int health;
  105. int health_max;
  106.  
  107. Outfit_t outfit;
  108. int32_t lookcorpse;
  109. int conditionImmunities;
  110. int damageImmunities;
  111. RaceType_t race;
  112. bool isSummonable;
  113. bool isIllusionable;
  114. bool isConvinceable;
  115. bool isAttackable;
  116. bool isHostile;
  117.  
  118. int lightLevel;
  119. int lightColor;
  120.  
  121. uint32_t manaCost;
  122. SummonList summonList;
  123. LootItems lootItems;
  124. SpellList spellAttackList;
  125. SpellList spellDefenseList;
  126.  
  127. uint32_t yellChance;
  128. uint32_t yellSpeedTicks;
  129. VoiceVector voiceVector;
  130.  
  131. int32_t changeTargetSpeed;
  132. int32_t changeTargetChance;
  133.  
  134. int32_t attackStrength;
  135. int32_t defenseStrength;
  136.  
  137. MonsterScriptList scriptList;
  138.  
  139. void createLoot(Container* corpse);
  140. void createLootContainer(Container* parent, const LootBlock& lootblock);
  141. Item* createLootItem(const LootBlock& lootblock);
  142. };
  143.  
  144. class Monsters{
  145. public:
  146. Monsters();
  147. ~Monsters();
  148.  
  149. bool loadFromXml(const std::string& _datadir, bool reloading = false);
  150. bool isLoaded(){return loaded;}
  151. bool reload();
  152.  
  153. MonsterType* getMonsterType(const std::string& name);
  154. MonsterType* getMonsterType(uint32_t mid);
  155. uint32_t getIdByName(const std::string& name);
  156.  
  157. static uint32_t getLootRandom();
  158.  
  159. private:
  160. ConditionDamage* getDamageCondition(ConditionType_t conditionType,
  161. int32_t maxDamage, int32_t minDamage, int32_t startDamage, uint32_t tickInterval);
  162. bool deserializeSpell(xmlNodePtr node, spellBlock_t& sb, const std::string& description = "");
  163.  
  164. MonsterType* loadMonster(const std::string& file, const std::string& monster_name, bool reloading = false);
  165.  
  166. bool loadLootContainer(xmlNodePtr, LootBlock&);
  167. bool loadLootItem(xmlNodePtr, LootBlock&);
  168.  
  169. typedef std::map<std::string, uint32_t> MonsterNameMap;
  170. MonsterNameMap monsterNames;
  171.  
  172. typedef std::map<uint32_t, MonsterType*> MonsterMap;
  173. MonsterMap monsters;
  174.  
  175. bool loaded;
  176. std::string datadir;
  177.  
  178. };
  179.  
  180. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement