-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing cost to the Heart Thrower spell
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Content/Spells/Base/SpellCosts/Stats/TotalManaPercentSpellCost.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using Terraria; | ||
|
||
namespace Spellwright.Content.Spells.Base.SpellCosts.Stats | ||
{ | ||
internal class TotalManaPercentSpellCost : SpellCost | ||
{ | ||
public float CostPercent { get; } | ||
|
||
public TotalManaPercentSpellCost(float cost) | ||
{ | ||
CostPercent = Math.Clamp(cost, 0, 1); | ||
} | ||
|
||
public override bool Consume(Player player, int playerLevel, SpellData spellData) | ||
{ | ||
float costPercent = CostPercent * spellData.CostModifier; | ||
int realCost = (int)Math.Floor(player.statManaMax * costPercent); | ||
if (realCost <= 0) | ||
return true; | ||
|
||
if (player.statMana < realCost) | ||
{ | ||
LastError = Spellwright.GetTranslation("SpellCost", "NotEnoughMana").Format(realCost); | ||
return false; | ||
} | ||
|
||
player.statMana -= realCost; | ||
return true; | ||
} | ||
|
||
public override string GetDescription(Player player, int playerLevel, SpellData spellData) | ||
{ | ||
float costPercent = CostPercent * spellData.CostModifier; | ||
int realCost = (int)Math.Floor(player.statManaMax * costPercent); | ||
if (realCost <= 0) | ||
return null; | ||
|
||
return Spellwright.GetTranslation("SpellCost", "ManaCost").Format(realCost); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters