diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 129 |
1 files changed, 67 insertions, 62 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1c793cc71bf..d1a1c128744 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -387,10 +387,15 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uin WorldPacket data( SMSG_MONSTER_MOVE, (GetPackGUID().size()+4+4+4+4+1+4+4+4+pathSize*4*3) ); data.append(GetPackGUID()); - data << GetPositionX( ) - << GetPositionY( ) - << GetPositionZ( ); - data << GetOrientation( ); + data << GetPositionX(); + data << GetPositionY(); + data << GetPositionZ(); + + // unknown field - unrelated to orientation + // seems to increment about 1000 for every 1.7 seconds + // for now, we'll just use mstime + data << getMSTime(); + data << uint8( 0 ); data << uint32( MovementFlags ); data << uint32( traveltime ); @@ -868,7 +873,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa { if(getVictim()) { - // if have target and damage pVictim just call AI recation + // if have target and damage pVictim just call AI reaction if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) ((Creature*)pVictim)->AI()->AttackedBy(this); } @@ -982,7 +987,7 @@ void Unit::CastStop(uint32 except_spellid) InterruptSpell(i,false); } -void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); @@ -992,10 +997,10 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte return; } - CastSpell(Victim,spellInfo,triggered,castItem,triggredByAura, originalCaster); + CastSpell(Victim,spellInfo,triggered,castItem,triggeredByAura, originalCaster); } -void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { assert(Victim); if(!spellInfo) @@ -1007,8 +1012,8 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggredByAura) - originalCaster = triggredByAura->GetCasterGUID(); + if(!originalCaster && triggeredByAura) + originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); @@ -1016,10 +1021,10 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I targets.setUnitTarget( Victim ); targets.setDestination( Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ(), false); spell->m_CastItem = castItem; - spell->prepare(&targets, triggredByAura); + spell->prepare(&targets, triggeredByAura); } -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); @@ -1029,10 +1034,10 @@ void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 return; } - CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggredByAura, originalCaster); + CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggeredByAura, originalCaster); } -void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { if(!spellInfo) { @@ -1043,8 +1048,8 @@ void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggredByAura) - originalCaster = triggredByAura->GetCasterGUID(); + if(!originalCaster && triggeredByAura) + originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); @@ -1060,11 +1065,11 @@ void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const SpellCastTargets targets; targets.setUnitTarget( Victim ); spell->m_CastItem = castItem; - spell->prepare(&targets, triggredByAura); + spell->prepare(&targets, triggeredByAura); } // used for scripting -void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); @@ -1074,11 +1079,11 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, return; } - CastSpell(x, y, z,spellInfo,triggered,castItem,triggredByAura, originalCaster); + CastSpell(x, y, z,spellInfo,triggered,castItem,triggeredByAura, originalCaster); } // used for scripting -void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { if(!spellInfo) { @@ -1089,15 +1094,15 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, boo if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggredByAura) - originalCaster = triggredByAura->GetCasterGUID(); + if(!originalCaster && triggeredByAura) + originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); SpellCastTargets targets; targets.setDestination(x, y, z); spell->m_CastItem = castItem; - spell->prepare(&targets, triggredByAura); + spell->prepare(&targets, triggeredByAura); } void Unit::DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit, bool isTriggeredSpell) @@ -1105,7 +1110,7 @@ void Unit::DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *da // TODO this in only generic way, check for exceptions DEBUG_LOG("DealFlatDamage (BEFORE) >> DMG:%u", *damage); - // Per-damage calss calculation + // Per-damage class calculation switch (spellInfo->DmgClass) { // Melee and Ranged Spells @@ -1711,7 +1716,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe RemainingDamage -= currentAbsorb; } - // only split damage if not damaing yourself + // only split damage if not damaging yourself if(pVictim != this) { AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); @@ -2191,7 +2196,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex else if (attType == OFF_ATTACK) hitInfo = HITINFO_LEFTSWING; else - return; // ignore ranaged case + return; // ignore ranged case uint32 extraAttacks = m_extraAttacks; @@ -2305,7 +2310,7 @@ MeleeHitOutcome Unit::RollPhysicalOutcomeAgainst (Unit const *pVictim, WeaponAtt } else { - // parry can be avoided only by some abilites + // parry can be avoided only by some abilities parry_chance = pVictim->GetUnitParryChance(); // block might be bypassed by it as well block_chance = pVictim->GetUnitBlockChance(); @@ -2319,7 +2324,7 @@ MeleeHitOutcome Unit::RollPhysicalOutcomeAgainst (Unit const *pVictim, WeaponAtt // Increase from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL aura crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, spellInfo->SchoolMask); - if( dodge_chance != 0.0f ) // if dodge chance is already 0, ignore talents fpr speed + if( dodge_chance != 0.0f ) // if dodge chance is already 0, ignore talents for speed { AuraList const& mCanNotBeDodge = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); for(AuraList::const_iterator i = mCanNotBeDodge.begin(); i != mCanNotBeDodge.end(); ++i) @@ -2885,7 +2890,7 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool } // TODO need use this code for spell hit result calculation - // now code commented for compotability + // now code commented for computability switch (spell->DmgClass) { case SPELL_DAMAGE_CLASS_RANGED: @@ -3057,7 +3062,7 @@ float Unit::GetUnitBlockChance() const if(tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); } - // is player but has no block ability or no not broken shield equiped + // is player but has no block ability or no not broken shield equipped return 0.0f; } else @@ -3138,7 +3143,7 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) if(((Player*)this)->IsInFeralForm()) return GetMaxSkillValueForLevel(); // always maximized SKILL_FERAL_COMBAT in fact - // weaon skill or (unarmed for base attack) + // weapon skill or (unarmed for base attack) uint32 skill = item ? item->GetSkill() : SKILL_UNARMED; // in PvP use full skill instead current skill value @@ -3456,7 +3461,7 @@ bool Unit::isInLine(Unit const* target, float distance) const return abs(sin(angle)) * distance < width; } -bool Unit::isInAccessablePlaceFor(Creature const* c) const +bool Unit::isInAccessiblePlaceFor(Creature const* c) const { if(IsInWater()) return c->canSwim(); @@ -3492,13 +3497,13 @@ int32 Unit::GetTotalAuraModifier(AuraType auratype) const float Unit::GetTotalAuraMultiplier(AuraType auratype) const { - float multipler = 1.0f; + float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - multipler *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; + multiplier *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; - return multipler; + return multiplier; } int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const @@ -3541,16 +3546,16 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const { - float multipler = 1.0f; + float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue & misc_mask) - multipler *= (100.0f + mod->m_amount)/100.0f; + multiplier *= (100.0f + mod->m_amount)/100.0f; } - return multipler; + return multiplier; } int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const @@ -3599,16 +3604,16 @@ int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const { - float multipler = 1.0f; + float multiplier = 1.0f; AuraList const& mTotalAuraList = GetAurasByType(auratype); for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue == misc_value) - multipler *= (100.0f + mod->m_amount)/100.0f; + multiplier *= (100.0f + mod->m_amount)/100.0f; } - return multipler; + return multiplier; } int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const @@ -3724,7 +3729,7 @@ bool Unit::AddAura(Aura *Aur) if (!RemoveNoStackAurasDueToAura(Aur)) { delete Aur; - return false; // couldnt remove conflicting aura with higher rank + return false; // couldn't remove conflicting aura with higher rank } } @@ -3866,7 +3871,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) for(int j = 0; j < 3; ++j) { // prevent remove dummy triggered spells at next effect aura add - switch(spellProto->Effect[j]) // main spell auras added added after triggred spell + switch(spellProto->Effect[j]) // main spell auras added added after triggered spell { case SPELL_EFFECT_DUMMY: switch(spellId) @@ -3879,7 +3884,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) if(is_triggered_by_spell) break; - // prevent remove form main spell by triggred passive spells + // prevent remove form main spell by triggered passive spells switch(i_spellProto->EffectApplyAuraName[j]) // main aura added before triggered spell { case SPELL_AURA_MOD_SHAPESHIFT: @@ -4048,7 +4053,7 @@ void Unit::RemoveAurasWithDispelType( DispelType type ) { // Create dispel mask by dispel type uint32 dispelMask = GetDispellMask(type); - // Dispel all existing auras vs current dispell type + // Dispel all existing auras vs current dispel type AuraMap& auras = GetAuras(); for(AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) { @@ -4481,7 +4486,7 @@ void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVic sLog.outDebug("ProcDamageAndSpell: invoked due to spell id %u %s", procSpell->Id, (isTriggeredSpell?"(triggered)":"")); // Assign melee/ranged proc flags for magic attacks, that are actually melee/ranged abilities - // not assign for spell proc triggered spell to prevent infinity (or unexpacted 2-3 times) melee damage spell proc call with melee damage effect + // not assign for spell proc triggered spell to prevent infinity (or unexpected 2-3 times) melee damage spell proc call with melee damage effect // That is the question though if it's fully correct if(procSpell && !isTriggeredSpell) { @@ -4508,7 +4513,7 @@ void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVic // Not much to do if no flags are set. if (procAttacker) { - // procces auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set + // processing auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcEffectAuraTypes,attType, procSpell, damage, damageSchoolMask); ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcCastAuraTypes,attType, procSpell, damage, damageSchoolMask); } @@ -4517,7 +4522,7 @@ void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVic // Not much to do if no flags are set or there is no victim if(pVictim && pVictim->isAlive() && procVictim) { - // procces auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set + // processing auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcEffectAuraTypes,attType,procSpell, damage, damageSchoolMask); pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcCastAuraTypes,attType,procSpell, damage, damageSchoolMask); } @@ -4706,7 +4711,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint case 18765: case 35429: { - // prevent chain of triggred spell from same triggred spell + // prevent chain of triggered spell from same triggered spell if(procSpell && procSpell->Id==26654) return false; @@ -5728,7 +5733,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint return false; uint32 spellId = 0; - // Every Lightning Bolt and Chain Lightning spell have dublicate vs half damage and zero cost + // Every Lightning Bolt and Chain Lightning spell have duplicate vs half damage and zero cost switch (procSpell->Id) { // Lightning Bolt @@ -5771,7 +5776,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint if (procSpell->SpellFamilyFlags & 0x0000000000000002LL) ((Player*)this)->RemoveSpellCooldown(spellId); - // Hmmm.. in most case spells alredy set half basepoints but... + // Hmmm.. in most case spells already set half basepoints but... // Lightning Bolt (2-10 rank) have full basepoint and half bonus from level // As on wiki: // BUG: Rank 2 to 10 (and maybe 11) of Lightning Bolt will proc another Bolt with FULL damage (not halved). This bug is known and will probably be fixed soon. @@ -5989,7 +5994,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB if( pVictim == this ) return false; - // custom chnace + // custom chance float chance = 0; switch (triggeredByAura->GetId()) { @@ -7053,7 +7058,7 @@ void Unit::RemoveAllAttackers() AttackerSet::iterator iter = m_attackers.begin(); if(!(*iter)->AttackStop()) { - sLog.outError("WORLD: Unit has an attacker that isnt attacking it!"); + sLog.outError("WORLD: Unit has an attacker that isn't attacking it!"); m_attackers.erase(iter); } } @@ -8374,7 +8379,7 @@ void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType ty float Unit::GetWeaponProcChance() const { // normalized proc chance for weapon attack speed - // (odd formulae...) + // (odd formula...) if(isAttackReady(BASE_ATTACK)) return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f); else if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) @@ -9063,7 +9068,7 @@ bool Unit::SelectHostilTarget() assert(GetTypeId()== TYPEID_UNIT); Unit* target = NULL; - //This function only useful once AI has been initilazied + //This function only useful once AI has been initialized if (!((Creature*)this)->AI()) return false; @@ -9095,7 +9100,7 @@ bool Unit::SelectHostilTarget() { for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) { - if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessablePlaceFor((Creature*)this) ) + if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessiblePlaceFor((Creature*)this) ) return false; } } @@ -9337,7 +9342,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f { if(unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { - sLog.outError("ERROR in HandleStatModifier(): nonexisted UnitMods or wrong UnitModifierType!"); + sLog.outError("ERROR in HandleStatModifier(): non existed UnitMods or wrong UnitModifierType!"); return false; } @@ -9407,7 +9412,7 @@ float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) co { if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { - sLog.outError("ERROR: trial to access nonexisted modifier value from UnitMods!"); + sLog.outError("ERROR: trial to access non existed modifier value from UnitMods!"); return 0.0f; } @@ -9437,7 +9442,7 @@ float Unit::GetTotalAuraModValue(UnitMods unitMod) const { if(unitMod >= UNIT_MOD_END) { - sLog.outError("ERROR: trial to access nonexisted UnitMods in GetTotalAuraModValue()!"); + sLog.outError("ERROR: trial to access non existed UnitMods in GetTotalAuraModValue()!"); return 0.0f; } @@ -9737,7 +9742,7 @@ void Unit::CleanupsBeforeDelete() if(m_uint32Values) // only for fully created object { InterruptNonMeleeSpells(true); - m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted ans will deleated at call in Map::RemoveAllObjectsInRemoveList + m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList CombatStop(); ClearComboPointHolders(); DeleteThreatList(); @@ -10047,7 +10052,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag if(!found) { sLog.outError("Spell aura %u (id:%u effect:%u) has been deleted before call spell proc event handler",*aur,i->triggeredByAura_SpellPair.first,i->triggeredByAura_SpellPair.second); - sLog.outError("It can be deleted one from early proccesed auras:"); + sLog.outError("It can be deleted one from early processed auras:"); for(ProcTriggeredList::iterator i2 = procTriggered.begin(); i != i2; ++i2) sLog.outError(" Spell aura %u (id:%u effect:%u)",*aur,i2->triggeredByAura_SpellPair.first,i2->triggeredByAura_SpellPair.second); sLog.outError(" <end of list>"); @@ -10297,7 +10302,7 @@ void Unit::StopMoving() clearUnitState(UNIT_STAT_MOVING); // send explicit stop packet - // rely on vmaps here because for exemple stormwind is in air + // rely on vmaps here because for example stormwind is in air float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); //if (fabs(GetPositionZ() - z) < 2.0f) // Relocate(GetPositionX(), GetPositionY(), z); |