[2008_10_31_01_mangos_creature_template.sql] Creature related code and DB cleanups.

* Rename 2 creature_template fields to more clean names and related code update also.
* Use enum values instead raw values for type_flags, use halper functions instead code repeating.
* Move tamed pet creating code to new function.
This commit is contained in:
VladimirMangos 2008-10-31 20:45:22 +03:00
parent c7ac8577ae
commit 41b876b395
11 changed files with 103 additions and 76 deletions

View file

@ -3517,12 +3517,8 @@ uint8 Spell::CanCast(bool strict)
if (m_targets.getUnitTarget()->getLevel() > m_caster->getLevel())
return SPELL_FAILED_HIGHLEVEL;
CreatureInfo const *cinfo = ((Creature*)m_targets.getUnitTarget())->GetCreatureInfo();
if( cinfo->type != CREATURE_TYPE_BEAST )
return SPELL_FAILED_BAD_TARGETS;
// use SMSG_PET_TAME_FAILURE?
if( !(cinfo->flag1 & 1) || !(cinfo->family) )
if (!((Creature*)m_targets.getUnitTarget())->GetCreatureInfo()->isTameable ())
return SPELL_FAILED_BAD_TARGETS;
if(m_caster->GetPetGUID())
@ -3634,13 +3630,7 @@ uint8 Spell::CanCast(bool strict)
return SPELL_FAILED_TARGET_NOT_LOOTED;
}
uint32 skill;
if(creature->GetCreatureInfo()->flag1 & 256)
skill = SKILL_HERBALISM; // special case
else if(creature->GetCreatureInfo()->flag1 & 512)
skill = SKILL_MINING; // special case
else
skill = SKILL_SKINNING; // normal case
uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill();
int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill);
int32 TargetLevel = m_targets.getUnitTarget()->getLevel();