Various changes + updates

This commit is contained in:
2022-08-14 15:27:54 +02:00
parent 76c8cde3d9
commit 30ef811bbf
20 changed files with 302 additions and 57 deletions

View File

@ -464,6 +464,9 @@ export class PegasusActor extends Actor {
ui.notifications.warn("Stun level cannot go below 0")
}
let stunAbove = combat.stunlevel - combat.stunthreshold
if (stunAbove > 0) {
ChatMessage.create( { content: `${this.name} Stun threshold has been exceeded.`})
}
if (incDec > 0 && stunAbove > 0) {
let delirium = duplicate(this.data.data.secondary.delirium)
delirium.value -= incDec
@ -561,6 +564,27 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
async preprocessItem(event, item, onDrop = false) {
// Pre-filter effects
if (item.data.type == 'effect' ) {
if ( this.checkMentalDisruption() && item.data.data.type == "mental" && item.data.data.genre == "positive") {
ChatMessage.create( { content: "Effects of this type cannot be applied while Disruption is applied, Use a Soft Action to remove Disruption"})
return
}
if ( this.checkPhysicalDisruption() && item.data.data.type == "physical" && item.data.data.genre == "positive") {
ChatMessage.create( { content: "Effects of this type cannot be applied while Disruption is applied, Use a Soft Action to remove Disruption"})
return
}
if ( this.checkMentalImmunity() && item.data.data.type == "mental" && item.data.data.genre == "negative") {
ChatMessage.create( { content: "Effects of this type cannot be applied while Immunity is applied"})
return
}
if ( this.checkPhysicalImmunity() && item.data.data.type == "physical" && item.data.data.genre == "negative") {
ChatMessage.create( { content: "Effects of this type cannot be applied while Immunity is applied"})
return
}
}
if (item.data.type == 'race') {
this.applyRace(item.data)
} else if (item.data.type == 'role') {
@ -833,6 +857,10 @@ export class PegasusActor extends Actor {
if (item) {
if (item.data.data.status == status) return;// Ensure we are really changing the status
if (this.checkNoPerksAllowed() ) {
ChatMessage( {content: "No perks activation allowed due to effect !"})
return
}
// Severe Trauma management
if (this.getTraumaState() == "severetrauma") {
@ -977,7 +1005,79 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `${this.name} has used a Hero Level to reroll !` })
return biodata.currentlevelremaining
}
/* -------------------------------------------- */
checkIgnoreHealth() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.ignorehealthpenalty) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkMentalDisruption() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.mentaldisruption) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkPhysicalDisruption() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.physicaldisruption) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkMentalImmunity() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.mentalimmunity) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkPhysicalImmunity() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.physicalimmunity) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkNoBonusDice() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.nobonusdice) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkNoPerksAllowed() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.noperksallowed) {
return true
}
}
return false
}
/* -------------------------------------------- */
checkIfPossible() {
for (let effect of this.data.items) {
if (effect.type == "effect" && effect.data.data.isthispossible.length > 0) {
ChatMessage.create( { content: effect.data.data.isthispossible} )
}
}
}
/* -------------------------------------------- */
async computeNRGHealth() {
if (this.isOwner || game.user.isGM) {
@ -1021,9 +1121,10 @@ export class PegasusActor extends Actor {
updates['data.nrg.value'] = nrgValue
}
nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.statistics.mnd.mod;
if (nrgValue != this.data.data.combat.stunthreshold) {
updates['data.combat.stunthreshold'] = nrgValue
let stunth = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + PegasusUtility.getDiceValue(this.data.data.statistics.foc.value)
+ this.data.data.statistics.mnd.mod + this.data.data.statistics.phy.mod + this.data.data.statistics.foc.mod
if (stunth != this.data.data.combat.stunthreshold) {
updates['data.combat.stunthreshold'] = stunth
}
let momentum = this.data.data.statistics.foc.value + this.data.data.statistics.foc.mod
@ -1038,7 +1139,6 @@ export class PegasusActor extends Actor {
updates['data.mr.value'] = mrLevel
}
let moralitythreshold = - (Number(PegasusUtility.getDiceValue(this.data.data.statistics.foc.value)) + Number(this.data.data.statistics.foc.mod))
if (moralitythreshold != this.data.data.biodata.moralitythreshold) {
updates['data.biodata.moralitythreshold'] = moralitythreshold
@ -1063,20 +1163,20 @@ export class PegasusActor extends Actor {
}
if (Object.entries(updates).length > 0) {
await this.update(updates)
this.computeThreatLevel()
}
this.computeThreatLevel()
}
if (this.isOwner || game.user.isGM) {
// Update current hindrance level
let hindrance = this.data.data.combat.hindrancedice
if (this.data.data.secondary.health.value < 0) {
if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.max + 1) / 2)) { // Severe wounded
hindrance += 3
} else {
hindrance += 1
if ( !this.checkIgnoreHealth() ) {
if (this.data.data.secondary.health.value < 0) {
if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.max + 1) / 2)) { // Severe wounded
hindrance += 3
} else {
hindrance += 1
}
}
}
this.data.data.combat.hindrancedice = hindrance
@ -1347,6 +1447,7 @@ export class PegasusActor extends Actor {
rollData.levelRemaining = this.getLevelRemaining()
rollData.activePerks = duplicate(this.getActivePerks())
rollData.diceList = PegasusUtility.getDiceList()
rollData.noBonusDice = this.checkNoBonusDice()
rollData.dicePool = []
if (statKey) {