Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Reading the Combat Log  (Read 4581 times)

Jack9

  • Escaped Lunatic
    • View Profile
Reading the Combat Log
« on: October 17, 2015, 09:54:53 pm »

I'm sure it's possible, but as a neophyte to DFHack, I have no idea what to look for.
I am interested in making a mod to read the combat log reports individually, then dig down to the details and make a new screen with new content (like what the assailant(s) and defenders looked like at the start and finish) after parsing individual fights.

I looked at the EventManager (https://github.com/DFHack/dfhack/blob/master/library/modules/EventManager.cpp) and the Lua API for creating unit combat reports. So I looked around a bit more and found eventful has onUnitAttack and onReport. I looked at soundsense and it uses the gamelog, which is not what I'm looking for.

There are all these completely different and mismatched tools and scripts. It's a mess.

I want to capture the individual combat details for XXX is fighting.

Is there no known way to access individual combat reports?
« Last Edit: October 17, 2015, 09:56:25 pm by Jack9 »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Reading the Combat Log
« Reply #1 on: October 17, 2015, 11:34:33 pm »

onReport is definitely what you want.

Code: [Select]
eventful.onReport.something=function(reportId)
    local report=df.report.find(reportId)
    --do stuff with report
end

This is the structure of a report
« Last Edit: October 17, 2015, 11:40:43 pm by Putnam »
Logged

Jack9

  • Escaped Lunatic
    • View Profile
Re: Reading the Combat Log
« Reply #2 on: October 21, 2015, 10:40:26 pm »

eventful is a lua script (called from a plugin?). It triggers on individual report events, not unit reports (see: DF_UNIT_REPORT_TYPE_H). Using lua, the most you can get is some opaque data that you can leak from report.h, which is pretty much what was in what you linked to...
Code: [Select]
        print("type:",report.type)
        print("text:",report.text)
        print("color:",report.color)
        print("bright:",report.bright)
        print("duration:",report.duration)
        print("flags:",report.flags)  -- bitfield
        print("flags.whole:",report.flags.whole)
        print("repeat_count:",report.repeat_count)
        print("pos:",report.pos)
        print("id:",report.id)
        print("year:",report.year)
        print("time:",report.time)
        print("unk_v40_1:",report.unk_v40_1)
        print("unk_v40_2:",report.unk_v40_2)
        print("unk_v40_3:",report.unk_v40_3)

What I want, is access to DF_UNIT_REPORT_TYPE_H or DF_COMBAT_REPORT_EVENT_TYPE_H , but it's not in DFHack's github afaik. Where does DFfolder/hack/include/df/combat_report_event_type.h in the LNP come from?
« Last Edit: October 21, 2015, 10:42:25 pm by Jack9 »
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Reading the Combat Log
« Reply #3 on: October 28, 2015, 03:23:06 pm »

AFAIK that file is automatically generated from some XML. The XML is not any better than just reading the header, what are you looking for? If you only want a certain kind of report why don't you examine the report type and only take action on the types you want?
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Jack9

  • Escaped Lunatic
    • View Profile
Re: Reading the Combat Log
« Reply #4 on: October 29, 2015, 03:03:59 pm »

As I previously listed, the amount of information that comes out of report.h is limited in comparison to others. getReport just provides that data from report.h
Events in this format (report.h), are unconnected. They are not associated as part of an individual combat report sequence. Yes there's a unique id, but events of this nature do not relate directly to an aggregate combat sequence.

> . The XML [that generates DF_UNIT_REPORT_TYPE_H or DF_COMBAT_REPORT_EVENT_TYPE_H] is not any better than just reading the header, what are you looking for?

Combat sequence information. ID of the sequence, first item, last item.
ID references to involved actors and items would be nice, but is not critical.

This is a combat sequence (5 pages worth):
http://dwarffortresswiki.org/images/thumb/5/53/Combat_report.png/600px-Combat_report.png

I am trying to obtain individual combat reports (regardless of length) that have already occurred and add an additional screen/functionality to the combat sequence details.


« Last Edit: October 29, 2015, 08:43:31 pm by Jack9 »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Reading the Combat Log
« Reply #5 on: October 29, 2015, 03:36:56 pm »

those are part of the unit IIRC

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Reading the Combat Log
« Reply #6 on: October 30, 2015, 02:49:12 pm »

So you get a report, look up the involved unit(s), and get where the report comes in the sequence from there? That makes sense, but it seems like a boneheaded way to design it.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Jack9

  • Escaped Lunatic
    • View Profile
Re: Reading the Combat Log
« Reply #7 on: October 31, 2015, 10:55:41 pm »

Specifically, I have generated a few hundred images of dwarf combat events (between dwarves) and am looking to provide a visual comic to accompany the verbose text representation, as a proof-of-concept visualization.

There are some quirks about what gets represented and what doesn't, why, and how to interpret certain actions. Via manual assembly, it's very effective at illustrating the events and lays the groundwork for other visualizations.

The primary block is being able to access the events in a single combat sequence, correctly. Interpreting the individual events and displaying the appropriate graphics in a pane off of that sequence is rather trivial after that.
Logged

Aedom

  • Bay Watcher
    • View Profile
Re: Reading the Combat Log
« Reply #8 on: September 20, 2016, 08:55:44 am »

onReport is definitely what you want.

Code: [Select]
eventful.onReport.something=function(reportId)
    local report=df.report.find(reportId)
    --do stuff with report
end

This is the structure of a report

Your code has "eventful.onReport.something = ...".  Is this correct or short hand?  I haven't had any success getting this to actually call me back with a report line.
Logged

Aedom

  • Bay Watcher
    • View Profile
Re: Reading the Combat Log
« Reply #9 on: September 20, 2016, 11:05:19 am »

Specifically, I have generated a few hundred images of dwarf combat events (between dwarves) and am looking to provide a visual comic to accompany the verbose text representation, as a proof-of-concept visualization.

There are some quirks about what gets represented and what doesn't, why, and how to interpret certain actions. Via manual assembly, it's very effective at illustrating the events and lays the groundwork for other visualizations.

The primary block is being able to access the events in a single combat sequence, correctly. Interpreting the individual events and displaying the appropriate graphics in a pane off of that sequence is rather trivial after that.

Trying looking at the UNIT_ATTACK event type.  You should be able to trace everything back from there.  I'm currently working it myself, so I'll let you know how it goes and probably share the code.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Reading the Combat Log
« Reply #10 on: September 20, 2016, 01:08:24 pm »

onReport is definitely what you want.

Code: [Select]
eventful.onReport.something=function(reportId)
    local report=df.report.find(reportId)
    --do stuff with report
end

This is the structure of a report

Your code has "eventful.onReport.something = ...".  Is this correct or short hand?  I haven't had any success getting this to actually call me back with a report line.

It's correct. Make sure ... is function(x).

Aedom

  • Bay Watcher
    • View Profile
Re: Reading the Combat Log
« Reply #11 on: September 23, 2016, 03:48:41 pm »

Keep an eye on http://www.bay12forums.com/smf/index.php?topic=160694.0.  I'm building a tool to analyze combat damage.  The analyzer has a heuristic system for matching the combat log messages back to discrete data about the attack strikes. 

I am currently moving towards the alpha testing phase.  I can separate out the parser for you to use as an external library, if you think it might be a good fit.
Logged

Aedom

  • Bay Watcher
    • View Profile
Re: Reading the Combat Log
« Reply #12 on: September 23, 2016, 04:36:05 pm »

onReport is definitely what you want.

Code: [Select]
eventful.onReport.something=function(reportId)
    local report=df.report.find(reportId)
    --do stuff with report
end

This is the structure of a report

Your code has "eventful.onReport.something = ...".  Is this correct or short hand?  I haven't had any success getting this to actually call me back with a report line.

It's correct. Make sure ... is function(x).


Thanks.  I had neglected to enable the event type.  Documentation for this stuff is..umm.....shall we say "poor"?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Reading the Combat Log
« Reply #13 on: September 23, 2016, 05:24:31 pm »

Thanks.  I had neglected to enable the event type.  Documentation for this stuff is..umm.....shall we say "poor"?

I dunno, it says in the second sentence for the section that "Each of [the EventManager-exported events) first [need] to be enabled."