local m = {}
local now_value1=0
local now_value2=0
local set_value1=0
local set_value2=0
local function overlay_on(ctx)
return [Link]("\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 = [Link](vkey)
if [Link](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 [Link] then
-- "[Link]" refers to MATCH_INFO structure
-- which has some interesting stuff
-- cast to a char pointer
local p = [Link]("char*", [Link])
-- now we can do pointer arithmetic and access memory
local a1 = p + 0x20
local a3 = p + 0x28
-- read what is there now
local was1 = [Link]("u32", [Link](a1, 4))
local was3 = [Link]("u32", [Link](a3, 4))
-- modify
[Link](a1, [Link]("u32", set_value1))
[Link](a3, [Link]("u32", set_value2))
-- verify changes
local now1 = [Link]("u32", [Link](a1, 4))
local now3 = [Link]("u32", [Link](a3, 4))
now_value1=now1
now_value2=now3
log([Link]("dword1 (%s) was=%d, now=%d", [Link](a1), was1,
now1))
log([Link]("dword3 (%s) was=%d, now=%d", [Link](a3), was3,
now3))
end
end
function [Link](ctx)
if not ffi then
error('LuaJIT FFI is disabled. Enable it with "[Link] = 1" in
[Link]')
end
[Link]("after_set_conditions", m.after_set_conditions)
[Link]("overlay_on", overlay_on)
[Link]("key_down", key_down)
end
return m