RafLoader is a lightweight ASI loader for Rise and Fall: Civilization at War, providing runtime modding through LuaJIT and native C++ APIs.
RafLoader injects into the game process and provides:
- Native function hooking powered by MinHook.
- Embedded LuaJIT runtime.
- DirectX9 rendering hook.
- Automatic Lua script loading.
- Built-in ImGui debug console.
- Crash recovery helpers.
- Per-frame (tick) callbacks.
Create native hooks directly from Lua.
Supported hook types:
- Standard function hooks.
__usercallbridge hooks.- Damage post hooks.
Example:
local hooks = _G.Engine.Hooks
local original
original = hooks.create(
0x401000,
"int (__cdecl *NAME)(int)",
function(value)
print("Hook:", value)
return original(value)
end
)Read and modify game memory.
Available functions:
local memory = _G.Engine.Memory
memory.write_nop(address, size)
memory.patch(address, bytes)
memory.read_int(address)
memory.read_float(address)
memory.write_int(address, value)
memory.write_float(address, value)Example:
memory.write_nop(0x401000, 5)
memory.patch(0x401100, {
0x90,
0x90,
0x90
})Execute Lua code every game update.
local tick = _G.Engine.Tick
tick.add(function()
-- Called every frame
end)Clear all callbacks:
tick.clear()Register recovery points for known crashes.
local crash = _G.Engine.VahCrash
crash.catch(
0x403000,
0x404000
)All Lua scripts inside the scripts directory are loaded automatically.
Example structure:
RafLoader.asi
scripts/
test.lua
cheats.lua
ui.lua
Files beginning with _ or . are ignored.
Built-in ImGui console.
Features:
- Live log output.
- Automatic logging from Lua
print(). - Log file (
RafLoader.log). - Toggle with F1.
local memory = _G.Engine.Memory
local hooks = _G.Engine.Hooks
local tick = _G.Engine.Tick
local crash = _G.Engine.VahCrash
memory.write_nop(0x401000, 5)
local original
original = hooks.create(
0x401050,
"int (__cdecl *NAME)(int)",
function(value)
print("Function called:", value)
return original(value)
end
)
tick.add(function()
-- Executed every frame
end)
crash.catch(
0x403000,
0x404000
)The Lua API is exposed through:
_G.Engine.Memory
_G.Engine.Hooks
_G.Engine.Tick
_G.Engine.VahCrashAdditional native functionality can be implemented through custom C++ plugins.
- x86 only.
- DirectX9 renderer.
- Requires knowledge of game memory addresses.
- Invalid hooks or memory patches may crash the game.
RafLoader provides a compact and lightweight framework for creating Lua-powered mods, runtime patches, hooks, and debugging tools for Rise and Fall: Civilization at War.