Fix #11 Speed management
This commit is contained in:
parent
241c7fa1ae
commit
52b7279cb8
@ -756,7 +756,7 @@ export class PegasusActor extends Actor {
|
|||||||
subActors.push(subActorId);
|
subActors.push(subActorId);
|
||||||
await this.update({ 'system.subactors': subActors });
|
await this.update({ 'system.subactors': subActors });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async delSubActor(subActorId) {
|
async delSubActor(subActorId) {
|
||||||
let newArray = [];
|
let newArray = [];
|
||||||
@ -1394,31 +1394,31 @@ export class PegasusActor extends Actor {
|
|||||||
let newItems = []
|
let newItems = []
|
||||||
if (ability.system.effectsgained) {
|
if (ability.system.effectsgained) {
|
||||||
for (let effect of ability.system.effectsgained) {
|
for (let effect of ability.system.effectsgained) {
|
||||||
if (!effect.system) effect.system = effect.data
|
if (!effect.system) effect.system = effect.data
|
||||||
newItems.push(effect);
|
newItems.push(effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability.system.powersgained) {
|
if (ability.system.powersgained) {
|
||||||
for (let power of ability.system.powersgained) {
|
for (let power of ability.system.powersgained) {
|
||||||
if (!power.system) power.system = power.data
|
if (!power.system) power.system = power.data
|
||||||
newItems.push(power);
|
newItems.push(power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability.system.specialisations) {
|
if (ability.system.specialisations) {
|
||||||
for (let spec of ability.system.specialisations) {
|
for (let spec of ability.system.specialisations) {
|
||||||
if (!spec.system) spec.system = spec.data
|
if (!spec.system) spec.system = spec.data
|
||||||
newItems.push(spec);
|
newItems.push(spec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability.system.attackgained) {
|
if (ability.system.attackgained) {
|
||||||
for (let weapon of ability.system.attackgained) {
|
for (let weapon of ability.system.attackgained) {
|
||||||
if (!weapon.system) weapon.system = weapon.data
|
if (!weapon.system) weapon.system = weapon.data
|
||||||
newItems.push(weapon);
|
newItems.push(weapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ability.system.armorgained) {
|
if (ability.system.armorgained) {
|
||||||
for (let armor of ability.system.armorgained) {
|
for (let armor of ability.system.armorgained) {
|
||||||
if (!armor.system) armor.system = armor.data
|
if (!armor.system) armor.system = armor.data
|
||||||
newItems.push(armor);
|
newItems.push(armor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1432,16 +1432,16 @@ export class PegasusActor extends Actor {
|
|||||||
let newItems = []
|
let newItems = []
|
||||||
await this.deleteAllItemsByType('race')
|
await this.deleteAllItemsByType('race')
|
||||||
newItems.push(race);
|
newItems.push(race);
|
||||||
|
|
||||||
console.log("DROPPED RACE", race)
|
console.log("DROPPED RACE", race)
|
||||||
for (let ability of race.system.abilities) {
|
for (let ability of race.system.abilities) {
|
||||||
if (!ability.system) ability.system = ability.data
|
if (!ability.system) ability.system = ability.data
|
||||||
newItems.push(ability)
|
newItems.push(ability)
|
||||||
this.applyAbility(ability, updates)
|
this.applyAbility(ability, updates)
|
||||||
}
|
}
|
||||||
if (race.system.perksgained) {
|
if (race.system.perksgained) {
|
||||||
for (let power of race.system.perks) {
|
for (let power of race.system.perks) {
|
||||||
if (!power.system) power.system = power.data
|
if (!power.system) power.system = power.data
|
||||||
newItems.push(power);
|
newItems.push(power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1656,7 +1656,7 @@ export class PegasusActor extends Actor {
|
|||||||
if (subKey == "ranged-dmg") {
|
if (subKey == "ranged-dmg") {
|
||||||
this.addVehicleWeapons(rollData, vehicle)
|
this.addVehicleWeapons(rollData, vehicle)
|
||||||
}
|
}
|
||||||
if (subKey == "defense") {
|
if (subKey == "defence") {
|
||||||
if (vehicle.isVehicleFullStop()) {
|
if (vehicle.isVehicleFullStop()) {
|
||||||
ui.notifications.warn("MAN not added to Defense due to Full Stop.")
|
ui.notifications.warn("MAN not added to Defense due to Full Stop.")
|
||||||
} else {
|
} else {
|
||||||
@ -1858,24 +1858,35 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* VEHICLE STUFF */
|
/* 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") {
|
if (speed == "fullstop") {
|
||||||
this.update({ 'system.secondary.moverange': "nomovement" })
|
this.update({ 'system.secondary.moverange': "nomovement" })
|
||||||
}
|
}
|
||||||
if (speed == "crawling") {
|
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") {
|
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") {
|
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") {
|
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") {
|
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) {
|
async manageVehicleSpeedBonus(speed, name, stat, level) {
|
||||||
if (this.system.statistics.ad.currentspeed == speed) {
|
let effect = duplicate(__bonusEffect)
|
||||||
if (!this.items.find(effect => effect.system.isspeed == speed)) {
|
effect.id = randomID(16)
|
||||||
let effect = duplicate(__bonusEffect)
|
effect.name = name
|
||||||
effect.name = name
|
effect.system.stataffected = stat
|
||||||
effect.system.stataffected = stat
|
effect.system.effectlevel = level
|
||||||
effect.system.effectlevel = level
|
effect.system.isspeed = speed
|
||||||
effect.system.isspeed = speed
|
await this.createEmbeddedDocuments("Item", [effect])
|
||||||
this.createEmbeddedDocuments("Item", [effect])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let effect = this.items.find(effect => effect.system.isspeed == speed)
|
|
||||||
if (effect) {
|
|
||||||
this.deleteEmbeddedDocuments("Item", [effect.id])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -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,10 +2062,10 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
addCrew(actorId) {
|
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.")
|
ui.notifications.warn("Vehicle crew is already full.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || [])
|
let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || [])
|
||||||
crewList.push({ id: actorId })
|
crewList.push({ id: actorId })
|
||||||
this.update({ 'system.crew': crewList })
|
this.update({ 'system.crew': crewList })
|
||||||
@ -2127,7 +2123,7 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
addVehicleShields(rollData) {
|
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) {
|
for (let shield of shields) {
|
||||||
rollData.vehicleShieldList.push({ label: `${shield.name} (${shield.system.arccoverage})`, type: "vehicleshield", applied: false, value: shield.system.shielddicevalue })
|
rollData.vehicleShieldList.push({ label: `${shield.name} (${shield.system.arccoverage})`, type: "vehicleshield", applied: false, value: shield.system.shielddicevalue })
|
||||||
}
|
}
|
||||||
@ -2141,7 +2137,7 @@ export class PegasusActor extends Actor {
|
|||||||
let rollData = this.getCommonRollData("hr")
|
let rollData = this.getCommonRollData("hr")
|
||||||
rollData.mode = "stat"
|
rollData.mode = "stat"
|
||||||
rollData.title = `Stat ${stat.label}`;
|
rollData.title = `Stat ${stat.label}`;
|
||||||
|
|
||||||
this.addVehicleShields(rollData)
|
this.addVehicleShields(rollData)
|
||||||
this.startRoll(rollData)
|
this.startRoll(rollData)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ export class PegasusVehicleSheet extends ActorSheet {
|
|||||||
this.actor.rollPoolFromVehicle( 'per', false, "ranged-dmg");
|
this.actor.rollPoolFromVehicle( 'per', false, "ranged-dmg");
|
||||||
});
|
});
|
||||||
html.find('.defense-roll').click((event) => {
|
html.find('.defense-roll').click((event) => {
|
||||||
this.actor.rollPoolFromVehicle( 'def', true, "defence");
|
this.actor.rollPoolFromVehicle( 'agi', true, "defence");
|
||||||
});
|
});
|
||||||
html.find('.damage-resistance').click((event) => {
|
html.find('.damage-resistance').click((event) => {
|
||||||
this.actor.rollVehicleDamageResistance( );
|
this.actor.rollVehicleDamageResistance( );
|
||||||
|
Loading…
Reference in New Issue
Block a user