Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
Core/Spells: Cleaned up and removed hack code from aura 332.
Browse files Browse the repository at this point in the history
thats to: Darkpeninsula

Signed-off-by: Bootz <bootz@projectskyfire.org>
  • Loading branch information
Bootz committed May 2, 2012
1 parent 99e7886 commit 5f8cbe0
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 50 deletions.
21 changes: 21 additions & 0 deletions sql/updates/world/2012_05_02_00_world_spell_override.sql
@@ -0,0 +1,21 @@
CREATE TABLE IF NOT EXISTS `spell_override` (
`overrideSpell` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`affSpell` INT(10) NOT NULL DEFAULT '0',
`aura` INT(10) NOT NULL DEFAULT '0',
`comment` LONGTEXT NOT NULL DEFAULT '',
PRIMARY KEY (`overrideSpell`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;

INSERT INTO spell_override VALUES
(93402,8921,48517,"Eclipse (Solar)"),
(91183,82731,0,"Frostfire orb"),
(88625,2050,0,"Chakra: Holy Word: Chastise"),
(88684,88625,0,"Chakra: Holy Word: Serenity"),
(88685,88625,0,"Chakra: Holy Word: Sanctuary"),
-- idky these are on spell-override there not aura 332
(86213,86121,0,"Soul Swap: Exhale"),
(91711,6229,9173,"Nether Ward Talent"),
(92315,11366,0,"Pyroblast!"),
(82928,19434,0,"Aimed Shot!"),
(89420,689,0,"Drain Life"),
(81170,6785,0,"Ravage");
58 changes: 10 additions & 48 deletions src/server/game/Spells/Auras/SpellAuraEffects.cpp
Expand Up @@ -6107,61 +6107,23 @@ void AuraEffect::HandleAuraSwapSpells(AuraApplication const * aurApp, uint8 mode

uint32 overrideId = GetAmount();

if (!overrideId)
return;
SpellEntry const* spell = sSpellStore.LookupEntry(overrideId);
if (!spell)
return;
uint32 affspell = 0;
ActionBarSpellOverride const* spellOverride = sSpellMgr->GetActionBarSpellOverride(overrideId);

if (overrideId == 93402) // Sunfire
{
if (target->HasAura(48517)) // Sunfire talent
affspell = 8921; // Moonfire
else
return;
}

if (overrideId == 91711)
{
if (target->HasAura(91713)) // The nether ward talent
affspell = 6229;
else
return;
}

if (overrideId == 92315) // Pyroblast
affspell = 11366;

if (overrideId == 82928) // Fire!
affspell = 19434;

if (overrideId == 89420) // Drain Life
affspell = 689;

if (overrideId == 81170) // Ravage
affspell = 6785;

if (overrideId == 93402) // Eclipse (Solar)
affspell = 8921;

if (overrideId == 92283) // Frostfire Orb Override
affspell = 82731;

if (overrideId == 88625) // Chakra: Serenity
affspell = 2050;
if(!spellOverride)
return;

if (overrideId == 86213) // Soul Swap: Exhale
affspell = 86121;
uint32 aura = spellOverride->aura;
uint32 affSpell = spellOverride->affSpell;

if (overrideId == 88684 || overrideId == 88685) // Chakra
affspell = 88625;
//Check Aura
if(aura > 0 && !target->HasAura(aura))
return;

if (apply)
{
target->AddTemporarySpell(overrideId);
WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4);
data << uint32(affspell); // here should be affected spell - not really necessary, after casting the real spell again, it auto-fixes
data << uint32(affSpell);
data << uint32(overrideId);
target->GetSession()->SendPacket(&data);
}
Expand All @@ -6170,7 +6132,7 @@ void AuraEffect::HandleAuraSwapSpells(AuraApplication const * aurApp, uint8 mode
target->RemoveTemporarySpell(overrideId);
WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4);
data << uint32(overrideId);
data << uint32(affspell); // here should be affected spell - not really necessary, after casting the real spell again, it auto-fixes
data << uint32(affSpell);
target->GetSession()->SendPacket(&data);
}
}
Expand Down
65 changes: 65 additions & 0 deletions src/server/game/Spells/SpellMgr.cpp
Expand Up @@ -2696,6 +2696,61 @@ void SpellMgr::LoadSpellAreas()
sLog->outString();
}

