Skip to content

Commit cb0673d

Browse files
committed
Updated script.json & fixes
* Added database indexing for improved performance * Changed data tags to reflect newest standard * Fixed bug relating to calculated AC0 when checking AC * Fixed ranged weapon magical to-hit bonus due to spells in operation
1 parent cebd9ff commit cb0673d

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

AttackMaster/1.038/attackMaster.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@
101101
* v1.038 08/01/2022 Added database indexing for improved performance
102102
* Changed data tags to reflect newest standard
103103
* Fixed bug relating to calculated AC0 when checking AC
104+
* Fixed ranged weapon magical to-hit bonus due to spells in operation
104105
*/
105106

106107
var attackMaster = (function() {
107108
'use strict';
108109
var version = 1.038,
109-
author = 'RED',
110+
author = 'Richard @ Damery',
110111
pending = null;
111112

112113
/*
@@ -3902,15 +3903,16 @@ var attackMaster = (function() {
39023903
} else {
39033904
let data = acValues[itemClass].data,
39043905
itemAdj = (parseInt(data.adj || 0) + parseInt(data.madj || 0) + parseInt(data.sadj || 0) + parseInt(data.padj || 0) + parseInt(data.badj || 0))/5;
3905-
if (itemClass == 'armour') {
3906+
// if (itemClass == 'armour') {
39063907
diff = (parseInt(data.ac || 10) - itemAdj - (parseFloat(data.db || 1)*dexBonus)) - (ac - adj - dexAdj);
3907-
} else {
3908-
diff = ((adj + dexAdj) - (itemAdj + (parseFloat(data.db || 1)*dexBonus)));
3908+
// } else {
3909+
// diff = ((adj + dexAdj) - (itemAdj + (parseFloat(data.db || 1)*dexBonus)));
39093910
if (itemClass.includes('protection') && acValues.armour.magic) {
39103911
armourMsg.push(itemName+' does not add to magical armour');
39113912
}
3912-
}
3913+
// }
39133914
}
3915+
39143916
} else {
39153917
armourMsg.push(itemName+' is overridden by another item');
39163918
diff = undefined;
@@ -3945,6 +3947,7 @@ var attackMaster = (function() {
39453947
});
39463948
}
39473949
}
3950+
// log('name='+itemName+', itemClass='+itemClass+', total adj='+(parseInt(acData.adj)+parseInt(acData.madj)+parseInt(acData.sadj)+parseInt(acData.padj)+parseInt(acData.badj))+', magic='+acValues.armour.magic);
39483951
}
39493952
}
39503953
}
@@ -4249,7 +4252,7 @@ var attackMaster = (function() {
42494252

42504253
totalAttkAdj = '([['+attkAdj+']][Weapon+]) + ([['+dmgAdj+']][Ammo+]) + ([[ '+weapDexBonus+' *[['+dexMissile+']]]][Dexterity+] )'
42514254
+ '+([['+weapStrBonus+'*[['+strHit+']]]][Strength+])+([['+race+']][Race mod])+([['+Math.min(proficiency,0)+']][Prof penalty])'
4252-
+ '+([['+twoWeapPenalty+']][2-weap penalty])+([['+rangeMod+']][Range mod])';
4255+
+ '+([['+magicHitAdj+']][Magic Hit+])+([['+twoWeapPenalty+']][2-weap penalty])+([['+rangeMod+']][Range mod])';
42534256

42544257
totalDmgAdj = '( ([['+dmgAdj+']][Ammo+]) +([['+magicDmgAdj+']][Magic dmg+]) +([['+(ammoStrBonus*strDmg)+']][Strength+]) )';
42554258

@@ -6285,7 +6288,8 @@ var attackMaster = (function() {
62856288
_.each( acValues, (e,k) => {
62866289
if (k == 'armour') return;
62876290
if (!k.toLowerCase().includes('protection') || !magicArmour) {
6288-
dmgAdj.armoured = _.mapObject(dmgAdj.armoured, (d,a) => {;return d + parseInt(e.data[a] || 0)});
6291+
6292+
dmgAdj.armoured = _.mapObject(dmgAdj.armoured, (d,a) => {return d + parseInt(e.data[a] || 0)});
62896293
armouredDexBonus *= parseFloat(e.data.db || 1);
62906294
if (k == 'shield') {
62916295
dmgAdj.armoured.adj += parseInt(e.data.ac || 1);
@@ -6308,6 +6312,9 @@ var attackMaster = (function() {
63086312
if (dexBonus) {
63096313
acValues.dexBonus = {name:('Dexterity Bonus '+dexBonus),specs:['',('Dexterity Bonus '+dexBonus),'dexterity','0H','dexterity'],data:{adj:dexBonus}};
63106314
}
6315+
6316+
// log('Final baseAC='+baseAC+', -adj='+dmgAdj.armoured.adj+', -dexBonus='+dexBonus);
6317+
63116318
setAttr( charCS, fields.Armour_normal, (baseAC - dmgAdj.armoured.adj - dexBonus) );
63126319
setAttr( charCS, fields.Armour_missile, (baseAC - dmgAdj.armoured.adj - dexBonus - dmgAdj.armoured.madj) );
63136320
setAttr( charCS, fields.Armour_surprised, (baseAC - dmgAdj.armoured.adj) );

AttackMaster/attackMaster.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@
101101
* v1.038 08/01/2022 Added database indexing for improved performance
102102
* Changed data tags to reflect newest standard
103103
* Fixed bug relating to calculated AC0 when checking AC
104+
* Fixed ranged weapon magical to-hit bonus due to spells in operation
104105
*/
105106

106107
var attackMaster = (function() {
107108
'use strict';
108109
var version = 1.038,
109-
author = 'RED',
110+
author = 'Richard @ Damery',
110111
pending = null;
111112

112113
/*
@@ -712,9 +713,7 @@ var attackMaster = (function() {
712713
+'<p>AttackMaster API provides functions to manage weapons, armour & shields, including taking weapons in hand and using them to attack. It uses standard AD&D 2e rules to the full extent, taking into account: ranged weapon ammo management with ranges varying appropriately and range penalties/bonuses applied; Strength & Dexterity bonuses where appropriate; any magic bonuses to attacks that are in effect (if used with <b>RoundMaster API</b> effects); penalties & bonuses for non-proficiency, proficiency, specialisation & mastery; penalties for non-Rangers attacking with two weapons; use of 1-handed, 2-handed or many-handed weapons and restrictions on the number of weapons & shields that can be held at the same time; plus many other features. This API works best with the databases provided with this API, which hold the data for automatic definition of weapons and armour. However, some attack commands will generally work with manual entry of weapons onto the character sheet. The <b>CommandMaster API</b> can be used by the GM to easily manage weapon proficiencies.</p>'
713714
+'<p>Specification for weapons, armour & shields are implemented as ability macros in specific database character sheets. This API comes with a wide selection of weapon and armour macros, held in databases that are created and updated automatically when the API is run. If the <b>MagicMaster API</b> is also loaded, it provides many more specifications for standard and magic items that are beneficial to melee actions and armour class. The GM can add to the provided items in the databases using standard Roll20 Character Sheet editing, following the instructions provided in the relevant Database Help handout.</p>'
714715
+'<p><b><u>Note:</u></b> For some aspects of the APIs to work, the <b>ChatSetAttr API</b> and the <b>Tokenmod API</b>, both from the Roll20 Script Library, must be loaded. It is also <i>highly recommended</i> to load all the other RPGMaster series APIs: <b>RoundMaster, InitiativeMaster, MagicMaster and CommandMaster</b>. This will provide the most immersive game-support environment</p>'
715-
+'<h2>Syntax of AttackMaster calls</h2>'
716-
+'<p>The AttackMaster API is called using !attk.</p>'
717-
+'<pre>!attk --help</pre>'
716+
+'<h2>Syntax of AttackMaster calls</h2>' +'<p>The AttackMaster API is called using !attk.</p>' +'<pre>!attk --help</pre>'
718717
+'<p>Commands to be sent to the AttackMaster API must be preceded by two hyphens <b>\'--\'</b> as above for the <b>--help</b> command. Parameters to these commands are separated by vertical bars \'|\', for example:</p>'
719718
+'<pre>!attk --attk-hit token_id | [message] | [monster weap1] | [monster weap2] | [monster weap3]</pre>'
720719
+'<p>If optional parameters are not to be included, but subsequent parameters are needed, use two vertical bars together with nothing between them, e.g.</p>'
@@ -3904,15 +3903,16 @@ var attackMaster = (function() {
39043903
} else {
39053904
let data = acValues[itemClass].data,
39063905
itemAdj = (parseInt(data.adj || 0) + parseInt(data.madj || 0) + parseInt(data.sadj || 0) + parseInt(data.padj || 0) + parseInt(data.badj || 0))/5;
3907-
if (itemClass == 'armour') {
3906+
// if (itemClass == 'armour') {
39083907
diff = (parseInt(data.ac || 10) - itemAdj - (parseFloat(data.db || 1)*dexBonus)) - (ac - adj - dexAdj);
3909-
} else {
3910-
diff = ((adj + dexAdj) - (itemAdj + (parseFloat(data.db || 1)*dexBonus)));
3908+
// } else {
3909+
// diff = ((adj + dexAdj) - (itemAdj + (parseFloat(data.db || 1)*dexBonus)));
39113910
if (itemClass.includes('protection') && acValues.armour.magic) {
39123911
armourMsg.push(itemName+' does not add to magical armour');
39133912
}
3914-
}
3913+
// }
39153914
}
3915+
39163916
} else {
39173917
armourMsg.push(itemName+' is overridden by another item');
39183918
diff = undefined;
@@ -3947,6 +3947,7 @@ var attackMaster = (function() {
39473947
});
39483948
}
39493949
}
3950+
// log('name='+itemName+', itemClass='+itemClass+', total adj='+(parseInt(acData.adj)+parseInt(acData.madj)+parseInt(acData.sadj)+parseInt(acData.padj)+parseInt(acData.badj))+', magic='+acValues.armour.magic);
39503951
}
39513952
}
39523953
}
@@ -4251,7 +4252,7 @@ var attackMaster = (function() {
42514252

42524253
totalAttkAdj = '([['+attkAdj+']][Weapon+]) + ([['+dmgAdj+']][Ammo+]) + ([[ '+weapDexBonus+' *[['+dexMissile+']]]][Dexterity+] )'
42534254
+ '+([['+weapStrBonus+'*[['+strHit+']]]][Strength+])+([['+race+']][Race mod])+([['+Math.min(proficiency,0)+']][Prof penalty])'
4254-
+ '+([['+twoWeapPenalty+']][2-weap penalty])+([['+rangeMod+']][Range mod])';
4255+
+ '+([['+magicHitAdj+']][Magic Hit+])+([['+twoWeapPenalty+']][2-weap penalty])+([['+rangeMod+']][Range mod])';
42554256

42564257
totalDmgAdj = '( ([['+dmgAdj+']][Ammo+]) +([['+magicDmgAdj+']][Magic dmg+]) +([['+(ammoStrBonus*strDmg)+']][Strength+]) )';
42574258

@@ -6287,7 +6288,8 @@ var attackMaster = (function() {
62876288
_.each( acValues, (e,k) => {
62886289
if (k == 'armour') return;
62896290
if (!k.toLowerCase().includes('protection') || !magicArmour) {
6290-
dmgAdj.armoured = _.mapObject(dmgAdj.armoured, (d,a) => {;return d + parseInt(e.data[a] || 0)});
6291+
6292+
dmgAdj.armoured = _.mapObject(dmgAdj.armoured, (d,a) => {return d + parseInt(e.data[a] || 0)});
62916293
armouredDexBonus *= parseFloat(e.data.db || 1);
62926294
if (k == 'shield') {
62936295
dmgAdj.armoured.adj += parseInt(e.data.ac || 1);
@@ -6310,6 +6312,9 @@ var attackMaster = (function() {
63106312
if (dexBonus) {
63116313
acValues.dexBonus = {name:('Dexterity Bonus '+dexBonus),specs:['',('Dexterity Bonus '+dexBonus),'dexterity','0H','dexterity'],data:{adj:dexBonus}};
63126314
}
6315+
6316+
// log('Final baseAC='+baseAC+', -adj='+dmgAdj.armoured.adj+', -dexBonus='+dexBonus);
6317+
63136318
setAttr( charCS, fields.Armour_normal, (baseAC - dmgAdj.armoured.adj - dexBonus) );
63146319
setAttr( charCS, fields.Armour_missile, (baseAC - dmgAdj.armoured.adj - dexBonus - dmgAdj.armoured.madj) );
63156320
setAttr( charCS, fields.Armour_surprised, (baseAC - dmgAdj.armoured.adj) );

AttackMaster/script.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"$schema": "https://github.com/DameryDad/roll20-api-scripts/blob/AttackMaster/AttackMaster/Script.json",
33
"name": "AttackMaster",
44
"script": "AttackMaster.js",
5-
"version": "1.036",
6-
"previousversions": [],
5+
"version": "1.038",
6+
"previousversions": ["1.036"],
77
"description": "AttackMaster API for AD&D 2E provides functions to manage weapons, armour & shields, including taking weapons in hand and using them to attack, ranged weapon range and ammo management; penalties & bonuses for non-proficiency, proficiency, specialisation & mastery; 1-handed, 2-handed or many-handed weapons, and multi-weapon attacks.\n[AttackMaster Documentation](https://wiki.roll20.net/Script:AttackMaster) \n\n### Related APIs\nThis API works best with the RPGMaster series of APIs\n[RPGMaster Documentation](https://wiki.roll20.net/RPGMaster) \n###Getting Started\n* After installation, add the commans `!attk --menu` and `!attk --other-menu` as Ability Macros on Character Sheets of Characters, NPCs & Monsters that will use the API, and tick 'Show as Token Action'. These menus will then be available to Players controlling those sheets and give access to all common commands used in game-play.",
88
"authors": "Richard E.",
99
"roll20userid": "6497708",

0 commit comments

Comments
 (0)