New weapon management, including shotgun
This commit is contained in:
@@ -90,6 +90,10 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
|
||||
if (!game.user.isGM ) {
|
||||
return
|
||||
}
|
||||
|
||||
let updates = {}
|
||||
if (this.wp.max !== this.characteristics.pow.value) {
|
||||
updates[`system.wp.max`] = this.characteristics.pow.value
|
||||
@@ -123,8 +127,6 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
dmgBonus = -2
|
||||
} else if (this.characteristics.str.value <= 8) {
|
||||
dmgBonus = -1
|
||||
} else if (this.characteristics.str.value <= 12) {
|
||||
dmgBonus = 0
|
||||
} else if (this.characteristics.str.value <= 16) {
|
||||
dmgBonus = 1
|
||||
} else if (this.characteristics.str.value <= 20) {
|
||||
@@ -137,9 +139,12 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
// BP (Breaking Point) management
|
||||
if (!this.san.breakingPointReached && this.san.value <= this.san.breakingPoint) {
|
||||
updates[`system.san.breakingPointReached`] = true
|
||||
this.san.breakingPointReached = true // Force local update to true
|
||||
ChatMessage.create({
|
||||
content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent }),
|
||||
// Get the user id of the actor owner
|
||||
whisper: [game.users.find(u => u.character?.name === this.parent?.name).id ]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -195,10 +200,6 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
}
|
||||
|
||||
async applySANConsequences(rollData) {
|
||||
// If sanType is "non", do nothing
|
||||
if (rollData.sanType === "none") {
|
||||
return
|
||||
}
|
||||
let msgData = {
|
||||
sanType: rollData.sanType,
|
||||
sanLoss: rollData.sanLoss,
|
||||
@@ -265,14 +266,21 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
updates[`system.san.helplessness`] = [false, false, false]
|
||||
msgData.adaptedToHelplessness = true
|
||||
}
|
||||
} else if (rollData.sanType === "unnatural" ) {
|
||||
template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-unnatural.hbs"
|
||||
} else {
|
||||
template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-none.hbs"
|
||||
}
|
||||
|
||||
console.log("CthulhuEternalProtagonist.applySANConsequences", rollData, updates, template)
|
||||
let content = await foundry.applications.handlebars.renderTemplate(template, msgData)
|
||||
let msg = await ChatMessage.create({
|
||||
content: content,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent }),
|
||||
whisper: game.users.filter(u => u.isGM).map(u => u.id),
|
||||
})
|
||||
msg.setFlag("fvtt-cthulhu-eternal", "rollData", msgData)
|
||||
await msg.setFlag("fvtt-cthulhu-eternal", "rollData", msgData)
|
||||
|
||||
if (Object.keys(updates).length > 0) {
|
||||
this.parent.update(updates)
|
||||
}
|
||||
@@ -284,12 +292,14 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
let san = Math.max(Math.min(this.san.value + rollData.sanLoss, this.san.max), 0)
|
||||
if (this.san.value !== san) {
|
||||
updates[`system.san.value`] = san
|
||||
rollData.sanValue = san
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/chat-san-type-request.hbs", rollData)
|
||||
let msg = await ChatMessage.create({
|
||||
content: content,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent })
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.parent }),
|
||||
whisper: game.users.filter(u => u.isGM).map(u => u.id)
|
||||
})
|
||||
msg.setFlag("fvtt-cthulhu-eternal", "rollData", rollData)
|
||||
await msg.setFlag("fvtt-cthulhu-eternal", "rollData", rollData)
|
||||
}
|
||||
if (Object.keys(updates).length > 0) {
|
||||
this.parent.update(updates)
|
||||
|
||||
@@ -13,12 +13,23 @@ export default class CthulhuEternalWeapon extends foundry.abstract.TypeDataModel
|
||||
|
||||
schema.weaponType = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_TYPE })
|
||||
schema.hasDirectSkill = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.directSkillValue = new fields.NumberField({ required: true, initial: 0, min: 0, max:99 })
|
||||
schema.directSkillValue = new fields.NumberField({ required: true, initial: 0, min: 0, max: 99 })
|
||||
|
||||
schema.hasDamageDistance = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.damageDistance = new fields.SchemaField(Array.fromRange(6, 1).reduce((damageDistance, i) => {
|
||||
damageDistance[`dist${i}`] = new fields.SchemaField({
|
||||
damage: new fields.StringField({ required: true, initial: "1d6" }),
|
||||
distance: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
return damageDistance
|
||||
}, {}));
|
||||
|
||||
schema.hasSelectiveFire = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.damage = new fields.StringField({required: true, initial: "1d6"})
|
||||
schema.hasSight = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.isStunning = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.damage = new fields.StringField({ required: true, initial: "1d6" })
|
||||
schema.applyDamageBonus = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.baseRange = new fields.StringField({required: true, initial: ""})
|
||||
schema.baseRange = new fields.StringField({ required: true, initial: "" })
|
||||
schema.rangeUnit = new fields.StringField({ required: true, initial: "yard", choices: SYSTEM.WEAPON_RANGE_UNIT })
|
||||
schema.lethality = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
schema.killRadius = new fields.NumberField({ required: true, initial: 0, min: 0 })
|
||||
@@ -43,7 +54,8 @@ export default class CthulhuEternalWeapon extends foundry.abstract.TypeDataModel
|
||||
}
|
||||
|
||||
isRanged() {
|
||||
return this.weaponType.includes("ranged")
|
||||
console.log("isRanged", this.weaponType, this)
|
||||
return this.weaponType.match("ranged")
|
||||
}
|
||||
|
||||
isFireArm() {
|
||||
|
||||
Reference in New Issue
Block a user