From 706518c1b4f9cd3adc3a6682c0ba8fc4050f2ef0 Mon Sep 17 00:00:00 2001 From: Wexx Date: Fri, 22 Dec 2023 18:40:57 -0800 Subject: [PATCH 1/3] util: fix encounter start time bug in make/test_timeilne.ts --- docs/TimelineGuide.md | 39 ++++++++++---------------------- resources/netregexes.ts | 7 ++++++ util/logtools/encounter_tools.ts | 34 ++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/docs/TimelineGuide.md b/docs/TimelineGuide.md index 650ce8e690..a7a674c097 100644 --- a/docs/TimelineGuide.md +++ b/docs/TimelineGuide.md @@ -597,9 +597,9 @@ $ node --loader=ts-node/esm util/logtools/make_timeline.ts -f docs/logs/TheAbyss ┌───────┬──────────────┬────────────────┬──────────┬──────────────────────────────────┬──────────────────────────────────┬──────────┐ │ Index │ Start Date │ Start Time │ Duration │ Zone Name │ Encounter Name │ End Type │ ├───────┼──────────────┼────────────────┼──────────┼──────────────────────────────────┼──────────────────────────────────┼──────────┤ -│ 1 │ 2023-10-06 │ 20:20:08.265 │ 10m │ The Abyssal Fracture (Extreme) │ The Abyssal Fracture (Extreme) │ Win │ -│ 2 │ 2023-10-06 │ 21:09:43.014 │ 12m │ The Abyssal Fracture (Extreme) │ The Abyssal Fracture (Extreme) │ Win │ -│ 3 │ 2023-10-06 │ 21:55:12.239 │ 9m │ The Abyssal Fracture (Extreme) │ The Abyssal Fracture (Extreme) │ Win │ +│ 1 │ 2023-10-06 │ 20:21:20.456 │ 9m │ The Abyssal Fracture (Extreme) │ The Abyssal Fracture (Extreme) │ Win │ +│ 2 │ 2023-10-06 │ 21:11:44.502 │ 10m │ The Abyssal Fracture (Extreme) │ The Abyssal Fracture (Extreme) │ Win │ +│ 3 │ 2023-10-06 │ 21:55:24.409 │ 9m │ The Abyssal Fracture (Extreme) │ The Abyssal Fracture (Extreme) │ Win │ └───────┴──────────────┴────────────────┴──────────┴──────────────────────────────────┴──────────────────────────────────┴──────────┘ ``` @@ -622,32 +622,18 @@ hideall "--Reset--" hideall "--sync--" 0.0 "--sync--" InCombat { inGameCombat: "1" } window 0,1 -72.8 "--sync--" Ability { id: "8C49", source: "Zeromus" } -75.8 "--sync--" Ability { id: "8C49", source: "Zeromus" } -83.9 "Abyssal Nox" Ability { id: "8B3F", source: "Zeromus" } -92.9 "--sync--" Ability { id: "8B41", source: "Zeromus" } -92.9 "--sync--" #Ability { id: "8B40", source: "Zeromus" } -92.9 "--sync--" #Ability { id: "8B40", source: "Zeromus" } -92.9 "--sync--" Ability { id: "8D2B", source: "Zeromus" } -97.9 "--sync--" Ability { id: "8B41", source: "Zeromus" } -97.9 "--sync--" Ability { id: "8B40", source: "Zeromus" } -99.9 "Abyssal Echoes" Ability { id: "8B42", source: "Zeromus" } +3.6 "--sync--" Ability { id: "8C49", source: "Zeromus" } +11.7 "Abyssal Nox" Ability { id: "8B3F", source: "Zeromus" } +20.7 "--sync--" Ability { id: "8B41", source: "Zeromus" } +20.7 "--sync--" #Ability { id: "8B40", source: "Zeromus" } +20.7 "--sync--" #Ability { id: "8B40", source: "Zeromus" } +20.7 "--sync--" Ability { id: "8D2B", source: "Zeromus" } +25.7 "--sync--" Ability { id: "8B41", source: "Zeromus" } +25.7 "--sync--" Ability { id: "8B40", source: "Zeromus" } +27.7 "Abyssal Echoes" Ability { id: "8B42", source: "Zeromus" } # etc etc etc ``` -TODO: for some reason, `make_timeline.ts` is confused here and thinks the first -real ability (Abyssal Nox 8B3F) occurs at time=83.9. -It's clear from the log that it should be t=11.1. -See: - -```text -260|2023-10-06T20:21:19.9510000-07:00|1|0| -20|2023-10-06T20:21:27.1110000-07:00|40022550|Zeromus|8B3F|Abyssal Nox|40022550|Zeromus|4.700|100.00|80.10|0.00|0.00| -22|2023-10-06T20:21:32.1010000-07:00|40022550|Zeromus|8B3F|Abyssal Nox|10FF0007|Kehabiqo Febiqo|4A|10000|E|6E90000|1B|8B3F8000|0|0|0|0|0|0|0|0|0|0|126650|128564|10000|10000|||99.95|97.53|0.00|3.14|39444801|40478540|10000|10000|||100.00|80.10|0.00|0.00|0001A48D|0|8| -``` - -You can fix this by running with `-p 8B3F:11.1` which will set the first use of `8B3F` to be time `11.`1. - From here, it's a question of massaging this timeline into something that's usable. It may be tedious, but the best place to start when making a timeline is by filling out the @@ -1218,7 +1204,6 @@ There's plenty of feature work and fixes for timelines if you are interested in * `test_timeline.ts` could know which file to use without `-t` (it could use `ZoneChange` lines to look up the correct timeline) * `make_timeline.ts` has issues with empty names: * `test_timeline.ts` sometimes misses seal lines that are in the log: -* investigate this drift issue: * make it possible to pass a set of ids that should be named `--sync--`: * fix the log splitter so that when importing into ACT separate fights stay separate (maybe need to keep one new zone line? or just insert a fake `/echo end`?) * fix the offset issue with make/test timeline on zeromus log file: diff --git a/resources/netregexes.ts b/resources/netregexes.ts index 419c4965a3..8d99f7a24b 100644 --- a/resources/netregexes.ts +++ b/resources/netregexes.ts @@ -594,6 +594,13 @@ export default class NetRegexes { return buildRegex('CEDirector', params); } + /** + * matches: https://github.com/OverlayPlugin/cactbot/blob/main/docs/LogGuide.md#line-260-0x104-incombat + */ + static inCombat(params?: NetParams['InCombat']): CactbotBaseRegExp<'InCombat'> { + return buildRegex('InCombat', params); + } + /** * matches: https://github.com/OverlayPlugin/cactbot/blob/main/docs/LogGuide.md#line-261-0x105-combatantmemory */ diff --git a/util/logtools/encounter_tools.ts b/util/logtools/encounter_tools.ts index 8ae2463d97..12c6b34667 100644 --- a/util/logtools/encounter_tools.ts +++ b/util/logtools/encounter_tools.ts @@ -26,6 +26,7 @@ type FightEncInfo = ZoneEncInfo & { sealName?: string; sealId?: string; logLines?: string[]; + inferredStartFromAbility?: boolean; }; export class EncounterFinder { @@ -33,7 +34,6 @@ export class EncounterFinder { currentFight: FightEncInfo = {}; currentSeal?: string; zoneInfo?: typeof ZoneInfo[number]; - haveWon = false; haveSeenSeals = false; @@ -45,6 +45,7 @@ export class EncounterFinder { win: CactbotBaseRegExp<'ActorControl'>; wipe: CactbotBaseRegExp<'ActorControl'>; commence: CactbotBaseRegExp<'ActorControl'>; + inCombat: CactbotBaseRegExp<'InCombat'>; playerAttackingMob: CactbotBaseRegExp<'Ability'>; mobAttackingPlayer: CactbotBaseRegExp<'Ability'>; }; @@ -70,6 +71,7 @@ export class EncounterFinder { win: NetRegexes.network6d({ command: '4000000[23]' }), wipe: commonNetRegex.wipe, commence: NetRegexes.network6d({ command: '4000000[16]' }), + inCombat: NetRegexes.inCombat({ inGameCombat: '1', isGameChanged: '1' }), playerAttackingMob: NetRegexes.ability({ sourceId: '1.{7}', targetId: '4.{7}' }), mobAttackingPlayer: NetRegexes.ability({ sourceId: '4.{7}', targetId: '1.{7}' }), }; @@ -187,7 +189,6 @@ export class EncounterFinder { const netSeal = this.regex.netSeal.exec(line)?.groups; if (netSeal) { this.onNetSeal(line, netSeal.param1, netSeal); - this.storeStartLine(line, store); return; } @@ -219,14 +220,33 @@ export class EncounterFinder { // Most dungeons and some older raid content have zone zeals that indicate encounters. // If they don't, we need to start encounters by looking for combat. + // InCombat (0x104) log lines (w/ isChanged fields) were implemented in OverlayPlugin v0.19.23. + // They are the preferred method of detection, but to maintain backwards compatibility + // with prior logs and to account for potentially strange edge cases, we should continue + // to use mobAttackingPlayer / playerAttackingMob as a fallback method to detect encounters. if (!(this.currentFight.startTime || this.haveWon || this.haveSeenSeals)) { + const combatLine = this.regex.inCombat.exec(line); + if (combatLine?.groups) { + this.onStartFight(line, combatLine.groups, this.currentZone.zoneName); + return; + } let a = this.regex.playerAttackingMob.exec(line); if (!a) // TODO: This regex catches faerie healing and could potentially give false positives! a = this.regex.mobAttackingPlayer.exec(line); if (a?.groups) { this.onStartFight(line, a.groups, this.currentZone.zoneName); - this.storeStartLine(line, store); + this.currentFight.inferredStartFromAbility = true; + return; + } + } + + // If we've already started a fight due to ability usage (see TODO above re: faerie healing), + // we should 'restart' the fight if we get an InCombat line. + if (this.currentFight.startTime && this.currentFight.inferredStartFromAbility) { + const combatLine = this.regex.inCombat.exec(line); + if (combatLine?.groups) { + this.onStartFight(line, combatLine.groups, this.currentZone.zoneName); return; } } @@ -246,7 +266,7 @@ export class EncounterFinder { } onStartFight( line: string, - matches: NetMatches['Ability' | 'GameLog' | 'SystemLogMessage'], + matches: NetMatches['Ability' | 'GameLog' | 'SystemLogMessage' | 'InCombat'], fightName?: string, sealId?: string, ): void { @@ -257,6 +277,8 @@ export class EncounterFinder { startLine: line, startTime: TLFuncs.dateFromMatches(matches), zoneId: this.currentZone.zoneId, + inferredStartFromAbility: false, + logLines: [line], }; } @@ -302,7 +324,7 @@ class EncounterCollector extends EncounterFinder { override onStartFight( line: string, - matches: NetMatches['Ability' | 'GameLog' | 'SystemLogMessage'], + matches: NetMatches['Ability' | 'GameLog' | 'SystemLogMessage' | 'InCombat'], fightName?: string, sealId?: string, ): void { @@ -313,6 +335,8 @@ class EncounterCollector extends EncounterFinder { startLine: line, startTime: TLFuncs.dateFromMatches(matches), zoneId: this.currentZone.zoneId, + inferredStartFromAbility: false, + logLines: [line], }; } From e1ba8150ea2b8d037fb11390168ef3c43614a813 Mon Sep 17 00:00:00 2001 From: Wexx Date: Fri, 22 Dec 2023 18:51:43 -0800 Subject: [PATCH 2/3] minor fix --- util/logtools/encounter_tools.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/util/logtools/encounter_tools.ts b/util/logtools/encounter_tools.ts index 12c6b34667..be8e14d52e 100644 --- a/util/logtools/encounter_tools.ts +++ b/util/logtools/encounter_tools.ts @@ -34,6 +34,7 @@ export class EncounterFinder { currentFight: FightEncInfo = {}; currentSeal?: string; zoneInfo?: typeof ZoneInfo[number]; + haveWon = false; haveSeenSeals = false; From 7efed97b68d7361b0eca58291e0e506269ec3250 Mon Sep 17 00:00:00 2001 From: Wexx Date: Fri, 22 Dec 2023 19:00:49 -0800 Subject: [PATCH 3/3] fixes quisquous/cactbot#5716 as well --- docs/TimelineGuide.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/TimelineGuide.md b/docs/TimelineGuide.md index a7a674c097..fcede86c0f 100644 --- a/docs/TimelineGuide.md +++ b/docs/TimelineGuide.md @@ -1203,7 +1203,6 @@ There's plenty of feature work and fixes for timelines if you are interested in * make it so you can pass multiple mob names to `-it` * `test_timeline.ts` could know which file to use without `-t` (it could use `ZoneChange` lines to look up the correct timeline) * `make_timeline.ts` has issues with empty names: -* `test_timeline.ts` sometimes misses seal lines that are in the log: * make it possible to pass a set of ids that should be named `--sync--`: * fix the log splitter so that when importing into ACT separate fights stay separate (maybe need to keep one new zone line? or just insert a fake `/echo end`?) * fix the offset issue with make/test timeline on zeromus log file: