Skip to content

Commit 14ddb3f

Browse files
authored
fix: (Day) Fixes issue where shields did not scale with equipment stats' (AscensionGameDev#2144)
* fix: (Day) Fixes issue where shields did not scale with equipment stats' * code review
1 parent a9b6549 commit 14ddb3f

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

Intersect.Server.Core/Entities/Combat/Status.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,21 @@ public Status(Entity en, Entity attacker, SpellBase spell, SpellEffect type, int
106106
// If we're adding a shield, actually add that according to the settings.
107107
if (type == SpellEffect.Shield)
108108
{
109-
for (var i = (int)Vital.Health; i < Enum.GetValues<Vital>().Length; i++)
109+
foreach (var vital in Enum.GetValues<Vital>())
110110
{
111-
var vitalDiff = spell.Combat.VitalDiff[i];
111+
var vitalDiff = Math.Abs(spell.Combat.VitalDiff[(int)vital]);
112+
113+
// If the user did not configure for this vital to have a mana shield, ignore it
114+
if (vitalDiff == 0 && vital == Vital.Mana)
115+
{
116+
continue;
117+
}
118+
119+
var shieldAmount = Formulas.CalculateDamage(
120+
vitalDiff, (DamageType)spell.Combat.DamageType, (Enums.Stat)spell.Combat.ScalingStat, spell.Combat.Scaling, 1.0, attacker, en
121+
);
112122

113-
shield[i] = Math.Abs(vitalDiff) +
114-
(int)(spell.Combat.Scaling * en.Stat[spell.Combat.ScalingStat].BaseStat / 100f);
123+
Shield[(int)vital] = Math.Abs(shieldAmount);
115124
}
116125
}
117126

@@ -204,7 +213,7 @@ public Status(Entity en, Entity attacker, SpellBase spell, SpellEffect type, int
204213
}
205214
}
206215

207-
public int[] shield { get; set; } = new int[Enum.GetValues<Vital>().Length];
216+
public int[] Shield { get; set; } = new int[Enum.GetValues<Vital>().Length];
208217

209218
public void TryRemoveStatus()
210219
{
@@ -218,7 +227,7 @@ public void TryRemoveStatus()
218227
{
219228
for (var i = (int)Vital.Health; i < Enum.GetValues<Vital>().Length; i++)
220229
{
221-
if (shield[i] > 0)
230+
if (Shield[i] > 0)
222231
{
223232
return;
224233
}
@@ -244,11 +253,11 @@ public void DamageShield(Vital vital, ref int amount)
244253
{
245254
if (Type == SpellEffect.Shield)
246255
{
247-
shield[(int)vital] -= amount;
248-
if (shield[(int)vital] <= 0)
256+
Shield[(int)vital] -= amount;
257+
if (Shield[(int)vital] <= 0)
249258
{
250-
amount = -shield[(int)vital]; //Return piercing damage.
251-
shield[(int)vital] = 0;
259+
amount = -Shield[(int)vital]; //Return piercing damage.
260+
Shield[(int)vital] = 0;
252261
TryRemoveStatus();
253262
}
254263
else

Intersect.Server.Core/Entities/Entity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ public StatusPacket[] StatusPackets()
30693069
vitalShields = new int[Enum.GetValues<Vital>().Length];
30703070
for (var x = 0; x < Enum.GetValues<Vital>().Length; x++)
30713071
{
3072-
vitalShields[x] = status.shield[x];
3072+
vitalShields[x] = status.Shield[x];
30733073
}
30743074
}
30753075

0 commit comments

Comments
 (0)