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.calls={}
onfunction.functions={} onfunction.functions={}
onfunction.names={} onfunction.names={}
onfunction.hints={}
end end
function OnFunction(values) function OnFunction(values)
--[=[print("Onfunction called!") --[=[print("Onfunction called!")
@ -43,9 +44,12 @@ function onfunction.patch(addr)
engine.poked(addr+1,engine.getmod("functions")-addr-5) engine.poked(addr+1,engine.getmod("functions")-addr-5)
end end
end end
function onfunction.AddFunction(addr,name) function onfunction.AddFunction(addr,name,hints)
onfunction.patch(addr) onfunction.patch(addr)
onfunction.names[name]=addr+5 onfunction.names[name]=addr+5
if hints~=nil then
onfunction.hints[name]=hints
end
end end
function onfunction.SetCallback(name,func) function onfunction.SetCallback(name,func)
if onfunction.names[name]==nil then 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") mypos=engine.getmod("functions")
function DeathMsg(values) function DeathMsg(values)
local name local name
if WINDOWS then name=engine.peek(values[onfunction.hints["Die"].creature],ptt_dfstring)
name=engine.peek(values.edi,ptt_dfstring)
else
name=engine.peek(values.ebx,ptt_dfstring)
end
print(name:getval().." died") print(name:getval().." died")
end end
if mypos then if mypos then
@ -13,13 +9,6 @@ if mypos then
--onfunction.patch(0x189dd6+offsets.base()) --onfunction.patch(0x189dd6+offsets.base())
else else
onfunction.install() onfunction.install()
if WINDOWS then dofile("dfusion/onfunction/locations.lua")
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
onfunction.SetCallback("Die",DeathMsg) onfunction.SetCallback("Die",DeathMsg)
end end