Fix #11 Speed management

This commit is contained in:
sladecraven 2022-09-25 15:13:59 +02:00
parent 241c7fa1ae
commit 52b7279cb8
2 changed files with 40 additions and 44 deletions

View File

@ -1656,7 +1656,7 @@ export class PegasusActor extends Actor {
if (subKey == "ranged-dmg") {
this.addVehicleWeapons(rollData, vehicle)
}
if (subKey == "defense") {
if (subKey == "defence") {
if (vehicle.isVehicleFullStop()) {
ui.notifications.warn("MAN not added to Defense due to Full Stop.")
} else {
@ -1858,24 +1858,35 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
/* VEHICLE STUFF */
manageCurrentSpeed(speed) {
async manageCurrentSpeed(speed) {
// Delete any previous effect
let effect = this.items.find(effect => effect.system.isspeed != undefined)
if (effect) {
await this.deleteEmbeddedDocuments("Item", [effect.id])
}
if (speed == "fullstop") {
this.update({ 'system.secondary.moverange': "nomovement" })
}
if (speed == "crawling") {
this.update({ 'system.secondary.moverange': "threatzone" })
await this.update({ 'system.secondary.moverange': "threatzone" })
await this.manageVehicleSpeedBonus("crawling", "Crawling MAN Bonus", "man", 3)
}
if (speed == "slow") {
this.update({ 'system.secondary.moverange': "close" })
await this.update({ 'system.secondary.moverange': "close" })
await this.manageVehicleSpeedBonus("slow", "Slow MAN Bonus", "man", 1)
}
if (speed == "average") {
this.update({ 'system.secondary.moverange': "medium" })
await this.update({ 'system.secondary.moverange': "medium" })
await this.manageVehicleSpeedBonus("average", "Avoid attack Bonus", "all", 1)
}
if (speed == "fast") {
this.update({ 'system.secondary.moverange': "long" })
await this.update({ 'system.secondary.moverange': "long" })
await this.manageVehicleSpeedBonus("fast", "Avoid attack Bonus", "all", 3)
}
if (speed == "extfast") {
this.update({ 'system.secondary.moverange': "extreme" })
await this.update({ 'system.secondary.moverange': "extreme" })
await this.manageVehicleSpeedBonus("extfast", "Avoid attack Bonus", "all", 5)
}
}
@ -1894,22 +1905,14 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
manageVehicleSpeedBonus(speed, name, stat, level) {
if (this.system.statistics.ad.currentspeed == speed) {
if (!this.items.find(effect => effect.system.isspeed == speed)) {
async manageVehicleSpeedBonus(speed, name, stat, level) {
let effect = duplicate(__bonusEffect)
effect.id = randomID(16)
effect.name = name
effect.system.stataffected = stat
effect.system.effectlevel = level
effect.system.isspeed = speed
this.createEmbeddedDocuments("Item", [effect])
}
} else {
let effect = this.items.find(effect => effect.system.isspeed == speed)
if (effect) {
this.deleteEmbeddedDocuments("Item", [effect.id])
}
}
await this.createEmbeddedDocuments("Item", [effect])
}
/* -------------------------------------------- */
@ -1998,13 +2001,6 @@ export class PegasusActor extends Actor {
}
}
// Speed effect management
this.manageVehicleSpeedBonus("crawling", "Crawling MAN Bonus", "man", 3)
this.manageVehicleSpeedBonus("slow", "Slow MAN Bonus", "man", 1)
this.manageVehicleSpeedBonus("average", "Avoid attack Bonus", "all", 1)
this.manageVehicleSpeedBonus("fast", "Avoid attack Bonus", "all", 3)
this.manageVehicleSpeedBonus("extfast", "Avoid attack Bonus", "all", 5)
}
/* -------------------------------------------- */
@ -2066,7 +2062,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
addCrew(actorId) {
if ( this.system.crew.length >= this.system.crewmax) {
if (this.system.crew.length >= this.system.crewmax) {
ui.notifications.warn("Vehicle crew is already full.")
return
}
@ -2127,7 +2123,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
addVehicleShields(rollData) {
let shields = this.items.filter( shield => shield.type == "vehiclemodule" && shield.system.activated && shield.system.shielddicevalue > 0) || []
let shields = this.items.filter(shield => shield.type == "vehiclemodule" && shield.system.activated && shield.system.shielddicevalue > 0) || []
for (let shield of shields) {
rollData.vehicleShieldList.push({ label: `${shield.name} (${shield.system.arccoverage})`, type: "vehicleshield", applied: false, value: shield.system.shielddicevalue })
}

View File

@ -215,7 +215,7 @@ export class PegasusVehicleSheet extends ActorSheet {
this.actor.rollPoolFromVehicle( 'per', false, "ranged-dmg");
});
html.find('.defense-roll').click((event) => {
this.actor.rollPoolFromVehicle( 'def', true, "defence");
this.actor.rollPoolFromVehicle( 'agi', true, "defence");
});
html.find('.damage-resistance').click((event) => {
this.actor.rollVehicleDamageResistance( );