forge friendlier health and damage management

Removed knockback though
This commit is contained in:
2026-04-28 11:22:24 +02:00
parent dcfd937e53
commit ec44306d48
24 changed files with 776 additions and 490 deletions

View File

@@ -0,0 +1,31 @@
using Gamesmiths.Forge.Abilities;
using Gamesmiths.Forge.Effects;
using Gamesmiths.Forge.Godot.Resources;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
namespace Movementtests.forge.abilities;
public class SimpleHitBehavior(ForgeEffectData? damage) : IAbilityBehavior
{
public void OnStarted(AbilityBehaviorContext context)
{
if (context.Target == null || damage == null) return;
var effect = new Effect(damage.GetEffectData(), new EffectOwnership(context.Owner, context.Target));
context.Target.EffectsManager.ApplyEffect(effect);
context.AbilityHandle.CommitAbility();
context.InstanceHandle.End();
}
public void OnEnded(AbilityBehaviorContext context) {}
}
[Tool]
[GlobalClass]
public partial class ForgeSimpleHitBehavior : ForgeAbilityBehavior
{
[Export] public ForgeEffectData? DamageEffect { get; set; }
public override IAbilityBehavior GetBehavior() => new SimpleHitBehavior(DamageEffect);
}

View File

@@ -0,0 +1 @@
uid://n6efm5o4uxvr

View File

