summaryrefslogtreecommitdiff
path: root/scripts/entities/actors/actions/MeleeAction.cs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/entities/actors/actions/MeleeAction.cs')
-rw-r--r--scripts/entities/actors/actions/MeleeAction.cs14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/entities/actors/actions/MeleeAction.cs b/scripts/entities/actors/actions/MeleeAction.cs
index b20430a..6dfeb78 100644
--- a/scripts/entities/actors/actions/MeleeAction.cs
+++ b/scripts/entities/actors/actions/MeleeAction.cs
@@ -15,7 +15,15 @@ public partial class MeleeAction : DirectionalAction
public override void Perform()
{
// Eu te disse que este método seria útil.
- Actor target = GetTargetActor();
+ Entity potentialTarget = GetTarget();
+
+ // Só podemos atacar atores.
+ if (potentialTarget is not Actor) {
+ return;
+ }
+
+ Actor target = (Actor)potentialTarget;
+
// Se não houver um ator na direção, não podemos continuar.
// Isto é uma ação gratuita.
@@ -24,13 +32,13 @@ public partial class MeleeAction : DirectionalAction
// não podemos ter dano negativo.
int damage = actor.Atk - target.Def;
- string attackDesc = $"{actor.ActorName} ataca {target.ActorName}";
+ string attackDesc = $"{actor.DisplayName} ataca {target.DisplayName}";
if (damage > 0) {
attackDesc += $" e remove {damage} de HP.";
target.Hp -= damage;
} else {
- attackDesc += $" mas {target.ActorName} tem músculos de aço.";
+ attackDesc += $" mas {target.DisplayName} tem músculos de aço.";
}
MessageLogData.Instance.AddMessage(attackDesc);