make deflection modifiers more descriptive
This commit is contained in:
parent
cd8b5ac7eb
commit
ba9eac716d
@ -1,18 +1,37 @@
|
||||
import { log } from './globals.js';
|
||||
|
||||
function hasDeflection(target, type) {
|
||||
return (
|
||||
target.actor.effects.filter(
|
||||
(e) => !e.disabled && e.name.toLowerCase().includes('deflection') && e.name.toLowerCase().includes(type),
|
||||
).length > 0
|
||||
);
|
||||
}
|
||||
|
||||
export async function preTraitRollModifiers(actor, trait, roll, modifiers, options) {
|
||||
const targets = Array.from(game.user.targets);
|
||||
const token = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0] : null;
|
||||
if (targets.some((target) => target.actor.system.status.isVulnerable)) {
|
||||
modifiers.push({ label: 'Target is Vulnerable', value: '+2', ignore: false });
|
||||
}
|
||||
if (
|
||||
targets.some(
|
||||
(target) =>
|
||||
target.actor.effects.filter((e) => !e.disabled && e.name.toLowerCase().includes('deflection')).length > 0,
|
||||
)
|
||||
) {
|
||||
modifiers.push({ label: 'Target has Deflection', value: '-2', ignore: false });
|
||||
if (targets.some((target) => hasDeflection(target, 'melee'))) {
|
||||
const ignore = trait?.type !== 'skill' || trait?.system?.swid !== 'fighting';
|
||||
modifiers.push({ label: 'Target has Melee Deflection', value: '-2', ignore: ignore });
|
||||
}
|
||||
if (targets.some((target) => hasDeflection(target, 'range'))) {
|
||||
const ignore =
|
||||
trait?.type !== 'skill' || !(trait?.system?.swid === 'shooting' || trait?.system?.swid === 'athletics');
|
||||
modifiers.push({ label: 'Target has Ranged Deflection', value: '-2', ignore: ignore });
|
||||
}
|
||||
if (targets.some((target) => hasDeflection(target, 'all'))) {
|
||||
const ignore =
|
||||
trait?.type !== 'skill' ||
|
||||
!(
|
||||
trait?.system?.swid === 'fighting' ||
|
||||
trait?.system?.swid === 'shooting' ||
|
||||
trait?.system?.swid === 'athletics'
|
||||
);
|
||||
modifiers.push({ label: 'Target has Deflection', value: '-2', ignore: ignore });
|
||||
}
|
||||
if (
|
||||
targets.some(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user