void SpellMgr::LoadActionBarSpellOverride()
{
uint32 oldMSTime = getMSTime();
mActionBarSpellOverrideMap.clear();

QueryResult result = WorldDatabase.Query("SELECT overrideSpell, affSpell, aura FROM spell_override ORDER BY overrideSpell ASC");

if (!result)
{
sLog->outString(">> Loaded 0 actionbar spell overrides. DB table `spell_override` is empty.");
sLog->outString();
return;
}

do
{
Field *fields = result->Fetch();

uint32 overrideSpell = fields[0].GetUInt32();
uint32 affSpell = fields[1].GetUInt32();
uint32 aura = fields[2].GetUInt32();

if(!sSpellStore.LookupEntry(overrideSpell))
{
sLog->outErrorDb("Spell (overrideSpell) %u listed in `spell_override` does not exist", overrideSpell);
continue;
}

if(!sSpellStore.LookupEntry(affSpell))
{
sLog->outErrorDb("Spell (affSpell) %u listed in `spell_override` does not exist", affSpell);
continue;
}

if(aura > 0)
{
if(!sSpellStore.LookupEntry(aura))
{
sLog->outErrorDb("Spell (aura) %u listed in `spell_override` does not exist", aura);
continue;
}
}

ActionBarSpellOverride actbarSpellov;
actbarSpellov.affSpell = affSpell;
actbarSpellov.aura = aura;

mActionBarSpellOverrideMap[overrideSpell]= actbarSpellov;
}
while (result->NextRow());

sLog->outString(">> Loaded %u actionbar spell overrides in %u ms", mActionBarSpellOverrideMap.size(), GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}

void SpellMgr::LoadSpellInfoStore()
{
uint32 oldMSTime = getMSTime();
Expand Down Expand Up @@ -2830,6 +2885,16 @@ void SpellMgr::LoadSpellInfoStore()
sLog->outString();
}

ActionBarSpellOverride const* SpellMgr::GetActionBarSpellOverride(uint32 overrideSpell) const
{
ActionBarSpellOverrideMap::const_iterator itr = mActionBarSpellOverrideMap.find(overrideSpell);

if(itr == mActionBarSpellOverrideMap.end())
return NULL;
else
return &itr->second;
}

void SpellMgr::UnloadSpellInfoStore()
{
for (uint32 i = 0; i < mSpellInfoMap.size(); ++i)
Expand Down
17 changes: 15 additions & 2 deletions src/server/game/Spells/SpellMgr.h
Expand Up @@ -337,6 +337,14 @@ enum SpellGroup
SPELL_GROUP_CORE_RANGE_MAX = 5,
};

struct ActionBarSpellOverride
{
uint32 affSpell;
uint32 aura;
};

typedef UNORDERED_MAP<uint32, ActionBarSpellOverride> ActionBarSpellOverrideMap;

#define SPELL_GROUP_DB_RANGE_MIN 1000

// spell_id, group_id
Expand Down Expand Up @@ -548,9 +556,9 @@ class SpellMgr
SpellMgr();
~SpellMgr();

// Accessors (const or static functions)
// Assessors (const or static functions)
public:
// Spell correctess for client using
// Spell correctness for client using
static bool IsSpellValid(SpellInfo const* spellInfo, Player* player = NULL, bool msg = true);

// Spell difficulty
Expand Down Expand Up @@ -605,6 +613,9 @@ class SpellMgr
SpellProcEntry const* GetSpellProcEntry(uint32 spellId) const;
bool CanSpellTriggerProcOnEvent(SpellProcEntry const& procEntry, ProcEventInfo& eventInfo);

// Actionbar override spell
ActionBarSpellOverride const* GetActionBarSpellOverride(uint32 overrideSpell) const;

// Spell bonus data table
SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const;

Expand Down Expand Up @@ -662,6 +673,7 @@ class SpellMgr
void UnloadSpellInfoStore();
//void UnloadSpellInfoImplicitTargetConditionLists();
void LoadSpellCustomAttr();
void LoadActionBarSpellOverride();

private:
SpellDifficultySearcherMap mSpellDifficultySearcherMap;
Expand Down Expand Up @@ -692,6 +704,7 @@ class SpellMgr
PetLevelupSpellMap mPetLevelupSpellMap;
PetDefaultSpellsMap mPetDefaultSpellsMap; // only spells not listed in related mPetLevelupSpellMap entry
SpellInfoMap mSpellInfoMap;
ActionBarSpellOverrideMap mActionBarSpellOverrideMap;
};

#define sSpellMgr ACE_Singleton<SpellMgr, ACE_Null_Mutex>::instance()
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/World/World.cpp
Expand Up @@ -1336,6 +1336,9 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading spell custom attributes...");
sSpellMgr->LoadSpellCustomAttr();

sLog->outString("Loading Actionbar Spell overrides...");
sSpellMgr->LoadActionBarSpellOverride();

sLog->outString("Loading Script Names...");
sObjectMgr->LoadScriptNames();

Expand Down

6 comments on commit 5f8cbe0

@Bootz
Copy link
Contributor Author

@Bootz Bootz commented on 5f8cbe0 May 2, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice typo... thats to = thanks to :/

@Kr4v3n5
Copy link
Contributor

@Kr4v3n5 Kr4v3n5 commented on 5f8cbe0 May 2, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanx

@tuxity
Copy link
Contributor

@tuxity tuxity commented on 5f8cbe0 May 2, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done with SpellFamilyFlags/SpellClassMask not ugly like that :P

@Truffy
Copy link

@Truffy Truffy commented on 5f8cbe0 May 2, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SMSG_SUPERCEDED_SPELL ain't the real opcode.

We still have to find it :)

@totomakers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahah, thx but i have made a pull request and they have told me "No it's Hacky"
https://github.com/seraphinchaos/SkyFireEMU/commit/80739afbba662ab637790a46897815548da329e0

@tuxity
Copy link
Contributor

@tuxity tuxity commented on 5f8cbe0 May 2, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry, still hacky ! :P

Please sign in to comment.