[8775] implement all creature difficulties + support bgs with this

former know as heroic_entry we now have 3 of those
which let us chose different creature_templates for different
map-types

normal maps will need a bit more support to use correct
spawnmodes

but for battlegrounds it works already good:
they are divided by levelrange:
    0-59  == normal spawn -> spiritguides level 60
    60-69 == difficulty=1 -> spritiguides level 70
    70-79 == difficulty=2 -> spiritguides level 80
    80    == difficulty=3 -> spiritguides level 80

this is needed mostly for alterac valley to get
right creature-templates spawned
and with that all creature->SetLevel hacks could
get removed from alterac valley code
This commit is contained in:
balrok 2009-11-05 10:22:10 +01:00
parent adde82b73c
commit c50df41b3c
18 changed files with 121 additions and 82 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_8770_01_mangos_quest_template` bit(1) default NULL
`required_8775_03_mangos_gameobject` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -1062,6 +1062,8 @@ DROP TABLE IF EXISTS `creature_template`;
CREATE TABLE `creature_template` (
`entry` mediumint(8) unsigned NOT NULL default '0',
`difficulty_entry_1` mediumint(8) unsigned NOT NULL default '0',
`difficulty_entry_2` mediumint(8) unsigned NOT NULL default '0',
`difficulty_entry_3` mediumint(8) unsigned NOT NULL default '0',
`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',

View file

@ -0,0 +1,6 @@
ALTER TABLE db_version CHANGE COLUMN required_8770_01_mangos_quest_template required_8775_01_mangos_creature_template bit;
ALTER TABLE `creature_template` ADD `difficulty_entry_2` MEDIUMINT(8) unsigned
NOT NULL default 0 AFTER `difficulty_entry_1`;
ALTER TABLE `creature_template` ADD `difficulty_entry_3` MEDIUMINT(8) unsigned
NOT NULL default 0 AFTER `difficulty_entry_2`;

View file

@ -0,0 +1,10 @@
ALTER TABLE db_version CHANGE COLUMN required_8775_01_mangos_creature_template required_8775_02_mangos_creature bit;
-- cause bgs now have different spawnmodes all creatures on those maps must go
-- to all spwanmodes.. maybe this isn't valid for all creatures - but i won't
-- destroy again all bgs :p
-- 0x1 = 2^0 - normal
-- 0x2 = 2^1 - difficulty_1
-- 0x4 = 2^2 - difficulty_2
-- 0x8 = 2^3 - difficulty_3
UPDATE creature SET spawnMask = (0x1 | 0x2 | 0x4 | 0x8) WHERE map IN (30, 489, 529, 566);

View file

@ -0,0 +1,6 @@
ALTER TABLE db_version CHANGE COLUMN required_8775_02_mangos_creature required_8775_03_mangos_gameobject bit;
-- cause bgs now have different spawnmodes all gameobjects on those maps must go
-- to all spwanmodes.. maybe this isn't valid for all gameobjects - but i won't
-- destroy again all bgs :p
UPDATE gameobject SET spawnMask = (0x1 | 0x2 | 0x4 | 0x8) WHERE map IN (30, 489, 529, 566);

View file

@ -148,6 +148,9 @@ pkgdata_DATA = \
8749_01_mangos_mail_loot_template.sql \
8769_01_mangos_mail_level_reward.sql \
8770_01_mangos_quest_template.sql \
8775_01_mangos_creature_template.sql \
8775_02_mangos_creature.sql \
8775_03_mangos_gameobject.sql \
README
## Additional files to include when running 'make dist'
@ -276,4 +279,7 @@ EXTRA_DIST = \
8749_01_mangos_mail_loot_template.sql \
8769_01_mangos_mail_level_reward.sql \
8770_01_mangos_quest_template.sql \
8775_01_mangos_creature_template.sql \
8775_02_mangos_creature.sql \
8775_03_mangos_gameobject.sql \
README

View file

