[9789] Implement spell selection, for creatures in instances, based on map difficulty

This commit is contained in:
Laise 2010-04-24 20:07:28 +03:00
parent 6ad2d18f1a
commit 51546e1ff9
10 changed files with 45 additions and 10 deletions

View file

@ -126,6 +126,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);
@ -323,7 +324,7 @@ void LoadDBCStores(const std::string& dataPath)
exit(1); exit(1);
} }
const uint32 DBCFilesCount = 84; const uint32 DBCFilesCount = 85;
barGoLink bar( (int)DBCFilesCount ); barGoLink bar( (int)DBCFilesCount );
@ -478,6 +479,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,sSpellDurationStore, dbcPath,"SpellDuration.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDifficultyStore, dbcPath,"SpellDifficulty.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");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc");

View file

@ -136,6 +136,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;

View file

@ -1469,7 +1469,7 @@ struct SpellEntry
//uint32 PowerDisplayId; // 228 PowerDisplay.dbc, new in 3.1 //uint32 PowerDisplayId; // 228 PowerDisplay.dbc, new in 3.1
//float unk_320_4[3]; // 229-231 3.2.0 //float unk_320_4[3]; // 229-231 3.2.0
//uint32 spellDescriptionVariableID; // 232 3.2.0 //uint32 spellDescriptionVariableID; // 232 3.2.0
//uint32 SpellDifficultyId; // 233 3.3.0 uint32 SpellDifficultyId; // 233 m_spellDifficultyID - id from SpellDifficulty.dbc
// helpers // helpers
int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff] + int32(1); } int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff] + int32(1); }
@ -1546,6 +1546,12 @@ struct SpellShapeshiftEntry
uint32 spellId[8]; // 27-34 spells which appear in the bar after shapeshifting uint32 spellId[8]; // 27-34 spells which appear in the bar after shapeshifting
}; };
struct SpellDifficultyEntry
{
uint32 ID; // 0 m_ID
uint32 spellId[MAX_DIFFICULTY]; // 1-4 m_spellId[4]
};
struct SpellDurationEntry struct SpellDurationEntry
{ {
uint32 ID; uint32 ID;

View file

@ -87,7 +87,8 @@ const char SkillLineAbilityfmt[]="niiiixxiiiiixx";
const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char SpellCastTimefmt[]="nixx"; const char SpellCastTimefmt[]="nixx";
const char SpellDurationfmt[]="niii"; const char SpellDurationfmt[]="niii";
const char SpellEntryfmt[]="niiiiiiiiiixixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx"; const char SpellDifficultyfmt[]="niiii";
const char SpellEntryfmt[]="niiiiiiiiiixixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxi";
const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx"; const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiixxx"; const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiixxx";
const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX"; const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";

View file

@ -312,13 +312,22 @@ void SpellCastTargets::write( ByteBuffer& data ) const
data << m_strTarget; data << m_strTarget;
} }
Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID, Spell** triggeringContainer ) Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID, Spell** triggeringContainer )
{ {
ASSERT( Caster != NULL && info != NULL ); ASSERT( caster != NULL && info != NULL );
ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element");
m_spellInfo = info; if (caster->GetTypeId() != TYPEID_PLAYER && caster->IsInWorld() && caster->GetMap()->IsDungeon())
m_caster = Caster; {
if (SpellEntry const* spellEntry = GetSpellEntryByDifficulty(info->SpellDifficultyId, caster->GetMap()->GetDifficulty()))
m_spellInfo = spellEntry;
else
m_spellInfo = info;
}
else
m_spellInfo = info;
m_caster = caster;
m_selfContainer = NULL; m_selfContainer = NULL;
m_triggeringContainer = triggeringContainer; m_triggeringContainer = triggeringContainer;
m_referencedFromCurrentSpell = false; m_referencedFromCurrentSpell = false;

View file

@ -358,7 +358,7 @@ class Spell
void EffectSpecCount(SpellEffectIndex eff_idx); void EffectSpecCount(SpellEffectIndex eff_idx);
void EffectActivateSpec(SpellEffectIndex eff_idx); void EffectActivateSpec(SpellEffectIndex eff_idx);
Spell( Unit* Caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), Spell** triggeringContainer = NULL ); Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), Spell** triggeringContainer = NULL );
~Spell(); ~Spell();
void prepare(SpellCastTargets const* targets, Aura* triggeredByAura = NULL); void prepare(SpellCastTargets const* targets, Aura* triggeredByAura = NULL);

View file

@ -3591,3 +3591,17 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
return true; return true;
} }
SpellEntry const* GetSpellEntryByDifficulty(uint32 id, Difficulty difficulty)
{
SpellDifficultyEntry const* spellDiff = sSpellDifficultyStore.LookupEntry(id);
if (!spellDiff)
return NULL;
if (!spellDiff->spellId[difficulty])
return NULL;
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellDiff->spellId[difficulty]);
return spellEntry;
}

View file

@ -447,6 +447,8 @@ bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group);
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group); DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group);
int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry const* spellproto); int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry const* spellproto);
SpellEntry const* GetSpellEntryByDifficulty(uint32 id, Difficulty difficulty);
// Spell proc event related declarations (accessed using SpellMgr functions) // Spell proc event related declarations (accessed using SpellMgr functions)
enum ProcFlags enum ProcFlags
{ {

View file

@ -1077,7 +1077,7 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte
CastSpell(Victim, spellInfo, triggered, castItem, triggeredByAura, originalCaster); CastSpell(Victim, spellInfo, triggered, castItem, triggeredByAura, originalCaster);
} }
void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster)
{ {
if(!spellInfo) if(!spellInfo)
{ {

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9788" #define REVISION_NR "9789"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__