Merge commit 'origin/master' into 310

This commit is contained in:
tomrus88 2009-04-25 17:24:05 +04:00
commit 55d6fbe3cb
46 changed files with 325 additions and 1369 deletions

View file

@ -497,17 +497,27 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
}
if(pVictim->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER)
if (GetTypeId() == TYPEID_PLAYER && this != pVictim)
{
if(((Player*)pVictim)->InBattleGround())
Player *killer = ((Player*)this);
// in bg, count dmg if victim is also a player
if (pVictim->GetTypeId()==TYPEID_PLAYER)
{
Player *killer = ((Player*)this);
if(killer != ((Player*)pVictim))
if(BattleGround *bg = killer->GetBattleGround())
bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
if (BattleGround *bg = killer->GetBattleGround())
{
// FIXME: kept by compatibility. don't know in BG if the restriction apply.
bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
}
}
killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, damage, 0, pVictim);
killer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT, damage);
}
if (pVictim->GetTypeId() == TYPEID_PLAYER)
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage);
if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet() && !((Creature*)pVictim)->hasLootRecipient())
((Creature*)pVictim)->SetLootRecipient(this);
@ -515,6 +525,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
{
DEBUG_LOG("DealDamage: victim just died");
if (pVictim->GetTypeId() == TYPEID_PLAYER)
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health);
// find player: owner of controlled `this` or `this` itself maybe
Player *player = GetCharmerOrOwnerPlayerOrPlayerItself();
@ -680,6 +694,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
{
DEBUG_LOG("DealDamageAlive");
if (pVictim->GetTypeId() == TYPEID_PLAYER)
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, damage);
pVictim->ModifyHealth(- (int32)damage);
if(damagetype != DOT)
@ -1291,8 +1308,8 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->procEx|=PROC_EX_NORMAL_HIT;
float reducePercent = 1.0f; //damage factor
// calculate base values and mods
float baseLowEnd = 1.3;
float baseHighEnd = 1.2;
float baseLowEnd = 1.3f;
float baseHighEnd = 1.2f;
switch(getClass()) // lowering base values for casters
{
case CLASS_SHAMAN:
@ -1300,17 +1317,17 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
case CLASS_MAGE:
case CLASS_WARLOCK:
case CLASS_DRUID:
baseLowEnd -= 0.7;
baseHighEnd -= 0.3;
baseLowEnd -= 0.7f;
baseHighEnd -= 0.3f;
break;
}
float maxLowEnd = 0.6;
float maxLowEnd = 0.6f;
switch(getClass()) // upper for melee classes
{
case CLASS_WARRIOR:
case CLASS_ROGUE:
maxLowEnd = 0.91; //If the attacker is a melee class then instead the lower value of 0.91
maxLowEnd = 0.91f; //If the attacker is a melee class then instead the lower value of 0.91
}
// calculate values
@ -1406,29 +1423,29 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// Reduce attack time
if (pVictim->haveOffhandWeapon() && offtime < basetime)
{
float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20;
float percent60 = 3 * percent20;
float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20f;
float percent60 = 3.0f * percent20;
if(offtime > percent20 && offtime <= percent60)
{
pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20));
}
else if(offtime > percent60)
{
offtime -= 2 * percent20;
offtime -= 2.0f * percent20;
pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime));
}
}
else
{
float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20;
float percent60 = 3 * percent20;
float percent60 = 3.0f * percent20;
if(basetime > percent20 && basetime <= percent60)
{
pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20));
}
else if(basetime > percent60)
{
basetime -= 2 * percent20;
basetime -= 2.0f * percent20;
pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime));
}
}
@ -1444,19 +1461,19 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
{
// -probability is between 0% and 40%
// 20% base chance
float Probability = 20;
float Probability = 20.0f;
//there is a newbie protection, at level 10 just 7% base chance; assuming linear function
if( pVictim->getLevel() < 30 )
Probability = 0.65f*pVictim->getLevel()+0.5;
Probability = 0.65f*pVictim->getLevel()+0.5f;
uint32 VictimDefense=pVictim->GetDefenseSkillValue();
uint32 AttackerMeleeSkill=GetUnitMeleeSkill();
Probability *= AttackerMeleeSkill/(float)VictimDefense;
if(Probability > 40)
Probability = 40;
if(Probability > 40.0f)
Probability = 40.0f;
if(roll_chance_f(Probability))
CastSpell(pVictim, 1604, true);
@ -1954,11 +1971,6 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
--m_extraAttacks;
}
}
// if damage pVictim call AI reaction
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
((Creature*)pVictim)->AI()->AttackedBy(this);
return;
}
@ -1979,6 +1991,10 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
DEBUG_LOG("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
// if damage pVictim call AI reaction
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
((Creature*)pVictim)->AI()->AttackedBy(this);
// extra attack only at any non extra attack (normal case)
if(!extra && extraAttacks)
{
@ -1989,10 +2005,6 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
--m_extraAttacks;
}
}
// if damage pVictim call AI reaction
if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
((Creature*)pVictim)->AI()->AttackedBy(this);
}
MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackType attType) const
@ -7215,9 +7227,9 @@ bool Unit::AttackStop(bool targetSwitch /*=false*/)
return true;
}
void Unit::CombatStop(bool cast)
void Unit::CombatStop(bool includingCast)
{
if(cast& IsNonMeleeSpellCasted(false))
if (includingCast && IsNonMeleeSpellCasted(false))
InterruptNonMeleeSpells(false);
AttackStop();
@ -7227,19 +7239,19 @@ void Unit::CombatStop(bool cast)
ClearInCombat();
}
void Unit::CombatStopWithPets(bool cast)
void Unit::CombatStopWithPets(bool includingCast)
{
CombatStop(cast);
CombatStop(includingCast);
if(Pet* pet = GetPet())
pet->CombatStop(cast);
pet->CombatStop(includingCast);
if(Unit* charm = GetCharm())
charm->CombatStop(cast);
charm->CombatStop(includingCast);
if(GetTypeId()==TYPEID_PLAYER)
{
GuardianPetList const& guardians = ((Player*)this)->GetGuardians();
for(GuardianPetList::const_iterator itr = guardians.begin(); itr != guardians.end(); ++itr)
if(Unit* guardian = Unit::GetUnit(*this,*itr))
guardian->CombatStop(cast);
guardian->CombatStop(includingCast);
}
}
@ -7424,6 +7436,33 @@ void Unit::UnsummonAllTotems()
}
}
int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical)
{
int32 gain = pVictim->ModifyHealth(int32(addhealth));
if (GetTypeId()==TYPEID_PLAYER)
{
SendHealSpellLog(pVictim, spellProto->Id, addhealth, critical);
if (BattleGround *bg = ((Player*)this)->GetBattleGround())
bg->UpdatePlayerScore((Player*)this, SCORE_HEALING_DONE, gain);
// use the actual gain, as the overheal shall not be counted, skip gain 0 (it ignored anyway in to criteria)
if (gain)
((Player*)this)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, gain, 0, pVictim);
((Player*)this)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED, addhealth);
}
if (pVictim->GetTypeId()==TYPEID_PLAYER)
{
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, gain);
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, addhealth);
}
return gain;
}
Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
{
if(!victim)