Skip to content

Action(行为)

Action 可以 实时改变游戏中的部分内容。

在 Hacknet Extension 中有两种方法使用 Action:

  • 通过 ConditionalAction
  • 通过 Faction

NOTE

ConditionalActions 与 Action 都可以被称为 Action。Hacknet.wiki 认为 Action 是 ConditionalActions 的一部分。为了以示区别,方便理解他们之间的关系,本章节均不会使用 Action 来代指 ConditionalActions。

Delay

部分可以被 Delay 的 Action 可以通过设置 DelayDelayHost 延迟执行。Hacknet 中 Action 的延迟执行需要借助 DelayHost 来实现。DelayHost 是任意一个拥有 FastActionHost Daemon 的 Node。DelayDelayHost皆为选填属性。

  • Delay?:float,延迟执行的时间。默认值为 0.0
  • DelayHost?:string,用于辅助延迟执行的 DelayHost。

Action AddIRCMessage 的 Delay 不需要 DelayHost,而是借助它的目标 Node 实现延迟执行。

除了 AddIRCMessage 的 Delay 小于 0 有特殊作用外,其他类型的 Action 的 Delay 小于等于 0 相当于立即执行。

示范中包含了 DelayDelayHost 的 Action 是可以延迟执行的 Action。 在此也使用 Delayable 作为能够被 Delay 的提示。

如果你想要延迟执行一个无法被 Delay 的 Action,你需要另写一个未被加载的 ConditionalActions 或使用 Faction 来实现。因为能延迟加载 ConditionalActions,所以能延迟执行其中的 Action。

所有 Action

LoadMission

xml
<LoadMission MissionName="Missions/MyMission.xml"/>

加载一个 Mission

AddConditionalActions Delayable

xml
<AddConditionalActions Filepath="Actions/NextAction.xml" DelayHost="delayNode" Delay="0"/>

加载 ConditionalActions。

  • Filepathstring,加载的 ConditionalActions 的文件路径。

RunFunction Delayable

xml
<RunFunction FunctionName="changeSong" FunctionValue="2" DelayHost="delayNode" Delay="1.0"/>

运行一个 Function

  • FunctionNamestring,Function 的名称。
  • FunctionValue?:string,Function 的参数。

参考:SARunFunction.cs

LaunchHackScript Delayable

xml
<LaunchHackScript Filepath="Scripts/HackerScript.txt" DelayHost="delayNode" Delay="0" SourceComp="SourceComp" TargetComp="TargetComp" RequireLogsOnSource="false" RequireSourceIntact="true"/>

执行 HackerScript。

  • Filepathstring,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( ConditionInstantly、不使用 Delay 或 Delay 时间为 0),会导致游戏内终端出现 NullReferenceException

具体使用详情见:(WIP)HackerScript

参考:SALaunchHackScript.cs

AddMissionToHubServer

xml
<AddMissionToHubServer MissionName="Missions/MyMission.xml" TargetComp="missionHub" AssignmentTag="Kaguya" StartsComplete="true"/>

将一个 Mission 添加到 MissionHub/DHS 的任务列表中。

  • MissionNamestring,Mission 的文件路径。
  • TargetCompstring,HubServer 的 Computer ID。
  • AssignmentTag?:string,分配Tag。如果是给 MissionHub 添加任务,用 "top" 就会使任务置顶。给 DHS 添加,就会提示分配给了谁。
  • StartsComplete?:bool,是否开始完成。默认值为 false

NOTE

MissionHub 是拥有 missionListingServermissionHubServer Daemon 的 Node,在游戏中作为“任务中心”。DHS 此处代指有 DHSDaemon Daemon 的 Node。

参考:SAAddMissionToHubServer.cs

RemoveMissionFromHubServer

xml
<RemoveMissionFromHubServer MissionFilepath="Missions/HubMission.xml" TargetComp="missionHub"/>

将一个 Mission 从 HubServer 移除

  • MissionFilepathstring,Mission 的文件路径。
  • TargetCompstring,HubServer 的 Computer ID。

NOTE

HubServer 是拥有 missionListingServer, missionHubServerDHSDaemon Daemon 的 Node,在游戏中作为“任务中心”。

参考:SARemoveMissionFromHubServer.cs

AddThreadToMissionBoard

xml
<AddThreadToMissionBoard ThreadFilepath="Docs/Thread.txt" TargetComp="elSec"/>

