0% found this document useful (0 votes)
11 views2 pages

Dynamic Difficulty.lua

The document outlines a Lua script for a mod that allows users to adjust two boost values for teams in a game. Users can change these values using specific key inputs, and the script ensures that only values between 0 and 5 are considered safe. The script also includes functions to read and write memory values related to the game state, logging changes made to the boost values.

Uploaded by

Milan Siljanov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Dynamic Difficulty.lua

The document outlines a Lua script for a mod that allows users to adjust two boost values for teams in a game. Users can change these values using specific key inputs, and the script ensures that only values between 0 and 5 are considered safe. The script also includes functions to read and write memory values related to the game state, logging changes made to the boost values.

Uploaded by

Milan Siljanov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

local m = {}

local now_value1=0
local now_value2=0

local set_value1=0
local set_value2=0

local function overlay_on(ctx)


return string.format("\nThe two values represent boosts for the two teams (To
Be Confirmed).\n\nCurrent values set by the mod:\nValue1 = %d\nValue2 = %d\n\n\nTo
change values for the next match press '9' and '0' to decrease/increase the first
value, and '-' and '+' for the second value.\n*Note that the set values will not
update instantly*\nNext Value1 = %d\nNext Value2 = %d\n\nOnly values between 0 and
5 are considered 'safe' to use for now. For NO boosting, similar to Local Match,
use 0 and 0", now_value1, now_value2, set_value1, set_value2)
end

local function get_character_for_vkey(vkey)


local c = string.char(vkey)
if string.match(c, "[A-Z0-9 ]") then
return c
end
end

local function key_down(ctx, vkey)


local character = get_character_for_vkey(vkey)
local MINUS_VALUE1_KEY = 0x39 -- 9 key
local PLUS_VALUE1_KEY = 0x30 -- 0 key
local MINUS_VALUE2_KEY = 0xbd -- - key
local PLUS_VALUE2_KEY = 0xbb -- + key

if vkey==MINUS_VALUE1_KEY and set_value1~=0 then


set_value1=set_value1-1
end
if vkey==PLUS_VALUE1_KEY then
set_value1=set_value1+1
end
if vkey==MINUS_VALUE2_KEY and set_value2~=0 then
set_value2=set_value2-1
end
if vkey==PLUS_VALUE2_KEY then
set_value2=set_value2+1
end

end

function m.after_set_conditions(ctx)
if ctx.mis then
-- "ctx.mis" refers to MATCH_INFO structure
-- which has some interesting stuff

-- cast to a char pointer


local p = ffi.cast("char*", ctx.mis)

-- now we can do pointer arithmetic and access memory


local a1 = p + 0x20
local a3 = p + 0x28
-- read what is there now
local was1 = memory.unpack("u32", memory.read(a1, 4))
local was3 = memory.unpack("u32", memory.read(a3, 4))

-- modify
memory.write(a1, memory.pack("u32", set_value1))
memory.write(a3, memory.pack("u32", set_value2))

-- verify changes
local now1 = memory.unpack("u32", memory.read(a1, 4))
local now3 = memory.unpack("u32", memory.read(a3, 4))
now_value1=now1
now_value2=now3

log(string.format("dword1 (%s) was=%d, now=%d", memory.hex(a1), was1,


now1))
log(string.format("dword3 (%s) was=%d, now=%d", memory.hex(a3), was3,
now3))

end
end

function m.init(ctx)
if not ffi then
error('LuaJIT FFI is disabled. Enable it with "luajit.ext.enabled = 1" in
sider.ini')
end
ctx.register("after_set_conditions", m.after_set_conditions)
ctx.register("overlay_on", overlay_on)
ctx.register("key_down", key_down)
end

return m

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy