Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable shaders, GUI and AI #14

Open
danielniccoli opened this issue Jul 25, 2022 · 3 comments
Open

Disable shaders, GUI and AI #14

danielniccoli opened this issue Jul 25, 2022 · 3 comments

Comments

@danielniccoli
Copy link

danielniccoli commented Jul 25, 2022

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
@Dadido3
Copy link
Owner

Dadido3 commented Jul 25, 2022

This is awesome. Did you use cheat engine to find these addresses?

I'm currently adding a settings menu, once that is done i will look into adding this. There will be advanced options to enable/disable a lot of stuff, and this will be a nice addition to the options.

@danielniccoli
Copy link
Author

Yes, I used Cheat Engine. Amazing tool.

@danielniccoli
Copy link
Author

Thanks for the shoutout in the README of v2❣️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants