|
|
|
|
@@ -112,6 +112,14 @@ export class PegasusActor extends Actor {
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
prepareDerivedData() {
|
|
|
|
|
|
|
|
|
|
if (this.system.secondary.stealthhealth) {
|
|
|
|
|
this.update({"system.secondary": {"-=stealthhealth": null}} )
|
|
|
|
|
}
|
|
|
|
|
if (this.system.secondary.socialhealth) {
|
|
|
|
|
this.update({"system.secondary": {"-=socialhealth": null}} )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.traumaState) {
|
|
|
|
|
this.traumaState = "none"
|
|
|
|
|
}
|
|
|
|
|
@@ -668,7 +676,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
for (let spec of specThreat) {
|
|
|
|
|
tl += PegasusUtility.getDiceValue(spec.system.level)
|
|
|
|
|
}
|
|
|
|
|
tl += this.system.nrg.absolutemax + this.system.secondary.health.max + this.system.secondary.delirium.max
|
|
|
|
|
tl += this.system.nrg.absolutemax /* NO MORE USED + this.system.secondary.health.max + this.system.secondary.delirium.max*/
|
|
|
|
|
tl += this.getPerks().length * 5
|
|
|
|
|
|
|
|
|
|
let weapons = this.getWeapons()
|
|
|
|
|
@@ -781,11 +789,12 @@ export class PegasusActor extends Actor {
|
|
|
|
|
if (stunAbove > 0) {
|
|
|
|
|
ChatMessage.create({ content: `${this.name} Stun threshold has been exceeded.` })
|
|
|
|
|
}
|
|
|
|
|
/* NO MORE AUTOMATION HERE
|
|
|
|
|
if (incDec > 0 && stunAbove > 0) {
|
|
|
|
|
let delirium = duplicate(myself.system.secondary.delirium)
|
|
|
|
|
delirium.value -= incDec
|
|
|
|
|
myself.update({ 'system.secondary.delirium': delirium })
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
@@ -1237,6 +1246,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
nrg.max += item.system.features.nrgcost.value
|
|
|
|
|
await this.update({ 'system.nrg': nrg })
|
|
|
|
|
}
|
|
|
|
|
/* NO MORE USED
|
|
|
|
|
if (item.system.features.bonushealth.flag) {
|
|
|
|
|
let health = duplicate(this.system.secondary.health)
|
|
|
|
|
health.value -= Number(item.system.features.bonushealth.value) || 0
|
|
|
|
|
@@ -1254,7 +1264,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
nrg.value -= Number(item.system.features.bonusnrg.value) || 0
|
|
|
|
|
nrg.max -= Number(item.system.features.bonusnrg.value) || 0
|
|
|
|
|
await this.update({ 'system.nrg': nrg })
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
this.disableWeaverPerk(item)
|
|
|
|
|
PegasusUtility.createChatWithRollMode(item.name, {
|
|
|
|
|
content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-perk-ready.html`, { name: this.name, perk: duplicate(item) })
|
|
|
|
|
@@ -1287,6 +1297,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
ui.notifications.warn("Not enough NRG to activate the Perk " + item.name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* NO MORE USED
|
|
|
|
|
if (item.system.features.bonushealth.flag) {
|
|
|
|
|
let health = duplicate(this.system.secondary.health)
|
|
|
|
|
health.value += Number(item.system.features.bonushealth.value) || 0
|
|
|
|
|
@@ -1298,7 +1309,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
delirium.value += Number(item.system.features.bonusdelirium.value) || 0
|
|
|
|
|
delirium.max += Number(item.system.features.bonusdelirium.value) || 0
|
|
|
|
|
await this.update({ 'system.secondary.delirium': delirium })
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
if (item.system.features.bonusnrg.flag) {
|
|
|
|
|
let nrg = duplicate(this.system.nrg)
|
|
|
|
|
nrg.value += Number(item.system.features.bonusnrg.value) || 0
|
|
|
|
|
@@ -1335,14 +1346,11 @@ export class PegasusActor extends Actor {
|
|
|
|
|
getTraumaState() {
|
|
|
|
|
this.traumaState = "none"
|
|
|
|
|
if (this.type == "character") {
|
|
|
|
|
let negDelirium = -Math.floor((this.system.secondary.delirium.max + 1) / 2)
|
|
|
|
|
if (this.type == "character") {
|
|
|
|
|
if (this.system.secondary.delirium.value <= 0 && this.system.secondary.delirium.value >= negDelirium) {
|
|
|
|
|
this.traumaState = "trauma"
|
|
|
|
|
}
|
|
|
|
|
if (this.system.secondary.delirium.value < negDelirium) {
|
|
|
|
|
this.traumaState = "severetrauma"
|
|
|
|
|
}
|
|
|
|
|
if ( this.system.secondary.delirium.status == "trauma") {
|
|
|
|
|
this.traumaState = "trauma"
|
|
|
|
|
}
|
|
|
|
|
if ( this.system.secondary.delirium.status == "severetrauma") {
|
|
|
|
|
this.traumaState = "severetrauma"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this.traumaState
|
|
|
|
|
@@ -1439,6 +1447,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
|
|
|
|
|
if (this.isOwner || game.user.isGM) {
|
|
|
|
|
let updates = {}
|
|
|
|
|
/* No more used
|
|
|
|
|
let phyDiceValue = PegasusUtility.getDiceValue(this.system.statistics.phy.value) + this.system.secondary.health.bonus + this.system.statistics.phy.mod + PegasusUtility.getDiceValue(this.system.statistics.phy.bonuseffect);
|
|
|
|
|
if (phyDiceValue != this.system.secondary.health.max) {
|
|
|
|
|
updates['system.secondary.health.max'] = phyDiceValue
|
|
|
|
|
@@ -1467,7 +1476,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
if (this.computeValue) {
|
|
|
|
|
updates['system.secondary.socialhealth.value'] = socDiceValue
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
let nrgValue = PegasusUtility.getDiceValue(this.system.statistics.foc.value) + this.system.nrg.mod + this.system.statistics.foc.mod + PegasusUtility.getDiceValue(this.system.statistics.foc.bonuseffect)
|
|
|
|
|
if (nrgValue != this.system.nrg.absolutemax) {
|
|
|
|
|
@@ -1511,11 +1520,11 @@ export class PegasusActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let race = this.getRace()
|
|
|
|
|
if (race && race.name && (race.name != this.system.biodata.racename)) {
|
|
|
|
|
if (race?.name && (race.name != this.system.biodata.racename)) {
|
|
|
|
|
updates['system.biodata.racename'] = race.name
|
|
|
|
|
}
|
|
|
|
|
let role = this.getRole()
|
|
|
|
|
if (role && role.name && (role.name != this.system.biodata.rolename)) {
|
|
|
|
|
if (role?.name && (role.name != this.system.biodata.rolename)) {
|
|
|
|
|
updates['system.biodata.rolename'] = role.name
|
|
|
|
|
}
|
|
|
|
|
if (Object.entries(updates).length > 0) {
|
|
|
|
|
@@ -1528,22 +1537,82 @@ export class PegasusActor extends Actor {
|
|
|
|
|
// Update current hindrance level
|
|
|
|
|
let hindrance = this.system.combat.hindrancedice
|
|
|
|
|
if (!this.checkIgnoreHealth()) {
|
|
|
|
|
if (this.system.secondary.health.value < 0) {
|
|
|
|
|
if (this.system.secondary.health.value < -Math.floor((this.system.secondary.health.max + 1) / 2)) { // Severe wounded
|
|
|
|
|
hindrance += 3
|
|
|
|
|
} else {
|
|
|
|
|
hindrance += 1
|
|
|
|
|
}
|
|
|
|
|
if (this.system.secondary.health.status == "wounded") {
|
|
|
|
|
hindrance += 1
|
|
|
|
|
}
|
|
|
|
|
if (this.system.secondary.health.status == "severelywounded") {
|
|
|
|
|
hindrance += 3
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.system.combat.hindrancedice = hindrance
|
|
|
|
|
this.getTraumaState()
|
|
|
|
|
this.cleanupPerksIfTrauma()
|
|
|
|
|
await this.parseStatEffects()
|
|
|
|
|
this.parseStatEffects()
|
|
|
|
|
this.parseDamageValues()
|
|
|
|
|
await this.parseStatusEffects()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
getArmorResistanceBonus() {
|
|
|
|
|
let bonus = 0
|
|
|
|
|
for (let a of armors) {
|
|
|
|
|
bonus += Number(a.system.resistance)
|
|
|
|
|
}
|
|
|
|
|
return bonus
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
parseDamageValues() {
|
|
|
|
|
if (this.system.biodata.noautobonus) { // If we are in "no-bonus mode
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let updates = []
|
|
|
|
|
|
|
|
|
|
/* Get MDL bonus */
|
|
|
|
|
let meleeBonus = 0
|
|
|
|
|
let effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && effect.system.affectstatus == "mdl" && (Number(effect.system.effectlevel) > 0))
|
|
|
|
|
for(let e of effects) {
|
|
|
|
|
meleeBonus += Number(e.system.effectlevel)
|
|
|
|
|
}
|
|
|
|
|
let weaponsMelee = this.items.filter( it => it.type == "weapon" && it.system.damagestatistic.toLowerCase() == "str")
|
|
|
|
|
for (let w of weaponsMelee) {
|
|
|
|
|
let damage = Number(w.system.damage) + this.system.biodata.sizenum + this.system.biodata.sizebonus + this.system.statistics.str.value + this.system.statistics.str.bonuseffect + meleeBonus
|
|
|
|
|
if (damage != w.system.mdl ) {
|
|
|
|
|
updates.push({ _id: w.id, "system.mdl": damage })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let rangedBonus = 0
|
|
|
|
|
effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && effect.system.affectstatus == "rdl" && (Number(effect.system.effectlevel) > 0))
|
|
|
|
|
for(let e of effects) {
|
|
|
|
|
rangedBonus += Number(e.system.effectlevel)
|
|
|
|
|
}
|
|
|
|
|
let weaponsRanged = this.items.filter( it => it.type == "weapon" && it.system.statistic.toLowerCase() == "agi")
|
|
|
|
|
for (let w of weaponsRanged) {
|
|
|
|
|
let damage = Number(w.system.damage) + rangedBonus
|
|
|
|
|
if (damage != w.system.rdl ) {
|
|
|
|
|
updates.push({ _id: w.id, "system.rdl": damage })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let armorBonus = 0
|
|
|
|
|
effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && effect.system.affectstatus == " adrl" && (Number(effect.system.effectlevel) > 0))
|
|
|
|
|
for(let e of effects) {
|
|
|
|
|
armorBonus += Number(e.system.effectlevel)
|
|
|
|
|
}
|
|
|
|
|
let armors = this.items.filter( it => it.type == "armor")
|
|
|
|
|
for (let a of armors) {
|
|
|
|
|
let adrl = this.system.statistics.phy.value + this.system.statistics.phy.bonuseffect + this.system.biodata.sizenum + this.system.biodata.sizebonus + a.system.resistance + armorBonus
|
|
|
|
|
if (adrl != a.system.adrl ) {
|
|
|
|
|
updates.push({ _id: a.id, "system.adrl": adrl })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (updates.length > 0) {
|
|
|
|
|
this.updateEmbeddedDocuments('Item', updates)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
parseStatEffects() {
|
|
|
|
|
if (this.system.biodata.noautobonus) { // If we are in "no-bonus mode
|
|
|
|
|
@@ -1693,13 +1762,13 @@ export class PegasusActor extends Actor {
|
|
|
|
|
if (objetQ) {
|
|
|
|
|
let newQ = objetQ.system.ammocurrent + incDec;
|
|
|
|
|
if (newQ >= 0 && newQ <= objetQ.system.ammomax) {
|
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.ammocurrent': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
|
await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.ammocurrent': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async applyAbility(ability, updates = [], directUpdate = false) {
|
|
|
|
|
async applyAbility(ability, updates = {}, directUpdate = false) {
|
|
|
|
|
// manage stat bonus
|
|
|
|
|
if (!ability.system) {
|
|
|
|
|
ability.system = ability.data
|
|
|
|
|
@@ -1722,6 +1791,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
nrg.mod += Number(ability.system.statusmodifier)
|
|
|
|
|
updates[`system.nrg`] = nrg
|
|
|
|
|
}
|
|
|
|
|
/* NO MORE USED
|
|
|
|
|
if (ability.system.statusaffected == 'health') {
|
|
|
|
|
let health = duplicate(this.system.secondary.health)
|
|
|
|
|
health.bonus += Number(ability.system.statusmodifier)
|
|
|
|
|
@@ -1741,7 +1811,7 @@ export class PegasusActor extends Actor {
|
|
|
|
|
let stealthhealth = duplicate(this.system.secondary.stealthhealth)
|
|
|
|
|
stealthhealth.bonus += Number(ability.system.statusmodifier)
|
|
|
|
|
updates[`system.secondary.stealthhealth`] = delirium
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
if (directUpdate) {
|
|
|
|
|
await this.update(updates)
|
|
|
|
|
@@ -1887,12 +1957,8 @@ export class PegasusActor extends Actor {
|
|
|
|
|
/* ROLL SECTION
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
pushEffect(rollData, effect) {
|
|
|
|
|
if (this.getTraumaState() == "none" && !this.checkNoBonusDice()) {
|
|
|
|
|
if ( (this.getTraumaState() == "none" && !this.checkNoBonusDice()) || !effect.system.bonusdice) {
|
|
|
|
|
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.system.effectlevel })
|
|
|
|
|
} else {
|
|
|
|
|
if (!effect.system.bonusdice) { // Do not push bonus dice effect when TraumaState is activated
|
|
|
|
|
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.system.effectlevel })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|