aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKittnz <frederik156@hotmail.com>2015-04-18 17:11:03 +0200
committerDDuarte <dnpd.dd@gmail.com>2015-08-15 18:34:48 +0100
commit21e0880fbaf78abd530e0fbb941f19adf556891a (patch)
tree7fef9aa6410c65290464c7958e167eca01e40974
parent519ba47429feb57175959281f63add9c25f66e8c (diff)
Core/Condition: Add In Water Condition
Updates #7019 (cherry picked from commit 5f8db047614a492dd178325b429839609d9f7fc5) Conflicts: src/server/game/Conditions/ConditionMgr.cpp src/server/game/Conditions/ConditionMgr.h Closes #15285 CONDITION_TERRAIN_SWAP (40) has been changed to 41 to keep compatibility with the 3.3.5 branch
-rw-r--r--sql/updates/world/2015_08_15_00_world.sql1
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp12
-rw-r--r--src/server/game/Conditions/ConditionMgr.h5
3 files changed, 16 insertions, 2 deletions
diff --git a/sql/updates/world/2015_08_15_00_world.sql b/sql/updates/world/2015_08_15_00_world.sql
new file mode 100644
index 00000000000..72645ab0734
--- /dev/null
+++ b/sql/updates/world/2015_08_15_00_world.sql
@@ -0,0 +1 @@
+UPDATE `conditions` SET `ConditionTypeOrReference`=41 WHERE `ConditionTypeOrReference`=40;
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 7cae9ee2221..8a37012f5f4 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -101,6 +101,7 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
{ "Health Value", true, true, false },
{ "Health Pct", true, true, false },
{ "Realm Achievement", true, false, false },
+ { "In Water", false, false, false },
{ "Terrain Swap", true, false, false }
};
@@ -425,6 +426,12 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
condMeets = true;
break;
}
+ case CONDITION_IN_WATER:
+ {
+ if (Unit* unit = object->ToUnit())
+ condMeets = unit->IsInWater();
+ break;
+ }
case CONDITION_TERRAIN_SWAP:
{
condMeets = object->IsInTerrainSwap(ConditionValue1);
@@ -602,6 +609,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition()
case CONDITION_REALM_ACHIEVEMENT:
mask |= GRID_MAP_TYPE_MASK_ALL;
break;
+ case CONDITION_IN_WATER:
+ mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER;
+ break;
case CONDITION_TERRAIN_SWAP:
mask |= GRID_MAP_TYPE_MASK_ALL;
break;
@@ -2120,6 +2130,8 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
break;
}
+ case CONDITION_IN_WATER:
+ break;
default:
break;
}
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index f2d27afb5f3..3549b1f2515 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -90,8 +90,9 @@ enum ConditionTypes
CONDITION_HP_VAL = 37, // hpVal ComparisonType 0 true if unit's hp matches given value
CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
CONDITION_REALM_ACHIEVEMENT = 39, // achievement_id 0 0 true if realm achievement is complete
- CONDITION_TERRAIN_SWAP = 40, // terrainSwap 0 0 true if object is in terrainswap
- CONDITION_MAX = 41 // MAX
+ CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water
+ CONDITION_TERRAIN_SWAP = 41, // terrainSwap 0 0 true if object is in terrainswap
+ CONDITION_MAX = 42 // MAX
};
/*! Documentation on implementing a new ConditionSourceType: