Action(行为)
Action 可以 实时改变游戏中的部分内容。
在 Hacknet Extension 中有两种方法使用 Action:
- 通过 ConditionalAction
- 通过 Faction
NOTE
ConditionalActions 与 Action 都可以被称为 Action。Hacknet.wiki 认为 Action 是 ConditionalActions 的一部分。为了以示区别,方便理解他们之间的关系,本章节均不会使用 Action 来代指 ConditionalActions。
Delay
部分可以被 Delay 的 Action 可以通过设置 Delay 和 DelayHost 延迟执行。Hacknet 中 Action 的延迟执行需要借助 DelayHost 来实现。DelayHost 是任意一个拥有 FastActionHost Daemon 的 Node。Delay 和 DelayHost皆为选填属性。
Delay?:float,延迟执行的时间。默认值为0.0。DelayHost?:string,用于辅助延迟执行的 DelayHost。
Action AddIRCMessage 的 Delay 不需要 DelayHost,而是借助它的目标 Node 实现延迟执行。
除了 AddIRCMessage 的 Delay 小于 0 有特殊作用外,其他类型的 Action 的 Delay 小于等于 0 相当于立即执行。
示范中包含了 Delay 和 DelayHost 的 Action 是可以延迟执行的 Action。 在此也使用 Delayable 作为能够被 Delay 的提示。
如果你想要延迟执行一个无法被 Delay 的 Action,你需要另写一个未被加载的 ConditionalActions 或使用 Faction 来实现。因为能延迟加载 ConditionalActions,所以能延迟执行其中的 Action。
所有 Action
LoadMission
<LoadMission MissionName="Missions/MyMission.xml"/>加载一个 Mission
MissionName:string,Mission 的路径。 参考:SALoadMission.cs
AddConditionalActions Delayable
<AddConditionalActions Filepath="Actions/NextAction.xml" DelayHost="delayNode" Delay="0"/>加载 ConditionalActions。
Filepath:string,加载的 ConditionalActions 的文件路径。
RunFunction Delayable
<RunFunction FunctionName="changeSong" FunctionValue="2" DelayHost="delayNode" Delay="1.0"/>运行一个 Function
FunctionName:string,Function 的名称。FunctionValue?:string,Function 的参数。
LaunchHackScript Delayable
<LaunchHackScript Filepath="Scripts/HackerScript.txt" DelayHost="delayNode" Delay="0" SourceComp="SourceComp" TargetComp="TargetComp" RequireLogsOnSource="false" RequireSourceIntact="true"/>执行 HackerScript。
Filepath:string,HackerScript 文件的路径。SourceComp?:string,攻击源 Node 的 Computer ID。TargetComp?:string,目标 Node 的 Computer ID。RequireLogsOnSource?:bool,目标 Node 是否需要在攻击源节点上留下日志。默认值为false。RequireSourceIntact?:bool,攻击源 Node 系统文件netcfgx.dll是否需要完好无损。默认值为false。
IMPORTANT
选填项的选填规则较为特殊。详情见:(WIP)HackerScript
当 HackerScript 作为立即执行的 StartingActions( Condition 为 Instantly、不使用 Delay 或 Delay 时间为 0),会导致游戏内终端出现 NullReferenceException。
具体使用详情见:(WIP)HackerScript
AddMissionToHubServer
<AddMissionToHubServer MissionName="Missions/MyMission.xml" TargetComp="missionHub" AssignmentTag="Kaguya" StartsComplete="true"/>将一个 Mission 添加到 MissionHub/DHS 的任务列表中。
MissionName:string,Mission 的文件路径。TargetComp:string,HubServer 的 Computer ID。AssignmentTag?:string,分配Tag。如果是给 MissionHub 添加任务,用"top"就会使任务置顶。给 DHS 添加,就会提示分配给了谁。StartsComplete?:bool,是否开始完成。默认值为false。
NOTE
MissionHub 是拥有 missionListingServer 或 missionHubServer Daemon 的 Node,在游戏中作为“任务中心”。DHS 此处代指有 DHSDaemon Daemon 的 Node。
RemoveMissionFromHubServer
<RemoveMissionFromHubServer MissionFilepath="Missions/HubMission.xml" TargetComp="missionHub"/>将一个 Mission 从 HubServer 移除
MissionFilepath:string,Mission 的文件路径。TargetComp:string,HubServer 的 Computer ID。
NOTE
HubServer 是拥有 missionListingServer, missionHubServer 或 DHSDaemon Daemon 的 Node,在游戏中作为“任务中心”。
参考:SARemoveMissionFromHubServer.cs
AddThreadToMissionBoard
<AddThreadToMissionBoard ThreadFilepath="Docs/Thread.txt" TargetComp="elSec"/>将一个 Thread 添加到 MessageBoard(虽然 Action 的名称里面是 MissionBoard)。MessageBoard 服务器是拥有 messageBoard Daemon 的 Node。
ThreadFilepath:string,Thread 的文件路径。TargetComp:string,MessageBoard 服务器的 Computer ID。
参考:SAAddThreadToMissionBoard.cs
AddIRCMessage Delayable
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">HI</AddIRCMessage>将一条 IRC 消息发送到指定的 IRC 服务器。IRC 服务器是拥有 IRCDaemon 或 DHSDaemon Daemon 的 Node。
Author?:string,消息的发送者。默认为""。TargetComp:string,IRC 服务器的 Computer ID。Delay?:float,延迟执行的时间。默认值为0.0。- AddIRCMessage 不需要通过
DelayHost延迟执行。 - 小于
0时将会给过去的时间添加 IRC 消息。
- AddIRCMessage 不需要通过
- 内容:消息的内容。
IMPORTANT
内容 不能为空
消息内容支持添加附件。
添加 note 附件:
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">!ATTACHMENT:note#%#Note Title#%#Note Content line1
Note line 2
Note line 3</AddIRCMessage>添加 link 附件:
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">!ATTACHMENT:link#%#enemyNode#%#123.123.123.123</AddIRCMessage>添加 account 附件:
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">!ATTACHMENT:account#%#enemyNode#%#123.123.123.123#%#username#%#password</AddIRCMessage>AddAsset
<AddAsset FileName="test" FileContents="test" TargetComp="playerComp" TargetFolderpath="home"/>向目标 Node 添加一个 Asset
FileName:string,Asset 的文件名。FileContents:string,Asset 的内容。无法换行。TargetComp:string,目标 Node 的 Computer ID。TargetFolderpath:string,目标 Node 的文件夹路径。
IMPORTANT
Hacknet 不会判断 FileName 或 FileContents 是否存在。FileName 或 FileContents 没填会导致 NullReferenceException。
AppendToFile Delayable
<AppendToFile TargetComp="companyWhitelist" TargetFolderpath="Whitelist" TargetFilename="list.txt" DelayHost="delayNode" Delay="0">#PLAYER_IP#</AppendToFile>向文件追加内容。
TargetComp:string,目标 Node 的 Computer ID。TargetFolderpath:string,目标文件的路径。TargetFilename:string,目标文件的文件名。- 内容:追加到文件的内容。
IMPORTANT
Hacknet 没有判断 TargetComp, TargetFolderpath, TargetFilename 是否存在。如果这些 attributes 不存在,会导致 NullReferenceException。
DeleteFile Delayable
<DeleteFile TargetComp="playerComp" FilePath="home" FileName="deleteme.txt" DelayHost="delayNode" Delay="0"/>删除文件。
TargetComp:string,目标 Node 的 Computer ID。FilePath:string,文件路径。FileName:string,文件名。
IMPORTANT
FilePath 不填会导致 NullReferenceException。
CopyAsset
<CopyAsset DestFilePath="home" DestFileName="copycat.txt" DestComp="playerComp" SourceComp="assetNode" SourceFileName="source.txt" SourceFilePath="home/copy"/>复制文件。
DestFilePath:string,目标文件路径。DestFileName?:string,目标文件的文件名。默认用SourceFileName的值。DestComp:string,目标 Node 的 Computer ID。SourceComp:string,源 Node 的 Computer ID。SourceFileName:string,源文件的文件名。SourceFilePath:string,源文件的路径。
KillExe Delayable
<KillExe DelayHost="delayNode" Delay="0" ExeName="*"/>结束指定进程。
ExeName?:string,进程名。默认值为""。""和"*"都表示结束所有进程。
参考:SAKillExe.cs
CrashComputer Delayable
<CrashComputer TargetComp="playerComp" CrashSource="enemyNode" DelayHost="delayNode" Delay="0"/>使目标 Node 被 Forkbomb
TargetComp:string,目标 Node 的 Computer ID。CrashSource:string,攻击者 Node 的 Computer ID。
NOTE
其实 TargetComp 和 CrashSource 都是选填,当 TargetComp 存在时 CrashSource 必填。不填 TargetComp 啥也不发生。
ChangeAlertIcon Delayable
<ChangeAlertIcon Target="mainHub" Type="irchub" DelayHost="delayNode" Delay="0"/>更改 AlertIcon(右上角的图标)以及其关联的 Node。
Target:string,关联的 Node 的 Computer ID。Type:"mail" | "irc" | "irchub" | "board",AlertIcon 的类型,需要与关联的 Node 类型相同。默认值为""。""表示不更改 AlertIcon。
类型与关联的 Node 所使用的 Daemon 的对应关系:
| Type | Daemon |
|---|---|
"mail" | mailServer |
"irc" | IRCDaemon |
"irchub" | DHSDaemon |
"board" | messageBoard |
IMPORTANT
Hacknet 没有判断 Target 是否存在。如果 Target 不存在,会导致 NullReferenceException。
Hacknet 也没有判断 Type 类型是否与关联的 Node 类型相同。如果 Type 类型与关联的 Node 类型不同,可能会导致游戏内 AlertIcon 无法正常使用。
如果 ChangeAlertIcon 作为立即执行的 StartingActions( Condition 为 Instantly、不使用 Delay 或 Delay 时间为 0),会导致 NullReferenceException。
ShowNode Delayable
<ShowNode DelayHost="delayNode" Delay="0" Target="storageServer"/>显示指定的 Node。
Target:string,目标 Node 的 Computer ID。
HideNode Delayable
<HideNode DelayHost="delayNode" Delay="0" TargetComp="companySecurity"/>隐藏指定的 Node。
TargetComp:string,目标 Node 的 Computer ID。
HideAllNodes Delayable
<HideAllNodes DelayHost="delayNode" Delay="0"/>隐藏所有 Node。
SwitchToTheme Delayable
<SwitchToTheme ThemePathOrName="Themes/ExampleTheme.xml" FlickerInDuration="2.0" DelayHost="delayNode" Delay="0"/>切换到指定的主题,可以有新旧主题来回交替的闪烁效果。
ThemePathOrName?:string,主题的路径或名称。默认为默认主题。FlickerInDuration?:float,主题切换时的闪烁时间。默认值为2.0。
主题名称见:(WIP)Theme.md
SetLock Delayable
<SetLock DelayHost="delayNode" Delay="0" Module="terminal" IsLocked="true" IsHidden="false"/>设置 Hacknet 指定 UI 模块的锁定状态。
Module:"terminal" | "ram" | "netmap" | "display",模块名。IsLocked?:bool,是否锁定。默认值为false。IsHidden?:bool,是否隐藏。默认值为false。
参考:SASetLock.cs
StartScreenBleedEffect Delayable
<StartScreenBleedEffect AlertTitle="Sequencer Attack" CompleteAction="Actions/ScreenBleedFailed.xml" TotalDurationSeconds="200" DelayHost="delayNode" Delay="0">Break into the Moonshine servers
Delete all files and backups
Get out of there!</StartScreenBleedEffect>开始 ScreenBleed 效果。与紧急恢复模式下的相似效果互不干扰。
AlertTitle:string,提示标题。在 Hacknet 中显示的字体的小写字母是大学字母的左右翻转版本。CompleteAction?:string,ScreenBleed结束后加载的 ConditionalActions 的文件路径。被 ActionCancelScreenBleedEffect取消时不会加载。TotalDurationSeconds?:float,总持续时间(秒)。默认值为200。- 内容:左下角的提示内容。最多三行。
IMPORTANT
没填 AlertTitle 会导致游戏黑屏。
CancelScreenBleedEffect Delayable
<CancelScreenBleedEffect DelayHost="delayNode" Delay="0"/>取消 ScreenBleed 效果。
参考:SACancelScreenBleedEffect.cs
GivePlayerUserAccount Delayable
<GivePlayerUserAccount DelayHost="delayNode" Delay="0" TargetComp="teamHub" Username="#PLAYERNAME#"/>给予玩家某节点的账号。可以在登录页面直接使用。
TargetComp:string,目标 Node 的 Computer ID。Username:string,用户名。
ChangeIP Delayable
<ChangeIP DelayHost="delayNode" Delay="0" TargetComp="finalNode" NewIP="123.123.123.123"/>更改指定 Node 的 IP 地址。
TargetComp:string,目标 Node 的 Computer ID。NewIP?:string,新的 IP 地址。如果不填、为空或者以#RANDOM开头,会随机生成一个 IP 地址。
SaveGame Delayable
<SaveGame DelayHost="delayNode" Delay="0"/>保存游戏。