diff options
| author | Rat <none@none> | 2010-04-10 10:20:01 +0200 |
|---|---|---|
| committer | Rat <none@none> | 2010-04-10 10:20:01 +0200 |
| commit | 4a8bf5900dbd3fa9b7d9d71989d46dad8112fd7f (patch) | |
| tree | 5bc2a92e77da8a3c1a8d51f35a098cadcc3a3b25 /src/game | |
| parent | 8bb3b394957f8e3edeb00f68812a997e59bd56d3 (diff) | |
*modified spelldifficulty handler to work with all spell casts for creatures that are in instances thanks to Shauren for help
*modified most of the scripts to use normal_mode spell for casting (code was autogenerated, post errors if any)
*added sql for all modded spells (autogenerated..)
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/Creature.cpp | 12 | ||||
| -rw-r--r-- | src/game/Creature.h | 1 | ||||
| -rw-r--r-- | src/game/CreatureAIImpl.h | 6 | ||||
| -rw-r--r-- | src/game/Spell.cpp | 2 | ||||
| -rw-r--r-- | src/game/SpellMgr.h | 44 | ||||
| -rw-r--r-- | src/game/UnitAI.cpp | 8 | ||||
| -rw-r--r-- | src/game/UnitAI.h | 4 |
7 files changed, 30 insertions, 47 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 4dd05fbaf87..66400709036 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -2211,18 +2211,6 @@ void Creature::GetRespawnCoord(float &x, float &y, float &z, float* ori, float* *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() { if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE)) diff --git a/src/game/Creature.h b/src/game/Creature.h index 0866877a3f5..3ffaa5e401f 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -418,7 +418,6 @@ class Creature : public Unit, public GridObject<Creature> void Update(uint32 time); // overwrited Unit::Update void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; uint32 GetEquipmentId() const { return GetCreatureInfo()->equipmentId; } - uint32 GetSpellIdForDifficulty(uint32 spellId); void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; } diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h index 2499c632ca8..d2f96ffcabc 100644 --- a/src/game/CreatureAIImpl.h +++ b/src/game/CreatureAIImpl.h @@ -593,15 +593,11 @@ inline bool CreatureAI::_EnterEvadeMode() return true; } -inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered, bool useMode) +inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered) { if (!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered)) return; - //search for instance mode spell - if(useMode && me->ToCreature()) - spellId = me->ToCreature()->GetSpellIdForDifficulty(spellId); - me->CastSpell(victim, spellId, triggered); } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 29693d969e5..9e9c3e2f16d 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -371,7 +371,7 @@ void SpellCastTargets::write (WorldPacket * data) } Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck) -: m_spellInfo(info), m_spellValue(new SpellValue(m_spellInfo)) +: m_spellInfo(spellmgr.GetSpellForDifficultyFromSpell(info, Caster)), m_spellValue(new SpellValue(m_spellInfo)) , m_caster(Caster) { m_customAttr = spellmgr.GetSpellCustomAttr(m_spellInfo->Id); diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index ab4eee6dd10..70f114057f0 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -1016,43 +1016,47 @@ class SpellMgr } // Spell Difficulty data - uint32 GetSpellIdForDifficultyFromSpellid(uint32 spellId, Difficulty mapDiff) + SpellEntry const* GetSpellForDifficultyFromSpell(SpellEntry const* spell, Unit* Caster) { - /*SpellEntry const* spell = sSpellStore.LookupEntry(spellId); - if (!spell) - return spellId;//CastSpell() will handle incorrect spells - */ - uint32 mode = uint32(mapDiff); + //spell never can be NULL in this case! + if(!Caster->ToCreature() || !Caster->ToCreature()->GetMap() || !Caster->ToCreature()->GetMap()->IsDungeon()) + return spell; + + uint32 mode = uint32(Caster->ToCreature()->GetMap()->GetSpawnMode()); if(mode >= MAX_DIFFICULTY) { - sLog.outError("GetSpellIdForDifficultyFromSpellid: Incorrect Difficulty for spell %u.", spellId); - return spellId;//return source spell + sLog.outError("GetSpellForDifficultyFromSpell: Incorrect Difficulty for spell %u.", spell->Id); + return spell;//return source spell } - uint32 SpellDiffId = GetSpellDifficultyId(spellId); + uint32 SpellDiffId = GetSpellDifficultyId(spell->Id); if(!SpellDiffId) - { - sLog.outDebug("GetSpellIdForDifficultyFromSpellid: Difficulty not found for spell %u.", spellId); - return spellId;//return source spell, it has only REGULAR_DIFFICULTY - } + return spell;//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 + sLog.outDebug("GetSpellForDifficultyFromSpell: SpellDifficultyEntry not found for spell %u. This Should never happen.", spell->Id); + return spell;//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); + sLog.outDebug("GetSpellForDifficultyFromSpell: spell %u mode %u spell is NULL, using mode %u", spell->Id, 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.outErrorDb("GetSpellForDifficultyFromSpell: spell %u mode %u spell is 0. Check spelldifficulty_dbc!", spell->Id, mode); + return spell; + } + SpellEntry const* newSpell = sSpellStore.LookupEntry(SpellDiff->SpellID[mode]); + if (!newSpell) + { + sLog.outDebug("GetSpellForDifficultyFromSpell: spell %u not found in spell, this should never happen.", newSpell->Id);//alerady checked at startup + return spell; } - sLog.outDebug("GetSpellForDifficultyFromSpellid: spellid for spell %u in %u mode is %u ", spellId, mode, uint32(SpellDiff->SpellID[mode])); - return uint32(SpellDiff->SpellID[mode]); + sLog.outDebug("GetSpellForDifficultyFromSpell: spellid for spell %u in mode %u is %u ", spell->Id, mode, newSpell->Id); + return newSpell; } // Spell target coordinates diff --git a/src/game/UnitAI.cpp b/src/game/UnitAI.cpp index 4fd4693885e..0404a284b29 100644 --- a/src/game/UnitAI.cpp +++ b/src/game/UnitAI.cpp @@ -193,12 +193,8 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) return; } -void UnitAI::DoCast(uint32 spellId, bool useMode) -{ - //search for instance mode spell - if(useMode && me->ToCreature()) - spellId = me->ToCreature()->GetSpellIdForDifficulty(spellId); - +void UnitAI::DoCast(uint32 spellId) +{ Unit *target = NULL; //sLog.outError("aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target); switch(AISpellInfo[spellId].target) diff --git a/src/game/UnitAI.h b/src/game/UnitAI.h index f0e4c996c84..81f4442cfbd 100644 --- a/src/game/UnitAI.h +++ b/src/game/UnitAI.h @@ -126,8 +126,8 @@ class UnitAI void AttackStartCaster(Unit *victim, float dist); void DoAddAuraToAllHostilePlayers(uint32 spellid); - void DoCast(uint32 spellId, bool useMode = false); - void DoCast(Unit* victim, uint32 spellId, bool triggered = false, bool useMode = false); + void DoCast(uint32 spellId); + void DoCast(Unit* victim, uint32 spellId, bool triggered = false); void DoCastToAllHostilePlayers(uint32 spellid, bool triggered = false); void DoCastVictim(uint32 spellId, bool triggered = false); void DoCastAOE(uint32 spellId, bool triggered = false); |
