ProjectSkyfire / SkyFire.406a

SkyFireEMU is a full featured F/OSS World of Warcraft: Cataclysm emulator written in C++. || Compatible with World of Warcraft client 4.0.6a (Build:13623) || Public DB is located on forum
http://www.projectskyfire.org
GNU General Public License v3.0
343 stars 218 forks source link

Evade when skinning #876

Closed Loukie closed 11 years ago

Loukie commented 11 years ago

After this https://github.com/ProjectSkyfire/SkyFireEMU/commit/48325bb922f5fc6d16290d39aee2dd53b9844987 update i am Evading when skinning. The server did not crash nor did the console give me any errors.

Evade

Loukie commented 11 years ago

I have turned off Mmaps to make sure it was not mmaps doing this but i can confirm that it dos not matter if mmaps is turned on or off it still happens

Retriman commented 11 years ago

ok, i fixed now!

Loukie commented 11 years ago

thx @Retriman

Loukie commented 11 years ago

ok so i have done some test on this when you attack a creep and it aggro you can not skin it it will Evade. agrro

so far it only happens when a creep aggro

Evade

but when i .dammage it befare it aggro i can skin it with no problem

damage

skinning

Loukie commented 11 years ago

i hope this helps

Retriman commented 11 years ago

@Loukie fixed test plz =) and comment jeje

diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index a5c8242..fd4abf2 100755
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -154,13 +154,20 @@ void CreatureAI::EnterEvadeMode()
             me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE);
         }
         else
+        {
+            // Required to prevent attacking creatures that are evading and cause them to reenter combat
+            // Does not apply to MoveFollow
+            me->AddUnitState(UNIT_STATE_EVADE);
             me->GetMotionMaster()->MoveTargetedHome();
+        }
     }

     Reset();

     if (me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
         me->GetVehicleKit()->Reset(true);
+
+    me->SetLastDamagedTime(0);
 }

 /*void CreatureAI::AttackedBy(Unit* attacker)
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 7d9e8e1..c4a7905 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -148,11 +148,24 @@ _hitMask(hitMask), m_spell(spell), _damageInfo(damageInfo), _healInfo(healInfo)
 #ifdef _MSC_VER
 #pragma warning(disable:4355)
 #endif
-Unit::Unit(bool isWorldObject): WorldObject(isWorldObject),
-_movedPlayer(NULL), m_lastSanctuaryTime(0), IsAIEnabled(false), NeedChangeAI(false),
-_ControlledByPlayer(false), i_AI(NULL), i_disabledAI(NULL), m_procDeep(0),
-m_removedAurasCount(0), i_motionMaster(this), m_ThreatManager(this), m_vehicle(NULL),
-_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this), movespline(new Movement::MoveSpline())
+Unit::Unit(bool isWorldObject): WorldObject(isWorldObject)
+    , _movedPlayer(NULL)
+    , m_lastSanctuaryTime(0) 
+    , IsAIEnabled(false) 
+    , NeedChangeAI(false)
+    , _ControlledByPlayer(false)
+    , i_AI(NULL)
+    , i_disabledAI(NULL)
+    , m_procDeep(0)
+    , m_removedAurasCount(0)
+    , i_motionMaster(this)
+    , m_ThreatManager(this)
+    , m_vehicle(NULL)
+    , _vehicleKit(NULL)
+    , m_unitTypeMask(UNIT_MASK_NONE)
+    , m_HostileRefManager(this)
+    , movespline(new Movement::MoveSpline())
+    , _lastDamagedTime(0)
 {
 #ifdef _MSC_VER
 #pragma warning(default:4355)
@@ -12929,6 +12942,10 @@ int32 Unit::ModifyHealth(int32 dVal)
     if (dVal == 0)
         return 0;

+    // Part of Evade mechanics. Only track health lost, not gained.
+    if (dVal < 0 && GetTypeId() != TYPEID_PLAYER && !isPet())
+        SetLastDamagedTime(time(NULL));
+
     int32 curHealth = (int32)GetHealth();

     int32 val = dVal + curHealth;
@@ -13563,6 +13580,14 @@ Unit* Creature::SelectVictim()
         return target;
     }

+    // Case where mob is being kited.
+    // Mob may not be in range to attack or may have dropped target. In any case,
+    //  don't evade if damage received within the last 10 seconds
+    // Does not apply to world bosses to prevent kiting to cities
+    if (!isWorldBoss() && !GetInstanceId())
+        if (time(NULL) - GetLastDamagedTime() <= MAX_AGGRO_RESET_TIME)
+            return target;
+
     // last case when creature must not go to evade mode:
     // it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list
     // for example at owner command to pet attack some far away creature
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 79fbf3c..e830859 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -289,6 +289,7 @@ enum UnitRename
 #define MAX_SPELL_VEHICLE       6
 #define MAX_SPELL_POSSESS       8
 #define MAX_SPELL_CONTROL_BAR   10
+#define MAX_AGGRO_RESET_TIME 10 // in seconds

 enum Swing
 {
@@ -2308,6 +2309,10 @@ class Unit : public WorldObject
         // Movement info
         Movement::MoveSpline* movespline;

+        // Part of Evade mechanics
+        time_t GetLastDamagedTime() const { return _lastDamagedTime; }
+        void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
+
     protected:
         explicit Unit (bool isWorldObject);

@@ -2435,6 +2440,8 @@ class Unit : public WorldObject

         std::map<uint32, uint32> _spellSwaps;
         float _healAbsorb;
+
+        time_t _lastDamagedTime; // Part of Evade mechanics
 };

 namespace SkyFire
Loukie commented 11 years ago

i am compiling now will give update shortly

Loukie commented 11 years ago

not working still Evading well maybe i did something wrong need some els to test this and confirm if this works or not

Loukie commented 11 years ago

the problem is defiantly aggro i killed a cow it did not aggro and i could skin it when up to a Mangy wolf it aggro and cant skin it it Evade

Loukie commented 11 years ago

thx it is fixed after https://github.com/ProjectSkyfire/SkyFireEMU/commit/c00bc1996c0c6415a4d128d9c8228e0ce8e436f1