diff options
author | megamage <none@none> | 2009-03-15 17:54:24 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-15 17:54:24 -0600 |
commit | 61f519ca26f6d75e2096b5469691a0f37d53bbed (patch) | |
tree | dd7acc3a654a5c33d37f1e37c362515fa42048a5 /src/game/SpellEffects.cpp | |
parent | 3c9c17b253e64da78fa395c1a972b6ce09cc926f (diff) |
[7464] Move check of spell using for lock open to single function. Remove more hacks. Author: VladimirMangos
--HG--
branch : trunk
Diffstat (limited to 'src/game/SpellEffects.cpp')
-rw-r--r-- | src/game/SpellEffects.cpp | 95 |
1 files changed, 21 insertions, 74 deletions
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 4f5e630c56b..e494274b751 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3143,92 +3143,39 @@ void Spell::EffectOpenLock(uint32 effIndex) return; } - if(!lockId) // possible case for GO and maybe for items. - { - SendLoot(guid, LOOT_CORPSE); - return; - } + SkillType skillId = SKILL_NONE; + int32 reqSkillValue = 0; + int32 skillValue; - // Get LockInfo - LockEntry const *lockInfo = sLockStore.LookupEntry(lockId); - - if (!lockInfo) + SpellCastResult res = CanOpenLock(effIndex,lockId,skillId,reqSkillValue,skillValue); + if(res != SPELL_CAST_OK) { - sLog.outError( "Spell::EffectOpenLock: %s [guid = %u] has an unknown lockId: %u!", - (gameObjTarget ? "gameobject" : "item"), GUID_LOPART(guid), lockId); - SendCastResult(SPELL_FAILED_BAD_TARGETS); + SendCastResult(res); return; } - bool reqKey = false; // some locks not have reqs + SendLoot(guid, LOOT_SKINNING); - for(int j = 0; j < 8; ++j) + // not allow use skill grou at item base open + if(!m_CastItem && skillId != SKILL_NONE) { - switch(lockInfo->Type[j]) + // update skill if really known + if(uint32 pureSkillValue = player->GetPureSkillValue(skillId)) { - // check key item (many fit cases can be) - case LOCK_KEY_ITEM: - if(lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry()==lockInfo->Index[j]) - { - SendLoot(guid, LOOT_CORPSE); - return; - } - reqKey = true; - break; - // check key skill (only single first fit case can be) - case LOCK_KEY_SKILL: + if(gameObjTarget) { - reqKey = true; - - // wrong locktype, skip - if(uint32(m_spellInfo->EffectMiscValue[effIndex]) != lockInfo->Index[j]) - continue; - - SkillType skillId = SkillByLockType(LockType(lockInfo->Index[j])); - - if ( skillId != SKILL_NONE ) - { - // skill bonus provided by casting spell (mostly item spells) - uint32 spellSkillBonus = uint32(damage); - uint32 reqSkillValue = lockInfo->Skill[j]; - - if ( player->GetSkillValue(skillId) + spellSkillBonus < reqSkillValue ) - { - SendCastResult(SPELL_FAILED_LOW_CASTLEVEL); - return; - } - - // update skill if really known - if(uint32 SkillValue = player->GetPureSkillValue(skillId)) - { - if(gameObjTarget) - { - // Allow one skill-up until respawned - if ( !gameObjTarget->IsInSkillupList( player->GetGUIDLow() ) && - player->UpdateGatherSkill(skillId, SkillValue, reqSkillValue) ) - gameObjTarget->AddToSkillupList( player->GetGUIDLow() ); - } - else if(itemTarget) - { - // Do one skill-up - player->UpdateGatherSkill(skillId, SkillValue, reqSkillValue); - } - } - } - - SendLoot(guid, LOOT_SKINNING); - return; + // Allow one skill-up until respawned + if ( !gameObjTarget->IsInSkillupList( player->GetGUIDLow() ) && + player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue) ) + gameObjTarget->AddToSkillupList( player->GetGUIDLow() ); + } + else if(itemTarget) + { + // Do one skill-up + player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue); } } } - - if(reqKey) - { - SendCastResult(SPELL_FAILED_BAD_TARGETS); - return; - } - - SendLoot(guid, LOOT_SKINNING); } void Spell::EffectSummonChangeItem(uint32 i) |