将一个 Thread 添加到 MessageBoard(虽然 Action 的名称里面是 MissionBoard)。MessageBoard 服务器是拥有 messageBoard Daemon 的 Node。

  • ThreadFilepathstring,Thread 的文件路径。
  • TargetCompstring,MessageBoard 服务器的 Computer ID。

参考:SAAddThreadToMissionBoard.cs

AddIRCMessage Delayable

xml
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">HI</AddIRCMessage>

将一条 IRC 消息发送到指定的 IRC 服务器。IRC 服务器是拥有 IRCDaemonDHSDaemon Daemon 的 Node。

  • Author?:string,消息的发送者。默认为 ""
  • TargetCompstring,IRC 服务器的 Computer ID。
  • Delay?:float,延迟执行的时间。默认值为 0.0
    • AddIRCMessage 不需要通过 DelayHost 延迟执行。
    • 小于 0 时将会给过去的时间添加 IRC 消息。
  • 内容:消息的内容。

IMPORTANT

内容 不能为空

消息内容支持添加附件。

添加 note 附件:

xml
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">!ATTACHMENT:note#%#Note Title#%#Note Content line1
Note line 2
Note line 3</AddIRCMessage>

添加 link 附件:

xml
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">!ATTACHMENT:link#%#enemyNode#%#123.123.123.123</AddIRCMessage>

添加 account 附件:

xml
<AddIRCMessage Author="Kaguya" TargetComp="ircNode" Delay="1">!ATTACHMENT:account#%#enemyNode#%#123.123.123.123#%#username#%#password</AddIRCMessage>

参考:SAAddIRCMessage.cs

AddAsset

xml
<AddAsset FileName="test" FileContents="test" TargetComp="playerComp" TargetFolderpath="home"/>

向目标 Node 添加一个 Asset

  • FileNamestring,Asset 的文件名。
  • FileContentsstring,Asset 的内容。无法换行。
  • TargetCompstring,目标 Node 的 Computer ID。
  • TargetFolderpathstring,目标 Node 的文件夹路径。

IMPORTANT

Hacknet 不会判断 FileNameFileContents 是否存在。FileNameFileContents 没填会导致 NullReferenceException

参考:SAAddAsset.cs

AppendToFile Delayable

xml
<AppendToFile TargetComp="companyWhitelist" TargetFolderpath="Whitelist" TargetFilename="list.txt" DelayHost="delayNode" Delay="0">#PLAYER_IP#</AppendToFile>

向文件追加内容。

  • TargetCompstring,目标 Node 的 Computer ID。
  • TargetFolderpathstring,目标文件的路径。
  • TargetFilenamestring,目标文件的文件名。
  • 内容:追加到文件的内容。

IMPORTANT

Hacknet 没有判断 TargetComp, TargetFolderpath, TargetFilename 是否存在。如果这些 attributes 不存在,会导致 NullReferenceException

参考:SAAppendToFile.cs

DeleteFile Delayable

xml
<DeleteFile TargetComp="playerComp" FilePath="home" FileName="deleteme.txt" DelayHost="delayNode" Delay="0"/>

删除文件。

  • TargetCompstring,目标 Node 的 Computer ID。
  • FilePathstring,文件路径。
  • FileNamestring,文件名。

IMPORTANT

FilePath 不填会导致 NullReferenceException

参考:SADeleteFile.cs

CopyAsset

xml
<CopyAsset DestFilePath="home" DestFileName="copycat.txt" DestComp="playerComp" SourceComp="assetNode" SourceFileName="source.txt" SourceFilePath="home/copy"/>

复制文件。

  • DestFilePathstring,目标文件路径。
  • DestFileName?:string,目标文件的文件名。默认用 SourceFileName 的值。
  • DestCompstring,目标 Node 的 Computer ID。
  • SourceCompstring,源 Node 的 Computer ID。
  • SourceFileNamestring,源文件的文件名。
  • SourceFilePathstring,源文件的路径。

参考:SACopyAsset.cs

KillExe Delayable

xml
<KillExe DelayHost="delayNode" Delay="0" ExeName="*"/>

