Fixed empregnate, and some other tools...

develop
Warmist 2012-03-25 11:48:53 +03:00
parent e36ed9ac07
commit 63634de8d5
2 changed files with 28 additions and 9 deletions

@ -61,7 +61,7 @@ dofile("dfusion/editor.lua")
unlockDF()
plugins={}
table.insert(plugins,{"simple_embark","A simple embark dwarf count editor"})
--table.insert(plugins,{"tools","some misc tools"})
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"})

@ -272,23 +272,42 @@ function tools.empregnate(unit)
if unit==nil then
error("Failed to empregnate. Unit not selected/valide")
end
print(string.format("%x %x",df.sizeof(unit)))
local arr1=unit.appearance.unk_51c
local arr2=unit.appearance.unk_51c
local created=false
if unit.relations.pregnancy_ptr == nil then
print("creating preg ptr.")
unit.relations.pregnancy_ptr=unit.relations:_field("pregnancy_ptr"):new()--=df.new(unit.relations.pregnancy_ptr._kind)
created=true
if false then
print(string.format("%x %x",df.sizeof(unit.relations:_field("pregnancy_ptr"))))
return
end
local tarr1=unit.relations.pregnancy_ptr:deref().anon_1
local tarr2=unit.relations.pregnancy_ptr:deref().anon_2
if created or tarr1.size~= arr1.size then
print("Setting up arr1")
initType(tarr1,arr1.size)
local size,offset=df.sizeof(unit.relations:_field("pregnancy_ptr"))
local s1=df.sizeof(arr1)
local s2=df.sizeof(arr2)
engine.poked(offset,engine.alloc(s1+s2))
created=true
end
if created or tarr2.size~= arr2.size then
local tarr1=unit.relations.pregnancy_ptr.anon_1
local tarr2=unit.relations.pregnancy_ptr.anon_2
if created or #tarr1~= #arr1 then
print(string.format("Before: %d vs %d",#tarr1,#arr1))
print("Setting up arr1")
initType(tarr2,arr2.size)
print(string.format("%x %x",df.sizeof(tarr1)))
--tarr1=arr1:new()
local size,offset=df.sizeof(tarr1)
engine.poked(offset,engine.alloc(#arr1))
engine.poked(offset+4,#arr1)
print(string.format("after: %d vs %d",#tarr1,#arr1))
end
if created or #tarr2~= #arr2 then
print("Setting up arr2")
--tarr2=arr2:new()
local size,offset=df.sizeof(tarr2)
engine.poked(offset,engine.alloc(#arr2*2))
engine.poked(offset+4,#arr2)
end
print("Setting preg timer.")
unit.relations.pregnancy_timer=10