New weapon management, including shotgun
This commit is contained in:
@@ -106,7 +106,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
}
|
||||
|
||||
static buildSelectiveFireChoices(actor, weapon) {
|
||||
if (!weapon || !weapon?.system?.hasSelectiveFire) {
|
||||
if (!weapon?.system?.hasSelectiveFire) {
|
||||
return {}
|
||||
}
|
||||
// Loop thru the selective fire choices and build the choices object when enough ammo in the weapon
|
||||
@@ -144,6 +144,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
ammoUsed = choice.ammoUsed // Override ammo used
|
||||
}
|
||||
|
||||
ammoUsed = Number(ammoUsed)
|
||||
|
||||
if (weapon.system.lethality > 0) {
|
||||
let lethalityRoll = new Roll("1d100")
|
||||
await lethalityRoll.evaluate()
|
||||
@@ -175,8 +177,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
}
|
||||
|
||||
// If the weapon is not lethal, we can proceed with the regular damage roll
|
||||
let formula = weapon.system.damage
|
||||
if (weapon.system.weaponType === "melee" || weapon.system.weaponType === "unarmed") {
|
||||
let formula = weapon?.damageFormula || weapon.system.damage || "0"
|
||||
if (weapon.system.applyDamageBonus) {
|
||||
formula += ` + ${actor.system?.damageBonus}`
|
||||
}
|
||||
if (options?.previousResultType === "successCritical") {
|
||||
@@ -205,6 +207,19 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
}, { rollMode: options.rollMode, create: true })
|
||||
}
|
||||
|
||||
|
||||
static computeWeaponModifiers(rollData) {
|
||||
let modifier = SYSTEM.WEAPON_MELEE_TARGET_MOVE[rollData.meleeTargetMoveChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_RANGED_RANGE[rollData.rangedRangeChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_RANGED_TARGET_MOVE[rollData.rangedTargetMoveChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_VISIBILITY[rollData.visibilityChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_ATTACKER_STATE[rollData.attackerStateChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_TARGET_SIZE[rollData.targetSizeChoice]?.modifier || 0
|
||||
modifier += (rollData.aimingLastRound) ? 20 : 0
|
||||
modifier += (rollData.aimingWithSight) ? 20 : 0
|
||||
return modifier
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user with a dialog to configure and execute a roll.
|
||||
*
|
||||
@@ -311,6 +326,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
rollType: options.rollType,
|
||||
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
|
||||
weapon: options?.weapon,
|
||||
isRangedWeapon: options?.weapon?.system?.isRanged(),
|
||||
initialScore: options.initialScore,
|
||||
targetScore: options.initialScore,
|
||||
isLowWP: options.isLowWP,
|
||||
@@ -324,12 +340,26 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
choiceModifier,
|
||||
choiceMultiplier,
|
||||
choiceSelectiveFire,
|
||||
choiceMeleeTargetMove: SYSTEM.WEAPON_MELEE_TARGET_MOVE,
|
||||
choiceRangedRange: SYSTEM.WEAPON_RANGED_RANGE,
|
||||
choiceRangedTargetMove: SYSTEM.WEAPON_RANGED_TARGET_MOVE,
|
||||
choiceVisibility: SYSTEM.WEAPON_VISIBILITY,
|
||||
choiceAttackerState: SYSTEM.WEAPON_ATTACKER_STATE,
|
||||
choiceTargetSize: SYSTEM.WEAPON_TARGET_SIZE,
|
||||
selectiveFireChoice: "shortburst",
|
||||
meleeTargetMoveChoice: "normal",
|
||||
rangedRangeChoice: "normal",
|
||||
rangedTargetMoveChoice: "normal",
|
||||
visibilityChoice: "clear",
|
||||
attackerStateChoice: "normal",
|
||||
targetSizeChoice: "normal",
|
||||
aimingLastRound: false,
|
||||
aimingWithSight: false,
|
||||
modifier,
|
||||
formula,
|
||||
hasTarget: options.hasTarget,
|
||||
hasModifier,
|
||||
hasMultiplier,
|
||||
modifier,
|
||||
selectiveFireChoice: "shortburst",
|
||||
multiplier
|
||||
}
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/roll-dialog.hbs", dialogContext)
|
||||
@@ -386,7 +416,9 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
if (options.rollType === "resource") {
|
||||
rollData.targetScore = options.initialScore * Number(rollContext.multiplier)
|
||||
} else {
|
||||
rollData.targetScore = Math.min(Math.max(options.initialScore + Number(rollData.modifier), 0), 100)
|
||||
let totalModifier = this.computeWeaponModifiers(rollData) + Number(rollData.modifier)
|
||||
rollData.totalModifier = Math.min(totalModifier, 40)
|
||||
rollData.targetScore = Math.min(Math.max(options.initialScore + Number(rollData.totalModifier), 0), 100)
|
||||
if (rollData.isLowWP || rollData.isExhausted) {
|
||||
rollData.targetScore -= 20
|
||||
}
|
||||
@@ -395,7 +427,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
}
|
||||
rollData.targetScore = Math.min(Math.max(rollData.targetScore, 0), 100)
|
||||
}
|
||||
if (!rollData.targetScore) {
|
||||
if (rollData.targetScore === undefined || rollData.targetScore === null) {
|
||||
rollData.targetScore = options.initialScore
|
||||
rollData.modifier = "0"
|
||||
}
|
||||
@@ -456,6 +488,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
this.options.isCritical = resultType === "successCritical" || resultType === "failureCritical"
|
||||
}
|
||||
rollData.resultType = resultType
|
||||
|
||||
this.options.isLowWP = rollData.isLowWP
|
||||
this.options.isZeroWP = rollData.isZeroWP
|
||||
this.options.isExhausted = rollData.isExhausted
|
||||
@@ -601,12 +634,14 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
rollItem: rollItem,
|
||||
rollData: rollData
|
||||
}
|
||||
// Get array of gamemaster ID
|
||||
let msg = await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/chat-san-request.hbs", msgData)
|
||||
let chatMsg = await ChatMessage.create({
|
||||
user: game.user.id,
|
||||
content: msg,
|
||||
speaker: ChatMessage.getSpeaker({ actor: rollData.actor })
|
||||
}, { rollMode: rollData.rollMode, create: true })
|
||||
speaker: ChatMessage.getSpeaker({ actor: rollData.actor }),
|
||||
whisper: game.users.filter(u => u.isGM).map(u => u.id),
|
||||
})
|
||||
await chatMsg.setFlag("fvtt-cthulhu-eternal", "rollData", rollData)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user