Skip to content

Commit 0db1e64

Browse files
committed
2026-04-28 血条覆盖
1 parent 840c291 commit 0db1e64

13 files changed

Lines changed: 143 additions & 8 deletions

File tree

BaseLib/01 - 添加卡牌/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using MegaCrit.Sts2.Core.ValueProps;
1414

1515
namespace Test.Scripts.Cards;
1616

17-
// 加入哪个卡池
17+
// 注册卡牌。如果要写自定义池看添加人物的开头
1818
[Pool(typeof(ColorlessCardPool))]
1919
public class TestCard : CustomCardModel
2020
{

BaseLib/03 - 添加新遗物/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
和添加卡牌类似。先新建一个类。
22

33
```csharp
4-
// 加入哪个遗物池,此处为通用
4+
// 注册遗物。如果要写自定义池看添加人物的开头
55
[Pool(typeof(SharedRelicPool))]
66
public class TestRelic : CustomRelicModel
77
{

BaseLib/04 - 添加卡牌属性/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ public class MyKeywords
6969
`:diff()`表示这个值一旦和基础值不同,就会变红色或绿色(例如升级时增加数值,预览变成绿色)。
7070

7171

72+
简单来说效果可以在`OnPlay`这么写,或者写一个自己的Cmd方便执行效果:
73+
```csharp
74+
// 使用DynamicVars["Leech"]获取数值,先让敌人失去生命(受到不可格挡不受能力影响的伤害)
75+
await CreatureCmd.Damage(choiceContext, [cardPlay.Target!], DynamicVars["Leech"].BaseValue, ValueProp.Unblockable | ValueProp.Unpowered, cardPlay.Card.Owner.Creature);
76+
// 再让玩家回复生命
77+
await CreatureCmd.Heal(cardPlay.Card.Owner.Creature, DynamicVars["Leech"].BaseValue);
78+
```
79+
7280
![alt text](../../images/image26.png)
7381

7482
## 添加卡牌提示文本

BaseLib/06 - 添加新药水/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using MegaCrit.Sts2.Core.Models.Cards;
1313

1414
namespace Test.Scripts;
1515

16+
// 注册药水。如果要写自定义池看添加人物的开头
1617
[Pool(typeof(TestPotionPool))]
1718
public class TestPotion : CustomPotionModel
1819
{

Basics/05 - 变量与描述/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
| `starIcons()` | 把数值渲染为辉星 | `获得{Stars:starIcons()}。` |
8080
| `IfUpgraded:show` | 根据升级情况显示不同文本 | `{IfUpgraded:show:升级文本\|未升级文本}` |
8181
| `abs` | 绝对值 | `{Damage:abs()}` |
82-
| `percentMore()` / `percentLess()` | 百分比 | `额外造成{Boost:percentMore()}伤害。` |
82+
| `percentMore()` / `percentLess()` | 百分比。<br>`PercentMore`把1.25变成25%。<br>`PercentLess`把0.75变成25%。 | `额外造成{Boost:percentMore()}%伤害。` |
8383

8484
`SmartFormat`的内置formatter:
8585

RitsuLib/01 - 添加卡牌/README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using STS2RitsuLib.Scaffolding.Content;
2626

2727
namespace Test.Scripts;
2828

29-
// 注册卡牌
29+
// 注册卡牌到指定池(这里是无色)。如果要写自定义池看添加人物的开头
3030
[RegisterCard(typeof(ColorlessCardPool))]
3131
// 注册成人物起始卡,后面是数量。不需要删除即可。
3232
// [RegisterCharacterStarterCard(typeof(TestCharacter), 5)]
@@ -46,6 +46,11 @@ public class TestCard : ModCardTemplate
4646
// 卡图资源
4747
public override CardAssetProfile AssetProfile => new(
4848
PortraitPath: $"res://Test/images/cards/{GetType().Name}.png"
49+
// 卡框等,有需求自己添加。需要自行判断卡牌类型(攻击、技能、能力等)设置,建议写在基类里。
50+
// 如果使用自定义卡池,需要改下material(TODO)
51+
// FramePath: "", // 卡牌背景
52+
// PortraitBorderPath: "", // 边框(状态牌感染使用的)
53+
// BannerTexturePath: "" // 横幅(不同类型)
4954
);
5055

5156
// 卡牌基础数值
@@ -121,7 +126,17 @@ namespace Test.Scripts;
121126
public abstract class TestCardModel : ModCardTemplate
122127
{
123128
public override CardAssetProfile AssetProfile => new(
124-
PortraitPath: $"res://Test/images/cards/{GetType().Name}.png"
129+
PortraitPath: $"res://RitsuTest/images/cards/{GetType().Name}.png",
130+
// 根据不同类型设置不同卡框
131+
FramePath: type switch
132+
{
133+
CardType.Attack => "res://RitsuTest/images/card_frame_attack.png",
134+
CardType.Skill => "res://RitsuTest/images/card_frame_skill.png",
135+
CardType.Power => "res://RitsuTest/images/card_frame_power.png",
136+
_ => ""
137+
}
138+
// PortraitBorderPath: "",
139+
// BannerTexturePath: ""
125140
);
126141

127142
public TestCardModel(int energyCost, CardType type, CardRarity rarity, TargetType targetType, bool shouldShowInCardLibrary)

RitsuLib/03 - 添加新遗物/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
和添加卡牌类似。先新建一个类。
44

55
```csharp
6+
using Godot;
67
using MegaCrit.Sts2.Core.Commands;
8+
using MegaCrit.Sts2.Core.Entities.Cards;
79
using MegaCrit.Sts2.Core.Entities.Players;
810
using MegaCrit.Sts2.Core.Entities.Relics;
911
using MegaCrit.Sts2.Core.GameActions.Multiplayer;
1012
using MegaCrit.Sts2.Core.Localization.DynamicVars;
13+
using MegaCrit.Sts2.Core.Models.RelicPools;
1114
using MegaCrit.Sts2.Core.Saves.Runs;
1215
using STS2RitsuLib.Interop.AutoRegistration;
1316
using STS2RitsuLib.Scaffolding.Content;
1417

1518
namespace Test.Scripts;
1619

17-
[RegisterRelic(typeof(TestRelicPool))]
20+
// 注册遗物。如果要写自定义池看添加人物的开头
21+
[RegisterRelic(typeof(SharedRelicPool))]
1822
// [RegisterCharacterStarterRelic(typeof(TestCharacter))] // 注册起始遗物
1923
public class TestRelic : ModRelicTemplate
2024
{

RitsuLib/04 - 添加卡牌属性/README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ public class MyKeywords
7474
`:diff()`表示这个值一旦和基础值不同,就会变红色或绿色(例如升级时增加数值,预览变成绿色)。
7575

7676

77+
简单来说效果可以在`OnPlay`这么写,或者写一个自己的Cmd方便执行效果:
78+
```csharp
79+
// 使用DynamicVars["Leech"]获取数值,先让敌人失去生命(受到不可格挡不受能力影响的伤害)
80+
await CreatureCmd.Damage(choiceContext, [cardPlay.Target!], DynamicVars["Leech"].BaseValue, ValueProp.Unblockable | ValueProp.Unpowered, cardPlay.Card.Owner.Creature);
81+
// 再让玩家回复生命
82+
await CreatureCmd.Heal(cardPlay.Card.Owner.Creature, DynamicVars["Leech"].BaseValue);
83+
```
84+
7785
![alt text](../../images/image26.png)
7886

7987

@@ -105,4 +113,30 @@ public class TestCard : ModCardTemplate
105113

106114
## 添加卡牌tag
107115

108-
`ritsulib`暂时不支持添加自定义的卡牌tag。也许暂时可以用keyword替代。
116+
tag是指`打击` `防御`这种。如果有打击tag会被打击木偶增伤。
117+
118+
```csharp
119+
[RegisterOwnedCardTag(nameof(Heavy))]
120+
// [RegisterOwnedCardTag(nameof(Heavy2))] // 添加更多就新加这个特性
121+
public class MyTags
122+
{
123+
public static readonly string Heavy = ModContentRegistry.GetQualifiedCardTagId(Entry.ModId, nameof(Heavy));
124+
125+
// public static readonly string Heavy2 = ModContentRegistry.GetQualifiedCardTagId(Entry.ModId, nameof(Heavy2));
126+
}
127+
```
128+
129+
然后在你的卡牌类里添加:
130+
131+
```csharp
132+
protected override IEnumerable<string> RegisteredCardTagIds => [MyTags.Heavy];
133+
```
134+
135+
需要使用时这么写。`Card`需要是个`CardModel`类型。
136+
137+
```csharp
138+
if (cardPlay.Card.HasModCardTag(MyTags.Heavy))
139+
{
140+
// Do something
141+
}
142+
```

RitsuLib/06 - 添加新药水/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ using STS2RitsuLib.Scaffolding.Content;
1414

1515
namespace Test.Scripts;
1616

17-
[RegisterPotion(typeof(TestPotionPool))]
17+
// 注册药水。如果要写自定义池看添加人物的开头
18+
[RegisterPotion(typeof(SharedPotionPool))]
1819
public class TestPotion : ModPotionTemplate
1920
{
2021
// 稀有度

RitsuLib/14 - 添加新人物/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ModTypeDiscoveryHub.RegisterModAssembly(ModId, assembly);
1616
```csharp
1717
using Godot;
1818
using STS2RitsuLib.Scaffolding.Content;
19+
using STS2RitsuLib.Utils;
1920

2021
namespace Test.Scripts;
2122

0 commit comments

Comments
 (0)