diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/include/sc_creature.cpp | 4 | ||||
-rw-r--r-- | src/game/Map.cpp | 7 | ||||
-rw-r--r-- | src/game/Object.h | 9 | ||||
-rw-r--r-- | src/game/TargetedMovementGenerator.cpp | 4 |
4 files changed, 20 insertions, 4 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index b6d6f90d2a4..b1044ff6319 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -92,7 +92,7 @@ void ScriptedAI::UpdateAI(const uint32 diff) if (m_creature->isAttackReady() ) { //If we are within range melee the target - if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + if (m_creature->IsWithinCombatDist(m_creature->getVictim(), ATTACK_DISTANCE)) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); @@ -148,7 +148,7 @@ void ScriptedAI::DoMeleeAttackIfReady() if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) { //If we are within range melee the target - if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + if (m_creature->IsWithinCombatDist(m_creature->getVictim(), ATTACK_DISTANCE)) { m_creature->AttackerStateUpdate(m_creature->getVictim()); m_creature->resetAttackTimer(); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 85fc6421a52..9deb86855a6 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1419,6 +1419,13 @@ InstanceMap::~InstanceMap() */ bool InstanceMap::CanEnter(Player *player) { + if(!player->isGameMaster() && i_data && i_data->IsEncounterInProgress()) + { + sLog.outDebug("InstanceMap::CanEnter - Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName()); + player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); + return false; + } + if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) { sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); diff --git a/src/game/Object.h b/src/game/Object.h index f858e212bb8..9b6b805d53e 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -372,6 +372,15 @@ class TRINITY_DLL_SPEC WorldObject : public Object // angle to face `obj` to `this` using distance includes size of `obj` GetNearPoint(obj,x,y,z,obj->GetObjectSize(),distance2d,GetAngle( obj )); } + void GetRandomContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const + { + float object_size = obj->GetObjectSize();//here we use object_size to determine the angle offset, the bigger object the smaller angle offset, then this makes mob move naturally in visual. + //let assume 12.0f is the max size for object to have 0 angle offset. + float angle_offset_ratio = 1 - object_size/12.0f; + if (angle_offset_ratio < 0.05) angle_offset_ratio = 0.05; + // angle to face `obj` to `this`plus a random angle offset(from -90 degree to 90 degree)*angle_offset_ratio using distance from distance2dMin to distance2dMax includes size of `obj` + GetNearPoint(obj,x,y,z,object_size,distance2dMin+(distance2dMax-distance2dMin)*rand_norm(), GetAngle( obj ) + (M_PI_2 - M_PI * rand_norm()) * angle_offset_ratio); + } float GetObjectSize() const { diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 67d4a8c098e..125335455d4 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -59,8 +59,8 @@ TargetedMovementGenerator<T>::_setTargetLocation(T &owner) float x, y, z; if(!i_offset) { - // to nearest contact position - i_target->GetContactPoint( &owner, x, y, z ); + // to nearest random contact position + i_target->GetRandomContactPoint( &owner, x, y, z,0.5f,4.5f ); } else { |