Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/creature.cpp b/src/creature.cpp
- index 70ca916..b3094ac 100755
- --- a/src/creature.cpp
- +++ b/src/creature.cpp
- @@ -1412,6 +1412,16 @@ bool Creature::isImmune(ConditionType_t type) const
- return hasBitSet((uint32_t)type, getConditionImmunities());
- }
- +bool Creature::canWalkthrough(CombatType_t type) const
- +{
- + return hasBitSet((uint32_t)type, getDamageWalkthroughs());
- +}
- +
- +bool Creature::canWalkthrough(ConditionType_t type) const
- +{
- + return hasBitSet((uint32_t)type, getConditionWalkthroughs());
- +}
- +
- bool Creature::isSuppress(ConditionType_t type) const
- {
- return hasBitSet((uint32_t)type, getConditionSuppressions());
- diff --git a/src/creature.h b/src/creature.h
- index dea9007..e927bac 100755
- --- a/src/creature.h
- +++ b/src/creature.h
- @@ -321,6 +321,8 @@ class Creature : virtual public Thing
- CreatureEventList getCreatureEvents(CreatureEventType_t type);
- virtual bool isImmune(ConditionType_t type) const;
- virtual bool isImmune(CombatType_t type) const;
- + virtual bool canWalkthrough(ConditionType_t type) const;
- + virtual bool canWalkthrough(CombatType_t type) const;
- virtual bool isSuppress(ConditionType_t type) const;
- virtual uint32_t getDamageImmunities() const {
- return 0;
- @@ -328,6 +330,12 @@ class Creature : virtual public Thing
- virtual uint32_t getConditionImmunities() const {
- return 0;
- }
- + virtual uint32_t getDamageWalkthroughs() const {
- + return 0;
- + }
- + virtual uint32_t getConditionWalkthroughs() const {
- + return 0;
- + }
- virtual uint32_t getConditionSuppressions() const {
- return 0;
- }
- diff --git a/src/map.cpp b/src/map.cpp
- index a038bb4..8c3eb9a 100755
- --- a/src/map.cpp
- +++ b/src/map.cpp
- @@ -858,7 +858,7 @@ int_fast32_t AStarNodes::getTileWalkCost(const Creature& creature, const Tile* t
- if (const MagicField* field = tile->getFieldItem()) {
- if (field->isHarmful()) {
- CombatType_t combatType = field->getCombatType();
- - if (!creature.isImmune(combatType) && !creature.hasCondition(Combat::DamageToConditionType(combatType))) {
- + if (!creature.isImmune(combatType) && !creature.hasCondition(Combat::DamageToConditionType(combatType)) && !creature.canWalkthrough(combatType)) {
- cost += MAP_NORMALWALKCOST * 4;
- }
- }
- diff --git a/src/monster.h b/src/monster.h
- index 81e8b90..14c6dd8 100755
- --- a/src/monster.h
- +++ b/src/monster.h
- @@ -281,6 +281,12 @@ class Monster : public Creature
- virtual uint32_t getConditionImmunities() const {
- return mType->conditionImmunities;
- }
- + virtual uint32_t getDamageWalkthroughs() const {
- + return mType->damageWalkthroughs;
- + }
- + virtual uint32_t getConditionWalkthroughs() const {
- + return mType->conditionWalkthroughs;
- + }
- virtual uint16_t getLookCorpse() const {
- return mType->lookcorpse;
- }
- diff --git a/src/monsters.cpp b/src/monsters.cpp
- index 845cc24..937c633 100755
- --- a/src/monsters.cpp
- +++ b/src/monsters.cpp
- @@ -1134,6 +1134,29 @@ bool Monsters::loadMonster(const std::string& file, const std::string& monster_n
- }
- }
- + if ((node = monsterNode.child("walkthroughs"))) {
- + for (pugi::xml_node walkthoroughNode = node.first_child(); walkthoroughNode; walkthoroughNode = walkthoroughNode.next_sibling()) {
- + if ((attr = walkthoroughNode.attribute("poison"))) {
- + if (attr.as_bool()) {
- + mType->damageWalkthroughs |= COMBAT_EARTHDAMAGE;
- + mType->conditionWalkthroughs |= CONDITION_POISON;
- + }
- + } else if ((attr = walkthoroughNode.attribute("energy"))) {
- + if (attr.as_bool()) {
- + mType->damageWalkthroughs |= COMBAT_ENERGYDAMAGE;
- + mType->conditionWalkthroughs |= CONDITION_ENERGY;
- + }
- + } else if ((attr = walkthoroughNode.attribute("fire"))) {
- + if (attr.as_bool()) {
- + mType->damageWalkthroughs |= COMBAT_FIREDAMAGE;
- + mType->conditionWalkthroughs |= CONDITION_FIRE;
- + }
- + } else {
- + std::cout << "[Warning - Monsters::loadMonster] Unknown walkthrough. " << file << std::endl;
- + }
- + }
- + }
- +
- if ((node = monsterNode.child("voices"))) {
- if ((attr = node.attribute("speed")) || (attr = node.attribute("interval"))) {
- mType->yellSpeedTicks = pugi::cast<uint32_t>(attr.value());
- diff --git a/src/monsters.h b/src/monsters.h
- index bc77103..0ef5261 100755
- --- a/src/monsters.h
- +++ b/src/monsters.h
- @@ -121,6 +121,8 @@ class MonsterType
- int32_t lightColor;
- int32_t conditionImmunities;
- int32_t damageImmunities;
- + int32_t conditionWalkthroughs;
- + int32_t damageWalkthroughs;
- int32_t defense;
- int32_t armor;
- int32_t targetStrategiesNearestPercent;
- diff --git a/src/tile.cpp b/src/tile.cpp
- index 0eae7e8..b02511e 100755
- --- a/src/tile.cpp
- +++ b/src/tile.cpp
- @@ -630,12 +630,12 @@ ReturnValue Tile::__queryAdd(int32_t, const Thing* thing, uint32_t, uint32_t fla
- }
- MagicField* field = getFieldItem();
- - if (field && !field->isBlocking()) {
- + if (field && !field->isBlocking() && field->isHarmful()) {
- CombatType_t combatType = field->getCombatType();
- //There is 3 options for a monster to enter a magic field
- //1) Monster is immune
- - if (!monster->isImmune(combatType) && field->isHarmful() && !monster->canIgnoreFields()) {
- + if (!monster->isImmune(combatType) && !monster->canIgnoreFields() && !monster->canWalkthrough(combatType)) {
- //1) Monster is "strong" enough to handle the damage
- //2) Monster is already afflicated by this type of condition
- if (hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags)) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement