embark and friendship working.

develop
Warmist 2012-03-18 00:50:47 +02:00
parent 16861781c2
commit 77738085e2
11 changed files with 79 additions and 81 deletions

@ -6,6 +6,12 @@ BYTE=3
QWORD=4 QWORD=4
DOUBLE=5 DOUBLE=5
FLOAT=6 FLOAT=6
getline=function (inp)
return Console.lineedit(inp or "")
end
io.stdin=nil
function printd(...) function printd(...)
if DEBUG then if DEBUG then
print(...) print(...)
@ -243,7 +249,8 @@ function it_menu:display()
local ans local ans
repeat repeat
local r local r
r=io.stdin:read() r=getline("")
if r==nil then return end
if r=='q' then return end if r=='q' then return end
ans=tonumber(r) ans=tonumber(r)
@ -359,12 +366,12 @@ function findVectors()
end end
function GetRaceToken(p) --actually gets token... function GetRaceToken(p) --actually gets token...
local vec=df.world.raws.creatures.alphabetic local vec=df.world.raws.creatures.all
return vec[p]:deref().creature_id return vec[p]:deref().creature_id
end end
function BuildNameTable() function BuildNameTable()
local rtbl={} local rtbl={}
local vec=df.world.raws.creatures.alphabetic local vec=df.world.raws.creatures.all
--print(string.format("Vector start:%x",vec.st)) --print(string.format("Vector start:%x",vec.st))
--print(string.format("Vector end:%x",vec.en)) --print(string.format("Vector end:%x",vec.en))
--print("Creature count:"..vec.size) --print("Creature count:"..vec.size)

@ -1,9 +1,7 @@
.intel_syntax .intel_syntax
mov eax , [esp+0x1C] mov eax , [esp+0x1C]
caste: caste:
movsx eax, word ptr[eax*2+0xdeadbeef] movsx ecx, word ptr[eax*2+0xdeadbeef]
mov [esp+0x04],eax
mov eax , [esp+0x1C]
race: race:
movzx eax,word ptr [eax*2+0xDEADBEEF] movzx eax,word ptr [eax*2+0xDEADBEEF]
ret ret

@ -16,6 +16,7 @@ function MakeTable(modpos,modsize,names)
if RaceTable[line] == nil then if RaceTable[line] == nil then
error("Failure, "..line.." not found!") error("Failure, "..line.." not found!")
end end
print("adding:"..line.." id:"..RaceTable[line])
engine.pokew(modpos+modsize+count*2,RaceTable[line]) -- add race engine.pokew(modpos+modsize+count*2,RaceTable[line]) -- add race
count = count + 1 count = count + 1
end end
@ -45,20 +46,23 @@ function embark(names)
loc=offsets.find(stoff,0x0f,0xb7,0x0d,DWORD_,tofind) --MOVZX ECX,WORD PTR[] loc=offsets.find(stoff,0x0f,0xb7,0x0d,DWORD_,tofind) --MOVZX ECX,WORD PTR[]
print("found:"..loc) print(string.format("found:%x",loc))
if((loc~=0)and(loc-stoff<1000)) then if((loc~=0)and(loc-stoff<1000)) then
modpos,modsize=engine.loadmod('dfusion/embark/embark.o','Embark',256) ModData=engine.installMod("dfusion/embark/embark.o","Embark",256)
modpos=ModData.pos
modsize=ModData.size
local castepos=modpos+engine.FindMarker(ModData,"caste")
local racepos=modpos+engine.FindMarker(ModData,"race")
count=MakeTable(modpos,modsize,names) count=MakeTable(modpos,modsize,names)
engine.poked(modpos+0x18,modpos+modsize) --fix array start for race engine.poked(castepos,modpos+modsize) --fix array start for race
engine.poked(modpos+0x08,modpos+modsize+count*2) --fix array start for caste engine.poked(racepos,modpos+modsize+count*2) --fix array start for caste
print("sucess loading mod @:"..modpos) print("sucess loading mod @:"..modpos)
-- build race vector after module. -- build race vector after module.
--finaly poke in the call! --finaly poke in the call!
engine.pokeb(loc,0x6a) engine.pokeb(loc,0x90)
engine.pokeb(loc+1,0xFF) engine.pokeb(loc+1,0x90)
engine.pokeb(loc+2,0xe8) engine.pokeb(loc+2,0xe8)
engine.poked(loc+3,modpos-loc-7) engine.poked(loc+3,modpos-loc-7)
--engine.pokeb(loc+5,0x90) --engine.pokeb(loc+5,0x90)

