v2 changes
This commit is contained in:
@@ -4,7 +4,7 @@ import { PegasusRollDialog } from "./pegasus-roll-dialog.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const coverBonusTable = { "nocover": 0, "lightcover": 2, "heavycover": 4, "entrenchedcover": 6 };
|
||||
const statThreatLevel = [ "agi", "str", "phy", "com", "def", "per" ]
|
||||
const statThreatLevel = ["agi", "str", "phy", "com", "def", "per"]
|
||||
/* -------------------------------------------- */
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
@@ -129,16 +129,16 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkAndPrepareEquipment(item) {
|
||||
if ( item.data.resistance ) {
|
||||
if (item.data.resistance) {
|
||||
item.data.resistanceDice = PegasusUtility.getDiceFromLevel(item.data.resistance)
|
||||
}
|
||||
if ( item.data.idr ) {
|
||||
if (item.data.idr) {
|
||||
item.data.idrDice = PegasusUtility.getDiceFromLevel(item.data.idr)
|
||||
}
|
||||
if ( item.data.damage) {
|
||||
if (item.data.damage) {
|
||||
item.data.damageDice = PegasusUtility.getDiceFromLevel(item.data.damage)
|
||||
}
|
||||
if( item.data.level) {
|
||||
if (item.data.level) {
|
||||
item.data.levelDice = PegasusUtility.getDiceFromLevel(item.data.level)
|
||||
}
|
||||
}
|
||||
@@ -298,32 +298,32 @@ export class PegasusActor extends Actor {
|
||||
/* ------------------------------------------- */
|
||||
computeThreatLevel() {
|
||||
let tl = 0
|
||||
for(let key of statThreatLevel) { // Init with concerned stats
|
||||
tl += PegasusUtility.getDiceValue( this.data.data.statistics[key].value )
|
||||
for (let key of statThreatLevel) { // Init with concerned stats
|
||||
tl += PegasusUtility.getDiceValue(this.data.data.statistics[key].value)
|
||||
}
|
||||
let powers = duplicate( this.getPowers() || [])
|
||||
if ( powers.length > 0 ) { // Then add some mental ones of powers
|
||||
tl += PegasusUtility.getDiceValue( this.data.data.statistics.foc.value )
|
||||
tl += PegasusUtility.getDiceValue( this.data.data.statistics.mnd.value )
|
||||
let powers = duplicate(this.getPowers() || [])
|
||||
if (powers.length > 0) { // Then add some mental ones of powers
|
||||
tl += PegasusUtility.getDiceValue(this.data.data.statistics.foc.value)
|
||||
tl += PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value)
|
||||
}
|
||||
tl += PegasusUtility.getDiceValue( this.data.data.mr.value )
|
||||
let specThreat = this.data.items.filter( it => it.type == "specialisation" && it.data.data.isthreatlevel) || []
|
||||
tl += PegasusUtility.getDiceValue(this.data.data.mr.value)
|
||||
let specThreat = this.data.items.filter(it => it.type == "specialisation" && it.data.data.isthreatlevel) || []
|
||||
for (let spec of specThreat) {
|
||||
tl += PegasusUtility.getDiceValue( spec.data.data.level )
|
||||
tl += PegasusUtility.getDiceValue(spec.data.data.level)
|
||||
}
|
||||
tl += this.data.data.nrg.absolutemax + this.data.data.secondary.health.max + this.data.data.secondary.delirium.max
|
||||
tl += this.getPerks().length * 5
|
||||
|
||||
let weapons = this.getWeapons()
|
||||
for(let weapon of weapons) {
|
||||
for (let weapon of weapons) {
|
||||
tl += PegasusUtility.getDiceValue(weapon.data.damage)
|
||||
}
|
||||
let armors = this.getArmors()
|
||||
for(let armor of armors) {
|
||||
for (let armor of armors) {
|
||||
tl += PegasusUtility.getDiceValue(armor.data.resistance)
|
||||
}
|
||||
let shields = duplicate(this.getShields())
|
||||
for(let shield of shields) {
|
||||
for (let shield of shields) {
|
||||
tl += PegasusUtility.getDiceValue(shield.data.level)
|
||||
}
|
||||
let abilities = duplicate(this.getAbilities())
|
||||
@@ -334,8 +334,8 @@ export class PegasusActor extends Actor {
|
||||
for (let equip of equipments) {
|
||||
tl += equip.data.threatlevel
|
||||
}
|
||||
if ( tl != this.data.data.biodata.threatlevel) {
|
||||
this.update( {'data.biodata.threatlevel': tl} )
|
||||
if (tl != this.data.data.biodata.threatlevel) {
|
||||
this.update({ 'data.biodata.threatlevel': tl })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ export class PegasusActor extends Actor {
|
||||
if (equip1._id != equip2._id && equip2.data.containerid == equip1._id) {
|
||||
equip1.data.contents.push(equip2)
|
||||
let q = equip2.data.quantity ?? 1
|
||||
equip1.data.contentsEnc += q *equip2.data.weight
|
||||
equip1.data.contentsEnc += q * equip2.data.weight
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -359,7 +359,7 @@ export class PegasusActor extends Actor {
|
||||
// Compute whole enc
|
||||
let enc = 0
|
||||
for (let item of equipments) {
|
||||
item.data.idrDice = PegasusUtility.getDiceFromLevel( Number(item.data.idr))
|
||||
item.data.idrDice = PegasusUtility.getDiceFromLevel(Number(item.data.idr))
|
||||
if (item.data.equipped) {
|
||||
if (item.data.iscontainer) {
|
||||
enc += item.data.contentsEnc
|
||||
@@ -399,11 +399,39 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
modifyStun(incDec) {
|
||||
let combat = duplicate(this.data.data.combat)
|
||||
combat.stunlevel += incDec
|
||||
if (combat.stunlevel >= 0) {
|
||||
this.update({ 'data.combat': combat })
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM'))
|
||||
}
|
||||
if (incDec > 0) {
|
||||
chatData.content = `<div>${this.name} suffered a Stun level.</div`
|
||||
} else {
|
||||
chatData.content = `<div>${this.name} recovered a Stun level.</div`
|
||||
}
|
||||
ChatMessage.create(chatData)
|
||||
} else {
|
||||
ui.notifications.warn("Stun level cannot go below 0")
|
||||
}
|
||||
let stunAbove = combat.stunlevel - combat.stunthreshold
|
||||
if (incDec > 0 && stunAbove > 0) {
|
||||
let delirium = duplicate(this.data.data.secondary.delirium)
|
||||
delirium.value -= incDec
|
||||
this.update({ 'data.secondary.delirium': delirium })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
modifyMomentum(incDec) {
|
||||
let momentum = duplicate(this.data.data.momentum)
|
||||
momentum.value += incDec
|
||||
if (momentum.value >= 0 ) {
|
||||
if (momentum.value >= 0) {
|
||||
this.update({ 'data.momentum': momentum })
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
@@ -416,7 +444,7 @@ export class PegasusActor extends Actor {
|
||||
chatData.content = `<div>${this.name} has used a Momentum</div`
|
||||
}
|
||||
ChatMessage.create(chatData)
|
||||
}else {
|
||||
} else {
|
||||
ui.notifications.warn("Momentum cannot go below 0")
|
||||
}
|
||||
}
|
||||
@@ -705,6 +733,18 @@ export class PegasusActor extends Actor {
|
||||
|
||||
if (item.data.data.status == status) return;// Ensure we are really changing the status
|
||||
|
||||
// Severe Trauma management
|
||||
if (this.getTraumaState() == "severetrauma") {
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM'))
|
||||
}
|
||||
chatData.content = `<div>${this.name} is suffering from Severe Trauma and cannot use Perks at this time.</div`
|
||||
ChatMessage.create(chatData)
|
||||
return
|
||||
}
|
||||
|
||||
let updateOK = true
|
||||
if (status == "ready") {
|
||||
await this.cleanPerkEffects(itemId)
|
||||
@@ -803,6 +843,20 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTraumaState() {
|
||||
this.traumaState = "none"
|
||||
if (this.type == "character") {
|
||||
if (this.data.data.secondary.delirium.value >= 0 && this.data.data.secondary.delirium.value <= Math.floor((this.data.data.secondary.delirium.max + 1) / 2)) {
|
||||
this.traumaState = "trauma"
|
||||
}
|
||||
if (this.data.data.secondary.delirium.value < 0) {
|
||||
this.traumaState = "severetrauma"
|
||||
}
|
||||
}
|
||||
return this.traumaState
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async computeNRGHealth() {
|
||||
if (this.isToken) return
|
||||
@@ -883,12 +937,15 @@ export class PegasusActor extends Actor {
|
||||
// Update current hindrance level
|
||||
let hindrance = this.data.data.combat.hindrancedice
|
||||
if (this.data.data.secondary.health.value < 0) {
|
||||
hindrance += Math.abs(this.data.data.secondary.health.value)
|
||||
}
|
||||
if (this.data.data.secondary.delirium.value < 0) {
|
||||
hindrance += Math.abs(this.data.data.secondary.delirium.value)
|
||||
if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.value + 1) / 2)) { // Severe wounded
|
||||
hindrance += 3
|
||||
} else {
|
||||
hindrance += 1
|
||||
|
||||
}
|
||||
}
|
||||
this.data.data.combat.hindrancedice = hindrance
|
||||
this.getTraumaState()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -937,7 +994,7 @@ export class PegasusActor extends Actor {
|
||||
let objetQ = this.data.items.get(objetId)
|
||||
if (objetQ) {
|
||||
let newQ = objetQ.data.data.ammocurrent + incDec;
|
||||
if ( newQ >= 0 && newQ <= objetQ.data.data.ammomax) {
|
||||
if (newQ >= 0 && newQ <= objetQ.data.data.ammomax) {
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.ammocurrent': newQ }]); // pdates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
@@ -1044,9 +1101,9 @@ export class PegasusActor extends Actor {
|
||||
this.getIncreaseStatValue(updates, role.data.statincrease1)
|
||||
this.getIncreaseStatValue(updates, role.data.statincrease2)
|
||||
|
||||
if ( role.data.specialability.length > 0) {
|
||||
if (role.data.specialability.length > 0) {
|
||||
console.log("Adding ability", role.data.specialability)
|
||||
newItems = newItems.concat( duplicate(role.data.specialability) ) // Add new ability
|
||||
newItems = newItems.concat(duplicate(role.data.specialability)) // Add new ability
|
||||
this.applyAbility(role.data.specialability[0], newItems)
|
||||
}
|
||||
await this.update(updates)
|
||||
@@ -1091,7 +1148,13 @@ export class PegasusActor extends Actor {
|
||||
if (effect.data.effectstatlevel) {
|
||||
effect.data.effectlevel = this.data.data.statistics[effect.data.effectstat].value
|
||||
}
|
||||
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
|
||||
if (this.getTraumaState() == "none") {
|
||||
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
|
||||
} else {
|
||||
if (!effect.data.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.data.effectlevel })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1141,8 +1204,11 @@ export class PegasusActor extends Actor {
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
rollData.img = this.img
|
||||
rollData.traumaState = this.getTraumaState()
|
||||
rollData.activePerks = duplicate(this.getActivePerks())
|
||||
|
||||
rollData.diceList = PegasusUtility.getDiceList()
|
||||
rollData.dicePool = []
|
||||
|
||||
if (statKey) {
|
||||
rollData.statKey = statKey
|
||||
rollData.stat = this.getStat(statKey)
|
||||
@@ -1153,8 +1219,13 @@ export class PegasusActor extends Actor {
|
||||
if (statKey.toLowerCase() == "mr") {
|
||||
rollData.img = "systems/fvtt-pegasus-rpg/images/icons/MR.webp"
|
||||
} else {
|
||||
rollData.img = `systems/fvtt-pegasus-rpg/images/icons/${rollData.stat.abbrev}.webp`
|
||||
rollData.img = `systems/fvtt-pegasus-rpg/images/icons/${rollData.stat.abbrev}.webp`
|
||||
}
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value)
|
||||
rollData.dicePool.push({
|
||||
name: "stat", key: diceKey,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
|
||||
})
|
||||
}
|
||||
|
||||
this.addEffects(rollData)
|
||||
@@ -1185,11 +1256,12 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollPool(statKey, useShield = false) {
|
||||
rollPool(statKey, useShield = false, subKey = "none") {
|
||||
let stat = this.getStat(statKey)
|
||||
if (stat) {
|
||||
let rollData = this.getCommonRollData(statKey, useShield)
|
||||
rollData.mode = "stat"
|
||||
rollData.subKey = subKey
|
||||
rollData.title = `Roll : ${stat.label} `
|
||||
rollData.img = "icons/dice/d12black.svg"
|
||||
|
||||
@@ -1259,6 +1331,9 @@ export class PegasusActor extends Actor {
|
||||
rollData.combatId = combatId
|
||||
rollData.combatantId = combatantId
|
||||
console.log("MR ROLL", rollData)
|
||||
if (isInit) {
|
||||
rollData.title = "MR / Initiative"
|
||||
}
|
||||
this.startRoll(rollData);
|
||||
} else {
|
||||
ui.notifications.warn("MR not found !");
|
||||
|
Reference in New Issue
Block a user