@@ -11,7 +11,7 @@ public class PlayerAttributeSet : AttributeSet
public PlayerAttributeSet()
{
Health = InitializeAttribute(nameof(Health), 100, 0, 150);
Health = InitializeAttribute(nameof(Health), 100, 0, 100);
Mana = InitializeAttribute(nameof(Mana), 100, 0, 100);
Strength = InitializeAttribute(nameof(Strength), 10, 0, 99);
Speed = InitializeAttribute(nameof(Speed), 5, 0, 10);

View File

@@ -16,19 +16,33 @@ using Movementtests.systems;
namespace Movementtests.tools.calculators;
public class RaiseEventTagExecution(TagContainer eventTags) : CustomExecution
public class RaiseEventTagExecution(TagContainer? ownerEventTags, TagContainer? targetEventTags) : CustomExecution
{
public override ModifierEvaluatedData[] EvaluateExecution(Effect effect, IForgeEntity target, EffectEvaluatedData? effectEvaluatedData)
{
var owner = effect.Ownership.Owner;
if (owner == null) return [];
owner.Events.Raise(new EventData
var magnitude = effectEvaluatedData is { ModifiersEvaluatedData.Length: > 0 }
? effectEvaluatedData.ModifiersEvaluatedData[0].Magnitude
: 0f;
if (owner != null && ownerEventTags != null)
{
EventTags = eventTags,
Source = owner,
EventMagnitude = 12f
});
owner.Events.Raise(new EventData
{
EventTags = ownerEventTags,
Source = owner,
EventMagnitude = magnitude
});
}
if (targetEventTags != null)
{
target.Events.Raise(new EventData
{
EventTags = targetEventTags,
Source = owner,
EventMagnitude = magnitude
});
}
return [];
}
@@ -39,10 +53,11 @@ public class RaiseEventTagExecution(TagContainer eventTags) : CustomExecution
[GlobalClass]
public partial class ForgeRaiseEventTagExecution : ForgeCustomExecution
{
[Export] ForgeTagContainer EventTags { get; set; }
[Export] ForgeTagContainer? EventTags { get; set; }
[Export] ForgeTagContainer? TargetEventTags { get; set; }
public override CustomExecution GetExecutionClass()
{
return new RaiseEventTagExecution(EventTags.GetTagContainer());
return new RaiseEventTagExecution(EventTags?.GetTagContainer(), TargetEventTags?.GetTagContainer());
}
}

View File

@@ -4,4 +4,4 @@
[resource]
script = ExtResource("1_l686n")
RegisteredTags = Array[String](["character.player", "character.enemy", "weapon", "status.stunned", "status.burning", "status.frozen", "abilities.weapon.land", "abilities.weapon.flying", "abilities.weapon.left", "events.combat.damage", "events.combat.hit", "events.weapon.flyingTick", "events.weapon.startedFlying", "events.weapon.stoppedFlying", "events.weapon.handToFlying", "events.weapon.flyingToHand", "events.weapon.plantedToHand", "events.weapon.plantedToFlying", "events.weapon.planted", "cooldown.empoweredAction", "cooldown.empoweredSwordThrow", "cues.resources.mana", "events.player.empowered_action_used", "cues.resources.mana.inhibited"])
RegisteredTags = Array[String](["character.player", "character.enemy", "weapon", "status.stunned", "status.burning", "status.frozen", "abilities.weapon.land", "abilities.weapon.flying", "abilities.weapon.left", "events.combat.damage", "events.combat.hit", "events.weapon.flyingTick", "events.weapon.startedFlying", "events.weapon.stoppedFlying", "events.weapon.handToFlying", "events.weapon.flyingToHand", "events.weapon.plantedToHand", "events.weapon.plantedToFlying", "events.weapon.planted", "cooldown.empoweredAction", "cooldown.empoweredSwordThrow", "cues.resources.mana", "events.player.empowered_action_used", "cues.resources.mana.inhibited", "cues.resources.health", "cooldown.enemy.hit", "status.invincible", "events.combat.death"])

View File

@@ -0,0 +1,100 @@
[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://b0ikxp5j8fn3n"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_xjqwu"]
[ext_resource type="Script" uid="uid://dngf30hxy5go4" path="res://addons/forge/resources/components/ModifierTags.cs" id="2_a16tf"]
[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="3_1wliv"]
[ext_resource type="Script" uid="uid://2gm1hdhi8u08" path="res://addons/forge/resources/magnitudes/ForgeModifierMagnitude.cs" id="4_7dtdc"]
[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="5_ewbg3"]
[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="6_0akms"]
[ext_resource type="Script" uid="uid://cl5hudinl1rex" path="res://forge/abilities/ForgeEffectApplicationBehavior.cs" id="7_mhqpo"]
[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="8_4vjp3"]
[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="9_go27d"]
[sub_resource type="Resource" id="Resource_87uc3"]
script = ExtResource("1_xjqwu")
ContainerTags = Array[String](["status.invincible"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_5ht6k"]
script = ExtResource("2_a16tf")
TagsToAdd = SubResource("Resource_87uc3")
metadata/_custom_type_script = "uid://dngf30hxy5go4"
[sub_resource type="Resource" id="Resource_bn2qi"]
script = ExtResource("3_1wliv")
BaseValue = 1.0
[sub_resource type="Resource" id="Resource_pl2a2"]
script = ExtResource("3_1wliv")
[sub_resource type="Resource" id="Resource_g02pf"]
script = ExtResource("3_1wliv")
[sub_resource type="Resource" id="Resource_7ak88"]
script = ExtResource("3_1wliv")
BaseValue = 1.0
[sub_resource type="Resource" id="Resource_f12ll"]
script = ExtResource("3_1wliv")
[sub_resource type="Resource" id="Resource_xodo6"]
script = ExtResource("3_1wliv")
[sub_resource type="Resource" id="Resource_mcqfd"]
script = ExtResource("3_1wliv")
BaseValue = 2.0
metadata/_custom_type_script = "uid://cn3b4ya15fg7e"
[sub_resource type="Resource" id="Resource_w3q2i"]
script = ExtResource("4_7dtdc")
ScalableFloat = SubResource("Resource_mcqfd")
Coefficient = SubResource("Resource_7ak88")
PreMultiplyAdditiveValue = SubResource("Resource_xodo6")
PostMultiplyAdditiveValue = SubResource("Resource_f12ll")
CalculatorCoefficient = SubResource("Resource_bn2qi")
CalculatorPreMultiplyAdditiveValue = SubResource("Resource_g02pf")
CalculatorPostMultiplyAdditiveValue = SubResource("Resource_pl2a2")
metadata/_custom_type_script = "uid://2gm1hdhi8u08"
[sub_resource type="Resource" id="Resource_vgvi5"]
script = ExtResource("5_ewbg3")
BaseValue = 1
[sub_resource type="Resource" id="Resource_0ujop"]
script = ExtResource("5_ewbg3")
BaseValue = 1
[sub_resource type="Resource" id="Resource_s8mqp"]
script = ExtResource("6_0akms")
Name = "Add Invincible tag effect"
Modifiers = Array[Object]([])
Components = Array[Object]([SubResource("Resource_5ht6k")])
Executions = []
DurationType = 2
Duration = SubResource("Resource_w3q2i")
StackLimit = SubResource("Resource_0ujop")
InitialStack = SubResource("Resource_vgvi5")
Cues = []
metadata/_custom_type_script = "uid://b83hf13nj37k3"
[sub_resource type="Resource" id="Resource_tcrdt"]
script = ExtResource("7_mhqpo")
EffectData = SubResource("Resource_s8mqp")
Name = "OnHitInvincibility"
Description = "Adds the invincible tag for a given period"
metadata/_custom_type_script = "uid://cl5hudinl1rex"
[sub_resource type="Resource" id="Resource_xs7wf"]
script = ExtResource("8_4vjp3")
Tag = "events.combat.damage"
metadata/_custom_type_script = "uid://dpakv7agvir6y"
[resource]
script = ExtResource("9_go27d")
Name = "OnHitInvincibility"
InstancingPolicy = 1
CooldownEffects = []
AbilityBehavior = SubResource("Resource_tcrdt")
TriggerSource = 1
TriggerTag = SubResource("Resource_xs7wf")
metadata/_custom_type_script = "uid://dhxfbxh54pyxp"

View File

@@ -0,0 +1,17 @@
[gd_resource type="Resource" script_class="ForgeCue" format=3 uid="uid://bsqvfefpb7jix"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_tvgrb"]
[ext_resource type="Script" uid="uid://cmrsxccn0ei4j" path="res://addons/forge/resources/ForgeCue.cs" id="2_dyb6j"]
[sub_resource type="Resource" id="Resource_f35o6"]
script = ExtResource("1_tvgrb")
ContainerTags = Array[String](["cues.resources.health"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[resource]
script = ExtResource("2_dyb6j")
CueKeys = SubResource("Resource_f35o6")
MaxValue = 100
MagnitudeType = 2
MagnitudeAttribute = "PlayerAttributeSet.Health"
metadata/_custom_type_script = "uid://cmrsxccn0ei4j"

View File

@@ -1,15 +1,15 @@
[gd_resource type="Resource" script_class="ForgeCue" format=3 uid="uid://dn7b8frkoxpxr"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_lbula"]
[ext_resource type="Script" uid="uid://cmrsxccn0ei4j" path="res://addons/forge/resources/ForgeCue.cs" id="2_jijlk"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_0pc1u"]
[ext_resource type="Script" uid="uid://cmrsxccn0ei4j" path="res://addons/forge/resources/ForgeCue.cs" id="2_g0vcr"]
[sub_resource type="Resource" id="Resource_4mhqs"]
script = ExtResource("1_lbula")
script = ExtResource("1_0pc1u")
ContainerTags = Array[String](["cues.resources.mana"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[resource]
script = ExtResource("2_jijlk")
script = ExtResource("2_g0vcr")
CueKeys = SubResource("Resource_4mhqs")
MaxValue = 100
MagnitudeType = 2

View File

@@ -1,54 +1,54 @@
[gd_resource type="Resource" script_class="ForgeEffectData" format=3 uid="uid://dh437cuxgjv6b"]
[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="1_mlifq"]
[ext_resource type="Resource" uid="uid://dn7b8frkoxpxr" path="res://forge/resources/cues/player_mana_changed_cue.tres" id="1_nsr3v"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_q8tml"]
[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="2_5tp50"]
[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="2_pm3n3"]
[ext_resource type="Script" uid="uid://b0eq12mjqfage" path="res://addons/forge/resources/components/TargetTagRequirements.cs" id="2_xbgy2"]
[ext_resource type="Script" uid="uid://bdfcavbjyhxxa" path="res://addons/forge/resources/ForgeModifier.cs" id="3_nsr3v"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_b244r"]
[ext_resource type="Script" uid="uid://b0eq12mjqfage" path="res://addons/forge/resources/components/TargetTagRequirements.cs" id="2_h46co"]
[ext_resource type="Resource" uid="uid://dn7b8frkoxpxr" path="res://forge/resources/cues/player_mana_changed_cue.tres" id="3_kw6jm"]
[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="4_fgmkc"]
[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="5_m4art"]
[ext_resource type="Script" uid="uid://bdfcavbjyhxxa" path="res://addons/forge/resources/ForgeModifier.cs" id="6_73cww"]
[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="7_xa46f"]
[sub_resource type="Resource" id="Resource_5yygy"]
script = ExtResource("1_q8tml")
script = ExtResource("1_b244r")
ContainerTags = Array[String](["character.player.mana.regen.inhibited", "cues.resources.mana.inhibited"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_ncjx6"]
script = ExtResource("2_xbgy2")
script = ExtResource("2_h46co")
OngoingIgnoredTags = SubResource("Resource_5yygy")
metadata/_custom_type_script = "uid://b0eq12mjqfage"
[sub_resource type="Resource" id="Resource_pm3n3"]
script = ExtResource("1_mlifq")
script = ExtResource("4_fgmkc")
BaseValue = 1
[sub_resource type="Resource" id="Resource_q8tml"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
BaseValue = 1.0
[sub_resource type="Resource" id="Resource_xbgy2"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
[sub_resource type="Resource" id="Resource_rhldn"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
[sub_resource type="Resource" id="Resource_p6h8c"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
BaseValue = 1.0
[sub_resource type="Resource" id="Resource_yqxv4"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
[sub_resource type="Resource" id="Resource_b6opn"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
[sub_resource type="Resource" id="Resource_5frso"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
BaseValue = 2.0
metadata/_custom_type_script = "uid://cn3b4ya15fg7e"
[sub_resource type="Resource" id="Resource_okenf"]
script = ExtResource("3_nsr3v")
script = ExtResource("6_73cww")
Attribute = "PlayerAttributeSet.Mana"
ScalableFloat = SubResource("Resource_5frso")
Coefficient = SubResource("Resource_p6h8c")
@@ -60,16 +60,16 @@ CalculatorPostMultiplyAdditiveValue = SubResource("Resource_xbgy2")
metadata/_custom_type_script = "uid://bdfcavbjyhxxa"
[sub_resource type="Resource" id="Resource_w35mq"]
script = ExtResource("2_pm3n3")
script = ExtResource("5_m4art")
BaseValue = 0.1
metadata/_custom_type_script = "uid://cn3b4ya15fg7e"
[sub_resource type="Resource" id="Resource_nsr3v"]
script = ExtResource("1_mlifq")
script = ExtResource("4_fgmkc")
BaseValue = 1
[resource]
script = ExtResource("2_5tp50")
script = ExtResource("7_xa46f")
Name = "Mana Regeneration"
Modifiers = Array[Object]([SubResource("Resource_okenf")])
Components = [SubResource("Resource_ncjx6")]
@@ -79,5 +79,5 @@ HasPeriodicApplication = true
Period = SubResource("Resource_w35mq")
StackLimit = SubResource("Resource_nsr3v")
InitialStack = SubResource("Resource_pm3n3")
Cues = Array[Object]([ExtResource("1_nsr3v")])
Cues = Array[Object]([ExtResource("3_kw6jm")])
metadata/_custom_type_script = "uid://b83hf13nj37k3"

View File

@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="ForgeTagContainer" format=3 uid="uid://cw2ytd34jsxj"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_vmvhu"]
[resource]
script = ExtResource("1_vmvhu")
ContainerTags = Array[String](["status.invincible"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"