@ -492,11 +492,10 @@ class BattleGround
// can be extended in in BG subclass
/* event related */
// generic implementation in BattleGround-class
// called when a creature gets added to map (NOTE: only triggered if
// a player activates the cell of the creature)
virtual void OnObjectDBLoad(Creature* /*creature*/);
virtual void OnObjectDBLoad(GameObject* /*obj*/);
void OnObjectDBLoad(Creature* /*creature*/);
void OnObjectDBLoad(GameObject* /*obj*/);
// (de-)spawns creatures and gameobjects from an event
void SpawnEvent(uint8 event1, uint8 event2, bool spawn);
bool IsActiveEvent(uint8 event1, uint8 event2)
@ -510,9 +509,6 @@ class BattleGround
void OpenDoorEvent(uint8 event1, uint8 event2 = 0);
bool IsDoor(uint8 event1, uint8 event2);
/* other things */
virtual void OnCreatureRespawn(Creature* /*creature*/) {}
void HandleTriggerBuff(uint64 const& go_guid);
// TODO: make this protected:

View file

@ -232,23 +232,6 @@ void BattleGroundAV::UpdateScore(BattleGroundTeamId team, int32 points )
UpdateWorldState(((team == BG_TEAM_HORDE) ? BG_AV_Horde_Score : BG_AV_Alliance_Score), m_TeamScores[team]);
}
void BattleGroundAV::OnObjectDBLoad(Creature* creature)
{
uint32 level = creature->getLevel();
if (level != 0)
level += GetMaxLevel() - 60; // maybe we can do this more generic for custom level - range.. actually it's ok
creature->SetLevel(level);
BattleGround::OnObjectDBLoad(creature);
}
void BattleGroundAV::OnCreatureRespawn(Creature* creature)
{
uint32 level = creature->getLevel();
if (level != 0)
level += GetMaxLevel() - 60; // maybe we can do this more generic for custom level - range.. actually it's ok
creature->SetLevel(level);
}
void BattleGroundAV::Update(uint32 diff)
{
BattleGround::Update(diff);

View file

@ -308,8 +308,6 @@ class BattleGroundAV : public BattleGround
/* inherited from BattlegroundClass */
virtual void AddPlayer(Player *plr);
virtual void OnObjectDBLoad(Creature* creature);
virtual void OnCreatureRespawn(Creature* creature);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();

View file

@ -191,17 +191,21 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
// get difficulty 1 mode entry
uint32 actualEntry = Entry;
CreatureInfo const *cinfo = normalInfo;
if(normalInfo->DifficultyEntry1)
// TODO correctly implement spawnmodes for non-bg maps
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff)
{
//we already have valid Map pointer for current creature!
//FIXME: spawn modes 2-3 must have own case DifficultyEntryN
if(GetMap()->GetSpawnMode() > 0)
if (normalInfo->DifficultyEntry[diff])
{
cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry1);
if(!cinfo)
// we already have valid Map pointer for current creature!
if (GetMap()->GetSpawnMode() > diff)
{
sLog.outErrorDb("Creature::UpdateEntry creature difficulty 1 entry %u does not exist.", actualEntry);
return false;
cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry[diff]);
if (!cinfo)
{
// maybe check such things already at startup
sLog.outErrorDb("Creature::UpdateEntry creature difficulty %u entry %u does not exist.", diff + 1, actualEntry);
return false;
}
}
}
}
@ -362,9 +366,6 @@ void Creature::Update(uint32 diff)
else
setDeathState( JUST_ALIVED );
if (GetMap()->IsBattleGround() && ((BattleGroundMap*)GetMap())->GetBG())
((BattleGroundMap*)GetMap())->GetBG()->OnCreatureRespawn(this); // for alterac valley needed to adjust the correct level again
//Call AI respawn virtual function
i_AI->JustRespawned();

View file

@ -158,7 +158,7 @@ enum CreatureFlagsExtra
struct CreatureInfo
{
uint32 Entry;
uint32 DifficultyEntry1;
uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
uint32 KillCredit[MAX_KILL_CREDIT];
uint32 DisplayID_A[2];
uint32 DisplayID_H[2];

View file

@ -2628,8 +2628,8 @@ uint32 InstanceMap::GetMaxPlayers() const
/* ******* Battleground Instance Maps ******* */
BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent)
: Map(id, expiry, InstanceId, DUNGEON_DIFFICULTY_NORMAL, _parent)
BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode)
: Map(id, expiry, InstanceId, spawnMode, _parent)
{
//lets initialize visibility distance for BG/Arenas
BattleGroundMap::InitVisibilityDistance();

View file

@ -612,7 +612,7 @@ class MANGOS_DLL_SPEC InstanceMap : public Map
class MANGOS_DLL_SPEC BattleGroundMap : public Map
{
public:
BattleGroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent);
BattleGroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode);
~BattleGroundMap();
bool Add(Player *);

