添加新附魔
首先创建附魔类:
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 using MegaCrit.Sts2.Core.Commands;using MegaCrit.Sts2.Core.Entities.Cards;using MegaCrit.Sts2.Core.Entities.Enchantments;using MegaCrit.Sts2.Core.GameActions.Multiplayer;using MegaCrit.Sts2.Core.HoverTips;using MegaCrit.Sts2.Core.Localization.DynamicVars;using MegaCrit.Sts2.Core.Models;using MegaCrit.Sts2.Core.ValueProps;using STS2RitsuLib.Interop.AutoRegistration;using STS2RitsuLib.Scaffolding.Content;namespace Test.Scripts ; [RegisterEnchantment ]public class TestEnchantment : ModEnchantmentTemplate { public override bool ShowAmount => true ; public override bool HasExtraCardText => true ; protected override IEnumerable<DynamicVar> CanonicalVars => [new CardsVar(2 )]; protected override IEnumerable<IHoverTip> ExtraHoverTips => [HoverTipFactory.FromKeyword(CardKeyword.Retain)]; public override EnchantmentAssetProfile AssetProfile => new ( IconPath: "res://icon.svg" ); public override bool CanEnchant (CardModel card ) { if (base .CanEnchant(card)) { return card.GainsBlock; } return false ; } protected override void OnEnchant () { Card.AddKeyword(CardKeyword.Retain); } public override decimal EnchantBlockAdditive (decimal originalBlock, ValueProp props ) { if (!props.IsPoweredCardOrMonsterMoveBlock()) { return 0 m; } return Amount; } public override async Task OnPlay (PlayerChoiceContext choiceContext, CardPlay? cardPlay ) { if (Status == EnchantmentStatus.Normal) { await CardPileCmd.Draw(choiceContext, DynamicVars.Cards.IntValue, Card.Owner); Status = EnchantmentStatus.Disabled; } } }
然后创建{modId}/localization/{Language}/enchantments.json。
1 2 3 4 5 { "TEST_ENCHANTMENT_TEST_ENCHANTMENT.title" : "戈多" , "TEST_ENCHANTMENT_TEST_ENCHANTMENT.extraCardText" : "你第一次打出这张牌时,抽{Cards}张牌。" , "TEST_ENCHANTMENT_TEST_ENCHANTMENT.description" : "这张牌获得[gold]保留[/gold]。\n这张牌获得的[gold]格挡[/gold]值增加[blue]{Amount}[/blue]点。\n第一次打出时抽{Cards}张牌。" }
如何使用:
控制台里输入enchant TEST_ENCHANTMENT_TEST_ENCHANTMENT [数量] [给予手牌的编号]。
在效果里,使用CardCmd.Enchant<TestEnchantment>(card, 2m)。第二个参数用于修改Amount。