Skip to content

Commit c9cb3c1

Browse files
committed
Fixed Fighting Style parsing
1 parent d56e0eb commit c9cb3c1

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

AttackMaster/5.0.1/attackMaster.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ API_Meta.AttackMaster={offset:Number.MAX_SAFE_INTEGER,lineCount:-1};
105105
* v5.0.0 28/07/2025 Tidy corrupted fighting styles tables. Fixed issues with the temporary mods functions,
106106
* especially around temp mods to HP. Added ^^targetid^^ attribute to those that
107107
* can be used in attack macro definitions. Fixed some rare attack macro bugs.
108-
* v5.0.1 06/08/2025 Fix issues with ammo allocation for ranged weapons
108+
* v5.0.1 06/08/2025 Fix issues with ammo allocation for ranged weapons. Fixed fighting styles
109+
* parsing and enactment.
109110
*/
110111

111112
var attackMaster = (function() { // eslint-disable-line no-unused-vars
@@ -1834,10 +1835,11 @@ var attackMaster = (function() { // eslint-disable-line no-unused-vars
18341835
let styleData = styleObj.data(/}}\s*styledata\s*=(.*?){{/im);
18351836
if (_.isUndefined( styleData )) return;
18361837

1837-
let styleProf = (parseInt(fightStyles.tableLookup( fields.Style_proficiency, r ) || 1) || 1);
1838-
if (styleProf) {
1838+
let styleProf = Math.min((styleData.length-1),Math.max(0,((parseInt(fightStyles.tableLookup( fields.Style_proficiency, r ) || 0) || 0)-1)));
1839+
if (!_.isUndefined(styleProf) && styleData[styleProf]) {
18391840
let benefits = styleData[styleProf][0];
18401841
styleBenefits.push(benefits);
1842+
let styleDef = (styleData[0] && styleData[0].length) ? parseData( styleData[0][0], reStyleData ) : {};
18411843
for (let i=0; !_.isUndefined(inHandName = InHandTable.tableLookup( fields.InHand_name, i, false )); i++) {
18421844
let inHand = InHandTable.tableLookup( fields.InHand_trueName, i ) || inHandName;
18431845
spell = melee = ranged = shield = throwing = false;
@@ -1859,7 +1861,6 @@ var attackMaster = (function() { // eslint-disable-line no-unused-vars
18591861
wst.push(c[4].dbName());
18601862
}
18611863
prime = both = offhand = true;
1862-
let styleDef = parseData( styleData[0][0], reStyleData );
18631864
if (i == 0 && styleDef.prime) {
18641865
prime = (spell && styleDef.prime.includes('spell'))
18651866
|| (melee && styleDef.prime.includes('melee'))
@@ -8555,10 +8556,10 @@ var attackMaster = (function() { // eslint-disable-line no-unused-vars
85558556
if (isGM) doIndexDB(arg);
85568557
break;
85578558
case 'disp-config':
8558-
sendAPI('!rpgm '+senderId+' --disp-config', senderId);
8559+
sendAPI('!magic '+senderId+' --disp-config', senderId);
85598560
break;
85608561
case 'options':
8561-
sendAPI('!rpgm '+senderId+' --options '+arg.join('|'), senderId);
8562+
sendAPI('!magic '+senderId+' --options '+arg.join('|'), senderId);
85628563
break;
85638564
case 'config':
85648565
if (isGM) doConfig(arg, senderId);

AttackMaster/attackMaster.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ API_Meta.AttackMaster={offset:Number.MAX_SAFE_INTEGER,lineCount:-1};
105105
* v5.0.0 28/07/2025 Tidy corrupted fighting styles tables. Fixed issues with the temporary mods functions,
106106
* especially around temp mods to HP. Added ^^targetid^^ attribute to those that
107107
* can be used in attack macro definitions. Fixed some rare attack macro bugs.
108-
* v5.0.1 06/08/2025 Fix issues with ammo allocation for ranged weapons
108+
* v5.0.1 06/08/2025 Fix issues with ammo allocation for ranged weapons. Fixed fighting styles
109+
* parsing and enactment.
109110
*/
110111

111112
var attackMaster = (function() { // eslint-disable-line no-unused-vars
@@ -1834,10 +1835,11 @@ var attackMaster = (function() { // eslint-disable-line no-unused-vars
18341835
let styleData = styleObj.data(/}}\s*styledata\s*=(.*?){{/im);
18351836
if (_.isUndefined( styleData )) return;
18361837

1837-
let styleProf = (parseInt(fightStyles.tableLookup( fields.Style_proficiency, r ) || 1) || 1);
1838-
if (styleProf) {
1838+
let styleProf = Math.min((styleData.length-1),Math.max(0,((parseInt(fightStyles.tableLookup( fields.Style_proficiency, r ) || 0) || 0)-1)));
1839+
if (!_.isUndefined(styleProf) && styleData[styleProf]) {
18391840
let benefits = styleData[styleProf][0];
18401841
styleBenefits.push(benefits);
1842+
let styleDef = (styleData[0] && styleData[0].length) ? parseData( styleData[0][0], reStyleData ) : {};
18411843
for (let i=0; !_.isUndefined(inHandName = InHandTable.tableLookup( fields.InHand_name, i, false )); i++) {
18421844
let inHand = InHandTable.tableLookup( fields.InHand_trueName, i ) || inHandName;
18431845
spell = melee = ranged = shield = throwing = false;
@@ -1859,7 +1861,6 @@ var attackMaster = (function() { // eslint-disable-line no-unused-vars
18591861
wst.push(c[4].dbName());
18601862
}
18611863
prime = both = offhand = true;
1862-
let styleDef = parseData( styleData[0][0], reStyleData );
18631864
if (i == 0 && styleDef.prime) {
18641865
prime = (spell && styleDef.prime.includes('spell'))
18651866
|| (melee && styleDef.prime.includes('melee'))
@@ -8555,10 +8556,10 @@ var attackMaster = (function() { // eslint-disable-line no-unused-vars
85558556
if (isGM) doIndexDB(arg);
85568557
break;
85578558
case 'disp-config':
8558-
sendAPI('!rpgm '+senderId+' --disp-config', senderId);
8559+
sendAPI('!magic '+senderId+' --disp-config', senderId);
85598560
break;
85608561
case 'options':
8561-
sendAPI('!rpgm '+senderId+' --options '+arg.join('|'), senderId);
8562+
sendAPI('!magic '+senderId+' --options '+arg.join('|'), senderId);
85628563
break;
85638564
case 'config':
85648565
if (isGM) doConfig(arg, senderId);

0 commit comments

Comments
 (0)