View file

@ -24,7 +24,7 @@
#include "InstanceSaveMgr.h"
#include "World.h"
MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0)
MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, DUNGEON_DIFFICULTY_NORMAL)
{
// initialize instanced maps list
m_InstancedMaps.clear();
@ -216,7 +216,9 @@ BattleGroundMap* MapInstanced::CreateBattleGroundMap(uint32 InstanceId, BattleGr
sLog.outDebug("MapInstanced::CreateBattleGroundMap: instance:%d for map:%d and bgType:%d created.", InstanceId, GetId(), bg->GetTypeID());
BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId, this);
// 0-59 normal spawn 60-69 difficulty_1, 70-79 difficulty_2, 80 dufficulty_3
uint8 spawnMode = (bg->GetQueueId() > QUEUE_ID_MAX_LEVEL_59) ? (bg->GetQueueId() - QUEUE_ID_MAX_LEVEL_59) : 0;
BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId, this, spawnMode);
ASSERT(map->IsBattleGroundOrArena());
map->SetBG(bg);
bg->SetBgMap(map);

View file

@ -118,7 +118,7 @@ MapManager::_createBaseMap(uint32 id)
}
else
{
m = new Map(id, i_gridCleanUpDelay, 0, 0);
m = new Map(id, i_gridCleanUpDelay, 0, DUNGEON_DIFFICULTY_NORMAL);
}
i_maps[id] = m;
}

View file

