Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.43 KB | None | 0 0
  1. diff --git a/src/creature.cpp b/src/creature.cpp
  2. index 70ca916..b3094ac 100755
  3. --- a/src/creature.cpp
  4. +++ b/src/creature.cpp
  5. @@ -1412,6 +1412,16 @@ bool Creature::isImmune(ConditionType_t type) const
  6.     return hasBitSet((uint32_t)type, getConditionImmunities());
  7.  }
  8.  
  9. +bool Creature::canWalkthrough(CombatType_t type) const
  10. +{
  11. +   return hasBitSet((uint32_t)type, getDamageWalkthroughs());
  12. +}
  13. +
  14. +bool Creature::canWalkthrough(ConditionType_t type) const
  15. +{
  16. +   return hasBitSet((uint32_t)type, getConditionWalkthroughs());
  17. +}
  18. +
  19.  bool Creature::isSuppress(ConditionType_t type) const
  20.  {
  21.     return hasBitSet((uint32_t)type, getConditionSuppressions());
  22. diff --git a/src/creature.h b/src/creature.h
  23. index dea9007..e927bac 100755
  24. --- a/src/creature.h
  25. +++ b/src/creature.h
  26. @@ -321,6 +321,8 @@ class Creature : virtual public Thing
  27.         CreatureEventList getCreatureEvents(CreatureEventType_t type);
  28.         virtual bool isImmune(ConditionType_t type) const;
  29.         virtual bool isImmune(CombatType_t type) const;
  30. +       virtual bool canWalkthrough(ConditionType_t type) const;
  31. +       virtual bool canWalkthrough(CombatType_t type) const;
  32.         virtual bool isSuppress(ConditionType_t type) const;
  33.         virtual uint32_t getDamageImmunities() const {
  34.             return 0;
  35. @@ -328,6 +330,12 @@ class Creature : virtual public Thing
  36.         virtual uint32_t getConditionImmunities() const {
  37.             return 0;
  38.         }
  39. +       virtual uint32_t getDamageWalkthroughs() const {
  40. +           return 0;
  41. +       }
  42. +       virtual uint32_t getConditionWalkthroughs() const {
  43. +           return 0;
  44. +       }
  45.         virtual uint32_t getConditionSuppressions() const {
  46.             return 0;
  47.         }
  48. diff --git a/src/map.cpp b/src/map.cpp
  49. index a038bb4..8c3eb9a 100755
  50. --- a/src/map.cpp
  51. +++ b/src/map.cpp
  52. @@ -858,7 +858,7 @@ int_fast32_t AStarNodes::getTileWalkCost(const Creature& creature, const Tile* t
  53.     if (const MagicField* field = tile->getFieldItem()) {
  54.         if (field->isHarmful()) {
  55.             CombatType_t combatType = field->getCombatType();
  56. -           if (!creature.isImmune(combatType) && !creature.hasCondition(Combat::DamageToConditionType(combatType))) {
  57. +           if (!creature.isImmune(combatType) && !creature.hasCondition(Combat::DamageToConditionType(combatType)) && !creature.canWalkthrough(combatType)) {
  58.                 cost += MAP_NORMALWALKCOST * 4;
  59.             }
  60.         }
  61. diff --git a/src/monster.h b/src/monster.h
  62. index 81e8b90..14c6dd8 100755
  63. --- a/src/monster.h
  64. +++ b/src/monster.h
  65. @@ -281,6 +281,12 @@ class Monster : public Creature
  66.         virtual uint32_t getConditionImmunities() const {
  67.             return mType->conditionImmunities;
  68.         }
  69. +       virtual uint32_t getDamageWalkthroughs() const {
  70. +           return mType->damageWalkthroughs;
  71. +       }
  72. +       virtual uint32_t getConditionWalkthroughs() const {
  73. +           return mType->conditionWalkthroughs;
  74. +       }
  75.         virtual uint16_t getLookCorpse() const {
  76.             return mType->lookcorpse;
  77.         }
  78. diff --git a/src/monsters.cpp b/src/monsters.cpp
  79. index 845cc24..937c633 100755
  80. --- a/src/monsters.cpp
  81. +++ b/src/monsters.cpp
  82. @@ -1134,6 +1134,29 @@ bool Monsters::loadMonster(const std::string& file, const std::string& monster_n
  83.         }
  84.     }
  85.  
  86. +   if ((node = monsterNode.child("walkthroughs"))) {
  87. +       for (pugi::xml_node walkthoroughNode = node.first_child(); walkthoroughNode; walkthoroughNode = walkthoroughNode.next_sibling()) {
  88. +           if ((attr = walkthoroughNode.attribute("poison"))) {
  89. +               if (attr.as_bool()) {
  90. +                   mType->damageWalkthroughs |= COMBAT_EARTHDAMAGE;
  91. +                   mType->conditionWalkthroughs |= CONDITION_POISON;
  92. +               }
  93. +           } else if ((attr = walkthoroughNode.attribute("energy"))) {
  94. +               if (attr.as_bool()) {
  95. +                   mType->damageWalkthroughs |= COMBAT_ENERGYDAMAGE;
  96. +                   mType->conditionWalkthroughs |= CONDITION_ENERGY;
  97. +               }
  98. +           } else if ((attr = walkthoroughNode.attribute("fire"))) {
  99. +               if (attr.as_bool()) {
  100. +                   mType->damageWalkthroughs |= COMBAT_FIREDAMAGE;
  101. +                   mType->conditionWalkthroughs |= CONDITION_FIRE;
  102. +               }
  103. +           }  else {
  104. +               std::cout << "[Warning - Monsters::loadMonster] Unknown walkthrough. " << file << std::endl;
  105. +           }
  106. +       }
  107. +   }
  108. +
  109.     if ((node = monsterNode.child("voices"))) {
  110.         if ((attr = node.attribute("speed")) || (attr = node.attribute("interval"))) {
  111.             mType->yellSpeedTicks = pugi::cast<uint32_t>(attr.value());
  112. diff --git a/src/monsters.h b/src/monsters.h
  113. index bc77103..0ef5261 100755
  114. --- a/src/monsters.h
  115. +++ b/src/monsters.h
  116. @@ -121,6 +121,8 @@ class MonsterType
  117.         int32_t lightColor;
  118.         int32_t conditionImmunities;
  119.         int32_t damageImmunities;
  120. +       int32_t conditionWalkthroughs;
  121. +       int32_t damageWalkthroughs;
  122.         int32_t defense;
  123.         int32_t armor;
  124.         int32_t targetStrategiesNearestPercent;
  125. diff --git a/src/tile.cpp b/src/tile.cpp
  126. index 0eae7e8..b02511e 100755
  127. --- a/src/tile.cpp
  128. +++ b/src/tile.cpp
  129. @@ -630,12 +630,12 @@ ReturnValue Tile::__queryAdd(int32_t, const Thing* thing, uint32_t, uint32_t fla
  130.             }
  131.  
  132.             MagicField* field = getFieldItem();
  133. -           if (field && !field->isBlocking()) {
  134. +           if (field && !field->isBlocking() && field->isHarmful()) {
  135.                 CombatType_t combatType = field->getCombatType();
  136.  
  137.                 //There is 3 options for a monster to enter a magic field
  138.                 //1) Monster is immune
  139. -               if (!monster->isImmune(combatType) && field->isHarmful() && !monster->canIgnoreFields()) {
  140. +               if (!monster->isImmune(combatType) && !monster->canIgnoreFields() && !monster->canWalkthrough(combatType)) {
  141.                     //1) Monster is "strong" enough to handle the damage
  142.                     //2) Monster is already afflicated by this type of condition
  143.                     if (hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags)) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement