Skip to content

Commit 54a0e03

Browse files
authored
Merge pull request DFHack#61 from PatrikLundell/deathcause
Deathcause
2 parents 20bee6f + 7b90330 commit 54a0e03

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

deathcause.rb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,32 @@ def display_death_event(e)
1919
end
2020

2121
def display_death_unit(u)
22-
death_info = u.counters.death_tg
23-
killer = death_info.killer_tg if death_info
24-
2522
str = "The #{u.race_tg.name[0]}"
2623
str << " #{u.name}" if u.name.has_name
27-
str << " died"
28-
str << " in year #{death_info.event_year}" if death_info
29-
str << " (cause: #{u.counters.death_cause.to_s.downcase})," if u.counters.death_cause != -1
30-
str << " killed by the #{killer.race_tg.name[0]} #{killer.name}" if killer
24+
25+
if not u.flags2.killed and not u.flags3.ghostly
26+
str << " is not dead yet !"
27+
28+
puts str.chomp(',')
29+
else
30+
death_info = u.counters.death_tg
31+
killer = death_info.killer_tg if death_info
3132

32-
puts str.chomp(',') + '.'
33+
str << " died" if !u.flags2.slaughter
34+
str << " was slaughtered" if u.flags2.slaughter
35+
36+
str << " in year #{death_info.event_year}" if death_info
37+
str << " (cause: #{u.counters.death_cause.to_s.downcase})," if u.counters.death_cause != -1
38+
str << " killed by the #{killer.race_tg.name[0]} #{killer.name}" if killer
39+
40+
puts str.chomp(',') + '.'
41+
end
3342
end
3443

3544
item = df.item_find(:selected)
3645
unit = df.unit_find(:selected)
3746

38-
if !item or !item.kind_of?(DFHack::ItemBodyComponent)
47+
if !unit and (!item or !item.kind_of?(DFHack::ItemBodyComponent))
3948
item = df.world.items.other[:ANY_CORPSE].find { |i| df.at_cursor?(i) }
4049
end
4150

@@ -52,13 +61,13 @@ def display_death_unit(u)
5261
if unit ||= item.unit_tg
5362
display_death_unit(unit)
5463
else
55-
puts "Not a historical figure, cannot death find info"
64+
puts "Not a historical figure, cannot find death info"
5665
end
5766

5867
else
5968
histfig = df.world.history.figures.binsearch(hf)
6069
unit = histfig ? df.unit_find(histfig.unit_id) : nil
61-
if unit and not unit.flags1.dead and not unit.flags3.ghostly
70+
if unit and not unit.flags2.killed and not unit.flags3.ghostly
6271
puts "#{unit.name} is not dead yet !"
6372

6473
else

0 commit comments

Comments
 (0)