The following stealth changes are implemented.

- Combat no longer removes stealth, only damage does
 - Creatures will pursue a stealthed unit they cannot see if they're already in combat with them
 - When a player is ~~3 yards~~ 8% + 1.5 yards away from the usual stealth detection distance, the creature will perform the "alerted" effect.
 - When sitting/sleeping creatures are distracted or alerted, they will stand up
 - Idle movement creatures will return to their original (spawn) orientation after distract/alert
 - When entering combat with a distracted/alerted creature, distract state is removed
 - NPC no longer have a limit to stealth visibility (granted by stealth modifier spells/buffs)
 - If alert visibility is greater than aggro range, no alert sent
This commit is contained in:
pete318 committed 2015-07-02 23:11:20 +00:00
1 parent 275bb93034
commit 1e0213bc57
11 files changed
+108 -14

No files matched your search

+16 -6
View File
@@ -1539,7 +1539,7 @@ float WorldObject::GetSightRange(const WorldObject* target) const
return 0.0f;
}
bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, bool distanceCheck) const
bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, bool distanceCheck, bool checkAlert) const
{
if (this == obj)
return true;
@@ -1611,7 +1611,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
if (obj->IsInvisibleDueToDespawn())
return false;
if (!CanDetect(obj, ignoreStealth))
if (!CanDetect(obj, ignoreStealth, checkAlert))
return false;
return true;
@@ -1622,7 +1622,7 @@ bool WorldObject::CanNeverSee(WorldObject const* obj) const
return GetMap() != obj->GetMap() || !InSamePhase(obj);
}
bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const
bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth, bool checkAlert) const
{
const WorldObject* seer = this;
@@ -1637,7 +1637,7 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const
if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
return false;
if (!ignoreStealth && !seer->CanDetectStealthOf(obj))
if (!ignoreStealth && !seer->CanDetectStealthOf(obj, checkAlert))
return false;
return true;
@@ -1674,7 +1674,7 @@ bool WorldObject::CanDetectInvisibilityOf(WorldObject const* obj) const
return true;
}
bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const
bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) const
{
// Combat reach is the minimal distance (both in front and behind),
// and it is also used in the range calculation.
@@ -1724,9 +1724,19 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const
// Calculate max distance
float visibilityRange = float(detectionValue) * 0.3f + combatReach;
if (visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
// If this unit is an NPC then player detect range doesn't apply
if (unit && unit->GetTypeId() == TYPEID_PLAYER && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
visibilityRange = MAX_PLAYER_STEALTH_DETECT_RANGE;
// When checking for alert state, look 8% further, and then 1.5 yards more than that.
if (checkAlert)
visibilityRange += (visibilityRange * 0.08f) + 1.5f;
// If checking for alert, and creature's visibility range is greater than aggro distance, No alert
Unit const* tunit = obj->ToUnit();
if (checkAlert && unit && unit->ToCreature() && visibilityRange >= unit->ToCreature()->GetAttackDistance(tunit) + unit->ToCreature()->m_CombatDistance)
return false;
if (distance > visibilityRange)
return false;
}