diff --git a/module/actor/actor.js b/module/actor/actor.js index b28fd1a..604490e 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -2096,7 +2096,7 @@ export class MothershipActor extends Actor { } //central check rolling function | TAKES '1d10','low','combat','Geology',10,[weapon item] | RETURNS chat message showing check result - async rollCheck(rollString, aimFor, attribute, skill, skillValue, weapon) { + async rollCheck(rollString, aimFor, attribute, skill, skillValue, weapon,overrideDamagaRollString=null) { //init vars let specialRoll = ``; let checkCrit = true; @@ -2135,7 +2135,11 @@ export class MothershipActor extends Actor { skill = 'none'; skillValue = 0; //set rollstring - rollString = weapon.system.damage; + if(overrideDamagaRollString){ + rollString=overrideDamagaRollString; + }else{ + rollString = weapon.system.damage; + } } //rest save if (attribute === 'restSave') { @@ -2249,7 +2253,11 @@ export class MothershipActor extends Actor { //if this is a damage roll if (specialRoll === 'damage') { //parse the roll string - parsedDamageString = this.parseRollString(weapon.system.damage, 'high'); + let damageRollString = weapon.system.damage + if(overrideDamagaRollString){ + damageRollString = overrideDamagaRollString; + } + parsedDamageString = this.parseRollString(damageRollString, 'high'); //override message header msgHeader = weapon.name; //override header image @@ -2357,7 +2365,11 @@ export class MothershipActor extends Actor { //prep damage dice in case its needed if (weapon && parsedRollResult.success) { //parse the roll string - parsedDamageString = this.parseRollString(weapon.system.damage, 'high'); + let damageRollString = weapon.system.damage + if(overrideDamagaRollString){ + damageRollString = overrideDamagaRollString; + } + parsedDamageString = this.parseRollString(damageRollString, 'high'); } //set chat message text //set roll result as greater than or less than diff --git a/module/actor/creature-sheet.js b/module/actor/creature-sheet.js index 881a2de..f10da03 100644 --- a/module/actor/creature-sheet.js +++ b/module/actor/creature-sheet.js @@ -184,12 +184,13 @@ export class MothershipCreatureSheet extends ActorSheet { } else { item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId)); } + let swarm_damage_roll_string =null; if (this.actor.system.swarm && this.actor.system.swarm.enabled){ //replace the roll damage for swarm actors let new_dice_ammount = item.system.damage.match(/([0-9]+)d[0-9]+/i)[1]*this.getWoundsLeft(html); - item.system.damage = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`); + swarm_damage_roll_string = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`); } - this.actor.rollCheck(null, 'low', 'combat', null, null, item); + this.actor.rollCheck(null, 'low', 'combat', null, null, item,swarm_damage_roll_string); }); // Rollable Damage @@ -201,12 +202,13 @@ export class MothershipCreatureSheet extends ActorSheet { } else { item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId)); } + let swarm_damage_roll_string =null; if (this.actor.system.swarm && this.actor.system.swarm.enabled){ //replace the roll damage for swarm actors let new_dice_ammount = item.system.damage.match(/([0-9]+)d[0-9]+/i)[1]*this.getWoundsLeft(html); - item.system.damage = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`); + swarm_damage_roll_string = item.system.damage.replace(/([0-9]+)(d[0-9]+)/i,`${new_dice_ammount}$2`); } - this.actor.rollCheck(null, null, 'damage', null, null, item); + this.actor.rollCheck(null, null, 'damage', null, null, item,swarm_damage_roll_string); }); //increase ammo diff --git a/module/settings/creature-settings.js b/module/settings/creature-settings.js index dbdb932..daed1cf 100644 --- a/module/settings/creature-settings.js +++ b/module/settings/creature-settings.js @@ -91,13 +91,16 @@ export class DLCreatureSettings extends FormApplication { }); }); html.find(`input[type=checkbox][id="system.swarm.enabled"]`).click(ev => { - if (ev.currentTarget.checked) { - const sanity = html.find(`input[type=checkbox][id="system.swarm.enabled"]`).prop('checked', true); - } - this.object.update({ "system.swarm.enabled": ev.currentTarget.checked }); + if (ev.currentTarget.checked) { + const new_combat = this.object.system.swarm.combat.value * ( this.object.system.hits.max - this.object.system.hits.value); + + this.object.update({ + "system.stats.combat.value":new_combat + }); + } }); } diff --git a/templates/actor/creature-sheet.html b/templates/actor/creature-sheet.html index 259f21d..2b93ca9 100644 --- a/templates/actor/creature-sheet.html +++ b/templates/actor/creature-sheet.html @@ -10,10 +10,17 @@
- {{ localize 'Mosh.Combat' }}{{#if system.swarm.enabled}} {{ localize 'Mosh.SwarmWoundShort' }}{{/if}} - + {{#if system.swarm.enabled}} + {{ localize 'Mosh.Combat' }} {{ localize 'Mosh.SwarmWoundShort' }} + + {{else}} + {{ localize 'Mosh.Combat' }} + + {{/if}}
{{/if}}