diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-01 19:41:25 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-01 19:41:25 -0300 |
| commit | 2023ac3fa6477142299115b056b4ad380a9a9f7a (patch) | |
| tree | 7584324f71e3a3a1853240042f956298c1c8cf0b /scripts | |
| parent | 2d0139c3275d5c0bdaedc23d38da4d744870020d (diff) | |
Implementado sistema de ações gratuitas.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Time/TurnManager.cs | 1 | ||||
| -rw-r--r-- | scripts/actors/AI/BaseAI.cs | 2 | ||||
| -rw-r--r-- | scripts/actors/AI/HostileEnemyAI.cs | 8 | ||||
| -rw-r--r-- | scripts/actors/actions/MeleeAction.cs | 3 | ||||
| -rw-r--r-- | scripts/actors/actions/MovementAction.cs | 2 |
5 files changed, 14 insertions, 2 deletions
diff --git a/scripts/Time/TurnManager.cs b/scripts/Time/TurnManager.cs index af721ee..cbf1176 100644 --- a/scripts/Time/TurnManager.cs +++ b/scripts/Time/TurnManager.cs @@ -63,6 +63,7 @@ public partial class TurnManager : RefCounted if (Player.Energy <= 0) { // Depois computamos os turnos dos outros atores. HandleEnemyTurns(); + map.UpdateFOV(Player.GridPosition); } // Por fim, se o jogador mudou de lugar, atualizamos seu campo de visão. if (Player.GridPosition != previousPlayerPos) { diff --git a/scripts/actors/AI/BaseAI.cs b/scripts/actors/AI/BaseAI.cs index 23cdcf6..733a61a 100644 --- a/scripts/actors/AI/BaseAI.cs +++ b/scripts/actors/AI/BaseAI.cs @@ -19,6 +19,8 @@ public abstract partial class BaseAI : Node { /// <summary> /// Computa um único turno para o ator controlado. + /// Aviso: NPCs não possuem ações gratuitas. + /// A IA SEMPRE precisa executar uma ação que custe energia. /// </summary> public abstract void Perform(); diff --git a/scripts/actors/AI/HostileEnemyAI.cs b/scripts/actors/AI/HostileEnemyAI.cs index af87360..35d6d1a 100644 --- a/scripts/actors/AI/HostileEnemyAI.cs +++ b/scripts/actors/AI/HostileEnemyAI.cs @@ -25,6 +25,14 @@ public partial class HostileEnemyAI : BaseAI // Só faz sentido atacar o jogador se o inimigo estiver visível. if (body.Map_Data.GetTile(body.GridPosition).IsInView) { + // Se o inimigo consegue ver que o jogador está morto, + // IT'S OVER. + if (!target.IsAlive) { + action = new WaitAction(body); + action.Perform(); + return; + } + // Se estiver do lado do jogador, ataque. if (distance <= 1) { action = new MeleeAction(body, offset); diff --git a/scripts/actors/actions/MeleeAction.cs b/scripts/actors/actions/MeleeAction.cs index ae94eff..b20430a 100644 --- a/scripts/actors/actions/MeleeAction.cs +++ b/scripts/actors/actions/MeleeAction.cs @@ -14,11 +14,11 @@ public partial class MeleeAction : DirectionalAction /// </summary> public override void Perform() { - actor.Energy -= cost; // Eu te disse que este método seria útil. Actor target = GetTargetActor(); // Se não houver um ator na direção, não podemos continuar. + // Isto é uma ação gratuita. if (target == null) return; // não podemos ter dano negativo. @@ -34,5 +34,6 @@ public partial class MeleeAction : DirectionalAction } MessageLogData.Instance.AddMessage(attackDesc); + actor.Energy -= cost; } } diff --git a/scripts/actors/actions/MovementAction.cs b/scripts/actors/actions/MovementAction.cs index 7d0c93b..3608357 100644 --- a/scripts/actors/actions/MovementAction.cs +++ b/scripts/actors/actions/MovementAction.cs @@ -11,7 +11,6 @@ public partial class MovementAction : DirectionalAction public override void Perform() { - actor.Energy -= cost; // Não anda se o destino for um tile sólido. if (!Map_Data.IsTileWalkable(Destination)) return; @@ -20,5 +19,6 @@ public partial class MovementAction : DirectionalAction if (GetTargetActor() != null) return; actor.Walk(Offset); + actor.Energy -= cost; } } |
