mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
c7ac8577ae
commit
41b876b395
11 changed files with 103 additions and 76 deletions
|
|
@ -711,7 +711,7 @@ CREATE TABLE `creature_template` (
|
||||||
`attackpower` int(10) unsigned NOT NULL default '0',
|
`attackpower` int(10) unsigned NOT NULL default '0',
|
||||||
`baseattacktime` int(10) unsigned NOT NULL default '0',
|
`baseattacktime` int(10) unsigned NOT NULL default '0',
|
||||||
`rangeattacktime` int(10) unsigned NOT NULL default '0',
|
`rangeattacktime` int(10) unsigned NOT NULL default '0',
|
||||||
`flags` int(10) unsigned NOT NULL default '0',
|
`unit_flags` int(10) unsigned NOT NULL default '0',
|
||||||
`dynamicflags` int(10) unsigned NOT NULL default '0',
|
`dynamicflags` int(10) unsigned NOT NULL default '0',
|
||||||
`family` tinyint(4) NOT NULL default '0',
|
`family` tinyint(4) NOT NULL default '0',
|
||||||
`trainer_type` tinyint(4) NOT NULL default '0',
|
`trainer_type` tinyint(4) NOT NULL default '0',
|
||||||
|
|
@ -722,7 +722,7 @@ CREATE TABLE `creature_template` (
|
||||||
`maxrangedmg` float NOT NULL default '0',
|
`maxrangedmg` float NOT NULL default '0',
|
||||||
`rangedattackpower` smallint(5) unsigned NOT NULL default '0',
|
`rangedattackpower` smallint(5) unsigned NOT NULL default '0',
|
||||||
`type` tinyint(3) unsigned NOT NULL default '0',
|
`type` tinyint(3) unsigned NOT NULL default '0',
|
||||||
`flag1` int(10) unsigned NOT NULL default '0',
|
`type_flags` int(10) unsigned NOT NULL default '0',
|
||||||
`lootid` mediumint(8) unsigned NOT NULL default '0',
|
`lootid` mediumint(8) unsigned NOT NULL default '0',
|
||||||
`pickpocketloot` mediumint(8) unsigned NOT NULL default '0',
|
`pickpocketloot` mediumint(8) unsigned NOT NULL default '0',
|
||||||
`skinloot` mediumint(8) unsigned NOT NULL default '0',
|
`skinloot` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
|
|
||||||
5
sql/updates/2008_10_31_01_mangos_creature_template.sql
Normal file
5
sql/updates/2008_10_31_01_mangos_creature_template.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE db_version CHANGE COLUMN required_2008_10_29_05_mangos_command required_2008_10_31_01_mangos_creature_template bit;
|
||||||
|
|
||||||
|
ALTER TABLE `creature_template`
|
||||||
|
CHANGE COLUMN `flags` `unit_flags` int(10) unsigned NOT NULL default '0',
|
||||||
|
CHANGE COLUMN `flag1` `type_flags` int(10) unsigned NOT NULL default '0';
|
||||||
|
|
@ -118,6 +118,7 @@ pkgdata_DATA = \
|
||||||
2008_10_29_03_mangos_db_version.sql \
|
2008_10_29_03_mangos_db_version.sql \
|
||||||
2008_10_29_04_mangos_mangos_string.sql \
|
2008_10_29_04_mangos_mangos_string.sql \
|
||||||
2008_10_29_05_mangos_command.sql \
|
2008_10_29_05_mangos_command.sql \
|
||||||
|
2008_10_31_01_mangos_creature_template.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -217,4 +218,5 @@ EXTRA_DIST = \
|
||||||
2008_10_29_03_mangos_db_version.sql \
|
2008_10_29_03_mangos_db_version.sql \
|
||||||
2008_10_29_04_mangos_mangos_string.sql \
|
2008_10_29_04_mangos_mangos_string.sql \
|
||||||
2008_10_29_05_mangos_command.sql \
|
2008_10_29_05_mangos_command.sql \
|
||||||
|
2008_10_31_01_mangos_creature_template.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
||||||
SetAttackTime(OFF_ATTACK, GetCreatureInfo()->baseattacktime);
|
SetAttackTime(OFF_ATTACK, GetCreatureInfo()->baseattacktime);
|
||||||
SetAttackTime(RANGED_ATTACK,GetCreatureInfo()->rangeattacktime);
|
SetAttackTime(RANGED_ATTACK,GetCreatureInfo()->rangeattacktime);
|
||||||
|
|
||||||
SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->Flags);
|
SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->unit_flags);
|
||||||
SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
|
SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
|
||||||
|
|
||||||
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor));
|
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor));
|
||||||
|
|
|
||||||
|
|
@ -165,9 +165,9 @@ struct CreatureInfo
|
||||||
uint32 attackpower;
|
uint32 attackpower;
|
||||||
uint32 baseattacktime;
|
uint32 baseattacktime;
|
||||||
uint32 rangeattacktime;
|
uint32 rangeattacktime;
|
||||||
uint32 Flags;
|
uint32 unit_flags; // enum UnitFlags mask values
|
||||||
uint32 dynamicflags;
|
uint32 dynamicflags;
|
||||||
uint32 family;
|
uint32 family; // enum CreatureFamily values for type==CREATURE_TYPE_BEAST, or 0 in another cases
|
||||||
uint32 trainer_type;
|
uint32 trainer_type;
|
||||||
uint32 trainer_spell;
|
uint32 trainer_spell;
|
||||||
uint32 classNum;
|
uint32 classNum;
|
||||||
|
|
@ -175,8 +175,8 @@ struct CreatureInfo
|
||||||
float minrangedmg;
|
float minrangedmg;
|
||||||
float maxrangedmg;
|
float maxrangedmg;
|
||||||
uint32 rangedattackpower;
|
uint32 rangedattackpower;
|
||||||
uint32 type;
|
uint32 type; // enum CreatureType values
|
||||||
uint32 flag1;
|
uint32 type_flags; // enum CreatureTypeFlags mask values
|
||||||
uint32 lootid;
|
uint32 lootid;
|
||||||
uint32 pickpocketLootId;
|
uint32 pickpocketLootId;
|
||||||
uint32 SkinLootId;
|
uint32 SkinLootId;
|
||||||
|
|
@ -202,6 +202,22 @@ struct CreatureInfo
|
||||||
uint32 MechanicImmuneMask;
|
uint32 MechanicImmuneMask;
|
||||||
uint32 flags_extra;
|
uint32 flags_extra;
|
||||||
char const* ScriptName;
|
char const* ScriptName;
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
SkillType GetRequiredLootSkill() const
|
||||||
|
{
|
||||||
|
if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
|
||||||
|
return SKILL_HERBALISM;
|
||||||
|
else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
|
||||||
|
return SKILL_MINING;
|
||||||
|
else
|
||||||
|
return SKILL_SKINNING; // normal case
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isTameable() const
|
||||||
|
{
|
||||||
|
return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEBLE);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CreatureLocale
|
struct CreatureLocale
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
|
||||||
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
|
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
|
||||||
data << SubName;
|
data << SubName;
|
||||||
data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0
|
data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0
|
||||||
data << (uint32)ci->flag1; // flags wdbFeild7=wad flags1
|
data << (uint32)ci->type_flags; // flags wdbFeild7=wad flags1
|
||||||
data << (uint32)ci->type;
|
data << (uint32)ci->type;
|
||||||
data << (uint32)ci->family; // family wdbFeild9
|
data << (uint32)ci->family; // family wdbFeild9
|
||||||
data << (uint32)ci->rank; // rank wdbFeild10
|
data << (uint32)ci->rank; // rank wdbFeild10
|
||||||
|
|
|
||||||
|
|
@ -1531,6 +1531,13 @@ enum CreatureFamily
|
||||||
CREATURE_FAMILY_SEA_LION = 36
|
CREATURE_FAMILY_SEA_LION = 36
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CreatureTypeFlags
|
||||||
|
{
|
||||||
|
CREATURE_TYPEFLAGS_TAMEBLE = 0x0001,
|
||||||
|
CREATURE_TYPEFLAGS_HERBLOOT = 0x0100,
|
||||||
|
CREATURE_TYPEFLAGS_MININGLOOT = 0x0200,
|
||||||
|
};
|
||||||
|
|
||||||
enum CreatureEliteType
|
enum CreatureEliteType
|
||||||
{
|
{
|
||||||
CREATURE_ELITE_NORMAL = 0,
|
CREATURE_ELITE_NORMAL = 0,
|
||||||
|
|
|
||||||
|
|
@ -3517,12 +3517,8 @@ uint8 Spell::CanCast(bool strict)
|
||||||
if (m_targets.getUnitTarget()->getLevel() > m_caster->getLevel())
|
if (m_targets.getUnitTarget()->getLevel() > m_caster->getLevel())
|
||||||
return SPELL_FAILED_HIGHLEVEL;
|
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?
|
// use SMSG_PET_TAME_FAILURE?
|
||||||
if( !(cinfo->flag1 & 1) || !(cinfo->family) )
|
if (!((Creature*)m_targets.getUnitTarget())->GetCreatureInfo()->isTameable ())
|
||||||
return SPELL_FAILED_BAD_TARGETS;
|
return SPELL_FAILED_BAD_TARGETS;
|
||||||
|
|
||||||
if(m_caster->GetPetGUID())
|
if(m_caster->GetPetGUID())
|
||||||
|
|
@ -3634,13 +3630,7 @@ uint8 Spell::CanCast(bool strict)
|
||||||
return SPELL_FAILED_TARGET_NOT_LOOTED;
|
return SPELL_FAILED_TARGET_NOT_LOOTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 skill;
|
uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill();
|
||||||
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
|
|
||||||
|
|
||||||
int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill);
|
int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill);
|
||||||
int32 TargetLevel = m_targets.getUnitTarget()->getLevel();
|
int32 TargetLevel = m_targets.getUnitTarget()->getLevel();
|
||||||
|
|
|
||||||
|
|
@ -3884,56 +3884,36 @@ void Spell::EffectTameCreature(uint32 /*i*/)
|
||||||
if(creatureTarget->isPet())
|
if(creatureTarget->isPet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_caster->getClass() == CLASS_HUNTER)
|
if(m_caster->getClass() != CLASS_HUNTER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// cast finish successfully
|
||||||
|
//SendChannelUpdate(0);
|
||||||
|
finish();
|
||||||
|
|
||||||
|
Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget,m_spellInfo->Id);
|
||||||
|
|
||||||
|
// kill original creature
|
||||||
|
creatureTarget->setDeathState(JUST_DIED);
|
||||||
|
creatureTarget->RemoveCorpse();
|
||||||
|
creatureTarget->SetHealth(0); // just for nice GM-mode view
|
||||||
|
|
||||||
|
// prepare visual effect for levelup
|
||||||
|
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1);
|
||||||
|
|
||||||
|
// add to world
|
||||||
|
MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);
|
||||||
|
|
||||||
|
// visual effect for levelup
|
||||||
|
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel());
|
||||||
|
|
||||||
|
// caster have pet now
|
||||||
|
m_caster->SetPet(pet);
|
||||||
|
|
||||||
|
if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
// cast finish successfully
|
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||||
//SendChannelUpdate(0);
|
((Player*)m_caster)->PetSpellInitialize();
|
||||||
finish();
|
|
||||||
|
|
||||||
Pet* pet = new Pet(HUNTER_PET);
|
|
||||||
|
|
||||||
if(!pet->CreateBaseAtCreature(creatureTarget))
|
|
||||||
{
|
|
||||||
delete pet;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
creatureTarget->setDeathState(JUST_DIED);
|
|
||||||
creatureTarget->RemoveCorpse();
|
|
||||||
creatureTarget->SetHealth(0); // just for nice GM-mode view
|
|
||||||
|
|
||||||
pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID());
|
|
||||||
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID());
|
|
||||||
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction());
|
|
||||||
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
|
||||||
|
|
||||||
if(!pet->InitStatsForLevel(creatureTarget->getLevel()))
|
|
||||||
{
|
|
||||||
sLog.outError("ERROR: InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
|
|
||||||
delete pet;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare visual effect for levelup
|
|
||||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1);
|
|
||||||
|
|
||||||
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
|
||||||
// this enables pet details window (Shift+P)
|
|
||||||
pet->AIM_Initialize();
|
|
||||||
pet->InitPetCreateSpells();
|
|
||||||
pet->SetHealth(pet->GetMaxHealth());
|
|
||||||
|
|
||||||
MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);
|
|
||||||
|
|
||||||
// visual effect for levelup
|
|
||||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel());
|
|
||||||
|
|
||||||
if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
|
||||||
{
|
|
||||||
m_caster->SetPet(pet);
|
|
||||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
|
||||||
((Player*)m_caster)->PetSpellInitialize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5537,13 +5517,7 @@ void Spell::EffectSkinning(uint32 /*i*/)
|
||||||
Creature* creature = (Creature*) unitTarget;
|
Creature* creature = (Creature*) unitTarget;
|
||||||
int32 targetLevel = creature->getLevel();
|
int32 targetLevel = creature->getLevel();
|
||||||
|
|
||||||
uint32 skill;
|
uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill();
|
||||||
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
|
|
||||||
|
|
||||||
((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING);
|
((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING);
|
||||||
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
|
creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
|
||||||
|
|
|
||||||
|
|
@ -10817,3 +10817,34 @@ void Unit::RemovePetAura(PetAura const* petSpell)
|
||||||
if(Pet* pet = GetPet())
|
if(Pet* pet = GetPet())
|
||||||
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
|
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
|
||||||
|
{
|
||||||
|
Pet* pet = new Pet(HUNTER_PET);
|
||||||
|
|
||||||
|
if(!pet->CreateBaseAtCreature(creatureTarget))
|
||||||
|
{
|
||||||
|
delete pet;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID());
|
||||||
|
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID());
|
||||||
|
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction());
|
||||||
|
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
|
||||||
|
|
||||||
|
if(!pet->InitStatsForLevel(creatureTarget->getLevel()))
|
||||||
|
{
|
||||||
|
sLog.outError("ERROR: Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry());
|
||||||
|
delete pet;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
||||||
|
// this enables pet details window (Shift+P)
|
||||||
|
pet->AIM_Initialize();
|
||||||
|
pet->InitPetCreateSpells();
|
||||||
|
pet->SetHealth(pet->GetMaxHealth());
|
||||||
|
|
||||||
|
return pet;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -985,6 +985,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
CharmInfo* GetCharmInfo() { return m_charmInfo; }
|
||||||
CharmInfo* InitCharmInfo(Unit* charm);
|
CharmInfo* InitCharmInfo(Unit* charm);
|
||||||
|
|
||||||
|
Pet* CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id = 0);
|
||||||
|
|
||||||
bool AddAura(Aura *aur);
|
bool AddAura(Aura *aur);
|
||||||
|
|
||||||
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
|
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue