Core/Spells: Implemented SPELL_ATTR9_AUTOCAST_OFF_BY_DEFAULT

Port From (https://github.com/TrinityCore/TrinityCore/commit/24096f6b661161f296bfef4a3303789f245873c4)
This commit is contained in:
Hondacrx
2024-08-26 18:03:08 -04:00
parent ce08437402
commit 87a04a76e9
4 changed files with 23 additions and 6 deletions
@@ -1983,7 +1983,7 @@ namespace Framework.Constants
IgnoreDefaultRatedBattlegroundRestrictions = 0x4000, // Ignore Default Rated Battleground Restrictions
DoNotDisplayPowerCost = 0x8000, // Do Not Display Power Cost (client only)
NextModalSpellRequiresSameUnitTarget = 0x10000, // Prevents automatically casting the spell from SpellClassOptions::ModalNextSpell after current spell if target was changed (client only)
Unk17 = 0x20000, // 17
AutocastOffByDefault = 0x20000, // AutoCast Off By Default
Unk18 = 0x40000, // 18
Unk19 = 0x80000, // 19
Unk20 = 0x100000, // 20
+5 -3
View File
@@ -1046,10 +1046,12 @@ namespace Game.Entities
if (active == ActiveStates.Decide) // active was not used before, so we save it's autocast/passive state here
{
if (spellInfo.IsAutocastable())
newspell.active = ActiveStates.Disabled;
else
if (!spellInfo.IsAutocastable())
newspell.active = ActiveStates.Passive;
else if (spellInfo.IsAutocastEnabledByDefault())
newspell.active = ActiveStates.Enabled;
else
newspell.active = ActiveStates.Disabled;
}
else
newspell.active = active;
+12 -2
View File
@@ -149,7 +149,7 @@ namespace Game.Entities
newstate = ActiveStates.Passive;
else
{
if (spellInfo.NeedsExplicitUnitTarget())
if (spellInfo.IsAutocastEnabledByDefault() && spellInfo.NeedsExplicitUnitTarget())
{
newstate = ActiveStates.Enabled;
ToggleCreatureAutocast(spellInfo, true);
@@ -188,7 +188,17 @@ namespace Game.Entities
byte j = (byte)((preferredSlot + i) % SharedConst.ActionBarIndexMax);
if (PetActionBar[j].GetAction() == 0 && PetActionBar[j].IsActionBarForSpell())
{
SetActionBar(j, spell_id, newstate == ActiveStates.Decide ? spellInfo.IsAutocastable() ? ActiveStates.Disabled : ActiveStates.Passive : newstate);
newstate = new Func<ActiveStates>(() =>
{
if (newstate != ActiveStates.Decide)
return newstate;
if (!spellInfo.IsAutocastable())
return ActiveStates.Passive;
if (spellInfo.IsAutocastEnabledByDefault())
return ActiveStates.Enabled;
return ActiveStates.Disabled;
})();
SetActionBar(j, spell_id, newstate);
return true;
}
}
+5
View File
@@ -433,6 +433,11 @@ namespace Game.Spells
return true;
}
public bool IsAutocastEnabledByDefault()
{
return !HasAttribute(SpellAttr9.AutocastOffByDefault);
}
public bool IsStackableWithRanks()
{
if (IsPassive())