血条覆盖
你可以使用该功能制作类似中毒 灾厄的血条覆盖层。
代码 在你的能力类上添加IHealthBarForecastSource接口并重写GetHealthBarForecastSegments:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 using Godot;using MegaCrit.Sts2.Core.Entities.Creatures;using MegaCrit.Sts2.Core.Entities.Powers;using MegaCrit.Sts2.Core.Localization.DynamicVars;using MegaCrit.Sts2.Core.Models;using MegaCrit.Sts2.Core.ValueProps;using STS2RitsuLib.Combat.HealthBars;using STS2RitsuLib.Interop.AutoRegistration;using STS2RitsuLib.Scaffolding.Content;namespace Test.Scripts ; [RegisterPower ]public class TestPower2 : ModPowerTemplate , IHealthBarForecastSource { public override PowerType Type => PowerType.Debuff; public override PowerStackType StackType => PowerStackType.Counter; public override PowerAssetProfile AssetProfile => new ( IconPath: "res://RitsuTest/images/powers/test_power.png" , BigIconPath: "res://RitsuTest/images/powers/test_power.png" ); protected override IEnumerable<DynamicVar> CanonicalVars => [ new DynamicVar("Weakness" , 1.25 m) ]; public override decimal ModifyDamageMultiplicative (Creature? target, decimal amount, ValueProp props, Creature? dealer, CardModel? cardSource ) { if (target != Owner || !props.IsPoweredAttack() || Owner.CurrentHp > Amount) return 1 m; return DynamicVars["Weakness" ].BaseValue; } public IEnumerable <HealthBarForecastSegment > GetHealthBarForecastSegments (HealthBarForecastContext context ) { return HealthBarForecasts.Single( context.Creature.GetPowerAmount<TestPower2>(), new Color(0.4f , 0.1f , 0.1f ), HealthBarForecastGrowthDirection.FromLeft ); } }
配套的文本powers.json:
1 2 3 4 5 { "TEST_POWER_TEST_POWER2.description" : "生命低于阈值时额外受到伤害。" , "TEST_POWER_TEST_POWER2.smartDescription" : "生命低于[blue]{Amount}[/blue]点时额外受到[blue]{Weakness:percentMore()}%[/blue]的伤害。" , "TEST_POWER_TEST_POWER2.title" : "弱点" }