Permalink
Browse files

[11842] Add spell difficulty selection for creature*_addon auras

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
  • Loading branch information...
1 parent 9227928 commit a7554a3363cfd77f427b73a78a5cd2fc5bb3f03f @Schmoozerd Schmoozerd committed Nov 7, 2011
Showing with 13 additions and 6 deletions.
  1. +10 −3 src/game/Creature.cpp
  2. +1 −1 src/game/Creature.h
  3. +1 −1 src/game/Totem.cpp
  4. +1 −1 src/shared/revision_nr.h
View
@@ -784,7 +784,7 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons
cPos.GetMap()->GetCreatureLinkingHolder()->AddMasterToHolder(this);
}
- LoadCreatureAddon();
+ LoadCreatureAddon(false, cPos.GetMap());
return true;
}
@@ -1911,7 +1911,7 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const
}
//creature_addon table
-bool Creature::LoadCreatureAddon(bool reload)
+bool Creature::LoadCreatureAddon(bool reload /*= false*/, Map* map /*= NULL*/)
{
CreatureDataAddon const *cainfo = GetCreatureAddon();
if(!cainfo)
@@ -1965,7 +1965,14 @@ bool Creature::LoadCreatureAddon(bool reload)
continue;
}
- CastSpell(this, *cAura, true);
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(*cAura); // Already checked on load
+
+ // Get Difficulty mode for initial case (npc not yet added to map)
+ if (spellInfo->SpellDifficultyId && !reload && map && map->IsDungeon())
+ if (SpellEntry const* spellEntry = GetSpellEntryByDifficulty(spellInfo->SpellDifficultyId, map->GetDifficulty(), map->IsRaid()))
+ spellInfo = spellEntry;
+
+ CastSpell(this, spellInfo, true);
}
}
return true;
View
@@ -462,7 +462,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
void RemoveFromWorld();
bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Team team = TEAM_NONE, const CreatureData *data = NULL, GameEventCreatureData const* eventData = NULL);
- bool LoadCreatureAddon(bool reload = false);
+ bool LoadCreatureAddon(bool reload = false, Map* map = NULL);
void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f);
void LoadEquipment(uint32 equip_entry, bool force=false);
View
@@ -64,7 +64,7 @@ bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const*
if (InstanceData* iData = GetMap()->GetInstanceData())
iData->OnCreatureCreate(this);
- LoadCreatureAddon();
+ LoadCreatureAddon(false, cPos.GetMap());
return true;
}
View
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "11841"
+ #define REVISION_NR "11842"
#endif // __REVISION_NR_H__

6 comments on commit a7554a3

Contributor

Shauren replied Nov 7, 2011

this is not needed, Spell::m_spellInfo is selected per difficulty in Spell constructor (so its done always, for all spell casts)

Contributor

Schmoozerd replied Nov 7, 2011

Not in mangos - when a creature is created it is not yet added to world (this is one of the last things done)

Hmm, but map pointer set before adding to world

Creature::Create : SetMap(cPos.GetMap());

Contributor

Shauren replied Nov 8, 2011

as @VladimirMangos said, map pointer is set before loading creature_addon, which is all you need to select the difficulty (IsInWorld check is not needed in spell ctor)

Contributor

Schmoozerd replied Nov 8, 2011

yes, probably we can substitute the IsInWorld check with GetMap in the spell constructor
Need to look closer into the difference between the two

Possible we can't, because casting spells by player out of world cases, but cleary we not need pass GetMap() values as arg in code and can base at current creature map pointer value. So just simplify change by drop new arg in LoadCreatureAddon

Please sign in to comment.