*added code for loading Spelldifficulty.dbc + Custom Spelldifficulty from Database
*added spell searcher based on creature's map difficulty, usage is optional and only for scipts for now *added new table spelldifficulty_dbc --HG-- branch : trunk
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
DROP TABLE IF EXISTS `spelldifficulty_dbc`;
|
||||||
|
CREATE TABLE `spelldifficulty_dbc` (
|
||||||
|
`id` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`spellid0` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`spellid1` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`spellid2` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`spellid3` int(11) unsigned NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
|
||||||
@@ -2211,6 +2211,18 @@ void Creature::GetRespawnCoord(float &x, float &y, float &z, float* ori, float*
|
|||||||
*dist = 0;
|
*dist = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 Creature::GetSpellIdForDifficulty(uint32 spellId)
|
||||||
|
{
|
||||||
|
//search for instance mode spell
|
||||||
|
if (GetMap() && GetMap()->IsDungeon())
|
||||||
|
{
|
||||||
|
spellId = spellmgr.GetSpellIdForDifficultyFromSpellid(spellId, Difficulty(GetMap()->GetSpawnMode()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sLog.outDebug("Unit::GetSpellIdForDifficulty called for non-instanced creature");
|
||||||
|
return spellId;
|
||||||
|
}
|
||||||
|
|
||||||
void Creature::AllLootRemovedFromCorpse()
|
void Creature::AllLootRemovedFromCorpse()
|
||||||
{
|
{
|
||||||
if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE))
|
if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE))
|
||||||
|
|||||||
@@ -418,6 +418,7 @@ class Creature : public Unit, public GridObject<Creature>
|
|||||||
void Update(uint32 time); // overwrited Unit::Update
|
void Update(uint32 time); // overwrited Unit::Update
|
||||||
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
|
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
|
||||||
uint32 GetEquipmentId() const { return GetCreatureInfo()->equipmentId; }
|
uint32 GetEquipmentId() const { return GetCreatureInfo()->equipmentId; }
|
||||||
|
uint32 GetSpellIdForDifficulty(uint32 spellId);
|
||||||
|
|
||||||
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
|
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
|
||||||
bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
|
bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "Platform/Define.h"
|
#include "Platform/Define.h"
|
||||||
#include "TemporarySummon.h"
|
#include "TemporarySummon.h"
|
||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
|
#include "SpellMgr.h"
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
@@ -592,11 +593,15 @@ inline bool CreatureAI::_EnterEvadeMode()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
|
inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered, bool useMode)
|
||||||
{
|
{
|
||||||
if (!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered))
|
if (!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//search for instance mode spell
|
||||||
|
if(useMode && me->ToCreature())
|
||||||
|
spellId = me->ToCreature()->GetSpellIdForDifficulty(spellId);
|
||||||
|
|
||||||
me->CastSpell(victim, spellId, triggered);
|
me->CastSpell(victim, spellId, triggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ SpellCategoryStore sSpellCategoryStore;
|
|||||||
PetFamilySpellsStore sPetFamilySpellsStore;
|
PetFamilySpellsStore sPetFamilySpellsStore;
|
||||||
|
|
||||||
DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore(SpellCastTimefmt);
|
DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore(SpellCastTimefmt);
|
||||||
|
DBCStorage <SpellDifficultyEntry> sSpellDifficultyStore(SpellDifficultyfmt);
|
||||||
DBCStorage <SpellDurationEntry> sSpellDurationStore(SpellDurationfmt);
|
DBCStorage <SpellDurationEntry> sSpellDurationStore(SpellDurationfmt);
|
||||||
DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore(SpellFocusObjectfmt);
|
DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore(SpellFocusObjectfmt);
|
||||||
DBCStorage <SpellRadiusEntry> sSpellRadiusStore(SpellRadiusfmt);
|
DBCStorage <SpellRadiusEntry> sSpellRadiusStore(SpellRadiusfmt);
|
||||||
@@ -384,6 +385,7 @@ void LoadDBCStores(const std::string& dataPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellCastTimesStore, dbcPath,"SpellCastTimes.dbc");
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellCastTimesStore, dbcPath,"SpellCastTimes.dbc");
|
||||||
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDifficultyStore, dbcPath,"SpellDifficulty.dbc", &CustomSpellDifficultyfmt, &CustomSpellDifficultyIndex);
|
||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc");
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc");
|
||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc");
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc");
|
||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc");
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc");
|
||||||
@@ -396,6 +398,24 @@ void LoadDBCStores(const std::string& dataPath)
|
|||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore, dbcPath,"SummonProperties.dbc");
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore, dbcPath,"SummonProperties.dbc");
|
||||||
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentStore, dbcPath,"Talent.dbc");
|
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentStore, dbcPath,"Talent.dbc");
|
||||||
|
|
||||||
|
// Create Spelldifficulty searcher
|
||||||
|
for (uint32 i = 0; i < sSpellDifficultyStore.GetNumRows(); ++i)
|
||||||
|
{
|
||||||
|
SpellDifficultyEntry const *spellDiff = sSpellDifficultyStore.LookupEntry(i);
|
||||||
|
if (!spellDiff)
|
||||||
|
continue;
|
||||||
|
for(int x = 0; x < MAX_DIFFICULTY; ++x)
|
||||||
|
{
|
||||||
|
if(spellDiff->SpellID[x] <= 0 || !sSpellStore.LookupEntry(spellDiff->SpellID[x]))
|
||||||
|
{
|
||||||
|
if(spellDiff->SpellID[x] > 0)//don't drop error if spell is <= 0, not all modes have spells and there are unknown negative values
|
||||||
|
sLog.outDebug("spelldifficulty_dbc: spell %i at field id:%u at spellid%i does not exist in SpellStore (spell.dbc), skipped loading", spellDiff->SpellID[x], spellDiff->ID, x);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
spellmgr.SetSpellDifficultyId(uint32(spellDiff->SpellID[x]), spellDiff->ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create talent spells set
|
// create talent spells set
|
||||||
for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i)
|
for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ extern DBCStorage <SkillLineEntry> sSkillLineStore;
|
|||||||
extern DBCStorage <SkillLineAbilityEntry> sSkillLineAbilityStore;
|
extern DBCStorage <SkillLineAbilityEntry> sSkillLineAbilityStore;
|
||||||
extern DBCStorage <SoundEntriesEntry> sSoundEntriesStore;
|
extern DBCStorage <SoundEntriesEntry> sSoundEntriesStore;
|
||||||
extern DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore;
|
extern DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore;
|
||||||
|
extern DBCStorage <SpellDifficultyEntry> sSpellDifficultyStore;
|
||||||
extern DBCStorage <SpellDurationEntry> sSpellDurationStore;
|
extern DBCStorage <SpellDurationEntry> sSpellDurationStore;
|
||||||
extern DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore;
|
extern DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore;
|
||||||
extern DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore;
|
extern DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore;
|
||||||
|
|||||||
@@ -1545,6 +1545,12 @@ struct SpellCastTimesEntry
|
|||||||
//int32 MinCastTime; // 3 unsure
|
//int32 MinCastTime; // 3 unsure
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SpellDifficultyEntry
|
||||||
|
{
|
||||||
|
uint32 ID; // 0
|
||||||
|
int32 SpellID[MAX_DIFFICULTY]; // 1-4 instance modes: 10N,25N,10H,25H or Normal/Heroic if only 1-2 is set, if 3-4 is 0 then Mode-2
|
||||||
|
};
|
||||||
|
|
||||||
struct SpellFocusObjectEntry
|
struct SpellFocusObjectEntry
|
||||||
{
|
{
|
||||||
uint32 ID; // 0
|
uint32 ID; // 0
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxx
|
|||||||
const char SkillLineAbilityfmt[]="niiiixxiiiiixx";
|
const char SkillLineAbilityfmt[]="niiiixxiiiiixx";
|
||||||
const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||||
const char SpellCastTimefmt[]="nixx";
|
const char SpellCastTimefmt[]="nixx";
|
||||||
|
const char SpellDifficultyfmt[]="niiii";
|
||||||
|
const std::string CustomSpellDifficultyfmt="ppppp";
|
||||||
|
const std::string CustomSpellDifficultyIndex="id";
|
||||||
const char SpellDurationfmt[]="niii";
|
const char SpellDurationfmt[]="niii";
|
||||||
const char SpellEntryfmt[]="niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx";
|
const char SpellEntryfmt[]="niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx";
|
||||||
const std::string CustomSpellEntryfmt="pappppppppaaaaaapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppppppppaaaaaapppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa";
|
const std::string CustomSpellEntryfmt="pappppppppaaaaaapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppppppppaaaaaapppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa";
|
||||||
|
|||||||
@@ -813,6 +813,8 @@ typedef std::pair<SkillLineAbilityMap::const_iterator,SkillLineAbilityMap::const
|
|||||||
typedef std::multimap<uint32, uint32> PetLevelupSpellSet;
|
typedef std::multimap<uint32, uint32> PetLevelupSpellSet;
|
||||||
typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
|
typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
|
||||||
|
|
||||||
|
typedef std::map<uint32, uint32> SpellDifficultySearcherMap;
|
||||||
|
|
||||||
struct PetDefaultSpellsEntry
|
struct PetDefaultSpellsEntry
|
||||||
{
|
{
|
||||||
uint32 spellid[MAX_CREATURE_SPELL_DATA_SLOT];
|
uint32 spellid[MAX_CREATURE_SPELL_DATA_SLOT];
|
||||||
@@ -1013,6 +1015,46 @@ class SpellMgr
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spell Difficulty data
|
||||||
|
uint32 GetSpellIdForDifficultyFromSpellid(uint32 spellId, Difficulty mapDiff)
|
||||||
|
{
|
||||||
|
/*SpellEntry const* spell = sSpellStore.LookupEntry(spellId);
|
||||||
|
if (!spell)
|
||||||
|
return spellId;//CastSpell() will handle incorrect spells
|
||||||
|
*/
|
||||||
|
uint32 mode = uint32(mapDiff);
|
||||||
|
if(mode >= MAX_DIFFICULTY)
|
||||||
|
{
|
||||||
|
sLog.outError("GetSpellIdForDifficultyFromSpellid: Incorrect Difficulty for spell %u.", spellId);
|
||||||
|
return spellId;//return source spell
|
||||||
|
}
|
||||||
|
uint32 SpellDiffId = GetSpellDifficultyId(spellId);
|
||||||
|
if(!SpellDiffId)
|
||||||
|
{
|
||||||
|
sLog.outDebug("GetSpellIdForDifficultyFromSpellid: Difficulty not found for spell %u.", spellId);
|
||||||
|
return spellId;//return source spell, it has only REGULAR_DIFFICULTY
|
||||||
|
}
|
||||||
|
SpellDifficultyEntry const *SpellDiff = sSpellDifficultyStore.LookupEntry(SpellDiffId);
|
||||||
|
if (!SpellDiff)
|
||||||
|
{
|
||||||
|
sLog.outDebug("GetSpellIdForDifficultyFromSpellid: SpellDifficultyEntry not found for spell %u. This Should never happen.", spellId);
|
||||||
|
return spellId;//return source spell
|
||||||
|
}
|
||||||
|
if(SpellDiff->SpellID[mode] <= 0 && mode > DUNGEON_DIFFICULTY_HEROIC)
|
||||||
|
{
|
||||||
|
uint8 baseMode = mode;
|
||||||
|
mode -= 2;
|
||||||
|
sLog.outDebug("GetSpellForDifficultyFromSpellid: spell %u mode %u spell is NULL, using mode %u", spellId, baseMode, mode);
|
||||||
|
}
|
||||||
|
if(SpellDiff->SpellID[mode] <= 0)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("GetSpellForDifficultyFromSpellid: spell %u mode %u spell is 0. Check spelldifficulty_dbc!", spellId, mode);
|
||||||
|
return spellId;
|
||||||
|
}
|
||||||
|
sLog.outDebug("GetSpellForDifficultyFromSpellid: spellid for spell %u in %u mode is %u ", spellId, mode, uint32(SpellDiff->SpellID[mode]));
|
||||||
|
return uint32(SpellDiff->SpellID[mode]);
|
||||||
|
}
|
||||||
|
|
||||||
// Spell target coordinates
|
// Spell target coordinates
|
||||||
SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const
|
SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const
|
||||||
{
|
{
|
||||||
@@ -1271,6 +1313,8 @@ class SpellMgr
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
uint32 GetSpellDifficultyId(uint32 spellId) { return mSpellDifficultySearcherMap[spellId] ? mSpellDifficultySearcherMap[spellId] : 0; }
|
||||||
|
void SetSpellDifficultyId(uint32 spellId, uint32 id) { mSpellDifficultySearcherMap[spellId] = id; }
|
||||||
|
|
||||||
const SpellsRequiringSpellMap GetSpellsRequiringSpell()
|
const SpellsRequiringSpellMap GetSpellsRequiringSpell()
|
||||||
{
|
{
|
||||||
@@ -1345,6 +1389,7 @@ class SpellMgr
|
|||||||
SpellAreaForQuestMap mSpellAreaForQuestEndMap;
|
SpellAreaForQuestMap mSpellAreaForQuestEndMap;
|
||||||
SpellAreaForAuraMap mSpellAreaForAuraMap;
|
SpellAreaForAuraMap mSpellAreaForAuraMap;
|
||||||
SpellAreaForAreaMap mSpellAreaForAreaMap;
|
SpellAreaForAreaMap mSpellAreaForAreaMap;
|
||||||
|
SpellDifficultySearcherMap mSpellDifficultySearcherMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define spellmgr SpellMgr::Instance()
|
#define spellmgr SpellMgr::Instance()
|
||||||
|
|||||||
+5
-1
@@ -193,8 +193,12 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitAI::DoCast(uint32 spellId)
|
void UnitAI::DoCast(uint32 spellId, bool useMode)
|
||||||
{
|
{
|
||||||
|
//search for instance mode spell
|
||||||
|
if(useMode && me->ToCreature())
|
||||||
|
spellId = me->ToCreature()->GetSpellIdForDifficulty(spellId);
|
||||||
|
|
||||||
Unit *target = NULL;
|
Unit *target = NULL;
|
||||||
//sLog.outError("aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target);
|
//sLog.outError("aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target);
|
||||||
switch(AISpellInfo[spellId].target)
|
switch(AISpellInfo[spellId].target)
|
||||||
|
|||||||
+2
-2
@@ -126,8 +126,8 @@ class UnitAI
|
|||||||
void AttackStartCaster(Unit *victim, float dist);
|
void AttackStartCaster(Unit *victim, float dist);
|
||||||
|
|
||||||
void DoAddAuraToAllHostilePlayers(uint32 spellid);
|
void DoAddAuraToAllHostilePlayers(uint32 spellid);
|
||||||
void DoCast(uint32 spellId);
|
void DoCast(uint32 spellId, bool useMode = false);
|
||||||
void DoCast(Unit* victim, uint32 spellId, bool triggered = false);
|
void DoCast(Unit* victim, uint32 spellId, bool triggered = false, bool useMode = false);
|
||||||
void DoCastToAllHostilePlayers(uint32 spellid, bool triggered = false);
|
void DoCastToAllHostilePlayers(uint32 spellid, bool triggered = false);
|
||||||
void DoCastVictim(uint32 spellId, bool triggered = false);
|
void DoCastVictim(uint32 spellId, bool triggered = false);
|
||||||
void DoCastAOE(uint32 spellId, bool triggered = false);
|
void DoCastAOE(uint32 spellId, bool triggered = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user