@ -3,12 +3,12 @@ function friendship_in.install(names)
RaceTable=RaceTable or BuildNameTable() RaceTable=RaceTable or BuildNameTable()
mypos=engine.getmod("Friendship") mypos=engine.getmod("Friendship")
if mypos then if mypos then
modpos=mypos modpos=mypos
_,modsize=engine.loadobj("dfusion/friendship/friendship.o") _,modsize=engine.loadobj("dfusion/friendship/friendship.o")
_=nil _=nil
else else
modpos,modsize=engine.loadmod("dfusion/friendship/friendship.o","Friendship",1024) modpos,modsize=engine.loadmod("dfusion/friendship/friendship.o","Friendship",1024)
print(string.format("Loaded module @:%x",modpos)) print(string.format("Loaded module @:%x",modpos))
end end
count=0 count=0
for _,v in pairs(names) do for _,v in pairs(names) do

@ -1,7 +1,7 @@
function friendship_in.patch() function friendship_in.patch()
UpdateRanges() UpdateRanges()
pos=GetTextRegion().start pos=GetTextRegion().start
local crace=VersionInfo.getGroup("Creatures"):getAddress("current_race") local crace=addressOf(df.ui,"race_id")--VersionInfo.getGroup("Creatures"):getAddress("current_race")
hits={} hits={}
i=1 i=1
repeat repeat

@ -2,11 +2,10 @@ if not(FILE) then
--sanity test --sanity test
--print("race num:"..engine.peekw(offsets.getEx("CurrentRace"))) --print("race num:"..engine.peekw(offsets.getEx("CurrentRace")))
--print(string.format("%x vs %x",offsets.getEx("CurrentRace"),VersionInfo.getGroup("Creatures"):getAddress("current_race"))) --print(string.format("%x vs %x",offsets.getEx("CurrentRace"),VersionInfo.getGroup("Creatures"):getAddress("current_race")))
add_race=VersionInfo.getGroup("Creatures"):getAddress("current_race") print("Race num:"..df.ui.race_id)
print("Race num:"..engine.peekw(add_race)) print("Your current race is:"..GetRaceToken(df.ui.race_id))
print("Your current race is:"..GetRaceToken(engine.peekw(add_race)))
print("If this is wrong please type 'q'") print("If this is wrong please type 'q'")
if(io.stdin:read()=='q') then if(getline()=='q') then
return return
end end

