Add initiative and ammo
This commit is contained in:
@@ -10,7 +10,7 @@ export class DarkStarsCombat extends Combat {
|
||||
let hasLastWord = token.actor.hasLastWord()
|
||||
while ( (initScore > 5) || (hasLastWord && initScore >= 5)) {
|
||||
initScore -= 5;
|
||||
toCreate.push({tokenId: c.tokenId, sceneId: c.sceneId, actorId: c.actorId, hidden: c.hidden, initiative: initScore, isDuplicated: true});
|
||||
toCreate.push({tokenId: c.tokenId, sceneId: c.sceneId, actorId: c.actorId, hidden: c.hidden, initiative: initScore, flags: { world: { isDuplicated: true} } } );
|
||||
}
|
||||
this.createEmbeddedDocuments("Combatant", toCreate);
|
||||
}
|
||||
@@ -28,6 +28,18 @@ export class DarkStarsCombat extends Combat {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
nextRound() {
|
||||
super.nextRound()
|
||||
let toDelete = []
|
||||
for (let c of this.combatants) {
|
||||
if (c.flags?.world?.isDuplicated) {
|
||||
toDelete.push(c._id)
|
||||
}
|
||||
}
|
||||
this.deleteEmbeddedDocuments("Combatant", toDelete);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onUpdate(changed, options, userId) {
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class DarkStarsUtility {
|
||||
Handlebars.registerHelper('locationLabel', function (key) {
|
||||
return __locationNames[key]
|
||||
})
|
||||
|
||||
|
||||
|
||||
this.gameSettings()
|
||||
|
||||
@@ -240,14 +240,14 @@ export class DarkStarsUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getAimingMalus(location) {
|
||||
static getAimingMalus(location) {
|
||||
if (location == "arm" || location == "head") {
|
||||
return -50
|
||||
}
|
||||
if (location == "torso" || location == "leg") {
|
||||
return -30
|
||||
}
|
||||
if (location == "hand" ) {
|
||||
if (location == "hand") {
|
||||
return -70
|
||||
}
|
||||
return 0
|
||||
@@ -255,14 +255,22 @@ export class DarkStarsUtility {
|
||||
/* -------------------------------------------- */
|
||||
static getAimingLocation(roll) {
|
||||
if (roll == 1) return "head"
|
||||
if (roll >=2 && roll <=4 ) return "chest"
|
||||
if (roll >=5 && roll <=6 ) return "abdomen"
|
||||
if (roll == 7 ) return "leftarm"
|
||||
if (roll == 8 ) return "rightarm"
|
||||
if (roll == 9 ) return "rightleg"
|
||||
if (roll == 10 ) return "leftleg"
|
||||
if (roll >= 2 && roll <= 4) return "chest"
|
||||
if (roll >= 5 && roll <= 6) return "abdomen"
|
||||
if (roll == 7) return "leftarm"
|
||||
if (roll == 8) return "rightarm"
|
||||
if (roll == 9) return "rightleg"
|
||||
if (roll == 10) return "leftleg"
|
||||
return "abdomen"
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static locationMultiplier(location) {
|
||||
if (location == "head") return 0.3
|
||||
if (location.includes("arm")) return 0.2
|
||||
if (location.includes("leg")) return 0.4
|
||||
if (location == "chest") return 0.5
|
||||
return 0.3 // Abdomen case
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollDarkStars(rollData) {
|
||||
@@ -271,13 +279,13 @@ export class DarkStarsUtility {
|
||||
|
||||
// ability/save/size => 0
|
||||
rollData.percentValue = 0
|
||||
if ( rollData.skill ) {
|
||||
if (rollData.skill) {
|
||||
rollData.percentValue = rollData.skill.total
|
||||
}
|
||||
rollData.percentValue += rollData.bonusMalus
|
||||
rollData.percentValue += rollData.bonusMalus
|
||||
rollData.diceFormula = "1d100"
|
||||
|
||||
if (rollData.isAboveEffectiveRange) {
|
||||
if (rollData.isAboveEffectiveRange) {
|
||||
rollData.percentValue -= 30
|
||||
rollData.percentValue = Math.max(0, rollData.percentValue)
|
||||
}
|
||||
@@ -299,18 +307,23 @@ export class DarkStarsUtility {
|
||||
rollData.isCriticalFailure = rollData.diceResult == 100
|
||||
rollData.isSuccess = rollData.diceResult == 1 || rollData.diceResult <= rollData.percentValue
|
||||
rollData.isFailure = rollData.diceResult == 100 || rollData.diceResult > rollData.percentValue
|
||||
rollData.degrees = Math.floor(rollData.percentValue/10) - Math.floor(rollData.diceResult/10)
|
||||
|
||||
rollData.degrees = Math.floor(rollData.percentValue / 10) - Math.floor(rollData.diceResult / 10)
|
||||
rollData.damageMultiplier = rollData.isCriticalSuccess ? 2 : 1
|
||||
|
||||
if (rollData.reroll) {
|
||||
actor.modifyRerolls(-1)
|
||||
rollData.rerolls = 0 // DIsable rerolls
|
||||
}
|
||||
|
||||
if (rollData.weaponAiming == "none" ) {
|
||||
let rollLoc = new Roll("1d10").roll({async: false})
|
||||
rollData.weaponAiming = this.getAimingLocation(rollLoc.total)
|
||||
if (rollData.mode == "weapon") {
|
||||
if (rollData.weaponAiming == "none") {
|
||||
let rollLoc = new Roll("1d10").roll({ async: false })
|
||||
rollData.weaponAiming = this.getAimingLocation(rollLoc.total)
|
||||
}
|
||||
// Compute
|
||||
rollData.locationMultiplier = this.locationMultiplier(rollData.weaponAiming)
|
||||
}
|
||||
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-dark-stars/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
@@ -418,7 +431,7 @@ export class DarkStarsUtility {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
bonusMalus : 0,
|
||||
bonusMalus: 0,
|
||||
isAboveEffectiveRange: false,
|
||||
weaponAiming: "none"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user