Skip to content

Disable shaders, GUI and AI #14

@danielniccoli

Description

@danielniccoli

This does disable shaders, GUI and AI. Because it writes to the processes memory, it works only on builds where we know the exact memory address. It also only works on the dev build, because the release build is missing the code that disables the AI.

This effectively replaces pressing F5, F8 and F12.
It also helps with getting a better screen cap, because it stops entities from moving, if the motion is caused by AI.

function OnWorldInitialized() -- This is called once the game world is initialized. Doesn't ensure any world chunks actually exist. Use OnPlayerSpawned to ensure the chunks around player have been loaded or created.
	--[[
		The following code disables shaders, GUI and AI.
	
		While shaders and GUI can be disabled in the release build as well, only the dev build has the debugging feature to disable the AI.
	
		Due to direct memory address write operations, only known builds on known operating systems are supported.
		Adding new builds or operating systems is easy, if someone supports us with the research.
	]] --
	local ffi = require("ffi")
	if DebugGetIsDevBuild() == false then
		GamePrint("This mod cannot be run in the release build. You must run the dev build (noita_dev.exe) to capture a map!")
		GamePrint("If you like to capture the world of your current run, read the README for instructions on how to copy the savegame to the dev build.")
		-- exit mod init somehow?
	else
		if ffi.os == "Windows" then
			if ffi.string(ffi.cast("char*", 0x00F77B0C)) == "Build Apr 23 2021 18:36:55" then -- GOG build
				ffi.cast("char*", 0x010E3B6C)[0] = 1 -- disable shaders (Debug: mPostFxDisabled)
				ffi.cast("char*", 0x010E3B6D)[0] = 1 -- disable GUI     (Debug: mGuiDisabled)
				ffi.cast("char*", 0x010E3B73)[0] = 1 -- freeze AI       (Debug: mFreezeAI)
			elseif ffi.string(ffi.cast("char*", 0x00F80384)) == "Build Apr 23 2021 18:40:40" then -- Steam build
				ffi.cast("char*", 0x010EDEBC)[0] = 1 -- disable shaders (Debug: mPostFxDisabled)
				ffi.cast("char*", 0x010EDEBD)[0] = 1 -- disable GUI     (Debug: mGuiDisabled)
				ffi.cast("char*", 0x010EDEC3)[0] = 1 -- freeze AI       (Debug: mFreezeAI)
			else
				GamePrint("You are running a currently unsupported Noita build.")
				GamePrint("We would appreciate your help to add support for this build. Please open a ticket at https://github.com/Dadido3/noita-mapcap.")
			end
		else
			GamePrint("You are running a currently unsupported OS.")
			GamePrint("We would appreciate your help to add support for this OS. Please open a ticket at https://github.com/Dadido3/noita-mapcap.")
		end
	end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions