EnhancedEnemies: GoToJail execute command is retired
Mod: EnhancedEnemies by Art024 (CurseForge ID 1772899, EnhancedNemesis_445A0EB4)
What happens
The GoToJail execute command has been retired, so the mod's Lua override is no longer supported. The game's Lua check reports this error for the mod:
> Lua Script Error
* Lua diagnostic error: Lua function 'B2Script_Crime:Override_Execute_GoToJail' is defined but not exported by C++.
As a result, the stalking-report and jail-confirmation events routed through that override stop working. The revised mod requires a game version that provides Execute_RequestImprisonment and does not work on older versions that lack it.
Why
The migration described here covers the mod's use of GoToJail to carry its own events:
- In
non_ufs/JsonPatch/Script_Interaction_patch.autosave.json, the affected executes use"Command": "GoToJail"with S1 set toEN_ReportStalkingBegin,EN_ReportStalking, orEN_JailTransportFinished. lua/B2/Scripts/B2Script_Crime.luaoverridesExecute_GoToJail. It handles theEN_*tokens and passes everything else toinzoi.FB2Script_Crime.Execute_GoToJail.
The GoToJail execute command is retired:
Execute_GoToJailno longer exists, soOverride_Execute_GoToJailno longer overrides anything.- Data validation rejects
"Command": "GoToJail", and the game no longer runs that command even if validation is skipped, so it never reaches the old Lua override. inzoi.FB2Script_Crime.Execute_GoToJailisnil. Calling it raises a Lua error.
The prison system now exposes separate commands for requesting transport, confirming a sentence, and ending custody:
| Command | Purpose |
|---|---|
RequestImprisonment | Requests jail transport for the BaseObject Zoi through an interaction. It does not mean that transport has already completed. |
ConfirmPrisonSentence | Confirms the prison term from a trial verdict. F1 is the term in days and must be greater than 0. |
ReleaseFromPrison | Ends the prison stay. Leave S1 empty where an interaction already handles leaving the cell; use SendOutside to request release with movement outside. |
The GoToJail action and the transport interaction remain. However, jail-arrival effects are now applied by the game itself instead of by data scripts, and prison buffs follow the Zoi's prison status. Keeping the action does not guarantee that a mod's assumptions about arrival, sentence buffs, or release remain valid. Step 3 below covers the arrival scripts that no longer run.
How to fix
To preserve this mod's existing event-routing approach, move the affected executes and their Lua override to RequestImprisonment together. The native command neither validates nor uses S1, so the override can continue to use the existing EN_* tokens.
This use of S1 is outside the command's documented parameters, which leave S1 empty (S1/S2=None), and RequestImprisonment is not a custom-event API. It works only because the override intercepts the tokens before the native command runs, and it can stop working if S1 validation is added for this command. Keep each token's existing handler and return behavior so a mod event does not fall through to native imprisonment.
The native commands are not behaviorally equivalent. The old GoToJail command used F1 as a delay in in-game minutes: zero, nearly zero, or negative values attempted the jail transfer right away; other positive values scheduled it for that many in-game minutes later. RequestImprisonment requests the transport interaction and does not preserve that F1 delay. A request can be deferred or blocked; do not treat the call returning as proof of arrival. These differences matter for calls passed to the native function, including any additional GoToJail uses you find in the mod.
1. Update the two stalking-event executes
In non_ufs/JsonPatch/Script_Interaction_patch.autosave.json, change the Command field only on the executes carrying EN_ReportStalkingBegin and EN_ReportStalking:
"Command": "RequestImprisonment"
This is a field edit inside each existing JSON object, not a complete replacement JSON document. Preserve the surrounding JSON syntax and all other fields, including the two S1 tokens.
Handle EN_JailTransportFinished separately in step 3: remove its existing connection and recreate it at the successful-action-completion point. Do not keep its old connection by only renaming the command.
2. Lua override
In lua/B2/Scripts/B2Script_Crime.lua, make these two name changes in the existing function:
| Location | Before | After |
|---|---|---|
| Override declaration | Script.Override_Execute_GoToJail | Script.Override_Execute_RequestImprisonment |
| Native call in the pass-through branch | inzoi.FB2Script_Crime.Execute_GoToJail | inzoi.FB2Script_Crime.Execute_RequestImprisonment |
Keep the existing parameters and arguments (context, execute), the entire handler bodies for all three EN_* tokens, and their return behavior. Only the two function names change in this step. Do not replace the function with a skeleton or remove its event-handling code.
Keep the pass-through branch for non-mod calls. The base game uses RequestImprisonment, including on arrest-card branches where bail is refused, and those calls must still reach the native function.
3. Move EN_JailTransportFinished to the jail action's successful completion
Previously, every jail arrival ran these five scripts:
AddBuff_Prison_Day1ChangeOutfit_PrisonerFinish_Change_Costume_Detach_BagsRemoveTodayTimelineAddFamilyMonitoringNotification_Prison
Jail arrival no longer runs any of them; the game applies the arrival effects itself. AddBuff_Prison_Day1, ChangeOutfit_Prisoner, and AddFamilyMonitoringNotification_Prison have also been removed from Script_Interaction.json.
Use FinishScriptIdList on the GoToJail action entry in these two Action records:
| Table | Data file | Record Id | Field |
|---|---|---|---|
Action | Action_Interaction.json | TeleportToPrison | Actions[Command=GoToJail].FinishScriptIdList |
Action | Action_Interaction.json | TeleportToPrison_Pos2 | Actions[Command=GoToJail].FinishScriptIdList |
The first record is reached through [InteractionBag] Next_Self_GotoPrison; the second is reached through [InteractionBag] Next_Self_GotoPrison_pos2. Connect both to cover both transport routes. Keep the action's Command as GoToJail.
This is a success-only connection: the GoToJail action finishes only after the Zoi has been moved into jail and arrival has been processed, and FinishScriptIdList runs only when the action finishes successfully. A failed transfer cancels the interaction instead, and cancellation does not run this list. Do not use StartScriptIdList, CancelScriptIdList, or the imprisonment request itself as an arrival notification.
Add a dedicated notification Script
The following example introduces a new [Script] EN_NotifyJailTransportFinished record. Add this patch object once to the existing PatchList in non_ufs/JsonPatch/Script_Interaction_patch.autosave.json (whose Struct is Script). Preserve the descriptor's other patches and metadata.
{
"Method": "Append",
"Query": "Script_Interaction",
"Value": {
"Id": "EN_NotifyJailTransportFinished",
"Comment": "Notify EnhancedEnemies after successful jail transport",
"Scripts": [
{
"IfType": "If",
"Conditions": [],
"Executes": [
{
"BaseObject": "Self",
"Command": "RequestImprisonment",
"S1": "EN_JailTransportFinished",
"S2": "None",
"F1": 0.0,
"F2": 0.0,
"Prob": 1.0
}
]
}
]
}
}
This Script only forwards the event to the renamed Lua override. It must not replay the old game scripts that granted prison buffs, changed outfits, or removed the timeline; the game already handles those effects.
In this finish script, Self is the transported Zoi, as it was in the old arrival scripts. Unlike those scripts, it can also have an interaction Target; do not interpret that Target as the reporting Zoi. Keep the existing EN_JailTransportFinished handler and its pending-report checks. It must ignore unrelated prisoners and return without calling native Execute_RequestImprisonment for this token, or the notification can request another transport. If the original event injection had mod-specific Conditions, carry those conditions into this new Script as well; the empty list above relies on the Lua handler to filter the event.
Append the Script Id to both Action entries
Create non_ufs/JsonPatch/Action_Interaction_patch.autosave.json with the descriptor below. If the mod already has an Action_Interaction patch file, merge these two objects into its existing PatchList and keep its metadata and other patches. Add each reference only once.
{
"Struct": "Action",
"PatchList": [
{
"Method": "Append",
"Query": "Action_Interaction[Id=TeleportToPrison].Actions[Command=GoToJail].FinishScriptIdList",
"Value": "EN_NotifyJailTransportFinished"
},
{
"Method": "Append",
"Query": "Action_Interaction[Id=TeleportToPrison_Pos2].Actions[Command=GoToJail].FinishScriptIdList",
"Value": "EN_NotifyJailTransportFinished"
}
]
}
Append takes a single value here: use the Script Id string, not an array containing it. This preserves any existing finish scripts. Each checked record has one GoToJail action entry; the query selects that entry by its command instead of assuming an array index.
Find and remove the previous EN_JailTransportFinished connection wherever the mod placed it. It may be attached to one of the retired arrival scripts or to a script that still runs from the transport interaction. Either way, move the notification to the Action finish lists above and remove the old injection to avoid duplicate notifications. If a patch operation also contains unrelated changes, rewrite it to retain only the still-valid changes and preserve any mod-specific event conditions in the new notification Script.
If an old patch operation targets a removed record, remove that operation entirely or move its still-needed changes to a valid target. Merely renaming its execute command does not fix the missing target. One failing patch is a mod-wide data-patch error, not just a missed arrival notification: the game reports a data patch error for the mod and skips its remaining patches, so the stalking-report patches in the same file can fail to apply as well. Do not leave a failing old operation alongside the new patches or recreate the removed game scripts to make it apply. Check the final patched data for one notification reference per action entry.
This hook covers successful completion of the two Action transport routes above; for the game version covered by this guide, DLC data adds no other GoToJail action. It is not a universal prison-status notification: a transfer that does not go through these actions, such as a delayed jail transfer created by the old GoToJail command in an older save, does not run this list. It can also run on a successful repeat transport, so retain the mod's existing check that a jail confirmation is still pending.
4. Check remaining references and package the change
- Search the mod's Lua files and JsonPatch files for remaining
Override_Execute_GoToJail,Execute_GoToJail, and"Command": "GoToJail"references. Review each match in context: an execute command and an action can share the nameGoToJail. Do not rename action references as part of this migration. - Review any additional native calls for reliance on immediate teleportation or F1 delay. They need separate adaptation rather than a blind name replacement.
- Ship the Lua and JsonPatch changes together. If the new override is not loaded, an
EN_*execute can invoke nativeRequestImprisonmentinstead of the mod's event handler and request unintended jail transport. Condition_ImprisonmentCountand its Lua override hook remain.Override_Condition_ImprisonmentCountdoes not need renaming for this API migration.
Verify on the target game build
Check the edited package with the target build's Lua and data validation tools, then test it in-game. A clean validation result confirms neither event behavior nor successful transport.
| Check | Expected result |
|---|---|
| Load the revised mod and validate its Lua and data | No obsolete Override_Execute_GoToJail diagnostic, retired execute-command error, or missing patch-target error remains. The renamed override loads, and both the stalking-report patches and the new arrival patches apply. |
| Start and complete a stalking report | Both EN_ReportStalkingBegin and EN_ReportStalking retain their existing behavior, without unintended jail transport for the reporting Zoi. |
| Complete transport through each patched Action record | The new Script runs once per successful action completion, after the Zoi has arrived. The intended pending jail confirmation in Prison.lua completes. |
| Cancel transport before arrival, or encounter a transfer failure | No arrival notification is emitted by the finish-script connection. A deferred imprisonment request emits none until an actual transport action succeeds. |
| Transport a Zoi with no pending EnhancedEnemies jail confirmation, or repeat a completed transport | The handler ignores an unrelated or already-completed confirmation and does not request another transport. |
| Exercise a base-game arrest-card branch that requests imprisonment | The non-mod call reaches native imprisonment through the pass-through branch; the override does not swallow it. |
| Follow the applicable sentencing and release flow | Sentence confirmation and release agree with the Zoi's prison status. Inspect any mod code that adds or removes prison buffs directly; those buffs alone no longer establish or clear custody. |
Run all of these checks before claiming full compatibility, and record the tested game build and mod version with the results.