@ -54,13 +54,15 @@ dofile("dfusion/xml_struct.lua")
unlockDF() unlockDF()
plugins={} plugins={}
table.insert(plugins,{"simple_embark","A simple embark dwarf count editor"}) table.insert(plugins,{"simple_embark","A simple embark dwarf count editor"})
--[=[table.insert(plugins,{"embark","Multi race embark"}) table.insert(plugins,{"tools","some misc tools"})
table.insert(plugins,{"items","A collection of item hacking tools"}) table.insert(plugins,{"embark","Multi race embark"})
table.insert(plugins,{"offsets","Find all offsets"})
table.insert(plugins,{"friendship","Multi race fort enabler"}) table.insert(plugins,{"friendship","Multi race fort enabler"})
--[=[table.insert(plugins,{"items","A collection of item hacking tools"})
table.insert(plugins,{"offsets","Find all offsets"})
table.insert(plugins,{"friendship_civ","Multi civ fort enabler"}) table.insert(plugins,{"friendship_civ","Multi civ fort enabler"})
table.insert(plugins,{"adv_tools","some tools for (mainly) advneturer hacking"}) table.insert(plugins,{"adv_tools","some tools for (mainly) advneturer hacking"})
table.insert(plugins,{"tools","some misc tools"})
table.insert(plugins,{"triggers","a function calling plug (discontinued...)"}) table.insert(plugins,{"triggers","a function calling plug (discontinued...)"})
table.insert(plugins,{"migrants","multi race imigrations"}) table.insert(plugins,{"migrants","multi race imigrations"})
table.insert(plugins,{"onfunction","run lua on some df function"})--]=] table.insert(plugins,{"onfunction","run lua on some df function"})--]=]

