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
DOUBLE=5
FLOAT=6
getline=function (inp)
return Console.lineedit(inp or "")
end
io.stdin=nil
function printd(...)
if DEBUG then
print(...)
@ -243,7 +249,8 @@ function it_menu:display()
local ans
repeat
local r
r=io.stdin:read()
r=getline("")
if r==nil then return end
if r=='q' then return end
ans=tonumber(r)
@ -359,12 +366,12 @@ function findVectors()
end
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
end
function BuildNameTable()
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 end:%x",vec.en))
--print("Creature count:"..vec.size)

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

@ -16,6 +16,7 @@ function MakeTable(modpos,modsize,names)
if RaceTable[line] == nil then
error("Failure, "..line.." not found!")
end
print("adding:"..line.." id:"..RaceTable[line])
engine.pokew(modpos+modsize+count*2,RaceTable[line]) -- add race
count = count + 1
end
@ -45,20 +46,23 @@ function embark(names)
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
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)
engine.poked(modpos+0x18,modpos+modsize) --fix array start for race
engine.poked(modpos+0x08,modpos+modsize+count*2) --fix array start for caste
engine.poked(castepos,modpos+modsize) --fix array start for race
engine.poked(racepos,modpos+modsize+count*2) --fix array start for caste
print("sucess loading mod @:"..modpos)
-- build race vector after module.
--finaly poke in the call!
engine.pokeb(loc,0x6a)
engine.pokeb(loc+1,0xFF)
engine.pokeb(loc,0x90)
engine.pokeb(loc+1,0x90)
engine.pokeb(loc+2,0xe8)
engine.poked(loc+3,modpos-loc-7)
--engine.pokeb(loc+5,0x90)

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

@ -1,7 +1,7 @@
function friendship_in.patch()
UpdateRanges()
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={}
i=1
repeat

@ -2,11 +2,10 @@ if not(FILE) then
--sanity test
--print("race num:"..engine.peekw(offsets.getEx("CurrentRace")))
--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:"..engine.peekw(add_race))
print("Your current race is:"..GetRaceToken(engine.peekw(add_race)))
print("Race num:"..df.ui.race_id)
print("Your current race is:"..GetRaceToken(df.ui.race_id))
print("If this is wrong please type 'q'")
if(io.stdin:read()=='q') then
if(getline()=='q') then
return
end

