* Allow spells to trigger ItemCombatSpells if spell is melee/ranged damage based. Original patch by freegajnja

* Tabs to spaces.

--HG--
branch : trunk
This commit is contained in:
krz
2009-06-23 04:47:46 +02:00
parent 4a93373c06
commit dd52461d40
4 changed files with 65 additions and 24 deletions
+8 -9
View File
@@ -252,22 +252,21 @@ MapManager::Update(time_t diff)
uint32 i=0; uint32 i=0;
MapMapType::iterator iter; MapMapType::iterator iter;
std::vector<Map*> update_queue(i_maps.size()); std::vector<Map*> update_queue(i_maps.size());
omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS)); omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++) for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++)
update_queue[i]=iter->second; update_queue[i]=iter->second;
/* /*
gomp in gcc <4.4 version cannot parallelise loops using random access iterators gomp in gcc <4.4 version cannot parallelise loops using random access iterators
so until gcc 4.4 isnt standard, we need the update_queue workaround so until gcc 4.4 isnt standard, we need the update_queue workaround
*/ */
#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue) #pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
for(int32 i = 0; i < i_maps.size(); ++i) for(int32 i = 0; i < i_maps.size(); ++i)
{ {
checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day
update_queue[i]->Update(i_timer.GetCurrent()); update_queue[i]->Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateMap %u", update_queue[i]->GetId()); sWorld.RecordTimeDiff("UpdateMap %u", update_queue[i]->GetId());
// sLog.outError("This is thread %d out of %d threads,updating map %u",omp_get_thread_num(),omp_get_num_threads(),iter->second->GetId()); // sLog.outError("This is thread %d out of %d threads,updating map %u",omp_get_thread_num(),omp_get_num_threads(),iter->second->GetId());
} }
ObjectAccessor::Instance().Update(i_timer.GetCurrent()); ObjectAccessor::Instance().Update(i_timer.GetCurrent());
+48 -12
View File
@@ -6990,17 +6990,53 @@ void Player::UpdateEquipSpellsAtFormChange()
} }
} }
} }
void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx)
void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPrototype const * proto)
{ {
Unit * Target = damageInfo->target; if(!target || !target->isAlive() || target == this)
WeaponAttackType attType = damageInfo->attackType;
if (!Target || Target == this )
return; return;
for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
{
// If usable, try to cast item spell
if (Item * item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i))
if(!item->IsBroken())
if (ItemPrototype const *proto = item->GetProto())
{
// Additional check for weapons
if (proto->Class==ITEM_CLASS_WEAPON)
{
// offhand item cannot proc from main hand hit etc
EquipmentSlots slot;
switch (attType)
{
case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break;
case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break;
case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break;
default: slot = EQUIPMENT_SLOT_END; break;
}
if (slot != i)
continue;
// Check if item is useable (forms or disarm)
if (attType == BASE_ATTACK)
{
if (!((Player*)this)->IsUseEquipedWeapon(true))
continue;
}
else
{
if (((Player*)this)->IsInFeralForm())
continue;
}
}
((Player*)this)->CastItemCombatSpell(target, attType, procVictim, procEx, item, proto);
}
}
}
void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemPrototype const * proto)
{
// Can do effect if any damage done to target // Can do effect if any damage done to target
if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE) if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
{ {
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
@@ -7022,7 +7058,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro
} }
// not allow proc extra attack spell at extra attack // not allow proc extra attack spell at extra attack
if( m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) if( m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS) )
return; return;
float chance = spellInfo->procChance; float chance = spellInfo->procChance;
@@ -7038,7 +7074,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro
} }
if (roll_chance_f(chance)) if (roll_chance_f(chance))
CastSpell(Target, spellInfo->Id, true, item); CastSpell(target, spellInfo->Id, true, item);
} }
} }
@@ -7058,13 +7094,13 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro
if (entry && entry->procEx) if (entry && entry->procEx)
{ {
// Check hit/crit/dodge/parry requirement // Check hit/crit/dodge/parry requirement
if((entry->procEx & damageInfo->procEx) == 0) if((entry->procEx & procEx) == 0)
continue; continue;
} }
else else
{ {
// Can do effect if any damage done to target // Can do effect if any damage done to target
if (!(damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)) if (!(procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE))
continue; continue;
} }
@@ -7093,7 +7129,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro
if(IsPositiveSpell(pEnchant->spellid[s])) if(IsPositiveSpell(pEnchant->spellid[s]))
CastSpell(this, pEnchant->spellid[s], true, item); CastSpell(this, pEnchant->spellid[s], true, item);
else else
CastSpell(Target, pEnchant->spellid[s], true, item); CastSpell(target, pEnchant->spellid[s], true, item);
} }
} }
} }
+2 -1
View File
@@ -1798,7 +1798,8 @@ class TRINITY_DLL_SPEC Player : public Unit
void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false); void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false); void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
void UpdateEquipSpellsAtFormChange(); void UpdateEquipSpellsAtFormChange();
void CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPrototype const * proto); void CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx);
void CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item *item, ItemPrototype const * proto);
void SendInitWorldStates(bool force = false, uint32 forceZoneId = 0); void SendInitWorldStates(bool force = false, uint32 forceZoneId = 0);
void SendUpdateWorldState(uint32 Field, uint32 Value); void SendUpdateWorldState(uint32 Field, uint32 Value);
+7 -2
View File
@@ -1043,11 +1043,16 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
procEx = createProcExtendMask(&damageInfo, missInfo); procEx = createProcExtendMask(&damageInfo, missInfo);
procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE;
caster->DealSpellDamage(&damageInfo, true);
// Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge)
if (missInfo != SPELL_MISS_REFLECT) if (missInfo != SPELL_MISS_REFLECT)
{
caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_canTrigger); caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_canTrigger);
if(caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET) == 0 &&
caster->DealSpellDamage(&damageInfo, true); (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED))
((Player *)caster)->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx);
}
// Shadow Word: Death - deals damage equal to damage done to caster if victim is not killed // Shadow Word: Death - deals damage equal to damage done to caster if victim is not killed
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellInfo->SpellFamilyFlags&0x0000000200000000LL && if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellInfo->SpellFamilyFlags&0x0000000200000000LL &&