|
|
@ -1,20 +1,28 @@
|
|
|
|
tools={}
|
|
|
|
tools={}
|
|
|
|
tools.menu=MakeMenu()
|
|
|
|
tools.menu=MakeMenu()
|
|
|
|
function tools.setrace()
|
|
|
|
function tools.setrace(name)
|
|
|
|
RaceTable=BuildNameTable()
|
|
|
|
RaceTable=BuildNameTable()
|
|
|
|
print("Your current race is:"..GetRaceToken(df.global.ui.race_id))
|
|
|
|
print("Your current race is:"..GetRaceToken(df.global.ui.race_id))
|
|
|
|
print("Type new race's token name in full caps (q to quit):")
|
|
|
|
local id
|
|
|
|
repeat
|
|
|
|
if name == nil then
|
|
|
|
entry=getline()
|
|
|
|
print("Type new race's token name in full caps (q to quit):")
|
|
|
|
if entry=="q" then
|
|
|
|
repeat
|
|
|
|
return
|
|
|
|
entry=getline()
|
|
|
|
|
|
|
|
if entry=="q" then
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
id=RaceTable[entry]
|
|
|
|
|
|
|
|
until id~=nil
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
id=RaceTable[name]
|
|
|
|
|
|
|
|
if id==nil then
|
|
|
|
|
|
|
|
error("Name not found!")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
id=RaceTable[entry]
|
|
|
|
end
|
|
|
|
until id~=nil
|
|
|
|
|
|
|
|
df.global.ui.race_id=id
|
|
|
|
df.global.ui.race_id=id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tools.menu:add("Set current race",tools.setrace)
|
|
|
|
tools.menu:add("Set current race",tools.setrace)
|
|
|
|
function tools.GiveSentience(names) --TODO make pattern...
|
|
|
|
function tools.GiveSentience(names)
|
|
|
|
RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
|
|
|
|
RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
|
|
|
|
if names ==nil then
|
|
|
|
if names ==nil then
|
|
|
|
ids={}
|
|
|
|
ids={}
|
|
|
@ -63,23 +71,7 @@ function tools.embark()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tools.menu:add("Embark anywhere",tools.embark)
|
|
|
|
tools.menu:add("Embark anywhere",tools.embark)
|
|
|
|
function tools.getlegendsid(croff)
|
|
|
|
function tools.getCreatureId(vector) --redo it to getcreature by name
|
|
|
|
local vec=engine.peek(croff,ptr_Creature.legends)
|
|
|
|
|
|
|
|
if vec:size()==0 then
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
for i =0,vector:size()-1 do
|
|
|
|
|
|
|
|
--if engine.peekd(vec:getval(i))~=0 then
|
|
|
|
|
|
|
|
-- print(string.format("%x",engine.peekd(vec:getval(i))-offsets.base()))
|
|
|
|
|
|
|
|
--end
|
|
|
|
|
|
|
|
if(engine.peekd(vec:getval(i))==offsets.getEx("vtableLegends")) then --easy to get.. just copy from player's-base
|
|
|
|
|
|
|
|
return engine.peekd(vec:getval(i)+4)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function tools.getCreatureId(vector)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tnames={}
|
|
|
|
tnames={}
|
|
|
|
rnames={}
|
|
|
|
rnames={}
|
|
|
|
--[[print("vector1 size:"..vector:size())
|
|
|
|
--[[print("vector1 size:"..vector:size())
|
|
|
@ -137,22 +129,25 @@ function tools.change_adv()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tools.menu:add("Change Adventurer",tools.change_adv)
|
|
|
|
tools.menu:add("Change Adventurer",tools.change_adv)
|
|
|
|
|
|
|
|
|
|
|
|
function tools.MakeFollow()
|
|
|
|
function tools.MakeFollow(unit,trgunit)
|
|
|
|
myoff=offsets.getEx("AdvCreatureVec")
|
|
|
|
|
|
|
|
vector=engine.peek(myoff,ptr_vector)
|
|
|
|
|
|
|
|
indx=tools.getCreatureId(vector)
|
|
|
|
|
|
|
|
print(string.format("current creature:%x",vector:getval(indx)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trgid=engine.peek(vector:getval(0)+ptr_Creature.ID.off,DWORD)
|
|
|
|
if unit == nil then
|
|
|
|
lfollow=engine.peek(vector:getval(indx)+ptr_Creature.followID.off,DWORD)
|
|
|
|
unit=getCreature()
|
|
|
|
if lfollow ~=0xFFFFFFFF then
|
|
|
|
end
|
|
|
|
print("Already following, unfollow? y/N")
|
|
|
|
if unit== nil then
|
|
|
|
r=getline()
|
|
|
|
error("Invalid creature")
|
|
|
|
if r== "y" then
|
|
|
|
end
|
|
|
|
engine.poke(vector:getval(indx)+ptr_Creature.followID.off,DWORD,0)
|
|
|
|
if trgunit==nil then
|
|
|
|
end
|
|
|
|
trgunit=df.global.world.units.other[0][0]
|
|
|
|
else
|
|
|
|
end
|
|
|
|
engine.poke(vector:getval(indx)+ptr_Creature.followID.off,DWORD,trgid)
|
|
|
|
unit.relations.group_leader_id=trgunit.id
|
|
|
|
|
|
|
|
local u_nem=getNemesis(unit)
|
|
|
|
|
|
|
|
local t_nem=getNemesis(trgunit)
|
|
|
|
|
|
|
|
if u_nem then
|
|
|
|
|
|
|
|
u_nem.group_leader_id=t_nem.id
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if t_nem and u_nem then
|
|
|
|
|
|
|
|
t_nem.companions:insert(#t_nem.companions,u_nem.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tools.menu:add("Make creature follow",tools.MakeFollow)
|
|
|
|
tools.menu:add("Make creature follow",tools.MakeFollow)
|
|
|
|