From e78b34c63fccc5ba7e5fb7fc057d48c63876b8be Mon Sep 17 00:00:00 2001 From: Seline Date: Sun, 19 Oct 2008 10:20:53 -0500 Subject: [svn] * Prevent creatures from moving if they are dead (if they were fleeing for example). * Critters now flee from attacker when taking damage. --HG-- branch : trunk --- src/game/Unit.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index eff464f110b..08a2ac93c92 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -500,17 +500,25 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // no xp,health if type 8 /critters/ if ( pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER) { - pVictim->setDeathState(JUST_DIED); - pVictim->SetHealth(0); + // critters run away when hit + pVictim->GetMotionMaster()->MoveFleeing(this); // allow loot only if has loot_id in creature_template - CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo(); - if(cInfo && cInfo->lootid) - pVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + if(damage >= pVictim->GetHealth()) + { + pVictim->setDeathState(JUST_DIED); + pVictim->SetHealth(0); - // some critters required for quests - if(GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); + CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo(); + if(cInfo && cInfo->lootid) + pVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + + // some critters required for quests + if(GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); + } + else + pVictim->ModifyHealth(- (int32)damage); return damage; } @@ -612,6 +620,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->CombatStop(); pVictim->getHostilRefManager().deleteReferences(); + // stop movement + pVictim->StopMoving(); + bool damageFromSpiritOfRedemtionTalent = spellProto && spellProto->Id == 27795; // if talent known but not triggered (check priest class for speedup check) -- cgit v1.2.3