|
|
|
@ -371,9 +371,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
ppp += Number(power.system.powerlevelcost)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log("PPP update", ppp)
|
|
|
|
|
if (ppp != this.system.ppp.spentPPP) {
|
|
|
|
|
console.log("PPP update2", ppp)
|
|
|
|
|
this.update({ 'system.ppp.spentPPP': ppp })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2034,7 +2032,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
if (this.system.statistics.hr.currentlevel == 0) {
|
|
|
|
|
ChatMessage.create({ content: `The vehicle ${this.name} has been destroyed !` })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.processVehicleArmorShields()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2096,47 +2094,6 @@ export class PegasusActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Armour management
|
|
|
|
|
if (item.type == "vehiclemodule" && item.system.category == "armor") {
|
|
|
|
|
let armorsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "armor") || []
|
|
|
|
|
armorsList.push(item)
|
|
|
|
|
let arcKey = item.system.location + "arc"
|
|
|
|
|
let arc = duplicate(this.system.arcs[arcKey])
|
|
|
|
|
let level = 0
|
|
|
|
|
for (let armour of armorsList) {
|
|
|
|
|
if (armour.system.armourdicevalue > 0) {
|
|
|
|
|
level += Number(armour.system.armourdicevalue)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (level != Number(arc.armourlevel)) {
|
|
|
|
|
arc.armourlevel = level
|
|
|
|
|
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shield management
|
|
|
|
|
if (item.type == "vehiclemodule" && item.system.category == "shield") {
|
|
|
|
|
let shieldsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "shield") || []
|
|
|
|
|
shieldsList.push(item)
|
|
|
|
|
let level = 0
|
|
|
|
|
for (let armour of shieldsList) {
|
|
|
|
|
if (armour.system.shielddicevalue > 0) {
|
|
|
|
|
level += Number(armour.system.shielddicevalue)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let shift = 500
|
|
|
|
|
for( let loc of __LocationsArmour) {
|
|
|
|
|
let arcKey = loc + "arc"
|
|
|
|
|
let arc = duplicate(this.system.arcs[arcKey])
|
|
|
|
|
if (level != Number(arc.shieldlevel)) {
|
|
|
|
|
arc.shieldlevel = level
|
|
|
|
|
setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
|
|
|
|
shift += 200
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2249,7 +2206,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
activateVehicleModule(itemId) {
|
|
|
|
|
async activateVehicleModule(itemId) {
|
|
|
|
|
let mod = this.items.get(itemId)
|
|
|
|
|
if (mod) {
|
|
|
|
|
if (mod.system.nrg && mod.system.nrg > 0) {
|
|
|
|
@ -2259,7 +2216,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
ChatMessage.create({ content: `The Vehicle ${this.name} does not have enough Energy to Activate this module at this time.` })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
|
|
|
|
await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
|
|
|
|
pc.actnrg += Number(mod.system.nrg)
|
|
|
|
|
pc.maxnrg -= Number(mod.system.nrg)
|
|
|
|
|
pc.curnrg -= Number(mod.system.nrg)
|
|
|
|
@ -2268,17 +2225,61 @@ export class PegasusActor extends Actor {
|
|
|
|
|
pc.actnrg -= Number(mod.system.nrg)
|
|
|
|
|
pc.maxnrg += Number(mod.system.nrg)
|
|
|
|
|
this.update({ 'system.statistics.pc': pc })
|
|
|
|
|
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
|
|
|
|
await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
|
|
|
|
}
|
|
|
|
|
await this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.processVehicleArmorShields()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
processVehicleArmorShields() {
|
|
|
|
|
// Shield management
|
|
|
|
|
let shieldsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "shield" && item.system.activated) || []
|
|
|
|
|
let level = 0
|
|
|
|
|
for (let armour of shieldsList) {
|
|
|
|
|
if (armour.system.shielddicevalue > 0) {
|
|
|
|
|
level += Number(armour.system.shielddicevalue)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let shift = 500
|
|
|
|
|
for (let loc of __LocationsArmour) {
|
|
|
|
|
let arcKey = loc + "arc"
|
|
|
|
|
let arc = duplicate(this.system.arcs[arcKey])
|
|
|
|
|
if (level != Number(arc.shieldlevel)) {
|
|
|
|
|
arc.shieldlevel = level
|
|
|
|
|
setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
|
|
|
|
shift += 200
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Armour management
|
|
|
|
|
let armorsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "armor" && item.system.activated) || []
|
|
|
|
|
for (let loc of __LocationsArmour) {
|
|
|
|
|
let arcKey = loc + "arc"
|
|
|
|
|
let arc = duplicate(this.system.arcs[arcKey])
|
|
|
|
|
let level = 0
|
|
|
|
|
for (let armour of armorsList) {
|
|
|
|
|
if (armour.system.location == loc && armour.system.armourdicevalue > 0) {
|
|
|
|
|
level += Number(armour.system.armourdicevalue)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (level != Number(arc.armourlevel)) {
|
|
|
|
|
arc.armourlevel = level
|
|
|
|
|
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
updateMaxNrg(currentLevel) {
|
|
|
|
|
this.update({ 'system.statistics.pc.maxnrg': Number(currentLevel) })
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
setTurningArc(currentLevel) {
|
|
|
|
|
this.update({ 'system.statistics.man.turningarc45': currentLevel })
|
|
|
|
|
this.update({ 'system.statistics.man.turningarc45': Number(currentLevel) })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|