Skip to content

Instantly share code, notes, and snippets.

@Roms1383
Last active May 9, 2024 19:31
Show Gist options
  • Save Roms1383/52648c867948a01d472bcc19b6232ef2 to your computer and use it in GitHub Desktop.
Save Roms1383/52648c867948a01d472bcc19b6232ef2 to your computer and use it in GitHub Desktop.
Lifecycle 2.12a
module Audioware
public static func E(msg: String) -> Void { ModLog(n"🌱", AsRef(msg)); }
public static func F(msg: String) -> Void { E(s"[ERROR] \(msg)"); }
public static func D(msg: String, self: wref<IScriptable>) -> Void { E(s"[\(ToString(self.GetClassName()))] \(msg)"); }
public abstract class CoreScriptableService extends ScriptableService {
private cb func OnLoad() { D("on load", this); }
private cb func OnReload() { D("on reload", this); }
private cb func OnInitialize() {
D("on initialize", this);
GameInstance.GetCallbackSystem().RegisterCallback(n"Session/BeforeStart", this, n"OnBeforeStart");
GameInstance.GetCallbackSystem().RegisterCallback(n"Session/Start", this, n"OnStart");
GameInstance.GetCallbackSystem().RegisterCallback(n"Session/Ready", this, n"OnReady");
GameInstance.GetCallbackSystem().RegisterCallback(n"Session/BeforeEnd", this, n"OnBeforeEnd");
GameInstance.GetCallbackSystem().RegisterCallback(n"Session/End", this, n"OnEnd");
}
private cb func OnUninitialize() {
D("on uninitialize", this);
GameInstance.GetCallbackSystem().UnregisterCallback(n"Session/BeforeStart", this, n"OnBeforeStart");
GameInstance.GetCallbackSystem().UnregisterCallback(n"Session/Start", this, n"OnStart");
GameInstance.GetCallbackSystem().UnregisterCallback(n"Session/Ready", this, n"OnReady");
GameInstance.GetCallbackSystem().UnregisterCallback(n"Session/BeforeEnd", this, n"OnBeforeEnd");
GameInstance.GetCallbackSystem().UnregisterCallback(n"Session/End", this, n"OnEnd");
}
private cb func OnBeforeStart(event: ref<GameSessionEvent>) { D("on before start", this); }
private cb func OnStart(event: ref<GameSessionEvent>) { D("on start", this); }
private cb func OnReady(event: ref<GameSessionEvent>) { D("on ready", this); }
private cb func OnBeforeEnd(event: ref<GameSessionEvent>) { D("on before end", this); }
private cb func OnEnd(event: ref<GameSessionEvent>) { D("on end", this); }
}
public abstract class CoreScriptableSystem extends ScriptableSystem {
private func OnAttach() { D("on attach", this); }
private func OnDetach() { D("on detach", this); }
private func OnRestored(s: Int32, g: Int32) { D("on restored", this); }
private final func OnPlayerAttach(request: ref<PlayerAttachRequest>) {
if IsDefined(request.owner) {
let player: ref<PlayerPuppet> = GameInstance
.GetPlayerSystem(request.owner.GetGame())
.GetLocalPlayerMainGameObject() as PlayerPuppet;
if IsDefined(player) { D("on player attach (both defined)", this); }
else { D("on player attach (only owner defined)", this); }
} else { D("on player attach (undefined)", this); }
}
private final func OnPlayerDetach(request: ref<PlayerDetachRequest>) {
let player: ref<PlayerPuppet> = request.owner as PlayerPuppet;
if IsDefined(player) { D("on player detach (defined)", this); }
else { D("on player detach (undefined)", this); }
}
}

Lifecycle for 2.12a

Demo: video on YouTube

