Skip to content

Commit

Permalink
Optimize StyleProcessor.CreateMagicEffect
Browse files Browse the repository at this point in the history
* It was cloning every spell from the `Combat_Styles_Effect` line before iterating the returned list. This could have been slow with many spells.
* Spells that arem't explicitely added to the `Combat_Styles_Effect` line in the DB are now allowed to be used as style procs.
  • Loading branch information
bm01 committed Aug 1, 2024
1 parent 80a845b commit bdd6b59
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions GameServer/styles/StyleProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,43 +590,26 @@ protected static bool CheckWeaponType(Style style, GameLiving living, DbInventor
/// <param name="spellID">The spellid of the magical effect</param>
protected static ISpellHandler CreateMagicEffect(GameLiving caster, GameLiving target, int spellID)
{
SpellLine styleLine = SkillBase.GetSpellLine(GlobalSpellsLines.Combat_Styles_Effect);
if (styleLine == null || target == null) return null;
Spell spell = SkillBase.GetSpellByID(spellID);

List<Spell> spells = SkillBase.GetSpellList(styleLine.KeyName);
if (spell == null)
return null;

Spell styleSpell = null;
foreach (Spell spell in spells)
{
if (spell.ID == spellID)
{
// We have to scale style procs when cast
if (caster is GameSummonedPet pet)
pet.ScalePetSpell(spell);
// We have to scale style procs when cast.
if (caster is GameSummonedPet pet)
pet.ScalePetSpell(spell);

styleSpell = spell;
break;
}
}
ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(caster, spell, SkillBase.GetSpellLine(GlobalSpellsLines.Combat_Styles_Effect));

ISpellHandler spellHandler = ScriptMgr.CreateSpellHandler(caster, styleSpell, styleLine);
if (spellHandler == null && styleSpell != null && caster is GamePlayer)
{
((GamePlayer)caster).Out.SendMessage(styleSpell.Name + " not implemented yet (" + styleSpell.SpellType + ")", eChatType.CT_System, eChatLoc.CL_SystemWindow);
if (spellHandler == null)
return null;
}

// No negative effects can be applied on a keep door or via attacking a keep door
if ((target is GameKeepComponent || target is GameKeepDoor) && spellHandler?.HasPositiveEffect == false)
{
if ((target is GameKeepComponent || target is GameDoorBase) && !spellHandler.HasPositiveEffect)
return null;
}


return spellHandler;
}


/// <summary>
/// Delve a Style handled by this processor
/// </summary>
Expand Down

0 comments on commit bdd6b59

Please sign in to comment.