diff options
| author | jj | 2012-09-21 15:47:46 +0200 |
|---|---|---|
| committer | jj | 2012-09-21 15:47:46 +0200 |
| commit | b3ae67cc8bfe48520daf85b0e1fe614531c6bd6c (patch) | |
| tree | c345c6fb06bb670698818a73bce85e1a6486415c | |
| parent | b115edcf68c69deb432915a6fbcd21ff6345bfe0 (diff) | |
| download | dfhack-b3ae67cc8bfe48520daf85b0e1fe614531c6bd6c.tar.gz dfhack-b3ae67cc8bfe48520daf85b0e1fe614531c6bd6c.tar.bz2 dfhack-b3ae67cc8bfe48520daf85b0e1fe614531c6bd6c.tar.xz | |
add scripts/deathcause
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | scripts/deathcause.rb | 37 |
2 files changed, 38 insertions, 0 deletions
@@ -33,6 +33,7 @@ DFHack v0.34.11-r2 (UNRELEASED) - fix/population-cap: run after every migrant wave to prevent exceeding the cap. - fix/stable-temp: counts items with temperature updates; does instant one-shot stable-temp. - fix/loyaltycascade: fix units allegiance, eg after ordering a dwarf merchant kill. + - deathcause: shows the circumstances of death for a given body. - digfort: designate areas to dig from a csv file. - drainaquifer: remove aquifers from the map. - growcrops: cheat to make farm crops instantly grow. diff --git a/scripts/deathcause.rb b/scripts/deathcause.rb new file mode 100644 index 00000000..178ebbc8 --- /dev/null +++ b/scripts/deathcause.rb @@ -0,0 +1,37 @@ +# show death cause of a creature + +def display_event(e) + p e if $DEBUG + + str = "#{e.victim_tg.name} died in year #{e.year}" + 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 << ", shot by a #{df.world.raws.itemdefs.weapons[e.weapon.bow_item_subtype].name}" if e.weapon.bow_item_type == :WEAPON + + puts str + '.' +end + +item = df.item_find(:selected) + +if !item or !item.kind_of?(DFHack::ItemBodyComponent) + item = df.world.items.other[:ANY_CORPSE].find { |i| df.at_cursor?(i) } +end + +if !item or !item.kind_of?(DFHack::ItemBodyComponent) + puts "Please select a corpse in the loo'k' menu" +else + hfig = item.hist_figure_id + if hfig == -1 + puts "Not a historical figure, cannot find info" + else + events = df.world.history.events + (0...events.length).reverse_each { |i| + if events[i].kind_of?(DFHack::HistoryEventHistFigureDiedst) and events[i].victim == hfig + display_event(events[i]) + break + end + } + end +end + |
