[7908] Extract class data from creature_*_addon bytes0 fields, drop its, amd add unit_class field to creature_template. Author: NoFantasy
--HG-- branch : trunk
This commit is contained in:
+3
-4
@@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
|
||||
CREATE TABLE `db_version` (
|
||||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`required_7904_01_mangos_creature_template` bit(1) default NULL
|
||||
`required_7908_03_mangos_creature_template_addon` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
@@ -563,7 +563,6 @@ DROP TABLE IF EXISTS `creature_addon`;
|
||||
CREATE TABLE `creature_addon` (
|
||||
`guid` int(11) NOT NULL default '0',
|
||||
`mount` mediumint(8) unsigned NOT NULL default '0',
|
||||
`bytes0` int(10) unsigned NOT NULL default '0',
|
||||
`bytes1` int(10) unsigned NOT NULL default '0',
|
||||
`bytes2` int(10) unsigned NOT NULL default '0',
|
||||
`emote` int(10) unsigned NOT NULL default '0',
|
||||
@@ -815,6 +814,7 @@ CREATE TABLE `creature_template` (
|
||||
`dmg_multiplier` float NOT NULL default '1',
|
||||
`baseattacktime` int(10) unsigned NOT NULL default '0',
|
||||
`rangeattacktime` int(10) unsigned NOT NULL default '0',
|
||||
`unit_class` tinyint(3) unsigned NOT NULL default '0',
|
||||
`unit_flags` int(10) unsigned NOT NULL default '0',
|
||||
`dynamicflags` int(10) unsigned NOT NULL default '0',
|
||||
`family` tinyint(4) NOT NULL default '0',
|
||||
@@ -864,7 +864,7 @@ CREATE TABLE `creature_template` (
|
||||
LOCK TABLES `creature_template` WRITE;
|
||||
/*!40000 ALTER TABLE `creature_template` DISABLE KEYS */;
|
||||
INSERT INTO `creature_template` VALUES
|
||||
(1,0,10045,0,10045,0,'Waypoint(Only GM can see it)','Visual',NULL,1,1,64,64,0,0,0,35,35,0,0.91,1,0,14,15,0,100,2000,2200,4096,0,0,0,0,0,0,1.76,2.42,100,8,5242886,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,3,1.0,1.0,0,1,0,0,0x82,'');
|
||||
(1,0,10045,0,10045,0,'Waypoint(Only GM can see it)','Visual',NULL,1,1,64,64,0,0,0,35,35,0,0.91,1,0,14,15,0,100,1,2000,2200,8,4096,0,0,0,0,0,0,1.76,2.42,100,8,5242886,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,3,1.0,1.0,0,1,0,0,0x82,'');
|
||||
/*!40000 ALTER TABLE `creature_template` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -876,7 +876,6 @@ DROP TABLE IF EXISTS `creature_template_addon`;
|
||||
CREATE TABLE `creature_template_addon` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`mount` mediumint(8) unsigned NOT NULL default '0',
|
||||
`bytes0` int(10) unsigned NOT NULL default '0',
|
||||
`bytes1` int(10) unsigned NOT NULL default '0',
|
||||
`bytes2` int(10) unsigned NOT NULL default '0',
|
||||
`emote` mediumint(8) unsigned NOT NULL default '0',
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
ALTER TABLE creature_template ADD COLUMN unit_class tinyint(3) unsigned NOT NULL default '0' AFTER rangeattacktime;
|
||||
|
||||
UPDATE creature_template ct
|
||||
JOIN creature c ON ct.entry=c.id
|
||||
JOIN creature_addon ad ON c.guid=ad.guid
|
||||
SET ct.unit_class=(ad.bytes0 & 0x0000FF00) >> 8
|
||||
WHERE ct.entry=c.id AND ct.unit_class=0;
|
||||
|
||||
UPDATE creature_template ct
|
||||
JOIN creature_template_addon ad ON ct.entry=ad.entry
|
||||
SET ct.unit_class=(ad.bytes0 & 0x0000FF00) >> 8
|
||||
WHERE ct.entry=ad.entry AND ct.unit_class=0;
|
||||
|
||||
UPDATE creature_template a1, creature_template a2 SET a1.unit_class=a2.unit_class WHERE a1.unit_class=0 AND a2.unit_class!=0 AND a1.entry=a2.heroic_entry;
|
||||
UPDATE creature_template a1, creature_template a2 SET a1.unit_class=a2.unit_class WHERE a1.unit_class=0 AND a2.unit_class!=0 AND a2.entry=a1.heroic_entry;
|
||||
|
||||
ALTER TABLE creature_addon
|
||||
DROP COLUMN bytes0;
|
||||
|
||||
ALTER TABLE creature_template_addon
|
||||
DROP COLUMN bytes0;
|
||||
|
||||
|
||||
@@ -277,6 +277,12 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
||||
SetEntry(Entry); // normal entry always
|
||||
m_creatureInfo = cinfo; // map mode related always
|
||||
|
||||
// equal to player Race field, but creature does not have race
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 0, 0);
|
||||
|
||||
// known valid are: CLASS_WARRIOR,CLASS_PALADIN,CLASS_ROGUE,CLASS_MAGE
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
|
||||
|
||||
// Cancel load if no model defined
|
||||
if (!(cinfo->GetFirstValidModelId()))
|
||||
{
|
||||
@@ -1347,6 +1353,8 @@ void Creature::SelectLevel(const CreatureInfo *cinfo)
|
||||
SetMaxPower(POWER_MANA, mana); //MAX Mana
|
||||
SetPower(POWER_MANA, mana);
|
||||
|
||||
// TODO: set UNIT_FIELD_POWER*, for some creature class case (energy, etc)
|
||||
|
||||
SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, health);
|
||||
SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, mana);
|
||||
|
||||
@@ -2120,9 +2128,6 @@ bool Creature::LoadCreaturesAddon(bool reload)
|
||||
if (cainfo->mount != 0)
|
||||
Mount(cainfo->mount);
|
||||
|
||||
if (cainfo->bytes0 != 0)
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
|
||||
|
||||
if (cainfo->bytes1 != 0)
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_1, cainfo->bytes1);
|
||||
|
||||
|
||||
+1
-1
@@ -203,6 +203,7 @@ struct CreatureInfo
|
||||
float dmg_multiplier;
|
||||
uint32 baseattacktime;
|
||||
uint32 rangeattacktime;
|
||||
uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
|
||||
uint32 unit_flags; // enum UnitFlags mask values
|
||||
uint32 dynamicflags;
|
||||
uint32 family; // enum CreatureFamily values (optional)
|
||||
@@ -318,7 +319,6 @@ struct CreatureDataAddon
|
||||
{
|
||||
uint32 guidOrEntry;
|
||||
uint32 mount;
|
||||
uint32 bytes0;
|
||||
uint32 bytes1;
|
||||
uint32 bytes2;
|
||||
uint32 emote;
|
||||
|
||||
@@ -553,6 +553,12 @@ void ObjectMgr::LoadCreatureTemplates()
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cInfo->unit_class != heroicInfo->unit_class)
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in heroic mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->HeroicEntry, heroicInfo->unit_class);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cInfo->npcflag != heroicInfo->npcflag)
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `npcflag` in heroic mode.",i);
|
||||
@@ -629,6 +635,9 @@ void ObjectMgr::LoadCreatureTemplates()
|
||||
const_cast<CreatureInfo*>(cInfo)->Modelid_H2 = 0;
|
||||
}
|
||||
|
||||
if (cInfo->unit_class && ((1 << (cInfo->unit_class-1)) & CLASSMASK_ALL_CREATURES) == 0)
|
||||
sLog.outErrorDb("Creature (Entry: %u) has invalid unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class);
|
||||
|
||||
if(cInfo->dmgschool >= MAX_SPELL_SCHOOL)
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool);
|
||||
|
||||
@@ -91,6 +91,8 @@ enum Classes
|
||||
(1<<(CLASS_MAGE-1)) |(1<<(CLASS_WARLOCK-1))|(1<<(CLASS_DRUID-1)) | \
|
||||
(1<<(CLASS_DEATH_KNIGHT-1)) )
|
||||
|
||||
#define CLASSMASK_ALL_CREATURES ((1<<(CLASS_WARRIOR-1)) | (1<<(CLASS_PALADIN-1)) | (1<<(CLASS_ROGUE-1)) | (1<<(CLASS_MAGE-1)) )
|
||||
|
||||
#define CLASSMASK_WAND_USERS ((1<<(CLASS_PRIEST-1))|(1<<(CLASS_MAGE-1))|(1<<(CLASS_WARLOCK-1)))
|
||||
|
||||
#define PLAYER_MAX_BATTLEGROUND_QUEUES 3
|
||||
|
||||
@@ -3683,8 +3683,9 @@ void AuraEffect::HandleAuraModPetTalentsPoints(bool Apply, bool Real, bool chang
|
||||
CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
|
||||
if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
//does not appear to have relevance. Why code added initially? See note below at !apply
|
||||
//to prevent client crash
|
||||
m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
//m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
//just to enable stat window
|
||||
charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
||||
//if charmed two demons the same session, the 2nd gets the 1st one's name
|
||||
@@ -3722,7 +3723,9 @@ void AuraEffect::HandleAuraModPetTalentsPoints(bool Apply, bool Real, bool chang
|
||||
// restore UNIT_FIELD_BYTES_0
|
||||
if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
|
||||
//does not appear to have relevance. Why code added initially? Class, gender, powertype should be same.
|
||||
//db field removed and replaced with better way to set class, restore using this if problems
|
||||
/*CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
|
||||
if(cainfo && cainfo->bytes0 != 0)
|
||||
m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
|
||||
else
|
||||
|
||||
+1
-7
@@ -13556,7 +13556,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
//to prevent client crash
|
||||
SetFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
//SetFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
|
||||
//just to enable stat window
|
||||
if(GetCharmInfo())
|
||||
@@ -13637,12 +13637,6 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
|
||||
CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo();
|
||||
if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
CreatureDataAddon const *cainfo = ((Creature*)this)->GetCreatureAddon();
|
||||
if(cainfo && cainfo->bytes0 != 0)
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
|
||||
else
|
||||
RemoveFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
|
||||
if(GetCharmInfo())
|
||||
GetCharmInfo()->SetPetNumber(0, true);
|
||||
else
|
||||
|
||||
@@ -27,11 +27,11 @@ extern DatabasePostgre WorldDatabase;
|
||||
extern DatabaseMysql WorldDatabase;
|
||||
#endif
|
||||
|
||||
const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifflliiis";
|
||||
const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifflliiii";
|
||||
const char CreatureDataAddonInfofmt[]="iiiiiiis";
|
||||
const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifflliiis";
|
||||
const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifflliiii";
|
||||
const char CreatureDataAddonInfofmt[]="iiiiiis";
|
||||
const char CreatureModelfmt[]="iffbi";
|
||||
const char CreatureInfoAddonInfofmt[]="iiiiiiis";
|
||||
const char CreatureInfoAddonInfofmt[]="iiiiiis";
|
||||
const char EquipmentInfofmt[]="iiii";
|
||||
const char GameObjectInfosrcfmt[]="iiisssiifiiiiiiiiiiiiiiiiiiiiiiiis";
|
||||
const char GameObjectInfodstfmt[]="iiisssiifiiiiiiiiiiiiiiiiiiiiiiiii";
|
||||
|
||||
Reference in New Issue
Block a user