fix deathcause for new df-structures

develop
jj 2012-10-10 18:56:23 +02:00
parent 46a24a83fb
commit e3e01107b9
1 changed files with 11 additions and 12 deletions

@ -1,15 +1,13 @@
# show death cause of a creature # show death cause of a creature
def display_event(e) def display_death_event(e)
p e if $DEBUG str = "The #{e.victim_hf_tg.race_tg.name[0]} #{e.victim_hf_tg.name} died in year #{e.year}"
str << " (cause: #{e.death_cause.to_s.downcase}),"
str = "#{e.victim_tg.name} died in year #{e.year}" str << " killed by the #{e.slayer_race_tg.name[0]} #{e.slayer_hf_tg.name}" if e.slayer_hf != -1
str << " of #{e.death_cause}" if false
str << " killed by the #{e.slayer_race_tg.name[0]} #{e.slayer_tg.name}" if e.slayer != -1
str << " using a #{df.world.raws.itemdefs.weapons[e.weapon.item_subtype].name}" if e.weapon.item_type == :WEAPON str << " using a #{df.world.raws.itemdefs.weapons[e.weapon.item_subtype].name}" if e.weapon.item_type == :WEAPON
str << ", shot by a #{df.world.raws.itemdefs.weapons[e.weapon.bow_item_subtype].name}" if e.weapon.bow_item_type == :WEAPON str << ", shot by a #{df.world.raws.itemdefs.weapons[e.weapon.bow_item_subtype].name}" if e.weapon.bow_item_type == :WEAPON
puts str + '.' puts str.chomp(',') + '.'
end end
item = df.item_find(:selected) item = df.item_find(:selected)
@ -21,14 +19,15 @@ end
if !item or !item.kind_of?(DFHack::ItemBodyComponent) if !item or !item.kind_of?(DFHack::ItemBodyComponent)
puts "Please select a corpse in the loo'k' menu" puts "Please select a corpse in the loo'k' menu"
else else
hfig = item.hist_figure_id hf = item.hist_figure_id
if hfig == -1 if hf == -1
puts "Not a historical figure, cannot find info" # TODO try to retrieve info from the unit (u = item.unit_tg)
puts "Not a historical figure, cannot death find info"
else else
events = df.world.history.events events = df.world.history.events
(0...events.length).reverse_each { |i| (0...events.length).reverse_each { |i|
if events[i].kind_of?(DFHack::HistoryEventHistFigureDiedst) and events[i].victim == hfig if events[i].kind_of?(DFHack::HistoryEventHistFigureDiedst) and events[i].victim_hf == hf
display_event(events[i]) display_death_event(events[i])
break break
end end
} }