diff options
-rw-r--r-- | src/game/Player.h | 2 | ||||
-rw-r--r-- | src/game/SpellMgr.cpp | 52 | ||||
-rw-r--r-- | src/game/SpellMgr.h | 19 | ||||
-rw-r--r-- | src/game/Unit.cpp | 36 | ||||
-rw-r--r-- | src/game/World.cpp | 3 |
5 files changed, 106 insertions, 6 deletions
diff --git a/src/game/Player.h b/src/game/Player.h index 0223364cce0..230d80785a7 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1714,7 +1714,7 @@ 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,Unit* Target, WeaponAttackType attType); + void CastItemCombatSpell(Item *item, CalcDamageInfo *damageInfo, ItemPrototype const * proto); void CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex); void SendInitWorldStates(uint32 zone, uint32 area); diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 4e5a4744e9a..49c88086c7a 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1351,6 +1351,58 @@ void SpellMgr::LoadSpellThreats() sLog.outString(); } +void SpellMgr::LoadSpellEnchantProcData() +{ + mSpellEnchantProcEventMap.clear(); // need for reload case + + uint32 count = 0; + + // 0 1 2 3 + QueryResult *result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data"); + if( !result ) + { + + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u spell enchant proc event conditions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + do + { + Field *fields = result->Fetch(); + + bar.step(); + + uint32 enchantId = fields[0].GetUInt32(); + + SpellItemEnchantmentEntry const *ench = sSpellItemEnchantmentStore.LookupEntry(enchantId); + if (!ench) + { + sLog.outErrorDb("Enchancment %u listed in `spell_enchant_proc_data` does not exist", enchantId); + continue; + } + + SpellEnchantProcEntry spe; + + spe.customChance = fields[1].GetUInt32(); + spe.PPMChance = fields[2].GetFloat(); + spe.procEx = fields[3].GetUInt32(); + + mSpellEnchantProcEventMap[enchantId] = spe; + + ++count; + } while( result->NextRow() ); + + delete result; + + sLog.outString( ">> Loaded %u enchant proc data definitions", count); +} + bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const { SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index c6d251e5457..6869f2e529e 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -500,6 +500,15 @@ struct SpellBonusEntry }; typedef UNORDERED_MAP<uint32, SpellProcEventEntry> SpellProcEventMap; + +struct SpellEnchantProcEntry +{ + uint32 customChance; + float PPMChance; + uint32 procEx; +}; + +typedef UNORDERED_MAP<uint32, SpellEnchantProcEntry> SpellEnchantProcEventMap; typedef UNORDERED_MAP<uint32, SpellBonusEntry> SpellBonusMap; #define ELIXIR_BATTLE_MASK 0x1 @@ -759,6 +768,14 @@ class SpellMgr bool IsSpellProcEventCanTriggeredBy( SpellProcEventEntry const * spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra, bool active); + SpellEnchantProcEntry const* GetSpellEnchantProcEvent(uint32 enchId) const + { + SpellEnchantProcEventMap::const_iterator itr = mSpellEnchantProcEventMap.find(enchId); + if( itr != mSpellEnchantProcEventMap.end( ) ) + return &itr->second; + return NULL; + } + // Spell bonus data SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const { @@ -1020,6 +1037,7 @@ class SpellMgr void LoadSkillLineAbilityMap(); void LoadSpellPetAuras(); void LoadSpellCustomAttr(); + void LoadSpellEnchantProcData(); void LoadSpellLinked(); void LoadPetLevelupSpellMap(); void LoadSpellAreas(); @@ -1040,6 +1058,7 @@ class SpellMgr SpellPetAuraMap mSpellPetAuraMap; SpellCustomAttribute mSpellCustomAttr; SpellLinkedMap mSpellLinkedMap; + SpellEnchantProcEventMap mSpellEnchantProcEventMap; PetLevelupSpellMap mPetLevelupSpellMap; SpellAreaMap mSpellAreaMap; SpellAreaForQuestMap mSpellAreaForQuestMap; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index e36c25883d4..3cd0c4fb2c7 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1699,15 +1699,41 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) CastSpell(pVictim, 1604, true); } - // If not miss - if (!(damageInfo->HitInfo & HITINFO_MISS)) + if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) { - if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) { - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - ((Player*)this)->CastItemCombatSpell(((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0,i), pVictim, damageInfo->attackType); + // If usable, try to cast item spell + if (Item * item = ((Player*)this)->GetUseableItemByPos(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 (damageInfo->attackType) + { + 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 (((Player*)this)->IsInFeralForm()) + continue; + } + ((Player*)this)->CastItemCombatSpell(item, damageInfo, proto); + } } + } + // Do effect if any damage done to target + if (damageInfo->damage) + { // victim's damage shield std::set<AuraEffect*> alreadyDone; uint32 removedAuras = pVictim->m_removedAurasCount; diff --git a/src/game/World.cpp b/src/game/World.cpp index 665fb6d4bdc..93d927c07eb 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1223,6 +1223,9 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading NPC Texts..." ); objmgr.LoadGossipText(); + sLog.outString( "Loading Enchant Spells Proc datas..."); + spellmgr.LoadSpellEnchantProcData(); + sLog.outString( "Loading Item Random Enchantments Table..." ); LoadRandomEnchantmentsTable(); |