diff options
| -rw-r--r-- | sql/mangos.sql | 7 | ||||
| -rw-r--r-- | sql/updates/3632_mangos_7908_world_creature_template.sql | 23 | ||||
| -rw-r--r-- | src/game/Creature.cpp | 11 | ||||
| -rw-r--r-- | src/game/Creature.h | 2 | ||||
| -rw-r--r-- | src/game/ObjectMgr.cpp | 9 | ||||
| -rw-r--r-- | src/game/SharedDefines.h | 2 | ||||
| -rw-r--r-- | src/game/SpellAuras.cpp | 7 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 8 | ||||
| -rw-r--r-- | src/shared/Database/SQLStorage.cpp | 8 |
9 files changed, 56 insertions, 21 deletions
diff --git a/sql/mangos.sql b/sql/mangos.sql index fe3869cfa46..e8455a0c4ee 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -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', diff --git a/sql/updates/3632_mangos_7908_world_creature_template.sql b/sql/updates/3632_mangos_7908_world_creature_template.sql new file mode 100644 index 00000000000..906fd008637 --- /dev/null +++ b/sql/updates/3632_mangos_7908_world_creature_template.sql @@ -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; + + diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 6eecc3213fa..840af9b4591 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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); diff --git a/src/game/Creature.h b/src/game/Creature.h index eaf76942e58..017b617cb94 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -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; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 0e684ee4213..440ee986f43 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -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); diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 8ccc820fa58..62d04b81646 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -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 diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index da2f2b8d7d8..bf760f6dea1 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -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 diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 41293837a1b..b901f76a7f3 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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 diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index 8274ccb0cd9..61ecaa7412f 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -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"; |