[2024-05-09 20:22:52 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on load
[2024-05-09 20:23:11 UTC+07:00] [27608] [🌱] [Audioware.AudioEngine] on initialize
[2024-05-09 20:23:12 UTC+07:00] [21472] [🌱] [Audioware.AudioEngine] on before start
[2024-05-09 20:23:12 UTC+07:00] [26060] [🌱] [Audioware.Audioware] on attach
[2024-05-09 20:23:12 UTC+07:00] [28236] [🌱] [Audioware.AudioEngine] on start
[2024-05-09 20:23:12 UTC+07:00] [28236] LuaVM: initialization finished!
[2024-05-09 20:23:12 UTC+07:00] [28236] [🌱] [Audioware.AudioEngine] on ready
[2024-05-09 20:23:35 UTC+07:00] [10428] [🌱] [Audioware.Audioware] on player attach (both defined)
[2024-05-09 20:23:52 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on before end
[2024-05-09 20:23:52 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on detach
[2024-05-09 20:23:52 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on end
[2024-05-09 20:23:52 UTC+07:00] [25952] [🌱] [Audioware.AudioEngine] on before start
[2024-05-09 20:23:53 UTC+07:00] [27608] [🌱] [Audioware.Audioware] on attach
[2024-05-09 20:23:55 UTC+07:00] [27132] [🌱] [Audioware.AudioEngine] on start
[2024-05-09 20:24:01 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on ready
[2024-05-09 20:24:01 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on restored
[2024-05-09 20:24:12 UTC+07:00] [16868] [🌱] [Audioware.Audioware] on player attach (both defined)
[2024-05-09 20:24:30 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on before end
[2024-05-09 20:24:30 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on detach
[2024-05-09 20:24:30 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on end
[2024-05-09 20:24:31 UTC+07:00] [25844] [🌱] [Audioware.AudioEngine] on before start
[2024-05-09 20:24:31 UTC+07:00] [4660]  [🌱] [Audioware.Audioware] on attach
[2024-05-09 20:24:34 UTC+07:00] [21784] [🌱] [Audioware.AudioEngine] on start
[2024-05-09 20:24:39 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on ready
[2024-05-09 20:24:39 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on restored
[2024-05-09 20:24:46 UTC+07:00] [25844] [🌱] [Audioware.Audioware] on player attach (both defined)
[2024-05-09 20:24:56 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on before end
[2024-05-09 20:24:57 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on detach
[2024-05-09 20:24:57 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on end
[2024-05-09 20:24:57 UTC+07:00] [10428] [🌱] [Audioware.AudioEngine] on before start
[2024-05-09 20:24:57 UTC+07:00] [26060] [🌱] [Audioware.Audioware] on attach
[2024-05-09 20:24:57 UTC+07:00] [4660]  [🌱] [Audioware.AudioEngine] on start
[2024-05-09 20:24:57 UTC+07:00] [27608] [🌱] [Audioware.AudioEngine] on ready
[2024-05-09 20:25:07 UTC+07:00] [10428] [🌱] [Audioware.Audioware] on player attach (both defined)
[2024-05-09 20:25:25 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on before end
[2024-05-09 20:25:25 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on detach
[2024-05-09 20:25:25 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on end
[2024-05-09 20:25:25 UTC+07:00] [13740] [🌱] [Audioware.AudioEngine] on before start
[2024-05-09 20:25:26 UTC+07:00] [28028] [🌱] [Audioware.Audioware] on attach
[2024-05-09 20:25:28 UTC+07:00] [27132] [🌱] [Audioware.AudioEngine] on start
[2024-05-09 20:25:34 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on ready
[2024-05-09 20:25:34 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on restored
[2024-05-09 20:25:40 UTC+07:00] [27132] [🌱] [Audioware.Audioware] on player attach (both defined)
[2024-05-09 20:25:55 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on before end
[2024-05-09 20:25:55 UTC+07:00] [10732] [🌱] [Audioware.Audioware] on detach
[2024-05-09 20:25:55 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on end
[2024-05-09 20:25:56 UTC+07:00] [10732] [🌱] [Audioware.AudioEngine] on uninitialize
[2024-05-09 20:25:56 UTC+07:00] [10732] [Codeware] ButtonHintsManager::OnUninitialize
module Audioware
public class AudioEngine extends CoreScriptableService {}
module Audioware
public class Audioware extends CoreScriptableSystem {}
@Roms1383
Copy link
Author

Roms1383 commented May 9, 2024

Following test to locate Rust plugin lifecycle:

audioware logs

note: in this sample, Addicted and Remark (test) are loaded

[2024-05-10 02:28:20.996] [audioware] [info] on register audioware
[2024-05-10 02:28:22.116] [audioware] [info] finished setup
[2024-05-10 02:28:22.116] [audioware] [warning] Registering 'Audioware.UpdateEngineState' has partially failed: failed to bind arguments at indexes: 0, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.116] [audioware] [warning] Registering 'Audioware.UpdateEngineLocale' has partially failed: failed to bind arguments at indexes: 0 1, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.123] [audioware] [warning] Registering 'Audioware.UpdateEngineGender' has partially failed: failed to bind arguments at indexes: 0, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.123] [audioware] [warning] Registering 'Audioware.DefineEngineSubtitles' has partially failed: failed to bind arguments at indexes: 0, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.123] [audioware] [warning] Registering 'Audioware.GetReactionDuration' has partially failed: failed to bind arguments at indexes: 0, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.123] [audioware] [warning] Registering 'Audioware.UpdatePlayerPreset' has partially failed: failed to bind arguments at indexes: 0, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.123] [audioware] [warning] Registering 'Audioware.PlayOverThePhone' has partially failed: failed to bind arguments at indexes: 0 1, this is only an issue if you don't define this function in redscript
[2024-05-10 02:28:22.151] [audioware] [info] on post register audioware
[2024-05-10 02:28:22.152] [audioware] [info] base address:       0x7FF7EE000000
[2024-05-10 02:28:22.152] [audioware] [info] relative address:   0x974F58
[2024-05-10 02:28:22.152] [audioware] [info] calculated address: 0x7FF7EE974F58
[2024-05-10 02:28:22.152] [audioware] [info] base address:       0x7FF7EE000000
[2024-05-10 02:28:22.152] [audioware] [info] relative address:   0x24503C8
[2024-05-10 02:28:22.152] [audioware] [info] calculated address: 0x7FF7F04503C8
[2024-05-10 02:28:22.153] [audioware] [info] base address:       0x7FF7EE000000
[2024-05-10 02:28:22.153] [audioware] [info] relative address:   0x291688
[2024-05-10 02:28:22.153] [audioware] [info] calculated address: 0x7FF7EE291688
[2024-05-10 02:29:26.006] [audioware] [info] updated preset successfully to no preset
[2024-05-10 02:29:26.006] [audioware] [info] successfully updated player preset to no preset
[2024-05-10 02:29:35.628] [audioware] [info] on unload audioware

scripting logs

[2024-05-10 02:28:30 UTC+07:00] [15208] Mod Addicted loaded! ('C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\Addicted')
[2024-05-10 02:28:30 UTC+07:00] [15208] Ignoring mod which does not contain init.lua! ('C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\AppearanceMenuMod')
[2024-05-10 02:28:30 UTC+07:00] [15208] Mod RedHotTools loaded! ('C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\RedHotTools')
[2024-05-10 02:28:30 UTC+07:00] [15208] Mod Slaughtomatic_Platinum loaded! ('C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\Slaughtomatic_Platinum')
[2024-05-10 02:28:30 UTC+07:00] [15208] Mod SynthDose loaded! ('C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\SynthDose')
[2024-05-10 02:28:31 UTC+07:00] [15208] [🌱] [Audioware.AudioEngine] on load
[2024-05-10 02:28:49 UTC+07:00] [29400] [🌱] [Audioware.AudioEngine] on initialize
[2024-05-10 02:28:49 UTC+07:00] [8268] [🌱] [Audioware.AudioEngine] on before start
[2024-05-10 02:28:49 UTC+07:00] [8268] [🌱] [Audioware.AudioEngine] on start
[2024-05-10 02:28:50 UTC+07:00] [26312] [Addicted]:onInit
[2024-05-10 02:28:50 UTC+07:00] [26312] Slaught-O-Matic Platinum initialized for CP2077 v2.12
[2024-05-10 02:28:50 UTC+07:00] [26312] LuaVM: initialization finished!
[2024-05-10 02:28:50 UTC+07:00] [26312] [🌱] [Audioware.AudioEngine] on ready
[2024-05-10 02:29:26 UTC+07:00] [15208] [🌱] [Audioware.AudioEngine] on before end
[2024-05-10 02:29:26 UTC+07:00] [15208] [🌱] [Audioware.AudioEngine] on end
[2024-05-10 02:29:26 UTC+07:00] [15208] [🌱] [Audioware.AudioEngine] on uninitialize
[2024-05-10 02:29:26 UTC+07:00] [15208] [Codeware] ButtonHintsManager::OnUninitialize

red4ext logs

[2024-05-10 02:28:16.105] [RED4ext] [info] RED4ext (v1.24.3) is initializing...
[2024-05-10 02:28:16.105] [RED4ext] [info] Product version: 2.12
[2024-05-10 02:28:16.105] [RED4ext] [info] File version: 3.0.76.64179
[2024-05-10 02:28:16.105] [RED4ext] [info] Loading game's addresses from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\cyberpunk2077_addresses.json'...
[2024-05-10 02:28:17.482] [RED4ext] [info] 908000 game addresses loaded
[2024-05-10 02:28:17.527] [RED4ext] [info] RED4ext has been successfully initialized
[2024-05-10 02:28:17.561] [RED4ext] [info] RED4ext is starting up...
[2024-05-10 02:28:17.567] [RED4ext] [info] Loading plugins...
[2024-05-10 02:28:17.567] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\red4ext\plugins\ArchiveXL\ArchiveXL.dll'...
[2024-05-10 02:28:17.710] [RED4ext] [info] ArchiveXL (version: 1.14.1, author(s): psiberx) has been loaded
[2024-05-10 02:28:17.711] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\red4ext\plugins\audioware\audioware.dll'...
[2024-05-10 02:28:17.711] [RED4ext] [info] audioware (version: 0.8.11, author(s): Roms1383) has been loaded
[2024-05-10 02:28:17.712] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\red4ext\plugins\Codeware\Codeware.dll'...
[2024-05-10 02:28:18.472] [RED4ext] [info] Codeware (version: 1.9.0, author(s): psiberx) has been loaded
[2024-05-10 02:28:18.472] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\red4ext\plugins\cyber_engine_tweaks\cyber_engine_tweaks.dll'...
[2024-05-10 02:28:18.475] [RED4ext] [warning] Cyber Engine Tweaks did not initialize properly, unloading...
[2024-05-10 02:28:18.475] [RED4ext] [info] Cyber Engine Tweaks has been unloaded
[2024-05-10 02:28:18.475] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\red4ext\plugins\RedHotTools\RedHotTools.dll'...
[2024-05-10 02:28:18.899] [RED4ext] [info] RedHotTools (version: 0.9.2, author(s): psiberx) has been loaded
[2024-05-10 02:28:18.899] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\red4ext\plugins\TweakXL\TweakXL.dll'...
[2024-05-10 02:28:19.038] [RED4ext] [info] TweakXL (version: 1.8.5, author(s): psiberx) has been loaded
[2024-05-10 02:28:19.038] [RED4ext] [info] Loading plugin from 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe'...
[2024-05-10 02:28:19.038] [RED4ext] [info] 5 plugin(s) loaded
[2024-05-10 02:28:19.038] [RED4ext] [info] RED4ext has been started
[2024-05-10 02:28:30.235] [RED4ext] [info] scc invoked successfully, 23736 source refs were registered
[2024-05-10 02:28:30.235] [RED4ext] [info] Scripts blob path was updated to 'C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\r6\cache\final.redscripts.modded'
[2024-05-10 02:29:27.700] [RED4ext] [info] RED4ext is shutting down...
[2024-05-10 02:29:35.627] [RED4ext] [info] ArchiveXL has been unloaded
[2024-05-10 02:29:35.628] [RED4ext] [info] audioware has been unloaded
[2024-05-10 02:29:36.136] [RED4ext] [info] Codeware has been unloaded
[2024-05-10 02:29:36.293] [RED4ext] [info] RedHotTools has been unloaded
[2024-05-10 02:29:36.515] [RED4ext] [info] TweakXL has been unloaded
[2024-05-10 02:29:36.516] [RED4ext] [info] 5 plugin(s) unloaded
[2024-05-10 02:29:36.803] [RED4ext] [info] RED4ext has been shut down
[2024-05-10 02:29:36.873] [RED4ext] [info] RED4ext is terminating...
[2024-05-10 02:29:36.905] [RED4ext] [info] RED4ext has been terminated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment