diff --git a/sql/mangos.sql b/sql/mangos.sql index a6748640b..f01f65d50 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_8158_01_mangos_playercreateinfo_action` bit(1) default NULL + `required_8190_01_mangos_creature_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -789,8 +789,8 @@ DROP TABLE IF EXISTS `creature_template`; CREATE TABLE `creature_template` ( `entry` mediumint(8) unsigned NOT NULL default '0', `heroic_entry` mediumint(8) unsigned NOT NULL default '0', - `unk1` int(11) UNSIGNED DEFAULT '0' NOT NULL, - `unk2` int(11) UNSIGNED DEFAULT '0' NOT NULL, + `KillCredit1` int(11) unsigned NOT NULL default '0', + `KillCredit2` int(11) unsigned NOT NULL default '0', `modelid_A` mediumint(8) unsigned NOT NULL default '0', `modelid_A2` mediumint(8) unsigned NOT NULL default '0', `modelid_H` mediumint(8) unsigned NOT NULL default '0', diff --git a/sql/updates/8190_01_mangos_creature_template.sql b/sql/updates/8190_01_mangos_creature_template.sql new file mode 100644 index 000000000..efefb4d8a --- /dev/null +++ b/sql/updates/8190_01_mangos_creature_template.sql @@ -0,0 +1,5 @@ +ALTER TABLE db_version CHANGE COLUMN required_8158_01_mangos_playercreateinfo_action required_8190_01_mangos_creature_template bit; + +ALTER TABLE `creature_template` + CHANGE COLUMN `unk1` `KillCredit1` int(11) unsigned NOT NULL default '0', + CHANGE COLUMN `unk2` `KillCredit2` int(11) unsigned NOT NULL default '0'; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index d520e5679..77ad89347 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -244,6 +244,7 @@ pkgdata_DATA = \ 8115_01_mangos_playercreateinfo_action.sql \ 8140_01_mangos_spell_proc_event.sql \ 8158_01_mangos_playercreateinfo_action.sql \ + 8190_01_mangos_creature_template.sql \ README ## Additional files to include when running 'make dist' @@ -468,4 +469,5 @@ EXTRA_DIST = \ 8115_01_mangos_playercreateinfo_action.sql \ 8140_01_mangos_spell_proc_event.sql \ 8158_01_mangos_playercreateinfo_action.sql \ + 8190_01_mangos_creature_template.sql \ README diff --git a/src/game/Creature.h b/src/game/Creature.h index 416f7477a..94743f54e 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -152,13 +152,14 @@ enum CreatureFlagsExtra #pragma pack(push,1) #endif +#define MAX_KILL_CREDIT 2 + // from `creature_template` table struct CreatureInfo { uint32 Entry; uint32 HeroicEntry; - uint32 unk1; - uint32 unk2; + uint32 KillCredit[MAX_KILL_CREDIT]; uint32 DisplayID_A[2]; uint32 DisplayID_H[2]; char* Name; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index c72865ac6..ad5941e8a 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4835,8 +4835,9 @@ bool ChatHandler::HandleQuestComplete(const char* args) } else if(creature > 0) { - for(uint16 z = 0; z < creaturecount; ++z) - player->KilledMonster(creature,0); + if(CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(creature)) + for(uint16 z = 0; z < creaturecount; ++z) + player->KilledMonster(cInfo,0); } else if(creature < 0) { diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 190f2774a..ff46463ac 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -640,6 +640,18 @@ void ObjectMgr::LoadCreatureTemplates() if (!displayScaleEntry) sLog.outErrorDb("Creature (Entry: %u) not has any existed display id in DisplayID_A/DisplayID_A2/DisplayID_H/DisplayID_H2", cInfo->Entry); + for(int k = 0; k < MAX_KILL_CREDIT; ++k) + { + if(cInfo->KillCredit[k]) + { + if(!GetCreatureTemplate(cInfo->KillCredit[k])) + { + sLog.outErrorDb("Creature (Entry: %u) has not existed creature entry in `KillCredit%d` (%u)",cInfo->Entry,k+1,cInfo->KillCredit[k]); + const_cast(cInfo)->KillCredit[k] = 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); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6dc98422a..041d9def2 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13396,7 +13396,17 @@ void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) UpdateForQuestWorldObjects(); } -void Player::KilledMonster( uint32 entry, uint64 guid ) +void Player::KilledMonster( CreatureInfo const* cInfo, uint64 guid ) +{ + if(cInfo->Entry) + KilledMonsterCredit(cInfo->Entry,guid); + + for(int i = 0; i < MAX_KILL_CREDIT; ++i) + if(cInfo->KillCredit[i]) + KilledMonsterCredit(cInfo->KillCredit[i],guid); +} + +void Player::KilledMonsterCredit( uint32 entry, uint64 guid ) { uint32 addkillcount = 1; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, entry, addkillcount); @@ -18914,7 +18924,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) { // normal creature (not pet/etc) can be only in !PvP case if(pVictim->GetTypeId()==TYPEID_UNIT) - pGroupGuy->KilledMonster(pVictim->GetEntry(), pVictim->GetGUID()); + pGroupGuy->KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetGUID()); } } } @@ -18939,7 +18949,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) // normal creature (not pet/etc) can be only in !PvP case if(pVictim->GetTypeId()==TYPEID_UNIT) - KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); + KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetGUID()); } } return xp || honored_kill; @@ -18963,11 +18973,11 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar // quest objectives updated only for alive group member or dead but with not released body if(pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse()) - pGroupGuy->KilledMonster(creature_id, creature_guid); + pGroupGuy->KilledMonsterCredit(creature_id, creature_guid); } } else // if (!pGroup) - KilledMonster(creature_id, creature_guid); + KilledMonsterCredit(creature_id, creature_guid); } bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const diff --git a/src/game/Player.h b/src/game/Player.h index b27883c41..364e9ab78 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1289,7 +1289,8 @@ class MANGOS_DLL_SPEC Player : public Unit void GroupEventHappens( uint32 questId, WorldObject const* pEventObject ); void ItemAddedQuestCheck( uint32 entry, uint32 count ); void ItemRemovedQuestCheck( uint32 entry, uint32 count ); - void KilledMonster( uint32 entry, uint64 guid ); + void KilledMonster( CreatureInfo const* cInfo, uint64 guid ); + void KilledMonsterCredit( uint32 entry, uint64 guid ); void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ); void TalkedToCreature( uint32 entry, uint64 guid ); void MoneyChanged( uint32 value ); diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index fd7846bdc..69be7e1dc 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -189,8 +189,8 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) data << uint32(ci->type); // CreatureType.dbc data << uint32(ci->family); // CreatureFamily.dbc data << uint32(ci->rank); // Creature Rank (elite, boss, etc) - data << uint32(ci->unk1); // new in 3.1, creature entry? - data << uint32(ci->unk2); // new in 3.1, creature entry? + data << uint32(ci->KillCredit[0]); // new in 3.1, kill credit + data << uint32(ci->KillCredit[1]); // new in 3.1, kill credit data << uint32(ci->DisplayID_A[0]); // modelid_male1 data << uint32(ci->DisplayID_H[0]); // modelid_female1 ? data << uint32(ci->DisplayID_A[1]); // modelid_male2 ? diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index df41fbafa..1831edbae 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -450,7 +450,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // some critters required for quests if(GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); + ((Player*)this)->KilledMonster(cInfo ,pVictim->GetGUID()); return damage; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 02ffa0853..f395437a7 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8189" + #define REVISION_NR "8190" #endif // __REVISION_NR_H__