aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-02-04 19:16:12 -0600
committermegamage <none@none>2009-02-04 19:16:12 -0600
commitcdcf465360e19b94d62917f3622837c517e7a4ca (patch)
treef6a1b1633b334723ebd285dffce2272531639426
parentc2550caf969f21bd3d8ead91d1b57f17a725e76a (diff)
parentae5e608c00bde11f8c1178b3f1f07bab4f855272 (diff)
*Merge.
--HG-- branch : trunk
-rw-r--r--src/game/Debugcmds.cpp (renamed from src/game/debugcmds.cpp)0
-rw-r--r--src/game/GameObject.cpp29
-rw-r--r--src/game/GameObject.h1
-rw-r--r--src/game/Tools.cpp (renamed from src/game/tools.cpp)0
4 files changed, 26 insertions, 4 deletions
diff --git a/src/game/debugcmds.cpp b/src/game/Debugcmds.cpp
index 22b7fb389fb..22b7fb389fb 100644
--- a/src/game/debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index df694fdd735..0b2dd179cdf 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -738,12 +738,12 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
return false;
// special invisibility cases
- /* TODO: implement trap stealth, take look at spell 2836
- if(GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed && u->IsHostileTo(GetOwner()))
+ if(GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed)
{
- if(check stuff here)
+ Unit *owner = GetOwner();
+ if(owner && u->IsHostileTo(owner) && !canDetectTrap(u, GetDistance(u)))
return false;
- }*/
+ }
}
// check distance
@@ -751,6 +751,27 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
+bool GameObject::canDetectTrap(Player const* u, float distance) const
+{
+ if(u->hasUnitState(UNIT_STAT_STUNNED))
+ return false;
+ if(distance < GetGOInfo()->size) //collision
+ return true;
+ if(!u->HasInArc(M_PI, this)) //behind
+ return false;
+ if(u->HasAuraType(SPELL_AURA_DETECT_STEALTH))
+ return true;
+
+ //Visible distance is modified by -Level Diff (every level diff = 0.25f in visible distance)
+ float visibleDistance = (int32(u->getLevel()) - int32(GetOwner()->getLevel()))* 0.25f;
+ //GetModifier for trap (miscvalue 1)
+ //35y for aura 2836
+ //WARNING: these values are guessed, may be not blizzlike
+ visibleDistance += u->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DETECT, 1)* 0.5f;
+
+ return distance < visibleDistance;
+}
+
void GameObject::Respawn()
{
if(m_spawnedByDefault && m_respawnTime > 0)
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 3c8cc768f37..64cf1b9b159 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -579,6 +579,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target);
bool isVisibleForInState(Player const* u, bool inVisibleList) const;
+ bool canDetectTrap(Player const* u, float distance) const;
GameObject* LookupFishingHoleAround(float range);
diff --git a/src/game/tools.cpp b/src/game/Tools.cpp
index f8663a4b4e4..f8663a4b4e4 100644
--- a/src/game/tools.cpp
+++ b/src/game/Tools.cpp