结束指定进程。

  • ExeName?:string,进程名。默认值为 """""*" 都表示结束所有进程。

参考:SAKillExe.cs

CrashComputer Delayable

xml
<CrashComputer TargetComp="playerComp" CrashSource="enemyNode" DelayHost="delayNode" Delay="0"/>

使目标 Node 被 Forkbomb

  • TargetCompstring,目标 Node 的 Computer ID。
  • CrashSourcestring,攻击者 Node 的 Computer ID。

NOTE

其实 TargetCompCrashSource 都是选填,当 TargetComp 存在时 CrashSource 必填。不填 TargetComp 啥也不发生。

参考:SACrashComputer.cs

ChangeAlertIcon Delayable

xml
<ChangeAlertIcon Target="mainHub" Type="irchub" DelayHost="delayNode" Delay="0"/>

更改 AlertIcon(右上角的图标)以及其关联的 Node。

  • Targetstring,关联的 Node 的 Computer ID。
  • Type"mail" | "irc" | "irchub" | "board",AlertIcon 的类型,需要与关联的 Node 类型相同。默认值为 """" 表示不更改 AlertIcon。

类型与关联的 Node 所使用的 Daemon 的对应关系:

TypeDaemon
"mail"mailServer
"irc"IRCDaemon
"irchub"DHSDaemon
"board"messageBoard

IMPORTANT

Hacknet 没有判断 Target 是否存在。如果 Target 不存在,会导致 NullReferenceException

Hacknet 也没有判断 Type 类型是否与关联的 Node 类型相同。如果 Type 类型与关联的 Node 类型不同,可能会导致游戏内 AlertIcon 无法正常使用。

如果 ChangeAlertIcon 作为立即执行的 StartingActions( ConditionInstantly、不使用 Delay 或 Delay 时间为 0),会导致 NullReferenceException

参考:SAChangeAlertIcon.cs

ShowNode Delayable

xml
<ShowNode DelayHost="delayNode" Delay="0" Target="storageServer"/>

显示指定的 Node。

  • Targetstring,目标 Node 的 Computer ID。

参考:SAShowNode.cs

HideNode Delayable

xml
<HideNode DelayHost="delayNode" Delay="0" TargetComp="companySecurity"/>

隐藏指定的 Node。

  • TargetCompstring,目标 Node 的 Computer ID。

参考:SAHideNode.cs

HideAllNodes Delayable

xml
<HideAllNodes DelayHost="delayNode" Delay="0"/>

隐藏所有 Node。

参考:SAHideAllNodes.cs

SwitchToTheme Delayable

xml
<SwitchToTheme ThemePathOrName="Themes/ExampleTheme.xml" FlickerInDuration="2.0" DelayHost="delayNode" Delay="0"/>

切换到指定的主题,可以有新旧主题来回交替的闪烁效果。

  • ThemePathOrName?:string,主题的路径或名称。默认为默认主题。
  • FlickerInDuration?:float,主题切换时的闪烁时间。默认值为 2.0

主题名称见:(WIP)Theme.md

参考:SASwitchToTheme.cs

SetLock Delayable

xml
<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

xml
<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 效果。与紧急恢复模式下的相似效果互不干扰。

  • AlertTitlestring,提示标题。在 Hacknet 中显示的字体的小写字母是大学字母的左右翻转版本。
  • CompleteAction?:stringScreenBleed 结束后加载的 ConditionalActions 的文件路径。被 Action CancelScreenBleedEffect 取消时不会加载。
  • TotalDurationSeconds?:float,总持续时间(秒)。默认值为 200
  • 内容:左下角的提示内容。最多三行。

IMPORTANT

没填 AlertTitle 会导致游戏黑屏。

参考:SAScreenBleedEffect.cs

CancelScreenBleedEffect Delayable

xml
<CancelScreenBleedEffect DelayHost="delayNode" Delay="0"/>

取消 ScreenBleed 效果。

参考:SACancelScreenBleedEffect.cs

GivePlayerUserAccount Delayable

xml
<GivePlayerUserAccount DelayHost="delayNode" Delay="0" TargetComp="teamHub" Username="#PLAYERNAME#"/>

给予玩家某节点的账号。可以在登录页面直接使用。

  • TargetCompstring,目标 Node 的 Computer ID。
  • Usernamestring,用户名。

参考:SAGivePlayerUserAccount.cs

ChangeIP Delayable

xml
<ChangeIP  DelayHost="delayNode" Delay="0" TargetComp="finalNode" NewIP="123.123.123.123"/>

更改指定 Node 的 IP 地址。

  • TargetCompstring,目标 Node 的 Computer ID。
  • NewIP?:string,新的 IP 地址。如果不填、为空或者以#RANDOM开头,会随机生成一个 IP 地址。

参考:SAChangeIP.cs

SaveGame Delayable

xml
<SaveGame DelayHost="delayNode" Delay="0"/>

保存游戏。

参考:SASaveGame.cs

Documentation is licensed under the CC BY-NC-SA 4.0 License.
粤ICP备2026007027号-1