Skip to content

Commit

Permalink
raidboss: convert NetRegexes.echo/message/dialog to params (#5451)
Browse files Browse the repository at this point in the history
Part of #4986.

Closes #5452.
  • Loading branch information
quisquous authored Jun 25, 2023
1 parent e67c9e2 commit 5f38b03
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 87 deletions.
12 changes: 9 additions & 3 deletions resources/netregexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const keysThatRequireTranslationAsConst = [
export const keysThatRequireTranslation: readonly string[] = keysThatRequireTranslationAsConst;
export type KeysThatRequireTranslation = typeof keysThatRequireTranslationAsConst[number];

export const gameLogCodes = {
echo: '0038',
dialog: '0044',
message: '0839',
} as const;

const defaultParams = <
T extends LogDefinitionTypes,
V extends LogDefinitionVersions,
Expand Down Expand Up @@ -474,7 +480,7 @@ export default class NetRegexes {
['type', 'timestamp', 'code', 'name', 'line', 'capture'],
);

return NetRegexes.gameLog({ ...params, code: '0038' });
return NetRegexes.gameLog({ ...params, code: gameLogCodes.echo });
}

/**
Expand All @@ -489,7 +495,7 @@ export default class NetRegexes {
['type', 'timestamp', 'code', 'name', 'line', 'capture'],
);

return NetRegexes.gameLog({ ...params, code: '0044' });
return NetRegexes.gameLog({ ...params, code: gameLogCodes.dialog });
}

/**
Expand All @@ -504,7 +510,7 @@ export default class NetRegexes {
['type', 'timestamp', 'code', 'name', 'line', 'capture'],
);

return NetRegexes.gameLog({ ...params, code: '0839' });
return NetRegexes.gameLog({ ...params, code: gameLogCodes.message });
}

/**
Expand Down
2 changes: 2 additions & 0 deletions resources/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Job, Role } from '../types/job';
import { NetMatches } from '../types/net_matches';
import { OutputStrings } from '../types/trigger';

import { gameLogCodes } from './netregexes';
import Outputs from './outputs';
import { callOverlayHandler } from './overlay_plugin_api';

Expand Down Expand Up @@ -414,6 +415,7 @@ const Util = {
watchCombatantOverride = watchFunc;
clearCombatantsOverride = clearFunc;
},
gameLogCodes: gameLogCodes,
} as const;

export default Util;
15 changes: 9 additions & 6 deletions ui/raidboss/data/00-misc/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import NetRegexes from '../../../../resources/netregexes';
import outputs from '../../../../resources/outputs';
import { ConfigValue } from '../../../../resources/user_config';
import Util from '../../../../resources/util';
Expand Down Expand Up @@ -237,7 +236,7 @@ const triggerSet: TriggerSet<Data> = {
id: 'Test Lang',
type: 'GameLog',
// In game: /echo cactbot lang
netRegex: NetRegexes.echo({ line: 'cactbot lang.*?', capture: false }),
netRegex: { line: 'cactbot lang.*?', code: Util.gameLogCodes.echo, capture: false },
infoText: (data, _matches, output) => output.text!({ lang: data.parserLang }),
outputStrings: {
text: {
Expand All @@ -253,7 +252,7 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'Test Response',
type: 'GameLog',
netRegex: NetRegexes.echo({ line: 'cactbot test response.*?', capture: false }),
netRegex: { line: 'cactbot test response.*?', code: Util.gameLogCodes.echo, capture: false },
response: (_data, _matches, output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
Expand All @@ -273,7 +272,7 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'Test Watch',
type: 'GameLog',
netRegex: NetRegexes.echo({ line: 'cactbot test watch.*?', capture: false }),
netRegex: { line: 'cactbot test watch.*?', code: Util.gameLogCodes.echo, capture: false },
promise: (data) =>
Util.watchCombatant({
names: [
Expand Down Expand Up @@ -315,7 +314,7 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'Test Config',
type: 'GameLog',
netRegex: NetRegexes.echo({ line: 'cactbot test config.*?', capture: false }),
netRegex: { line: 'cactbot test config.*?', code: Util.gameLogCodes.echo, capture: false },
alertText: (data, _matches, output) => {
return output.text!({ value: data.triggerSetConfig.testTriggerOutput.toString() });
},
Expand All @@ -331,7 +330,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'Test Combatant Cast Enable',
type: 'GameLog',
netRegex: NetRegexes.echo({ line: 'cactbot test combatant cast.*?', capture: false }),
netRegex: {
line: 'cactbot test combatant cast.*?',
code: Util.gameLogCodes.echo,
capture: false,
},
run: (data) => {
data.watchingForCast = true;
},
Expand Down
7 changes: 4 additions & 3 deletions ui/raidboss/data/02-arr/dungeon/haukke_manor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Conditions from '../../../../../resources/conditions';
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -52,10 +52,11 @@ const triggerSet: TriggerSet<Data> = {
// Void Lamp Spawn
id: 'Haukke Normal Void Lamps',
type: 'GameLog',
netRegex: NetRegexes.message({
netRegex: {
line: 'The void lamps have begun emitting an eerie glow',
code: Util.gameLogCodes.message,
capture: false,
}),
},
infoText: (_data, _matches, output) => output.text!(),
outputStrings: {
text: {
Expand Down
7 changes: 4 additions & 3 deletions ui/raidboss/data/02-arr/raid/t1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Conditions from '../../../../../resources/conditions';
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -89,10 +89,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'T1 Slime Timer First',
type: 'GameLog',
netRegex: NetRegexes.message({
netRegex: {
line: 'The Allagan megastructure will be sealed off.*?',
code: Util.gameLogCodes.message,
capture: false,
}),
},
delaySeconds: 35,
suppressSeconds: 5,
infoText: (_data, _matches, output) => output.text!(),
Expand Down
8 changes: 6 additions & 2 deletions ui/raidboss/data/02-arr/raid/t8.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -27,7 +27,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'T8 Landmine Start',
type: 'GameLog',
netRegex: NetRegexes.message({ line: 'Landmines have been scattered.*?', capture: false }),
netRegex: {
line: 'Landmines have been scattered.*?',
code: Util.gameLogCodes.message,
capture: false,
},
alertText: (_data, _matches, output) => output.text!(),
run: (data) => data.landmines = {},
outputStrings: {
Expand Down
8 changes: 6 additions & 2 deletions ui/raidboss/data/03-hw/alliance/dun_scaith.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Conditions from '../../../../../resources/conditions';
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -456,7 +456,11 @@ const triggerSet: TriggerSet<Data> = {
// However, the RP text seems to be the only indicator.
id: 'Dun Scaith Shadow Links',
type: 'GameLog',
netRegex: NetRegexes.message({ line: 'Shadows gather on the floor.*?', capture: false }),
netRegex: {
line: 'Shadows gather on the floor.*?',
code: Util.gameLogCodes.message,
capture: false,
},
suppressSeconds: 5,
response: Responses.stopMoving(),
},
Expand Down
18 changes: 12 additions & 6 deletions ui/raidboss/data/03-hw/alliance/weeping_city.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Conditions from '../../../../../resources/conditions';
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -84,16 +84,21 @@ const triggerSet: TriggerSet<Data> = {
// only when that boss is in progress.
id: 'Weeping City HeadMarker Arachne',
type: 'GameLog',
netRegex: NetRegexes.message({
netRegex: {
line: 'The Queen\'s Room will be sealed off.*?',
code: Util.gameLogCodes.message,
capture: false,
}),
},
run: (data) => data.arachneStarted = true,
},
{
id: 'Weeping City HeadMarker Ozma',
type: 'GameLog',
netRegex: NetRegexes.message({ line: 'The Gloriole will be sealed off.*?', capture: false }),
netRegex: {
line: 'The Gloriole will be sealed off.*?',
code: Util.gameLogCodes.message,
capture: false,
},
run: (data) => {
data.arachneStarted = false;
data.ozmaStarted = true;
Expand All @@ -102,10 +107,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'Weeping City HeadMarker Calofisteri',
type: 'GameLog',
netRegex: NetRegexes.message({
netRegex: {
line: 'The Tomb Of The Nullstone will be sealed off.*?',
code: Util.gameLogCodes.message,
capture: false,
}),
},
run: (data) => {
data.ozmaStarted = false;
data.calStarted = true;
Expand Down
26 changes: 21 additions & 5 deletions ui/raidboss/data/04-sb/eureka/eureka_hydatos.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -92,13 +92,21 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'BA Seal',
type: 'GameLog',
netRegex: NetRegexes.message({ line: '.* will be sealed off.*?', capture: false }),
netRegex: {
line: '.* will be sealed off.*?',
code: Util.gameLogCodes.message,
capture: false,
},
run: (data) => data.sealed = true,
},
{
id: 'BA Clear Data',
type: 'GameLog',
netRegex: NetRegexes.message({ line: '.*is no longer sealed.*?', capture: false }),
netRegex: {
line: '.*is no longer sealed.*?',
code: Util.gameLogCodes.message,
capture: false,
},
run: (data) => {
delete data.side;
delete data.mythcall;
Expand Down Expand Up @@ -250,7 +258,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'BA Owain Fire Element',
type: 'GameLog',
netRegex: NetRegexes.dialog({ line: '[^:]*:Munderg, turn flesh to ash.*?', capture: false }),
netRegex: {
line: '[^:]*:Munderg, turn flesh to ash.*?',
code: Util.gameLogCodes.dialog,
capture: false,
},
condition: (data) => data.side === 'east',
alertText: (_data, _matches, output) => output.getToIce!(),
infoText: (_data, _matches, output) => output.switchMagia!(),
Expand All @@ -276,7 +288,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'BA Owain Ice Element',
type: 'GameLog',
netRegex: NetRegexes.dialog({ line: '[^:]*:Munderg, turn blood to ice.*?', capture: false }),
netRegex: {
line: '[^:]*:Munderg, turn blood to ice.*?',
code: Util.gameLogCodes.dialog,
capture: false,
},
condition: (data) => data.side === 'east',
alertText: (_data, _matches, output) => output.getToFire!(),
infoText: (_data, _matches, output) => output.switchMagia!(),
Expand Down
7 changes: 4 additions & 3 deletions ui/raidboss/data/04-sb/trial/byakko-ex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Conditions from '../../../../../resources/conditions';
import NetRegexes from '../../../../../resources/netregexes';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -193,10 +193,11 @@ const triggerSet: TriggerSet<Data> = {
{
id: 'ByaEx Tiger Add',
type: 'GameLog',
netRegex: NetRegexes.dialog({
netRegex: {
line: '[^:]*:Twofold is my wrath, twice-cursed my foes!.*?',
code: Util.gameLogCodes.dialog,
capture: false,
}),
},
condition: (data) => data.role === 'tank',
infoText: (_data, _matches, output) => output.text!(),
outputStrings: {
Expand Down
7 changes: 4 additions & 3 deletions ui/raidboss/data/04-sb/trial/tsukuyomi-ex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Conditions from '../../../../../resources/conditions';
import NetRegexes from '../../../../../resources/netregexes';
import Outputs from '../../../../../resources/outputs';
import { Responses } from '../../../../../resources/responses';
import Util from '../../../../../resources/util';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';
Expand Down Expand Up @@ -161,10 +161,11 @@ const triggerSet: TriggerSet<Data> = {
// There's no "starts using" here. She pushes at 35% to this ability.
// This happens after 2nd meteors naturally, but if dps is good
// then this could push unexpectedly earlier (or paired with buster).
netRegex: NetRegexes.dialog({
netRegex: {
line: '[^:]*:No\. No\.\.\. Not yet\. Not\. Yet\..*?',
code: Util.gameLogCodes.dialog,
capture: false,
}),
},
response: Responses.aoe(),
},
{
Expand Down
Loading

0 comments on commit 5f38b03

Please sign in to comment.