模组:事件数据
← 目录
此页面解释了游戏如何存储和解析事件数据。这是一份面向模组开发者的进阶指南。
原始数据
事件根据其发生的地点存储在资源 Data/Events/<地点名称> 中。你可以解包 XNB 文件进行参考。
例如,以下是截至 1.6.14 版本中,潘姆的拖车 (Data/Events/Trailer) 的原始数据(英文):
数据
{
"35/f Penny 1000/p Penny": "50s/-1000 -1000/farmer -30 30 0 Penny 12 7 0 Pam -100 -100 0/skippable/specificTemporarySprite pennyMess/viewport 12 7 true/pause 1000/speak Penny \"Ughh... It's so dirty in here.$s\"/pause 500/warp farmer 12 9/playSound doorClose/pause 500/faceDirection Penny 2/pause 500/emote Penny 16/pause 300/speak Penny \"@! Um... Sorry that it's such a mess. I was about to clean up.$u\"/pause 500/move farmer 0 -1 0/pause 600/emote Penny 32/pause 300/speak Penny \"You'll help me? You really mean it?$h\"/pause 500/faceDirection Penny 1/faceDirection farmer 1/speak Penny \"Okay, you can get started over there. I'll clean the kitchen.\"/move farmer 2 0 1/move farmer 0 -2 1/move farmer 1 0 1/move Penny -1 0 0/animate Penny false true 100 24 25/animate farmer false true 100 35/pause 200/playSound dwop/removeSprite 16 6/pause 200/move Penny -1 0 0/animate Penny false true 100 24 25/stopAnimation farmer/faceDirection farmer 0/pause 1200/stopAnimation Penny/removeSprite 10 5/playSound dwop/move Penny -1 0 0/animate Penny false true 100 24 25/pause 900/animate farmer false true 100 41/pause 300/playSound dwop/removeSprite 15 5/stopAnimation farmer/pause 1400/stopAnimation Penny/move Penny 1 0 0/pause 800/warp Pam 12 9/playSound doorClose/stopMusic/move Pam 0 -1 0/faceDirection Penny 2/faceDirection farmer 3/faceDirection Pam 1/pause 500/faceDirection Pam 3/speak Pam \"Whaddya think you're doing?!$u\"/faceDirection Pam 1/faceDirection Pam 3/faceDirection Pam 0/speak Pam \"Stop it! I had everything just the way I like it!$u\"/move Penny 2 0 2/pause 500/emote Penny 28/pause 500/speak Penny \"Mom, the house is a total mess. @ and I were just trying to tidy things up a bit.#$b#*sniff* *sniff*... Were you at the saloon just now? You smell like beer...$s\"/pause 300/move Pam -1 0 3/emote Pam 12/pause 400/speak Pam \"It's none of your damn business where I go!$4\"/pause 500/speak Penny \"It IS my business! I don't want you destroying yourself!$a#$b#Don't you realize your choices have an effect on me? Stop being so selfish!$a\"/faceDirection Pam 0/shake Pam 5000/pause 600/speak Pam \"Selfish? I put a roof over your head and clothes on your back and you call me selfish!? You ungrateful little...$u\"/pause 500/emote farmer 28/pause 500/faceDirection Pam 1/faceDirection Penny 1/move farmer -2 0 2/move farmer 0 2 3/pause 500/speak Pam \"You'd better go. I'm sorry you had to see this, kid.$4\"/pause 500/move farmer -1 0 2/move farmer 0 1 2/pause 500/faceDirection farmer 0/faceDirection Penny 2/pause 700/faceDirection farmer 2/pause 500/warp farmer -40 -40/playSound doorClose/pause 500/move Pam 0 -1 1/pause 300/faceDirection Penny 3/speak Pam \"He's a nice young man...^She's a nice young lady...\"/speak Pam \"But I don't want you tellin' others to clean up my house! It's embarrassing! You understand?$4\"/pause 300/faceDirection Penny 2/pause 600/showFrame Penny 23/pause 700/speak Penny \"...Yes, mother.$s\"/pause 1000/mail PennyCleanTrailer/end warpOut",
"36/f Penny 1500/p Penny": "musicboxsong/9 7/farmer -30 30 0 Penny 9 7 0/skippable/pause 1000/playSound doorClose/warp farmer 12 9/pause 400/faceDirection Penny 2/pause 300/speak Penny \"@, you came at a good time!#$b#I'm just about finished cooking a new recipe I invented!$h\"/pause 400/move farmer 0 -2 3/faceDirection Penny 1/move farmer -2 0 3/speak Penny \"Let me just finish up real quick.\"/pause 200/faceDirection Penny 0/pause 200/animate Penny false true 120 29 30/playSound crafting/pause 320/playSound crafting/pause 320/playSound crafting/pause 320/playSound crafting/pause 320/stopAnimation Penny/pause 500/playSound openBox/showFrame Penny 29/pause 400/playSound furnace/showFrame Penny 30/pause 1500/playSound clank/faceDirection Penny 0/pause 500/faceDirection Penny 1 true/showFrame Penny 28/speak Penny \"Here, give that a little taste.\"/pause 800/faceDirection farmer 2/farmerEat 200/showFrame Penny 4/pause 2500/stopAnimation farmer/pause 500/playSound gulp/animate farmer false true 350 104 105/pause 500/specificTemporarySprite pennyCook/pause 1500/faceDirection farmer 2/pause 500/speak Penny \"$q 72 null#...well?#$r 72 50 event_cook1#(Lie) Mmm! That was delicious!#$r 73 -50 event_cook2#Uh... can I get the rest to go?#$r 73 0 event_cook3#Well it's definitely unique... how did you get it so rubbery?\"/pause 500/speak Penny \"$p 72#Hey, since you're the first person to try it, I'm going to name this one 'Chili de @'.$h|Well, I guess this recipe was a failure...$s\"/stopAnimation farmer/faceDirection farmer 3/pause 600/speak Penny \"Um... so how about we watch a movie or something?\"/pause 500/move farmer 5 0 0 true/move Penny 5 0 0 true/globalFade/viewport -1000 -1000/end dialogue Penny \"Thanks for being my taste-tester.$h\"",
"963313/n pamPotatoJuice": "playful/10 7/farmer -100 -100 0 Pam 10 7 0/mail pamNewChannel/skippable/pause 3000/speak Pam \"Heheh... I see the delivery came in.$h\"/pause 500/speak Pam \"Let's have a little taste.$h\"/pause 1000/playSound coin/showFrame Pam 32/pause 2000/animate Pam false true 400 33 34/playSound glug/pause 800/playSound glug/pause 800/playSound glug/pause 800/playSound glug/pause 790/stopAnimation Pam/showFrame Pam 32/pause 400/emote Pam 40/pause 800/showFrame Pam 35/textAboveHead Pam \"Ptooey!\"/playSound slimedead/shake Pam 2000/pause 2000/animate Pam false true 400 28 29/speak Pam \"I said potato, not fermented baboon kidney!$u\"/pause 2000/end dialogue Pam \"The juice? Yeah, I tried it, kid. $4#$b#How'd it taste? ...Some things are better left unsaid. Let's just leave it at that.$4\""
}
事件前置条件
格式
每个事件都有一个格式为 <事件 ID>/[前置条件] 的键,由两部分组成:
| 字段 | 用法 |
|---|---|
| 事件 ID | 用于标识事件的唯一字符串 ID。旧的原版事件出于兼容性原因使用数字,但强烈建议模组事件遵循唯一字符串 ID 格式(包括模组 ID 前缀),以防止模组之间的冲突。 |
| 前置条件 |
由斜杠 (/) 分隔的列表,包含下文列出的前置条件。你可以在任何前置条件前加上 前置条件键不区分大小写,但其参数可能区分。建议使用所示的确切大写格式以避免问题。 你可以使用引号转义参数中的空格和斜杠,例如: |
示例(假设你使用了带有 {{ModId}} 令牌的 Content Patcher):
{{ModId}}_EventId/:事件 ID 为{{ModId}}_EventId,且无前置条件。{{ModId}}_EventId/Time 1900 2300/Friendship Clint 750:事件 ID 为{{ModId}}_EventId;该事件仅在晚上 7 点到 11 点之间,且你与克林特的友好度达到 3 心(750 分)时发生。
内置前置条件
游戏状态查询
这允许你检查其他前置条件未涵盖的任意条件。
| 名称与参数 | 描述 |
|---|---|
GameStateQuery <query>
|
游戏状态查询匹配,例如 GameStateQuery !WEATHER Here Sun 表示“此地点当前不是晴天”。
|
世界/环境
这些检查当前的时间、日期、天气等。它们与特定玩家无关。
| 名称与参数 | 描述 |
|---|---|
ActiveDialogueEvent <ID>
|
具有给定 ID 的特殊对话事件(包括对话主题)正在进行中。 |
DayOfMonth <number>+
|
今天是月份中指定的日期之一(可指定多个日期)。日期应为整数(例如 12)。 |
DayOfWeek <day>+
|
今天是指定的一周中的某天(可指定多天)。可以是区分大小写的三个字母缩写(如 Mon)或全称(如 Monday)。 |
| FestivalDay | 今天是节日。 |
GoldenWalnuts <number>
|
玩家总共找到了至少这么多金色核桃(包括已消耗的)。 |
InUpgradedHouse [level]
|
当前地点是农舍或小屋,且已升级至少 [level] 次。默认值:2。
|
NPCVisible <name>
|
具有该内部名称的 NPC 在任何地点出现且可见。 |
NpcVisibleHere <name>
|
具有该内部名称的 NPC 在当前地点出现且可见。 |
Random <number>
|
随机匹配,<number> 是允许事件发生的概率,介于 0 和 1 之间(例如 0.2 表示 20% 的概率)。
|
Season <season>+
|
当前季节是给定值之一(可指定多个季节)。 |
Time <min> <max>
|
当前时间在给定值之间(含)。数值使用 26 小时制(从 600 到 2600)。 |
UpcomingFestival <number>
|
节日将在给定的天数内发生。 |
Weather <weather>
|
当前地点环境的天气匹配 <weather>。有效值:rainy(雨天)、sunny(晴天)或具体的天气 ID。
|
WorldState <ID>
|
给定的世界状态 ID 在任何地方处于激活状态。 |
Year <year>
|
如果 <year> 为 1,则必须在第一年。否则,年份必须至少为该值。
|
当前玩家
这些检查当前玩家(正在玩此游戏实例的玩家)。
| 名称与参数 | 描述 |
|---|---|
ChoseDialogueAnswers <dialogue ID>+
|
当前玩家已选择所有给定的对话回答 ID(可指定多个 ID)。 |
Dating <name>
|
当前玩家正在与该内部名称的 NPC 约会。 |
EarnedMoney <number>
|
当前玩家已累计赚取至少这么多钱(包括已花掉的)。 |
FreeInventorySlots <number>
|
当前玩家至少有这么多空余的物品栏格子。 |
Friendship <name> <number>+
|
当前玩家与所有指定内部名称的 NPC 至少有这么多友好度点数(可指定多个名称/数值对)。 |
Gender <gender>
|
当前玩家是男性(如果 <gender> 为 male,不区分大小写)或非男性(如果 <gender> 为其他值)。
|
HasItem <item ID>
|
当前玩家的物品栏中拥有给定的物品。 |
HasMoney <number>
|
当前玩家手头至少有这么多钱(不包括已花掉的)。 |
LocalMail <letter ID>
|
当前玩家已收到给定的信件。 |
MissingPet [pet]
|
当前玩家尚未获得宠物,且他们的偏好匹配 [pet](可以是任何宠物类型)。默认:匹配任何偏好。
|
ReachedMineBottom [number]
|
当前玩家已到达矿井底层的次数至少达到该数值。默认值:1。 |
| Roommate | 当前玩家与任何 NPC 是室友关系。 |
SawEvent <event ID>+
|
当前玩家已看过给定事件中的“任意”一个(可指定多个 ID)。
若要检查玩家是否看过“所有”几个事件,请多次使用此前置条件。 |
SawSecretNote <number>
|
当前玩家已看过给定 ID(整数)的秘密纸条。 |
Shipped <item ID> <number>+
|
当前玩家已运送至少这么多指定的物品(可指定多个物品/数值对)。这仅适用于游戏跟踪的运送统计项(显示在运送收集品菜单中)。 |
Skill <name> <level>
|
当前玩家在给定技能中至少达到了该等级(Combat 战斗、Farming 耕种、Fishing 钓鱼、Foraging 采摘、Luck 运气或 Mining 采矿之一)。 |
Spouse <name>
|
当前玩家已与该内部名称的 NPC 结婚或订婚。 |
| SpouseBed | 当前玩家屋里有一张双人床(或者如果是室友,则为单人床)。但如果室友是科罗布斯,则永远不匹配。 |
Tile <x> <y>+
|
当前玩家正站在给定的地块位置之一(可指定多个 x/y 位置)。 |
主机玩家
这些检查主机玩家(运行多人游戏农场的玩家,不一定是当前玩家)。在单人游戏中,这始终是当前玩家。
| 名称与参数 | 描述 |
|---|---|
| CommunityCenterOrWarehouseDone | 社区中心或 Joja 仓库已完工。 |
DaysPlayed <number>
|
主机玩家已玩天数至少达到该数值。 |
HostMail <letter ID>
|
主机玩家已收到指定的信件。 |
HostOrLocalMail <letter ID>
|
主机玩家或当前玩家其中之一已收到指定的信件。 |
| IsHost | 当前玩家是主机玩家。 |
| JojaBundlesDone | 所有 Joja 组合已完工。 |
已弃用内容
此处省略了部分已弃用的别名和条件(详见英文原页面),建议在编写新事件时使用上述现代语法。
事件脚本
基本格式
每个事件的值即为事件脚本。它规定了事件中发生的一切——从光效、音乐到 NPC 的移动和对话。脚本由多个斜杠 (/) 分隔的命令组成。事件命令支持引号,因此你可以在参数中使用空格和斜杠,例如 speak Penny \"I'm running A/B tests\",而无需转义它们(引号本身仍需转义)。
每条脚本必须以前三个特定顺序的命令开始:
| 索引 | 语法 | 描述 |
|---|---|---|
| 0 | <music ID>
|
事件期间播放的背景音乐或环境音。可以是:
稍后可以使用 |
| 1 | <x> <y>
|
事件开始时摄像头应对准的地块坐标。 |
| 2 | [<character ID> <x> <y> <direction>]+
|
初始化一个或多个角色的起始地块位置和方向。角色 ID 可以是 farmer 或 NPC 名字如 Abigail。注意:与带有 <direction> 参数的其他命令不同,此命令中的方向“必须”是数值。
|
这三个命令之后可以跟随以下任何命令序列:
| 命令 | 描述 |
|---|---|
action <action>
|
运行一个触发器动作字符串,例如 action AddMoney 500 为当前玩家增加 |
addItem <item ID> [count] [quality]
|
向玩家物品栏添加物品(如果物品栏已满,则打开抓取菜单)。<item ID> 是限定或非限定物品 ID,[quality] 是数值质量值。
|
addQuest <quest ID>
|
向任务日志添加指定任务。 |
advancedMove <actor> <loop> <x y>... 或 <direction duration>
|
为角色设置多个移动步骤。 |
animate <actor> <flip> <loop> <frame duration> <frames...>
|
为指定角色播放动画。 |
emote <actor> <emote ID> [continue]
|
让指定 NPC 显示表情气泡。 |
| end | 渐隐并结束事件。 |
fork [req] <event ID>
|
如果满足 [req] 条件,则跳转到另一个事件脚本分支。
|
pause <duration>
|
暂停游戏指定的毫秒数。 |
question fork<answer index> "<question>#<answer 0>#<answer 1>#..."
|
弹出带有选项的对话框,通常后跟 fork 命令处理结果。 |
speak <character> "<text>"
|
显示指定 NPC 的对话文本。 |
方向
在事件命令中使用 direction 参数时,请使用以下数值或不区分大小写的名称:
| 数值 | 名称 | 含义 |
|---|---|---|
| 0 | up | 向上看 |
| 1 | right | 向右看 |
| 2 | down | 向下看 |
| 3 | left | 向左看 |
常见值
表情 (Emotes)
“表情”是显示在 NPC 头部上方的动画图标气泡,用于表示情绪或反应。
| ID | 含义 |
|---|---|
| 8 | 问号 (questionMark) |
| 12 | 生气 (angry) |
| 16 | 感叹号 (exclamation) |
| 20 | 爱心 (heart) |
| 28 | 难过 (sad) |
| 32 | 高兴 (happy) |
| 60 | 脸红 (blush) |

沪公网安备 31011002002714 号