@ -54,13 +54,15 @@ dofile("dfusion/xml_struct.lua")
unlockDF()
plugins={}
table.insert(plugins,{"simple_embark","A simple embark dwarf count editor"})
--[=[table.insert(plugins,{"embark","Multi race embark"})
table.insert(plugins,{"items","A collection of item hacking tools"})
table.insert(plugins,{"offsets","Find all offsets"})
table.insert(plugins,{"tools","some misc tools"})
table.insert(plugins,{"embark","Multi race embark"})
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,{"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,{"migrants","multi race imigrations"})
table.insert(plugins,{"onfunction","run lua on some df function"})--]=]

@ -1,11 +1,11 @@
tools={}
tools.menu=MakeMenu()
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("Type new race's token name in full caps (q to quit):")
repeat
entry=io.stdin:read()
entry=getline()
if entry=="q" then
return
end
@ -20,7 +20,7 @@ function tools.GiveSentience(names) --TODO make pattern...
ids={}
print("Type race's token name in full caps to give sentience to:")
repeat
entry=io.stdin:read()
entry=getline()
id=RaceTable[entry]
until id~=nil
table.insert(ids,id)
@ -107,7 +107,7 @@ function tools.getCreatureId(vector)
end
print("=====================================")
print("type in name or number:")
r=io.stdin:read()
r=getline()
if tonumber(r) ==nil then
indx=rnames[r]
if indx==nil then return end
@ -125,7 +125,7 @@ function tools.change_adv()
tval=vector:getval(0)
vector:setval(0,vector:getval(indx))
vector:setval(indx,tval)
r=io.stdin:read()
r=getline()
if r=='q' then
return
end
@ -153,7 +153,7 @@ function tools.MakeFollow()
lfollow=engine.peek(vector:getval(indx)+ptr_Creature.followID.off,DWORD)
if lfollow ~=0xFFFFFFFF then
print("Already following, unfollow? y/N")
r=io.stdin:read()
r=getline()
if r== "y" then
engine.poke(vector:getval(indx)+ptr_Creature.followID.off,DWORD,0)
end
@ -165,7 +165,7 @@ tools.menu:add("Make creature follow",tools.MakeFollow)
function tools.runscript(files)
if files==nil then
files={}
table.insert(files,io.stdin:read())
table.insert(files,getline())
end
for _,v in pairs(files) do
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:")
names={}
repeat
w=io.stdin:read();
w=getline();
if rwords[w]~=nil then
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))
if i%100==99 then
r=io.stdin:read()
r=getline()
end
end
end
print("Type which to change (q cancels):")
repeat
r=io.stdin:read()
r=getline()
n=tonumber(r)
if(r=='q') then return end
until n~=nil
@ -268,7 +268,7 @@ function tools.changesite(names)
print((k-1).."->"..v)
end
repeat
r=io.stdin:read()
r=getline()
n2=tonumber(r)
if(r=='q') then return end
until n2~=nil
@ -300,7 +300,7 @@ function tools.changeflags(names)
end
end
print("Type number to flip, or 'q' to quit.")
q=io.stdin:read()
q=getline()
n2=tonumber(q)
if n2~=nil then
@ -354,7 +354,7 @@ function tools.protectsite()
print("2. range (x0 x1 y0 y1 z0 z1)")
print("3. One block around pointer")
print("anything else- quit")
q=io.stdin:read()
q=getline()
n2=tonumber(q)
if n2==nil then return end
if n2>3 or n2<1 then return end
@ -368,17 +368,17 @@ function tools.protectsite()
ze=z-1
elseif n2==2 then
print("enter x0:")
xs=tonumber(io.stdin:read())
xs=tonumber(getline())
print("enter x1:")
xe=tonumber(io.stdin:read())
xe=tonumber(getline())
print("enter y0:")
ys=tonumber(io.stdin:read())
ys=tonumber(getline())
print("enter y1:")
ye=tonumber(io.stdin:read())
ye=tonumber(getline())
print("enter z0:")
zs=tonumber(io.stdin:read())
zs=tonumber(getline())
print("enter z1:")
ze=tonumber(io.stdin:read())
ze=tonumber(getline())
function clamp(t,vmin,vmax)
if t> vmax then return vmax 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("3. One block around pointer")
print("anything else- quit")
q=io.stdin:read()
q=getline()
n2=tonumber(q)
if n2==nil then return end
if n2>3 or n2<1 then return end
@ -448,17 +448,17 @@ function tools.fixwarp()
ze=z-1
elseif n2==2 then
print("enter x0:")
xs=tonumber(io.stdin:read())
xs=tonumber(getline())
print("enter x1:")
xe=tonumber(io.stdin:read())
xe=tonumber(getline())
print("enter y0:")
ys=tonumber(io.stdin:read())
ys=tonumber(getline())
print("enter y1:")
ye=tonumber(io.stdin:read())
ye=tonumber(getline())
print("enter z0:")
zs=tonumber(io.stdin:read())
zs=tonumber(getline())
print("enter z1:")
ze=tonumber(io.stdin:read())
ze=tonumber(getline())
function clamp(t,vmin,vmax)
if t> vmax then return vmax end
if t< vmin then return vmin end

@ -1,28 +1,8 @@
--[=[
bld=buildinglist[1]
bld.x1=10
bld.flags.exists=true
boolval=bld.flags.justice
if boolval then
bld.mat_type=bld.mat_type+1
end
type info:
--]=]
if types ~= nil then
return
end
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)
for k,v in ipairs(t) do
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
local btype=node.xarg["base-type"] or "uint32_t"
--print(btype.." t="..convertType(btype))
o.etype=getSimpleType(btype) -- should be simple type
o.size=o.etype.size
o.__align=o.etype.__align
o:setbtype(btype)
return o
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)
local o={}
o.mtype=self
@ -185,7 +188,8 @@ function type_bitfield.new(node,obj)
o.size=o.size+1
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)
--[=[if math.mod(o.size,o.__align) ~= 0 then
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
return xtypes["static-array"].new(node,obj)
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
if node.xarg.subtype==nil then
return xtypes["struct-type"].new(node,obj)