@ -1,11 +1,11 @@
tools={} tools={}
tools.menu=MakeMenu() tools.menu=MakeMenu()
function tools.setrace() function tools.setrace()
RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again RaceTable=BuildNameTable()
print("Your current race is:"..GetRaceToken(df.ui.race_id)) print("Your current race is:"..GetRaceToken(df.ui.race_id))
print("Type new race's token name in full caps (q to quit):") print("Type new race's token name in full caps (q to quit):")
repeat repeat
entry=io.stdin:read() entry=getline()
if entry=="q" then if entry=="q" then
return return
end end
@ -20,7 +20,7 @@ function tools.GiveSentience(names) --TODO make pattern...
ids={} ids={}
print("Type race's token name in full caps to give sentience to:") print("Type race's token name in full caps to give sentience to:")
repeat repeat
entry=io.stdin:read() entry=getline()
id=RaceTable[entry] id=RaceTable[entry]
until id~=nil until id~=nil
table.insert(ids,id) table.insert(ids,id)
@ -107,7 +107,7 @@ function tools.getCreatureId(vector)
end end
print("=====================================") print("=====================================")
print("type in name or number:") print("type in name or number:")
r=io.stdin:read() r=getline()
if tonumber(r) ==nil then if tonumber(r) ==nil then
indx=rnames[r] indx=rnames[r]
if indx==nil then return end if indx==nil then return end
@ -125,7 +125,7 @@ function tools.change_adv()
tval=vector:getval(0) tval=vector:getval(0)
vector:setval(0,vector:getval(indx)) vector:setval(0,vector:getval(indx))
vector:setval(indx,tval) vector:setval(indx,tval)
r=io.stdin:read() r=getline()
if r=='q' then if r=='q' then
return return
end end
@ -153,7 +153,7 @@ function tools.MakeFollow()
lfollow=engine.peek(vector:getval(indx)+ptr_Creature.followID.off,DWORD) lfollow=engine.peek(vector:getval(indx)+ptr_Creature.followID.off,DWORD)
if lfollow ~=0xFFFFFFFF then if lfollow ~=0xFFFFFFFF then
print("Already following, unfollow? y/N") print("Already following, unfollow? y/N")
r=io.stdin:read() r=getline()
if r== "y" then if r== "y" then
engine.poke(vector:getval(indx)+ptr_Creature.followID.off,DWORD,0) engine.poke(vector:getval(indx)+ptr_Creature.followID.off,DWORD,0)
end end
@ -165,7 +165,7 @@ tools.menu:add("Make creature follow",tools.MakeFollow)
function tools.runscript(files) function tools.runscript(files)
if files==nil then if files==nil then
files={} files={}
table.insert(files,io.stdin:read()) table.insert(files,getline())
end end
for _,v in pairs(files) do for _,v in pairs(files) do
print("Running script:"..v) print("Running script:"..v)
@ -181,7 +181,7 @@ function tools.getsite(names)
print("Type words that are in the site name, FULLCAPS, no modifiers (lovely->LOVE), q to quit:") print("Type words that are in the site name, FULLCAPS, no modifiers (lovely->LOVE), q to quit:")
names={} names={}
repeat repeat
w=io.stdin:read(); w=getline();
if rwords[w]~=nil then if rwords[w]~=nil then
table.insert(names,w) table.insert(names,w)
@ -246,14 +246,14 @@ function tools.getsite(names)
print(string.format("%d)%s off=%x type=%s\t flags=%x",i,r,off,snames[typ+1],flg)) print(string.format("%d)%s off=%x type=%s\t flags=%x",i,r,off,snames[typ+1],flg))
if i%100==99 then if i%100==99 then
r=io.stdin:read() r=getline()
end end
end end
end end
print("Type which to change (q cancels):") print("Type which to change (q cancels):")
repeat repeat
r=io.stdin:read() r=getline()
n=tonumber(r) n=tonumber(r)
if(r=='q') then return end if(r=='q') then return end
until n~=nil until n~=nil
@ -268,7 +268,7 @@ function tools.changesite(names)
print((k-1).."->"..v) print((k-1).."->"..v)
end end
repeat repeat
r=io.stdin:read() r=getline()
n2=tonumber(r) n2=tonumber(r)
if(r=='q') then return end if(r=='q') then return end
until n2~=nil until n2~=nil
@ -300,7 +300,7 @@ function tools.changeflags(names)
end end
end end
print("Type number to flip, or 'q' to quit.") print("Type number to flip, or 'q' to quit.")
q=io.stdin:read() q=getline()
n2=tonumber(q) n2=tonumber(q)
if n2~=nil then if n2~=nil then
@ -354,7 +354,7 @@ function tools.protectsite()
print("2. range (x0 x1 y0 y1 z0 z1)") print("2. range (x0 x1 y0 y1 z0 z1)")
print("3. One block around pointer") print("3. One block around pointer")
print("anything else- quit") print("anything else- quit")
q=io.stdin:read() q=getline()
n2=tonumber(q) n2=tonumber(q)
if n2==nil then return end if n2==nil then return end
if n2>3 or n2<1 then return end if n2>3 or n2<1 then return end
@ -368,17 +368,17 @@ function tools.protectsite()
ze=z-1 ze=z-1
elseif n2==2 then elseif n2==2 then
print("enter x0:") print("enter x0:")
xs=tonumber(io.stdin:read()) xs=tonumber(getline())
print("enter x1:") print("enter x1:")
xe=tonumber(io.stdin:read()) xe=tonumber(getline())
print("enter y0:") print("enter y0:")
ys=tonumber(io.stdin:read()) ys=tonumber(getline())
print("enter y1:") print("enter y1:")
ye=tonumber(io.stdin:read()) ye=tonumber(getline())
print("enter z0:") print("enter z0:")
zs=tonumber(io.stdin:read()) zs=tonumber(getline())
print("enter z1:") print("enter z1:")
ze=tonumber(io.stdin:read()) ze=tonumber(getline())
function clamp(t,vmin,vmax) function clamp(t,vmin,vmax)
if t> vmax then return vmax end if t> vmax then return vmax end
if t< vmin then return vmin end if t< vmin then return vmin end
@ -434,7 +434,7 @@ function tools.fixwarp()
print("2. range (x0 x1 y0 y1 z0 z1)") print("2. range (x0 x1 y0 y1 z0 z1)")
print("3. One block around pointer") print("3. One block around pointer")
print("anything else- quit") print("anything else- quit")
q=io.stdin:read() q=getline()
n2=tonumber(q) n2=tonumber(q)
if n2==nil then return end if n2==nil then return end
if n2>3 or n2<1 then return end if n2>3 or n2<1 then return end
@ -448,17 +448,17 @@ function tools.fixwarp()
ze=z-1 ze=z-1
elseif n2==2 then elseif n2==2 then
print("enter x0:") print("enter x0:")
xs=tonumber(io.stdin:read()) xs=tonumber(getline())
print("enter x1:") print("enter x1:")
xe=tonumber(io.stdin:read()) xe=tonumber(getline())
print("enter y0:") print("enter y0:")
ys=tonumber(io.stdin:read()) ys=tonumber(getline())
print("enter y1:") print("enter y1:")
ye=tonumber(io.stdin:read()) ye=tonumber(getline())
print("enter z0:") print("enter z0:")
zs=tonumber(io.stdin:read()) zs=tonumber(getline())
print("enter z1:") print("enter z1:")
ze=tonumber(io.stdin:read()) ze=tonumber(getline())
function clamp(t,vmin,vmax) function clamp(t,vmin,vmax)
if t> vmax then return vmax end if t> vmax then return vmax end
if t< vmin then return vmin end if t< vmin then return vmin end

