Skip to content

Commit d24b3e2

Browse files
committed
2026-04-30 添加音频
1 parent c3c31a7 commit d24b3e2

13 files changed

Lines changed: 124 additions & 68 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
## 方法一:使用Fmod加载
2+
3+
使用塔2使用的fmod工具进行加载。
4+
5+
### 下载fmod
6+
7+
前往官网 https://www.fmod.com/download#fmodstudio ,下载2.03.06版本的fmod studio。
8+
9+
![alt text](../../images/image35.png)
10+
11+
安装完毕后打开。
12+
13+
### 下载原版工程
14+
15+
先下载一个拥有原版音频guid对应的工程,可以下载ritsulib作者制作的音频示例工程(整个一起下载): https://github.com/BAKAOLC/SwarmTheSpire-FModProject ,或者网盘: https://pan.baidu.com/s/1yuxPkDpCV8EVLkDubqiirg?pwd=apar
16+
17+
下载完毕后打开。
18+
19+
### 导入音频
20+
21+
点击左侧的`Assets`栏,将你的音频拖入其中或者右键`Import Assets`
22+
23+
![alt text](../../images/image36.png)
24+
25+
### 重命名bank
26+
27+
点击中间的`Banks`栏,将两个bank重命名为你的项目的名字,最好也是`XXX``XXXMaster`
28+
29+
* 不能删除然后重建,不能叫`Master`
30+
31+
![alt text](../../images/image37.png)
32+
33+
### 新建event
34+
35+
点击左侧的`Events`栏,可以右键新建文件夹,套一些文件夹改名防止你和别人的id撞上。然后右键新建event。
36+
37+
![alt text](../../images/image38.png)
38+
39+
右键你的event,点击`Assgin To Bank`,选择`Test`或者你重命名的那个。(*不是Master那个*
40+
41+
![alt text](../../images/image39.png)
42+
43+
### 新建sheet
44+
45+
然后点击你刚才的event,中间会出现sheet界面。在其中右键新建一个任意类型的sheet。
46+
47+
* 简单来说,timeline可以实现音频拼接或者延迟触发,action可以多个音频随机触发一个,parameter可以调整音频的参数等。
48+
49+
![alt text](../../images/image42.png)
50+
51+
例如我们新建一个timeline sheet,然后点击assets将音频素材拖到轨道里。
52+
53+
![alt text](../../images/image40.png)
54+
55+
### 构建
56+
57+
* 点击菜单栏的`File`,点击`Build`,然后再点击`Export GUIDs`
58+
59+
* 从你保存的项目的根目录找到`Build`这个文件夹,复制`GUIDs.txt``Desktop/Test.bank`(或者你的命名的bank,不是任何其他带有Master的bank)到你的mod项目中,例如复制到`Test/audios`里。
60+
61+
* 你也可以设置自动构建的路径,点击`Edit - Preference - Build`选择构建路径。
62+
63+
![alt text](../../images/image43.png)
64+
65+
### 代码加载
66+
67+
在你的初始化函数中加载:
68+
69+
```csharp
70+
using STS2RitsuLib.Audio;
71+
72+
namespace Test.Scripts;
73+
74+
[ModInitializer(nameof(Init))]
75+
public class Entry
76+
{
77+
public static void Init()
78+
{
79+
// 其余省略
80+
FmodStudioServer.TryLoadBank("res://Test/audios/Test.bank");
81+
FmodStudioServer.TryWaitForAllLoads();
82+
FmodStudioServer.TryLoadStudioGuidMappings("res://Test/audios/GUIDs.txt");
83+
}
84+
}
85+
```
86+
87+
然后你指定的fmod就被加载到游戏里了。例如使用:
88+
89+
* 人物音频:
90+
91+
```csharp
92+
Audio: new(
93+
// AttackSfx: null,
94+
// CastSfx: null,
95+
// DeathSfx: null,
96+
CharacterSelectSfx: "event:/sfx/kokodayo"
97+
// CharacterTransitionSfx: "event:/sfx/ui/wipe_ironclad"
98+
),
99+
```
100+
101+
* 卡牌音效:
102+
103+
```csharp
104+
await DamageCmd.Attack(DynamicVars.Damage.BaseValue)
105+
.FromCard(this)
106+
.WithHitFx(sfx: "event:/sfx/sword_slash") // 伤害音效
107+
.Targeting(cardPlay.Target!)
108+
.Execute(choiceContext);
109+
```
110+
111+
```csharp
112+
SfxCmd.Play("event:/sfx/block_gain");
113+
```

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ TestEnergyCounter (Control)
297297

298298
![alt text](../../images/image19.png)
299299

300-
*仅供参考,我这没挂脚本,需要挂脚本*
301-
302300
## 自定义商店模型
303301

304302
修改`AssetProfile`里的:
@@ -647,25 +645,20 @@ position = Vector2(0, -144)
647645
### test_energy_counter.tscn
648646

649647
```tscn
650-
[gd_scene load_steps=5 format=3 uid="uid://cs3a5onikvhi4"]
648+
[gd_scene load_steps=2 format=3 uid="uid://cs3a5onikvhi4"]
651649
652650
[ext_resource type="Texture2D" uid="uid://hn2nofekpwrp" path="res://icon.svg" id="1_85qf2"]
653-
[ext_resource type="Script" uid="uid://b4eaf7kin174o" path="res://Scripts/NTestEnergyCounter.cs" id="1_moaty"]
654-
[ext_resource type="Script" uid="uid://b8vmh6070x38m" path="res://Scripts/NTestParticlesContainer.cs" id="2_sphyw"]
655-
[ext_resource type="Script" uid="uid://camgj4bhk5dps" path="res://Scripts/TestMegaLabel.cs" id="4_ea8ix"]
656651
657652
[node name="TestEnergyCounter" type="Control"]
658653
layout_mode = 3
659654
anchors_preset = 0
660655
offset_right = 128.0
661656
offset_bottom = 128.0
662-
script = ExtResource("1_moaty")
663657
metadata/_edit_lock_ = true
664658
665659
[node name="EnergyVfxBack" type="Node2D" parent="."]
666660
unique_name_in_owner = true
667661
position = Vector2(64, 64)
668-
script = ExtResource("2_sphyw")
669662
670663
[node name="Layers" type="Control" parent="."]
671664
unique_name_in_owner = true
@@ -695,7 +688,6 @@ expand_mode = 1
695688
[node name="EnergyVfxFront" type="Node2D" parent="."]
696689
unique_name_in_owner = true
697690
position = Vector2(64, 64)
698-
script = ExtResource("2_sphyw")
699691
700692
[node name="Label" type="Label" parent="."]
701693
layout_mode = 1
@@ -719,7 +711,6 @@ theme_override_font_sizes/font_size = 36
719711
text = "3/3"
720712
horizontal_alignment = 1
721713
vertical_alignment = 1
722-
script = ExtResource("4_ea8ix")
723714
```
724715

725716
### test_character_merchant.tscn

RitsuLib/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
https://github.com/BAKAOLC/STS2-RitsuLib
44

5-
> 以下内容使用ritsulib0.2.3
5+
> 以下内容使用ritsulib0.2.15
66
77
先依赖ritsulib才能查看这里里面的文章。
88

99
## 下载
1010

1111
* 前往 https://github.com/BAKAOLC/STS2-RitsuLib/releases 下载`dll`,和`json`两个文件,把他们放在`mods`文件夹里。记住你下载的版本。
1212

13+
* 请根据你的游戏版本选择对应的`RitsuLib`版本。例如不带后缀的`STS2.RitsuLib.XXX.github.zip`一般跟随测试版,而例如`STS2.RitsuLib.Compat.0.103.2.XXX.github.zip`这种是兼容`0.103.2`正式版的版本。
14+
1315
*`csproj`文件中相应位置引用`STS2-RitsuLib.dll`,如下,两种方式都可。推荐使用nuget。
1416

1517
```xml
@@ -31,6 +33,8 @@ https://github.com/BAKAOLC/STS2-RitsuLib
3133
</Reference> -->
3234
<!-- NuGet获取,注意版本是否一致,不一致手动更改Version -->
3335
<PackageReference Include="STS2.RitsuLib" Version="*" />
36+
<!-- 如果你在正式版开发用这个 -->
37+
<!-- <PackageReference Include=" STS2.RitsuLib.Compat.0.103.2 " Version="*" /> -->
3438
</ItemGroup>
3539
```
3640

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
}
2525
```
2626

27-
## Spine导入&模型替换
27+
## Spine导入
2828

2929
尖塔使用`4.2.43`版本的Spine,在这之下版本的不能直接使用。(神秘链接或网盘:https://github.com/wang606/SpineSkeletonDataConverter
3030

31-
* 第一步,安装一个`Spine Godot Extension`,建议直接下载我编译好的:https://pan.baidu.com/s/1yuxPkDpCV8EVLkDubqiirg?pwd=apar 。参考 https://zh.esotericsoftware.com/spine-godot
31+
* 第一步,安装一个`Spine Godot Extension`,建议直接下载我编译好的:https://pan.baidu.com/s/1yuxPkDpCV8EVLkDubqiirg?pwd=apar 。参考 https://zh.esotericsoftware.com/spine-godot把里面的文件放到你的项目根目录,然后~~可能需要~~重启一下Godot。
3232

33-
* 把里面的文件放到你的项目根目录,然后~~可能需要~~重启一下Godot。把spine中导出的atlas,skel,png文件放入项目指定位置,能在Godot文件系统中看到就算成功。
33+
* 把spine中导出的atlas,skel,png文件放入项目你自己指定的位置,能在Godot文件系统中看到就算成功。
3434

35-
* 创建一个`SpineSkeletonDataResource`,并把`Atlas Res``SkeletonFile Res`分别设置为atlas和skel文件。
35+
* 右键godot文件系统创建资源,创建一个`SpineSkeletonDataResource`,并把`Atlas Res``SkeletonFile Res`分别设置为atlas和skel文件。
3636

3737
* 你的战斗人物模型需要有`idle_loop`(待机循环),`attack`(攻击动作),`cast`(能力卡动作),`hurt`(受伤),`die`(死亡)这些动画名。
3838

@@ -44,59 +44,7 @@
4444

4545
![3](../../images/image16.png)
4646

47-
然后可以参考这段替换角色:(此处仅替换战斗人物且不播放初始动画,仅供参考)
48-
49-
```csharp
50-
using System;
51-
using Godot;
52-
using HarmonyLib;
53-
using MegaCrit.Sts2.Core.Bindings.MegaSpine;
54-
using MegaCrit.Sts2.Core.Modding;
55-
using MegaCrit.Sts2.Core.Nodes.Combat;
56-
57-
namespace Test.Scripts;
58-
59-
[ModInitializer(nameof(Init))]
60-
public static class Entry
61-
{
62-
// 替换哪个角色
63-
private const string TargetCharacterId = "IRONCLAD";
64-
65-
// spine资源的路径
66-
private const string SkinPath = "res://spineskins/test_skin.tres";
67-
// Harmony的ID,确保唯一性
68-
private const string HarmonyId = "sts2.reme.spineskintemplate";
69-
70-
private static Resource? _skinData;
71-
72-
public static void Init()
73-
{
74-
_skinData = ResourceLoader.Load<Resource>(SkinPath, null, ResourceLoader.CacheMode.Reuse);
75-
76-
new Harmony(HarmonyId).PatchAll();
77-
}
78-
79-
[HarmonyPatch(typeof(NCreature), nameof(NCreature._Ready))]
80-
private static class NCreature_Ready_Patch
81-
{
82-
private static void Postfix(NCreature __instance)
83-
{
84-
if (_skinData == null) return;
85-
86-
var player = __instance?.Entity?.Player;
87-
if (player == null) return;
88-
89-
if (!string.Equals(player.Character.Id.Entry, TargetCharacterId, StringComparison.OrdinalIgnoreCase))
90-
return;
91-
92-
var visuals = __instance.Visuals;
93-
if (visuals?.SpineBody == null || !visuals.HasSpineAnimation) return;
94-
95-
visuals.SpineBody.SetSkeletonDataRes(new MegaSkeletonDataResource(_skinData));
96-
}
97-
}
98-
}
99-
```
47+
~~然后可以参考这段替换角色:(此处仅替换战斗人物且不播放初始动画,仅供参考)~~ 以前的代码功能太少,为了不误导新人这里删了
10048

10149
## 任意模型替换思路
10250

images/image35.png

148 KB
Loading

images/image36.png

18.6 KB
Loading

images/image37.png

20 KB
Loading

images/image38.png

21.5 KB
Loading

images/image39.png

70.1 KB
Loading

images/image40.png

46 KB
Loading

0 commit comments

Comments
 (0)