Refactored onfunction a bit, added function hints.

develop
Warmist 2011-08-21 20:29:35 +03:00
parent 78ed7d314b
commit cc73dd3140
3 changed files with 14 additions and 14 deletions

@ -15,6 +15,7 @@ function onfunction.install()
onfunction.calls={}
onfunction.functions={}
onfunction.names={}
onfunction.hints={}
end
function OnFunction(values)
--[=[print("Onfunction called!")
@ -43,9 +44,12 @@ function onfunction.patch(addr)
engine.poked(addr+1,engine.getmod("functions")-addr-5)
end
end
function onfunction.AddFunction(addr,name)
function onfunction.AddFunction(addr,name,hints)
onfunction.patch(addr)
onfunction.names[name]=addr+5
if hints~=nil then
onfunction.hints[name]=hints
end
end
function onfunction.SetCallback(name,func)
if onfunction.names[name]==nil then

@ -0,0 +1,7 @@
if WINDOWS then --windows function defintions
onfunction.AddFunction(0x55499D+offsets.base(),"Move") --on creature move found with "watch mem=xcoord"
onfunction.AddFunction(0x275933+offsets.base(),"Die",{creature="edi"}) --on creature death? found by watching dead flag then stepping until new function
else --linux
onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"}) -- same
end

@ -1,11 +1,7 @@
mypos=engine.getmod("functions")
function DeathMsg(values)
local name
if WINDOWS then
name=engine.peek(values.edi,ptt_dfstring)
else
name=engine.peek(values.ebx,ptt_dfstring)
end
name=engine.peek(values[onfunction.hints["Die"].creature],ptt_dfstring)
print(name:getval().." died")
end
if mypos then
@ -13,13 +9,6 @@ if mypos then
--onfunction.patch(0x189dd6+offsets.base())
else
onfunction.install()
if WINDOWS then
onfunction.AddFunction(0x55499D+offsets.base(),"Move") --on creature move found with "watch mem=xcoord"
onfunction.AddFunction(0x275933+offsets.base(),"Die") --on creature death? found by watching dead flag then stepping until new function
else
--onfunction.AddFunction(0x0899be82+offsets.base(),"Move") -- found out by attaching watch...
onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
onfunction.AddFunction(0x850eecd+offsets.base(),"Die") -- same
end
dofile("dfusion/onfunction/locations.lua")
onfunction.SetCallback("Die",DeathMsg)
end