Skip to content

Commit

Permalink
Update spawn.lua for DFHack 0.34.11-r4
Browse files Browse the repository at this point in the history
  • Loading branch information
Putnam3145 committed Nov 13, 2013
1 parent 97fc92b commit 96b176b
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions Dwarf Fortress/hack/scripts/spawn.lua
Expand Up @@ -65,13 +65,13 @@ function CreateUnit(race_id,caste_id)
unit.race=race_id
unit.caste=caste_id
unit.id=df.global.unit_next_id
df.global.unit_next_id=df.global.unit_next_id+1
if caste.misc.maxage_max==-1 then
unit.relations.old_year=-1
else
unit.relations.old_year=df.global.cur_year-15+math.random(caste.misc.maxage_min,caste.misc.maxage_max)
end
unit.sex=caste.gender
df.global.unit_next_id=df.global.unit_next_id+1
if caste.misc.maxage_max==-1 then
unit.relations.old_year=-1
else
unit.relations.old_year=df.global.cur_year-15+math.random(caste.misc.maxage_min,caste.misc.maxage_max)
end
unit.sex=caste.gender
local body=unit.body

body.body_plan=caste.body_info
Expand Down Expand Up @@ -117,14 +117,14 @@ function CreateUnit(race_id,caste_id)
stuff.body_part_relsize:resize(body_part_count) -- all =0

--TODO add correct sizes. (calculate from age)
local size=caste.body_size_2[#caste.body_size_2-1]
body.size_info.size_cur=size
body.size_info.size_base=size
body.size_info.area_cur=math.pow(size,0.666)
body.size_info.area_base=math.pow(size,0.666)
local size=caste.body_size_2[#caste.body_size_2-1]
body.size_info.size_cur=size
body.size_info.size_base=size
body.size_info.area_cur=math.pow(size,0.666)
body.size_info.area_base=math.pow(size,0.666)
body.size_info.area_cur=math.pow(size*10000,0.333)
body.size_info.area_base=math.pow(size*10000,0.333)
body.size_info.area_base=math.pow(size*10000,0.333)
stuff.were_race=race_id
stuff.were_caste=caste_id
stuff.normal_race=race_id
Expand Down Expand Up @@ -160,36 +160,40 @@ function CreateUnit(race_id,caste_id)
df.global.world.units.all:insert("#",unit)
df.global.world.units.active:insert("#",unit)
--todo set weapon bodypart
local num_inter=#caste.body_info.interactions
unit.curse.anon_5:resize(num_inter)
local num_inter=#caste.body_info.interactions
unit.curse.anon_5:resize(num_inter)
return unit
end
function findRace(name)
for k,v in pairs(df.global.world.raws.creatures.all) do
if v.creature_id==name then
return k
end
end
qerror("Race:"..name.." not found!")
for k,v in pairs(df.global.world.raws.creatures.all) do
if v.creature_id==name then
return k
end
end
qerror("Race:"..name.." not found!")
end
function PlaceUnit(race,caste,name,position)
local pos=position or copyall(df.global.cursor)
if pos.x==-30000 then
qerror("Point your pointy thing somewhere")
qerror("Point your pointy thing somewhere")
end
race=findRace(race)
local u=CreateUnit(race,tonumber(caste) or 0)
u.pos:assign(pos)
if name then
u.name.first_name=name
u.name.has_name=true
end
u.civ_id=df.global.ui.civ_id
race=findRace(race)
local u=CreateUnit(race,tonumber(caste) or 0)
u.pos:assign(pos)
if name then
u.name.first_name=name
u.name.has_name=true
end
u.civ_id=df.global.ui.civ_id

local desig,ocupan=dfhack.maps.getTileFlags(pos)
ocupan.unit=true
--createNemesis(u)
local desig,ocupan=dfhack.maps.getTileFlags(pos)
if ocupan.unit then
ocupan.unit_grounded=true
u.flags1.on_ground=true
else
ocupan.unit=true
--createNemesis(u)
end
function createFigure(trgunit)
local hf=df.historical_figure:new()
Expand Down Expand Up @@ -238,10 +242,10 @@ end
local argPos

if #args>3 then
argPos={}
argPos.x=args[4]
argPos.y=args[5]
argPos.z=args[6]
argPos={}
argPos.x=args[4]
argPos.y=args[5]
argPos.z=args[6]
end

PlaceUnit(args[1],args[2],args[3],argPos) --Creature (ID), caste (number), name, x,y,z for spawn.

0 comments on commit 96b176b

Please sign in to comment.