summaryrefslogtreecommitdiff
path: root/plugins/Dfusion
diff options
context:
space:
mode:
authorWarmist2012-04-04 19:06:56 +0300
committerWarmist2012-04-04 19:06:56 +0300
commitaaffdd56d8c2684667082372ea4effd02d3f4b2a (patch)
tree19d7b0ff9bb02c41a7a4104197279e0d4edd3734 /plugins/Dfusion
parent9707939f2c9c6edf7314a33c790e475046da22a7 (diff)
downloaddfhack-aaffdd56d8c2684667082372ea4effd02d3f4b2a.tar.gz
dfhack-aaffdd56d8c2684667082372ea4effd02d3f4b2a.tar.bz2
dfhack-aaffdd56d8c2684667082372ea4effd02d3f4b2a.tar.xz
Fixes to all of the new stuff.
Diffstat (limited to 'plugins/Dfusion')
-rw-r--r--plugins/Dfusion/luafiles/adv_tools/init.lua25
-rw-r--r--plugins/Dfusion/luafiles/common.lua8
-rw-r--r--plugins/Dfusion/luafiles/tools/init.lua6
3 files changed, 16 insertions, 23 deletions
diff --git a/plugins/Dfusion/luafiles/adv_tools/init.lua b/plugins/Dfusion/luafiles/adv_tools/init.lua
index c6917a76..f5fd9a47 100644
--- a/plugins/Dfusion/luafiles/adv_tools/init.lua
+++ b/plugins/Dfusion/luafiles/adv_tools/init.lua
@@ -1,7 +1,7 @@
adv_tools= {}
adv_tools.menu=MakeMenu()
--TODO make every tool generic (work for both modes)
-function adv_tools.reincarnate(swap_soul) --only for adventurer i guess, TODO soul swap...
+function adv_tools.reincarnate(swap_soul) --only for adventurer i guess
if swap_soul==nil then
swap_soul=true
end
@@ -15,12 +15,15 @@ function adv_tools.reincarnate(swap_soul) --only for adventurer i guess, TODO so
end
local events=df.global.world.history.events
local trg_hist_fig
- for i=#events-1,0,-1 do
+ for i=#events-1,0,-1 do -- reverse search because almost always it will be last entry
if df.history_event_hist_figure_diedst:is_instance(events[i]) then
--print("is instance:"..i)
if events[i].hfid==hist_fig.id then
--print("Is same id:"..i)
trg_hist_fig=events[i].slayer
+ if trg_hist_fig then
+ trg_hist_fig=df.historical_figure.find(trg_hist_fig)
+ end
break
end
end
@@ -28,23 +31,13 @@ function adv_tools.reincarnate(swap_soul) --only for adventurer i guess, TODO so
if trg_hist_fig ==nil then
error("Slayer not found")
end
- local trg_unit
- for k,v in pairs(df.global.world.history.figures) do --maybe getting it by [] would be enought?
- if v.id==trg_hist_fig then
- trg_unit=v.unit_id
- break
- end
- end
+
+ local trg_unit=trg_hist_fig.unit_id
if trg_unit==nil then
error("Unit id not found!")
end
- local trg_unit_final
- for k,v in pairs(df.global.world.units.all) do
- if v.id==trg_unit then
- trg_unit_final=v
- break
- end
- end
+ local trg_unit_final=df.unit.find(trg_unit)
+
tools.change_adv(trg_unit_final)
if swap_soul then --actually add a soul...
t_soul=adv.status.current_soul
diff --git a/plugins/Dfusion/luafiles/common.lua b/plugins/Dfusion/luafiles/common.lua
index b74c6aa8..7e41dc4e 100644
--- a/plugins/Dfusion/luafiles/common.lua
+++ b/plugins/Dfusion/luafiles/common.lua
@@ -513,7 +513,7 @@ function getCreature()
end
function getNemesisId(unit)
for k,v in pairs(unit.refs) do
- if tostring(v._type)=="<type: general_ref_is_nemesisst>" then
+ if df.general_ref_is_nemesisst:is_instance(v) then
return v.nemesis_id
end
end
@@ -521,11 +521,7 @@ end
function getNemesis(unit)
local id=getNemesisId(unit)
if id then
- for k,v in pairs(df.global.world.nemesis.all) do
- if id==v.id then
- return v
- end
- end
+ return df.nemesis_record.find(id)
end
end
function Allocate(size)
diff --git a/plugins/Dfusion/luafiles/tools/init.lua b/plugins/Dfusion/luafiles/tools/init.lua
index 27624e0a..e690e941 100644
--- a/plugins/Dfusion/luafiles/tools/init.lua
+++ b/plugins/Dfusion/luafiles/tools/init.lua
@@ -136,7 +136,11 @@ function tools.change_adv(unit,nemesis)
if nem then
nem.flags[0]=true
nem.flags[2]=true
- df.global.ui_advmode.player_id=nem.id
+ for k,v in pairs(df.global.world.nemesis.all) do
+ if v.id==nem.id then
+ df.global.ui_advmode.player_id=k
+ end
+ end
else
error("Current unit does not have nemesis record, further working not guaranteed")
end