Addon Author: atom0s
Addon Version: v1.0.0.0
Here is a simple addon to add an in-game UI to enable/disable some basic mini-map features. With this you can enable the visibility of enemies, npcs and players with ease.

To use this addon, you must do the following:
- Open your NosHook folder.
- Open the /Scripts/Addons/ folder.
- Create a new folder named maphacks
- Download the code below and place it into the maphacks folder. (The file should be named maphacks.lua)
- Paste the below code into that file and save it.
- In-game open the NosHook console and type: /addon load maphacks
- --[[
- * NosHook - Copyright (c) 2016 atom0s [atom0s@live.com]
- *
- * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
- * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to
- * Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
- *
- * By using NosHook, you agree to the above license and its terms.
- *
- * Attribution - You must give appropriate credit, provide a link to the license and indicate if changes were
- * made. You must do so in any reasonable manner, but not in any way that suggests the licensor
- * endorses you or your use.
- *
- * Non-Commercial - You may not use the material (NosHook) for commercial purposes.
- *
- * No-Derivatives - If you remix, transform, or build upon the material (NosHook), you may not distribute the
- * modified material. You are, however, allowed to submit the modified works back to the original
- * NosHook project in attempt to have it added to the original project.
- *
- * You may not apply legal terms or technological measures that legally restrict others
- * from doing anything the license permits.
- *
- * No warranties are given.
- ]]--
- require 'common'
- require 'imguidef'
- _addon.author = 'atom0s';
- _addon.name = 'maphacks';
- _addon.version = '1.00';
- ----------------------------------------------------------------------------------------------------
- -- Variables
- ----------------------------------------------------------------------------------------------------
- local variables =
- {
- ['var_ShowMapHacksWindow'] = { nil, ImGuiVar_BOOLCPP, true },
- ['var_EnableEnemies'] = { nil, ImGuiVar_BOOLCPP, false },
- ['var_EnableNpcs'] = { nil, ImGuiVar_BOOLCPP, false },
- ['var_EnablePlayers'] = { nil, ImGuiVar_BOOLCPP, false },
- };
- local map_pointer = 0;
- local map_offset1 = 0xA8;
- local map_show_enemies = 0xCE;
- local map_show_npcs = 0xCD;
- local map_show_players = 0xCC;
- ----------------------------------------------------------------------------------------------------
- -- func: WriteMapValue
- -- desc: Writes a value to the map pointer at the given offset.
- ----------------------------------------------------------------------------------------------------
- local function WriteMapValue(offset, value)
- -- Prevent invalid write attempts..
- if (map_pointer == 0) then
- return;
- end
- -- Convert the value..
- if (value == true) then
- value = 1;
- else
- value = 0;
- end
- -- Read into the pointer..
- local pointer = mem.ReadULong(map_pointer);
- pointer = mem.ReadULong(pointer + map_offset1);
- -- Write to the offset..
- mem.UnprotectMemory(pointer + offset, 1);
- mem.WriteUChar(pointer + offset, value);
- end
- ----------------------------------------------------------------------------------------------------
- -- func: load
- -- desc: Event called when the addon is being loaded.
- ----------------------------------------------------------------------------------------------------
- hook.register_event('load', function()
- -- Initialize the custom variables..
- for k, v in pairs(variables) do
- -- Create the variable..
- if (v[2] >= ImGuiVar_CDSTRING) then
- variables[k][1] = imgui.CreateVar(variables[k][2], variables[k][3]);
- else
- variables[k][1] = imgui.CreateVar(variables[k][2]);
- end
- -- Set a default value if present..
- if (#v > 2 and v[2] < ImGuiVar_CDSTRING) then
- imgui.SetVarValue(variables[k][1], variables[k][3]);
- end
- end
- -- Locate map pointer..
- local ptr = mem.FindPattern('nostalex.dat', '8B128942??8BCBB201A1????????E8????????A3????????8BCBB201', 0x14, 0x00);
- if (ptr == 0) then
- error('Failed to locate required map pointer!');
- end
- map_pointer = mem:ReadULong(ptr);
- end);
- ----------------------------------------------------------------------------------------------------
- -- func: unload
- -- desc: Event called when the addon is being unloaded.
- ----------------------------------------------------------------------------------------------------
- hook.register_event('unload', function()
- -- Cleanup the custom variables..
- for k, v in pairs(variables) do
- if (variables[k][1] ~= nil) then
- imgui.DeleteVar(variables[k][1]);
- end
- variables[k][1] = nil;
- end
- end);
- ----------------------------------------------------------------------------------------------------
- -- func: prerender
- -- desc: Event called when BeginScene() is called in Direct3D.
- ----------------------------------------------------------------------------------------------------
- hook.register_event('prerender', function()
- local show_enemies = imgui.GetVarValue(variables['var_EnableEnemies'][1]);
- local show_npcs = imgui.GetVarValue(variables['var_EnableNpcs'][1]);
- local show_players = imgui.GetVarValue(variables['var_EnablePlayers'][1]);
- WriteMapValue(map_show_enemies, show_enemies);
- WriteMapValue(map_show_npcs, show_npcs);
- WriteMapValue(map_show_players, show_players);
- end);
- ----------------------------------------------------------------------------------------------------
- -- func: render
- -- desc: Event called when EndScene() is called in Direct3D.
- ----------------------------------------------------------------------------------------------------
- hook.register_event('render', function()
- -- Do not render the UI if it was hidden..
- if (imgui.GetVarValue(variables['var_ShowMapHacksWindow'][1]) == false) then
- return;
- end
- -- Render the UI..
- imgui.SetNextWindowSize(200, 100, ImGuiSetCond_Always);
- if (not imgui.Begin('Map Hacks', variables['var_ShowMapHacksWindow'][1], imgui.bor(ImGuiWindowFlags_NoResize))) then
- imgui.End();
- return;
- end
- imgui.Checkbox('Show Enemies', variables['var_EnableEnemies'][1]);
- imgui.Checkbox('Show NPCs', variables['var_EnableNpcs'][1]);
- imgui.Checkbox('Show Players', variables['var_EnablePlayers'][1]);
- imgui.End();
- end);