Jump to content

Lua script template v0.0.0: Patching memory addresses in the libil2cpp library | by Phantom Combat Venue | example game :: Sniper Warrior: PvP Sniper v0.0.3 build 19 Last updated on Aug 29, 2023 1.0.0

   (0 reviews)

2 Screenshots

About This File

Phantom Combat Venue Lua Script Template v0.0.0 - No Recoil Camera Hack and Utility Functions

Introduction:
Hello, GameGuardian community! Today, I'm excited to share the Phantom Combat Venue Lua Script Template v0.0.0, an open-source script under the MIT license.

This template serves as a foundation for patching memory addresses in the libil2cpp library for any game. I used "Sniper Warrior: PvP Sniper" as an example.

In this post, we'll focus on the No Recoil Camera Hack as an example, and we'll also explore some utility functions and other Lua code provided in the template.

License:
This script is open-source under the MIT license, giving you the freedom to modify and adapt it for your needs.

Global Variables:
- `__ON` and `__OFF`: Emoji indicators for ON and OFF states.
- `VISIBILITY_FLAG`: A flag to manage script visibility.

Utility Functions:

1. libBase(lib, offsets, vals, type):
   - Purpose: Finds and modifies memory addresses in the specified library.
   - Parameters:
      - `lib`: Library name.
      - `offsets`: List of offsets.
      - `vals`: List of values.
      - `type`: Data type.
   - Functionality: Iterates through memory ranges, identifies the library, and modifies addresses.

function libBase(lib, offsets, vals, type)
    local rangeList = gg.getRangesList(lib)
    local addresses = {}

    for i, v in ipairs(rangeList) do
        if v.state == "Xa" then
            for j, offset in ipairs(offsets) do
                table.insert(addresses, {
                    address = v.start + offset,
                    flags = type,
                    value = vals[j] .. "h"
                })
            end
            break
        end
    end

    if #addresses == 0 then
        print("Not found lib")
    else
        gg.setValues(addresses)
    end
end

 

2. convertToHexString(number, digits):
   - Purpose: Converts a number to a hexadecimal string with a specified number of digits.
   - Parameters:
      - `number`: Number to convert.
      - `digits`: Number of hexadecimal digits.
   - Functionality: Applies a bitmask and formats the number as a hexadecimal string.

function convertToHexString(number, digits)
    local mask = (1 << (digits * 4)) - 1
    return string.format("%X", number & mask)
end

 

3. getHexValueByOffset(offset):
   - Purpose: Retrieves the hexadecimal value at a specific offset in libil2cpp.
   - Parameters:
      - `offset`: Offset to read.
   - Functionality: Uses `gg.getValues` to obtain the hexadecimal value at the specified offset.

function getHexValueByOffset(offset)
    local responseVal = gg.getValues({{
        address = gg.getRangesList("libil2cpp.so")[1].start + offset,
        flags = gg.TYPE_DWORD
    }})
    return convertToHexString(responseVal[1].value, 8)
end

 

Main Function:

- Main():
   - Purpose: Entry point for script execution.
   - Functionality: Displays a menu with options, including the No Recoil Camera, and handles user input.

function Main()
    VISIBILITY_FLAG = -1
    gg.setVisible(false)

    menu = gg.choice({
        no_recoil_camera_state .. "No Recoil Camera.",
        "❌    EXIT    ❌"
    }, nil, "Sniper Warrior v 0.0.3 b19 - MOD")

    if menu == nil then
        gg.toast(" ⚠️ MINIMIZED ⚠️")
        gg.setVisible(false)
    elseif menu == 1 then
        no_recoil_camera_fn()
    else
        os.exit()
    end
end

 

No Recoil Camera:

1. Initialization:
   - `no_recoil_camera_offset`: Offset for the No Recoil Camera hack.
   - `no_recoil_camera_active_hack_hex_code`: Hex code for the active state.

no_recoil_camera_offset = 0x115DA58
no_recoil_camera_active_hack_hex_code = "D65F03C0"  -- "~A8 RET"

 

2. State Check:
   - Checks the current state of the No Recoil Camera and sets the corresponding state indicator (`__ON` or `__OFF`).

if getHexValueByOffset(no_recoil_camera_offset) == no_recoil_camera_active_hack_hex_code then
    no_recoil_camera_state = __ON
else
    no_recoil_camera_state = __OFF
end

 

3. Function: no_recoil_camera_fn():
   - Purpose: Activates or deactivates the No Recoil Camera.
   - Functionality: Utilizes `libBase` to modify the necessary memory addresses based on the current state.

function no_recoil_camera_fn()
    local offsets = {0x115DA58, 0x115DA5C, 0x115DA60, 0x115DA64, 0x115DA68, 0x115DA6C, 0x115DA70}
    local values_on = {no_recoil_camera_active_hack_hex_code, no_recoil_camera_active_hack_hex_code, no_recoil_camera_active_hack_hex_code, no_recoil_camera_active_hack_hex_code, no_recoil_camera_active_hack_hex_code, no_recoil_camera_active_hack_hex_code, no_recoil_camera_active_hack_hex_code}
    local values_off = {"6DBD23E9", "F9000BF3", "A9027BFD", "910083FD", "4EA01C08", "AA0003F3", "9400000E"}
    
    if no_recoil_camera_state == __OFF then
        libBase("libil2cpp.so", offsets, values_on, gg.TYPE_DWORD)
        gg.toast("No Recoil Camera activated")
        no_recoil_camera_state = __ON
    elseif no_recoil_camera_state == __ON then
        libBase("libil2cpp.so", offsets, values_off, gg.TYPE_DWORD)
        gg.toast("No Recoil Camera deactivated")
        no_recoil_camera_state = __OFF
    end
end

 

Entrypoint:

- While Loop:
   - Purpose: Keeps the script running in the background.
   - Functionality: Checks for script visibility and calls the `Main()` function accordingly.

while true do
    if gg.isVisible(true) then
        VISIBILITY_FLAG = 1
        gg.setVisible(false)
    end

    if VISIBILITY_FLAG == 1 then
        Main()
    end
end

 

Happy scripting! ❤️😁 Your friend, Phantom Combat Venue.

 Share


User Feedback

You may only provide a review once you have downloaded the file.

There are no reviews to display.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.