Changeset 229 for trunk/src/game/Unit.cpp
- Timestamp:
- 11/19/08 13:48:34 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Unit.cpp
r226 r229 388 388 WorldPacket data( SMSG_MONSTER_MOVE, (GetPackGUID().size()+4+4+4+4+1+4+4+4+pathSize*4*3) ); 389 389 data.append(GetPackGUID()); 390 data << GetPositionX( ) 391 << GetPositionY( ) 392 << GetPositionZ( ); 393 data << GetOrientation( ); 390 data << GetPositionX(); 391 data << GetPositionY(); 392 data << GetPositionZ(); 393 394 // unknown field - unrelated to orientation 395 // seems to increment about 1000 for every 1.7 seconds 396 // for now, we'll just use mstime 397 data << getMSTime(); 398 394 399 data << uint8( 0 ); 395 400 data << uint32( MovementFlags ); … … 869 874 if(getVictim()) 870 875 { 871 // if have target and damage pVictim just call AI re cation876 // if have target and damage pVictim just call AI reaction 872 877 if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) 873 878 ((Creature*)pVictim)->AI()->AttackedBy(this); … … 983 988 } 984 989 985 void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* trigg redByAura, uint64 originalCaster)990 void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) 986 991 { 987 992 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); … … 993 998 } 994 999 995 CastSpell(Victim,spellInfo,triggered,castItem,trigg redByAura, originalCaster);996 } 997 998 void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* trigg redByAura, uint64 originalCaster)1000 CastSpell(Victim,spellInfo,triggered,castItem,triggeredByAura, originalCaster); 1001 } 1002 1003 void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) 999 1004 { 1000 1005 assert(Victim); … … 1008 1013 DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); 1009 1014 1010 if(!originalCaster && trigg redByAura)1011 originalCaster = trigg redByAura->GetCasterGUID();1015 if(!originalCaster && triggeredByAura) 1016 originalCaster = triggeredByAura->GetCasterGUID(); 1012 1017 1013 1018 Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); … … 1017 1022 targets.setDestination( Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ(), false); 1018 1023 spell->m_CastItem = castItem; 1019 spell->prepare(&targets, trigg redByAura);1020 } 1021 1022 void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* trigg redByAura, uint64 originalCaster)1024 spell->prepare(&targets, triggeredByAura); 1025 } 1026 1027 void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) 1023 1028 { 1024 1029 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); … … 1030 1035 } 1031 1036 1032 CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,trigg redByAura, originalCaster);1033 } 1034 1035 void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* trigg redByAura, uint64 originalCaster)1037 CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggeredByAura, originalCaster); 1038 } 1039 1040 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) 1036 1041 { 1037 1042 if(!spellInfo) … … 1044 1049 DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); 1045 1050 1046 if(!originalCaster && trigg redByAura)1047 originalCaster = trigg redByAura->GetCasterGUID();1051 if(!originalCaster && triggeredByAura) 1052 originalCaster = triggeredByAura->GetCasterGUID(); 1048 1053 1049 1054 Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); … … 1061 1066 targets.setUnitTarget( Victim ); 1062 1067 spell->m_CastItem = castItem; 1063 spell->prepare(&targets, trigg redByAura);1068 spell->prepare(&targets, triggeredByAura); 1064 1069 } 1065 1070 1066 1071 // used for scripting 1067 void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* trigg redByAura, uint64 originalCaster)1072 void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) 1068 1073 { 1069 1074 SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); … … 1075 1080 } 1076 1081 1077 CastSpell(x, y, z,spellInfo,triggered,castItem,trigg redByAura, originalCaster);1082 CastSpell(x, y, z,spellInfo,triggered,castItem,triggeredByAura, originalCaster); 1078 1083 } 1079 1084 1080 1085 // used for scripting 1081 void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* trigg redByAura, uint64 originalCaster)1086 void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) 1082 1087 { 1083 1088 if(!spellInfo) … … 1090 1095 DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); 1091 1096 1092 if(!originalCaster && trigg redByAura)1093 originalCaster = trigg redByAura->GetCasterGUID();1097 if(!originalCaster && triggeredByAura) 1098 originalCaster = triggeredByAura->GetCasterGUID(); 1094 1099 1095 1100 Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); … … 1098 1103 targets.setDestination(x, y, z); 1099 1104 spell->m_CastItem = castItem; 1100 spell->prepare(&targets, trigg redByAura);1105 spell->prepare(&targets, triggeredByAura); 1101 1106 } 1102 1107 … … 1106 1111 DEBUG_LOG("DealFlatDamage (BEFORE) >> DMG:%u", *damage); 1107 1112 1108 // Per-damage c alss calculation1113 // Per-damage class calculation 1109 1114 switch (spellInfo->DmgClass) 1110 1115 { … … 1712 1717 } 1713 1718 1714 // only split damage if not dama ing yourself1719 // only split damage if not damaging yourself 1715 1720 if(pVictim != this) 1716 1721 { … … 2192 2197 hitInfo = HITINFO_LEFTSWING; 2193 2198 else 2194 return; // ignore ran aged case2199 return; // ignore ranged case 2195 2200 2196 2201 uint32 extraAttacks = m_extraAttacks; … … 2306 2311 else 2307 2312 { 2308 // parry can be avoided only by some abilit es2313 // parry can be avoided only by some abilities 2309 2314 parry_chance = pVictim->GetUnitParryChance(); 2310 2315 // block might be bypassed by it as well … … 2320 2325 crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, spellInfo->SchoolMask); 2321 2326 2322 if( dodge_chance != 0.0f ) // if dodge chance is already 0, ignore talents f pr speed2327 if( dodge_chance != 0.0f ) // if dodge chance is already 0, ignore talents for speed 2323 2328 { 2324 2329 AuraList const& mCanNotBeDodge = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); … … 2886 2891 2887 2892 // TODO need use this code for spell hit result calculation 2888 // now code commented for comp otability2893 // now code commented for computability 2889 2894 switch (spell->DmgClass) 2890 2895 { … … 3058 3063 return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); 3059 3064 } 3060 // is player but has no block ability or no not broken shield equip ed3065 // is player but has no block ability or no not broken shield equipped 3061 3066 return 0.0f; 3062 3067 } … … 3139 3144 return GetMaxSkillValueForLevel(); // always maximized SKILL_FERAL_COMBAT in fact 3140 3145 3141 // wea on skill or (unarmed for base attack)3146 // weapon skill or (unarmed for base attack) 3142 3147 uint32 skill = item ? item->GetSkill() : SKILL_UNARMED; 3143 3148 … … 3457 3462 } 3458 3463 3459 bool Unit::isInAccess ablePlaceFor(Creature const* c) const3464 bool Unit::isInAccessiblePlaceFor(Creature const* c) const 3460 3465 { 3461 3466 if(IsInWater()) … … 3493 3498 float Unit::GetTotalAuraMultiplier(AuraType auratype) const 3494 3499 { 3495 float multipl er = 1.0f;3500 float multiplier = 1.0f; 3496 3501 3497 3502 AuraList const& mTotalAuraList = GetAurasByType(auratype); 3498 3503 for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) 3499 multipl er *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f;3500 3501 return multipl er;3504 multiplier *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; 3505 3506 return multiplier; 3502 3507 } 3503 3508 … … 3542 3547 float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const 3543 3548 { 3544 float multipl er = 1.0f;3549 float multiplier = 1.0f; 3545 3550 3546 3551 AuraList const& mTotalAuraList = GetAurasByType(auratype); … … 3549 3554 Modifier* mod = (*i)->GetModifier(); 3550 3555 if (mod->m_miscvalue & misc_mask) 3551 multipl er *= (100.0f + mod->m_amount)/100.0f;3552 } 3553 return multipl er;3556 multiplier *= (100.0f + mod->m_amount)/100.0f; 3557 } 3558 return multiplier; 3554 3559 } 3555 3560 … … 3600 3605 float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const 3601 3606 { 3602 float multipl er = 1.0f;3607 float multiplier = 1.0f; 3603 3608 3604 3609 AuraList const& mTotalAuraList = GetAurasByType(auratype); … … 3607 3612 Modifier* mod = (*i)->GetModifier(); 3608 3613 if (mod->m_miscvalue == misc_value) 3609 multipl er *= (100.0f + mod->m_amount)/100.0f;3610 } 3611 return multipl er;3614 multiplier *= (100.0f + mod->m_amount)/100.0f; 3615 } 3616 return multiplier; 3612 3617 } 3613 3618 … … 3725 3730 { 3726 3731 delete Aur; 3727 return false; // couldn t remove conflicting aura with higher rank3732 return false; // couldn't remove conflicting aura with higher rank 3728 3733 } 3729 3734 } … … 3867 3872 { 3868 3873 // prevent remove dummy triggered spells at next effect aura add 3869 switch(spellProto->Effect[j]) // main spell auras added added after trigg red spell3874 switch(spellProto->Effect[j]) // main spell auras added added after triggered spell 3870 3875 { 3871 3876 case SPELL_EFFECT_DUMMY: … … 3880 3885 break; 3881 3886 3882 // prevent remove form main spell by trigg red passive spells3887 // prevent remove form main spell by triggered passive spells 3883 3888 switch(i_spellProto->EffectApplyAuraName[j]) // main aura added before triggered spell 3884 3889 { … … 4049 4054 // Create dispel mask by dispel type 4050 4055 uint32 dispelMask = GetDispellMask(type); 4051 // Dispel all existing auras vs current dispel ltype4056 // Dispel all existing auras vs current dispel type 4052 4057 AuraMap& auras = GetAuras(); 4053 4058 for(AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) … … 4482 4487 4483 4488 // Assign melee/ranged proc flags for magic attacks, that are actually melee/ranged abilities 4484 // not assign for spell proc triggered spell to prevent infinity (or unexp acted 2-3 times) melee damage spell proc call with melee damage effect4489 // not assign for spell proc triggered spell to prevent infinity (or unexpected 2-3 times) melee damage spell proc call with melee damage effect 4485 4490 // That is the question though if it's fully correct 4486 4491 if(procSpell && !isTriggeredSpell) … … 4509 4514 if (procAttacker) 4510 4515 { 4511 // proc cesauras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set4516 // 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 4512 4517 ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcEffectAuraTypes,attType, procSpell, damage, damageSchoolMask); 4513 4518 ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcCastAuraTypes,attType, procSpell, damage, damageSchoolMask); … … 4518 4523 if(pVictim && pVictim->isAlive() && procVictim) 4519 4524 { 4520 // proc cesauras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set4525 // 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 4521 4526 pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcEffectAuraTypes,attType,procSpell, damage, damageSchoolMask); 4522 4527 pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcCastAuraTypes,attType,procSpell, damage, damageSchoolMask); … … 4707 4712 case 35429: 4708 4713 { 4709 // prevent chain of trigg red spell from same triggred spell4714 // prevent chain of triggered spell from same triggered spell 4710 4715 if(procSpell && procSpell->Id==26654) 4711 4716 return false; … … 5729 5734 5730 5735 uint32 spellId = 0; 5731 // Every Lightning Bolt and Chain Lightning spell have du blicate vs half damage and zero cost5736 // Every Lightning Bolt and Chain Lightning spell have duplicate vs half damage and zero cost 5732 5737 switch (procSpell->Id) 5733 5738 { … … 5772 5777 ((Player*)this)->RemoveSpellCooldown(spellId); 5773 5778 5774 // Hmmm.. in most case spells alre dy set half basepoints but...5779 // Hmmm.. in most case spells already set half basepoints but... 5775 5780 // Lightning Bolt (2-10 rank) have full basepoint and half bonus from level 5776 5781 // As on wiki: … … 5990 5995 return false; 5991 5996 5992 // custom ch nace5997 // custom chance 5993 5998 float chance = 0; 5994 5999 switch (triggeredByAura->GetId()) … … 7054 7059 if(!(*iter)->AttackStop()) 7055 7060 { 7056 sLog.outError("WORLD: Unit has an attacker that isn t attacking it!");7061 sLog.outError("WORLD: Unit has an attacker that isn't attacking it!"); 7057 7062 m_attackers.erase(iter); 7058 7063 } … … 8375 8380 { 8376 8381 // normalized proc chance for weapon attack speed 8377 // (odd formula e...)8382 // (odd formula...) 8378 8383 if(isAttackReady(BASE_ATTACK)) 8379 8384 return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f); … … 9064 9069 Unit* target = NULL; 9065 9070 9066 //This function only useful once AI has been initi lazied9071 //This function only useful once AI has been initialized 9067 9072 if (!((Creature*)this)->AI()) 9068 9073 return false; … … 9096 9101 for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) 9097 9102 { 9098 if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccess ablePlaceFor((Creature*)this) )9103 if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessiblePlaceFor((Creature*)this) ) 9099 9104 return false; 9100 9105 } … … 9338 9343 if(unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) 9339 9344 { 9340 sLog.outError("ERROR in HandleStatModifier(): non existed UnitMods or wrong UnitModifierType!");9345 sLog.outError("ERROR in HandleStatModifier(): non existed UnitMods or wrong UnitModifierType!"); 9341 9346 return false; 9342 9347 } … … 9408 9413 if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) 9409 9414 { 9410 sLog.outError("ERROR: trial to access non existed modifier value from UnitMods!");9415 sLog.outError("ERROR: trial to access non existed modifier value from UnitMods!"); 9411 9416 return 0.0f; 9412 9417 } … … 9438 9443 if(unitMod >= UNIT_MOD_END) 9439 9444 { 9440 sLog.outError("ERROR: trial to access non existed UnitMods in GetTotalAuraModValue()!");9445 sLog.outError("ERROR: trial to access non existed UnitMods in GetTotalAuraModValue()!"); 9441 9446 return 0.0f; 9442 9447 } … … 9738 9743 { 9739 9744 InterruptNonMeleeSpells(true); 9740 m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted ans will deleated at call in Map::RemoveAllObjectsInRemoveList9745 m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList 9741 9746 CombatStop(); 9742 9747 ClearComboPointHolders(); … … 10048 10053 { 10049 10054 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); 10050 sLog.outError("It can be deleted one from early proc cesed auras:");10055 sLog.outError("It can be deleted one from early processed auras:"); 10051 10056 for(ProcTriggeredList::iterator i2 = procTriggered.begin(); i != i2; ++i2) 10052 10057 sLog.outError(" Spell aura %u (id:%u effect:%u)",*aur,i2->triggeredByAura_SpellPair.first,i2->triggeredByAura_SpellPair.second); … … 10298 10303 10299 10304 // send explicit stop packet 10300 // rely on vmaps here because for ex emple stormwind is in air10305 // rely on vmaps here because for example stormwind is in air 10301 10306 float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); 10302 10307 //if (fabs(GetPositionZ() - z) < 2.0f)