@ -1,28 +1,8 @@
--[=[ if types ~= nil then
bld=buildinglist[1] return
bld.x1=10 end
bld.flags.exists=true
boolval=bld.flags.justice
if boolval then
bld.mat_type=bld.mat_type+1
end
type info:
--]=]
dofile("dfusion/xml_types.lua") dofile("dfusion/xml_types.lua")
--[=[sometype={
}
sometype.x1={INT32_T,0}
sometype.y1={INT32_T,4}
--...
sometype.flags={"building_flags",7*4}
--...
types.building=sometype
]=]
function parseTree(t) function parseTree(t)
for k,v in ipairs(t) do for k,v in ipairs(t) do
if v.xarg~=nil and v.xarg["type-name"]~=nil and v.label=="ld:global-type" then if v.xarg~=nil and v.xarg["type-name"]~=nil and v.label=="ld:global-type" then

@ -137,11 +137,14 @@ function type_enum.new(node,obj)
end end
local btype=node.xarg["base-type"] or "uint32_t" local btype=node.xarg["base-type"] or "uint32_t"
--print(btype.." t="..convertType(btype)) --print(btype.." t="..convertType(btype))
o.etype=getSimpleType(btype) -- should be simple type o:setbtype(btype)
o.size=o.etype.size
o.__align=o.etype.__align
return o return o
end end
function type_enum:setbtype(btype)
self.etype=getSimpleType(btype) -- should be simple type
self.size=self.etype.size
self.__align=self.etype.__align
end
function type_enum:makewrap(address) function type_enum:makewrap(address)
local o={} local o={}
o.mtype=self o.mtype=self
@ -185,7 +188,8 @@ function type_bitfield.new(node,obj)
o.size=o.size+1 o.size=o.size+1
end end
end end
o.size=o.size/8 -- size in bytes, not bits. --o.size=o.size/8 -- size in bytes, not bits.
o.size=4
o.size=math.ceil(o.size) o.size=math.ceil(o.size)
--[=[if math.mod(o.size,o.__align) ~= 0 then --[=[if math.mod(o.size,o.__align) ~= 0 then
o.size=o.size+ (o.__align-math.mod(o.size,o.__align)) o.size=o.size+ (o.__align-math.mod(o.size,o.__align))
@ -571,7 +575,11 @@ parser["ld:field"]=function (node,obj,canDelay)
elseif meta=="static-array" then elseif meta=="static-array" then
return xtypes["static-array"].new(node,obj) return xtypes["static-array"].new(node,obj)
elseif meta=="global" then elseif meta=="global" then
return getGlobal(node.xarg["type-name"],canDelay) local ltype=getGlobal(node.xarg["type-name"],canDelay)
if node.xarg["base-type"]~=nil then
ltype:setbtype(node.xarg["base-type"])
end
return ltype
elseif meta=="compound" then elseif meta=="compound" then
if node.xarg.subtype==nil then if node.xarg.subtype==nil then
return xtypes["struct-type"].new(node,obj) return xtypes["struct-type"].new(node,obj)