aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/MapManager.cpp17
-rw-r--r--src/game/Player.cpp60
-rw-r--r--src/game/Player.h3
-rw-r--r--src/game/Spell.cpp9
4 files changed, 65 insertions, 24 deletions
diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp
index 5a66ab6cea8..d1f3824fc9d 100644
--- a/src/game/MapManager.cpp
+++ b/src/game/MapManager.cpp
@@ -252,22 +252,21 @@ MapManager::Update(time_t diff)
uint32 i=0;
MapMapType::iterator iter;
std::vector<Map*> update_queue(i_maps.size());
- omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
- for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++)
- update_queue[i]=iter->second;
+ omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
+ for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++)
+ update_queue[i]=iter->second;
/*
- 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
+ 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
*/
#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
for(int32 i = 0; i < i_maps.size(); ++i)
{
checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day
- update_queue[i]->Update(i_timer.GetCurrent());
- 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());
-
+ update_queue[i]->Update(i_timer.GetCurrent());
+ 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());
}
ObjectAccessor::Instance().Update(i_timer.GetCurrent());
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index c449c53b23b..b24b3da2ace 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -6990,17 +6990,53 @@ void Player::UpdateEquipSpellsAtFormChange()
}
}
}
-
-void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPrototype const * proto)
+void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 procVictim, uint32 procEx)
{
- Unit * Target = damageInfo->target;
- WeaponAttackType attType = damageInfo->attackType;
-
- if (!Target || Target == this )
+ if(!target || !target->isAlive() || target == this)
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
- if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
+ if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
{
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
- if( m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS) )
+ if( m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS) )
return;
float chance = spellInfo->procChance;
@@ -7038,7 +7074,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro
}
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)
{
// Check hit/crit/dodge/parry requirement
- if((entry->procEx & damageInfo->procEx) == 0)
+ if((entry->procEx & procEx) == 0)
continue;
}
else
{
// 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;
}
@@ -7093,7 +7129,7 @@ void Player::CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPro
if(IsPositiveSpell(pEnchant->spellid[s]))
CastSpell(this, pEnchant->spellid[s], true, item);
else
- CastSpell(Target, pEnchant->spellid[s], true, item);
+ CastSpell(target, pEnchant->spellid[s], true, item);
}
}
}
diff --git a/src/game/Player.h b/src/game/Player.h
index 384acf7b760..dd211b6364e 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1798,7 +1798,8 @@ class TRINITY_DLL_SPEC Player : public Unit
void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false);
void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false);
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 SendUpdateWorldState(uint32 Field, uint32 Value);
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 4a0e51e9372..a7fb8840158 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -1043,11 +1043,16 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
procEx = createProcExtendMask(&damageInfo, missInfo);
procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE;
+
+ caster->DealSpellDamage(&damageInfo, true);
// Do triggers for unit (reflect triggers passed on hit phase for correct drop charge)
if (missInfo != SPELL_MISS_REFLECT)
+ {
caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_canTrigger);
-
- caster->DealSpellDamage(&damageInfo, true);
+ if(caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET) == 0 &&
+ (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
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellInfo->SpellFamilyFlags&0x0000000200000000LL &&