mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
Replace hack code in Spell::EffectOpenLock by generic way for check lock key items/skills
This commit is contained in:
parent
7dd997617e
commit
991376067d
3 changed files with 86 additions and 76 deletions
|
|
@ -4172,6 +4172,7 @@ uint8 Spell::CanCast(bool strict)
|
|||
{
|
||||
// check for lock - key pair (checked by client also, just prevent cheating
|
||||
bool ok_key = false;
|
||||
bool req_key = false;
|
||||
for(int it = 0; it < 8; ++it)
|
||||
{
|
||||
switch(lockInfo->Type[it])
|
||||
|
|
@ -4180,6 +4181,7 @@ uint8 Spell::CanCast(bool strict)
|
|||
break;
|
||||
case LOCK_KEY_ITEM:
|
||||
{
|
||||
req_key = true;
|
||||
if(lockInfo->Index[it])
|
||||
{
|
||||
if(m_CastItem && m_CastItem->GetEntry()==lockInfo->Index[it])
|
||||
|
|
@ -4189,30 +4191,22 @@ uint8 Spell::CanCast(bool strict)
|
|||
}
|
||||
case LOCK_KEY_SKILL:
|
||||
{
|
||||
req_key = true;
|
||||
if(uint32(m_spellInfo->EffectMiscValue[i])!=lockInfo->Index[it])
|
||||
break;
|
||||
|
||||
switch(lockInfo->Index[it])
|
||||
{
|
||||
case LOCKTYPE_HERBALISM:
|
||||
if(((Player*)m_caster)->HasSkill(SKILL_HERBALISM))
|
||||
ok_key =true;
|
||||
break;
|
||||
case LOCKTYPE_MINING:
|
||||
if(((Player*)m_caster)->HasSkill(SKILL_MINING))
|
||||
ok_key =true;
|
||||
break;
|
||||
default:
|
||||
ok_key =true;
|
||||
break;
|
||||
}
|
||||
SkillType skill = SkillByLockType(LockType(lockInfo->Index[it]));
|
||||
if(skill==SKILL_NONE)
|
||||
ok_key =true;
|
||||
else if(((Player*)m_caster)->HasSkill(skill))
|
||||
ok_key =true;
|
||||
}
|
||||
}
|
||||
if(ok_key)
|
||||
break;
|
||||
}
|
||||
|
||||
if(!ok_key)
|
||||
if(!ok_key && req_key)
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue