67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using Gamesmiths.Forge.Attributes;
|
|
using Gamesmiths.Forge.Core;
|
|
using Gamesmiths.Forge.Effects;
|
|
using Gamesmiths.Forge.Effects.Calculator;
|
|
using Gamesmiths.Forge.Effects.Magnitudes;
|
|
using Gamesmiths.Forge.Effects.Modifiers;
|
|
using Godot;
|
|
|
|
namespace Movementtests.tools.calculators;
|
|
|
|
public class FlyingWeaponExecution : CustomExecution
|
|
{
|
|
private readonly Node3D _comboSystem;
|
|
|
|
public AttributeCaptureDefinition TargetHealth { get; }
|
|
public AttributeCaptureDefinition AttackerStrength { get; }
|
|
|
|
public FlyingWeaponExecution()
|
|
{
|
|
|
|
TargetHealth = new AttributeCaptureDefinition(
|
|
"CombatAttributeSet.CurrentHealth",
|
|
AttributeCaptureSource.Target,
|
|
Snapshot: false);
|
|
|
|
AttackerStrength = new AttributeCaptureDefinition(
|
|
"StatAttributeSet.Strength",
|
|
AttributeCaptureSource.Source,
|
|
Snapshot: true);
|
|
|
|
AttributesToCapture.Add(TargetHealth);
|
|
AttributesToCapture.Add(AttackerStrength);
|
|
|
|
CustomCueParameters.Add("cues.combat.combo_count", 0);
|
|
CustomCueParameters.Add("cues.combat.combo_damage", 0f);
|
|
}
|
|
|
|
public override ModifierEvaluatedData[] EvaluateExecution(Effect effect, IForgeEntity target, EffectEvaluatedData? effectEvaluatedData)
|
|
{
|
|
var results = new List<ModifierEvaluatedData>();
|
|
|
|
int strength = CaptureAttributeMagnitude(AttackerStrength, effect, target, effectEvaluatedData);
|
|
int comboCount = 0;
|
|
|
|
// Calculate combo damage
|
|
float baseDamage = strength * 0.8f;
|
|
float comboDamage = baseDamage * (1 + comboCount * 0.2f);
|
|
|
|
// Apply health damage
|
|
if (TargetHealth.TryGetAttribute(target, out EntityAttribute? healthAttribute))
|
|
{
|
|
results.Add(new ModifierEvaluatedData(
|
|
healthAttribute,
|
|
ModifierOperation.FlatBonus,
|
|
-comboDamage, // Negative for damage
|
|
channel: 0
|
|
));
|
|
}
|
|
|
|
// Add combo to cue parameters
|
|
CustomCueParameters["cues.combat.combo_count"] = comboCount;
|
|
CustomCueParameters["cues.combat.combo_damage"] = comboDamage;
|
|
|
|
return results.ToArray();
|
|
}
|
|
} |