@ -473,8 +473,8 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount );
sLog.outString();
std::set<uint32> difficultyEntries1; // already loaded difficulty 1 value in creatures
std::set<uint32> hasDifficultyEntries1; // already loaded creatures with difficulty 1 values
std::set<uint32> difficultyEntries[MAX_DIFFICULTY - 1]; // already loaded difficulty 1 value in creatures
std::set<uint32> hasDifficultyEntries[MAX_DIFFICULTY - 1]; // already loaded creatures with difficulty 1 values
// check data correctness
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
@ -483,84 +483,105 @@ void ObjectMgr::LoadCreatureTemplates()
if (!cInfo)
continue;
if (cInfo->DifficultyEntry1)
bool ok = true; // bool to allow continue outside this loop
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
{
CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry1);
if (!cInfo->DifficultyEntry[diff])
continue;
ok = false; // will be set to true at the end of this loop again
CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
if (!difficultyInfo)
{
sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_1`=%u but creature entry %u not exist.", i, cInfo->DifficultyEntry1, cInfo->DifficultyEntry1);
sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u not exist.",
i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]);
continue;
}
if (difficultyEntries1.find(i)!=difficultyEntries1.end())
if (difficultyEntries[diff].find(i) != difficultyEntries[diff].end())
{
sLog.outErrorDb("Creature (Entry: %u) listed as difficulty 1 but have value in `difficulty_entry_1`.",i);
sLog.outErrorDb("Creature (Entry: %u) listed as difficulty %u but have value in `difficulty_entry_1`.", i, diff + 1);
continue;
}
if (difficultyEntries1.find(cInfo->DifficultyEntry1)!=difficultyEntries1.end())
bool ok2 = true;
for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2)
{
sLog.outErrorDb("Creature (Entry: %u) already listed as difficulty 1 for another entry.",cInfo->DifficultyEntry1);
continue;
}
ok2 = false;
if (difficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != difficultyEntries[diff2].end())
{
sLog.outErrorDb("Creature (Entry: %u) already listed as difficulty %u for another entry.", cInfo->DifficultyEntry[diff], diff2 + 1);
continue;
}
if (hasDifficultyEntries1.find(cInfo->DifficultyEntry1)!=hasDifficultyEntries1.end())
{
sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_1`=%u but creature entry %u have difficulty 1 entry also.",i,cInfo->DifficultyEntry1,cInfo->DifficultyEntry1);
continue;
if (hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != hasDifficultyEntries[diff2].end())
{
sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u have difficulty %u entry also.",
i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1);
continue;
}
ok2 = true;
}
if (!ok2)
continue;
if (cInfo->unit_class != difficultyInfo->unit_class)
{
sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty 1 mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->DifficultyEntry1, difficultyInfo->unit_class);
sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty %u mode (Entry: %u, class %u).",
i, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class);
continue;
}
if (cInfo->npcflag != difficultyInfo->npcflag)
{
sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1);
sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
if (cInfo->trainer_class != difficultyInfo->trainer_class)
{
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1);
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
if (cInfo->trainer_race != difficultyInfo->trainer_race)
{
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1);
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
if (cInfo->trainer_type != difficultyInfo->trainer_type)
{
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1);
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
if (cInfo->trainer_spell != difficultyInfo->trainer_spell)
{
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1);
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
if (difficultyInfo->AIName && *difficultyInfo->AIName)
{
sLog.outErrorDb("Difficulty 1 mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.",cInfo->DifficultyEntry1,i);
sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.",
diff, cInfo->DifficultyEntry[diff], i);
continue;
}
if (difficultyInfo->ScriptID)
{
sLog.outErrorDb("Difficulty 1 mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.",cInfo->DifficultyEntry1,i);
sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.",
diff, cInfo->DifficultyEntry[diff], i);
continue;
}
hasDifficultyEntries1.insert(i);
difficultyEntries1.insert(cInfo->DifficultyEntry1);
hasDifficultyEntries[diff].insert(i);
difficultyEntries[diff].insert(cInfo->DifficultyEntry[diff]);
ok = true;
}
if (!ok)
continue;
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A);
if (!factionTemplate)
@ -1032,11 +1053,12 @@ void ObjectMgr::LoadCreatures()
}
// build single time for check creature data
std::set<uint32> difficultyCreatures1;
for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if(cInfo->DifficultyEntry1)
difficultyCreatures1.insert(cInfo->DifficultyEntry1);
std::set<uint32> difficultyCreatures[MAX_DIFFICULTY - 1];
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff)
if (cInfo->DifficultyEntry[diff])
difficultyCreatures[diff].insert(cInfo->DifficultyEntry[diff]);
// build single time for check spawnmask
std::map<uint32,uint32> spawnMasks;
@ -1095,11 +1117,18 @@ void ObjectMgr::LoadCreatures()
if (data.spawnMask & ~spawnMasks[data.mapid])
sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid );
if(difficultyCreatures1.find(data.id)!=difficultyCreatures1.end())
bool ok = true;
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty 1 template (entry: %u) in `creature_template`, skipped.",guid, data.id );
continue;
if (difficultyCreatures[diff].find(data.id) != difficultyCreatures[diff].end())
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.",
guid, diff + 1, data.id );
ok = false;
}
}
if (!ok)
continue;
if(data.equipmentId > 0) // -1 no equipment, 0 use default
{
@ -3191,7 +3220,7 @@ void ObjectMgr::LoadGroups()
uint32 diff = fields[4].GetUInt8();
if(diff >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))
{
sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff);
sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff + 1);
diff = 0; // default for both difficaly types
}

View file

@ -25,8 +25,8 @@ extern DatabasePostgre WorldDatabase;
extern DatabaseMysql WorldDatabase;
#endif
const char CreatureInfosrcfmt[]="iiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiis";
const char CreatureInfodstfmt[]="iiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiii";
const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiis";
const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiii";
const char CreatureDataAddonInfofmt[]="iiiiiis";
const char CreatureModelfmt[]="iffbi";
const char CreatureInfoAddonInfofmt[]="iiiiiis";

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8774"
#define REVISION_NR "8775"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_8721_01_characters_guild"
#define REVISION_DB_MANGOS "required_8770_01_mangos_quest_template"
#define REVISION_DB_MANGOS "required_8775_03_mangos_gameobject"
#define REVISION_DB_REALMD "required_8728_01_realmd_account"
#endif // __REVISION_SQL_H__