Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a creature falls to 0 Wounds, they gain the Prone condition. #1988

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion modules/actor/actor-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ export default class ActorWfrp4e extends WFRP4eDocumentMixin(Actor)
await super._onUpdate(data, options, user);

if (options.deltaWounds) {
this._displayScrollingChange(options.deltaWounds > 0 ? "+" + options.deltaWounds : options.deltaWounds);
if (options.deltaWounds < 0) {
this._displayScrollingChange(options.deltaWounds);

if(this.status.wounds.value === 0)
this.addCondition("prone");

} else {
this._displayScrollingChange("+" + options.deltaWounds);
}
}
if (options.deltaAdv) {
this._displayScrollingChange(options.deltaAdv, { advantage: true });
Expand Down
22 changes: 0 additions & 22 deletions modules/actor/sheet/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ export default class ActorSheetWfrp4e extends WFRP4eSheetMixin(ActorSheet) {
html.on('mousedown', '.quantity-click', this._onQuantityClick.bind(this));
html.on('click', '.weapon-item-name', this._onWeaponNameClick.bind(this));
html.on('mousedown', '.armour-total', this._onArmourTotalClick.bind(this));
html.on('mousedown', '.auto-calc-toggle', this._onAutoCalcToggle.bind(this));
html.on('mousedown', '.weapon-damage', this._onWeaponDamageClick.bind(this));
html.on('change', '.skill-advances', this._onChangeSkillAdvances.bind(this));
html.on('mousedown', '.condition-toggle', this._onConditionToggle.bind(this));
Expand Down Expand Up @@ -1145,27 +1144,6 @@ export default class ActorSheetWfrp4e extends WFRP4eSheetMixin(ActorSheet) {
return spell.update({ "system.cn.SL": SL })
}

async _onAutoCalcToggle(ev) {
let toggle = ev.target.attributes["toggle-type"].value;
if (ev.button == 2) {
let newFlags = duplicate(this.actor.flags);
if (toggle == "walk") newFlags.autoCalcWalk = !newFlags.autoCalcWalk;

else if (toggle == "run")
newFlags.autoCalcRun = !newFlags.autoCalcRun;
else if (toggle == "wounds")
newFlags.autoCalcWounds = !newFlags.autoCalcWounds;
else if (toggle == "critW")
newFlags.autoCalcCritW = !newFlags.autoCalcCritW;
else if (toggle == "corruption")
newFlags.autoCalcCorruption = !newFlags.autoCalcCorruption;
else if (toggle == "encumbrance")
newFlags.autoCalcEnc = !newFlags.autoCalcEnc;

return this.actor.update({ 'flags': newFlags })
}
}

async _onDiseaseRoll(ev) {
const itemId = this._getId(ev);
let disease = this.actor.items.get(itemId).toObject();
Expand Down
43 changes: 32 additions & 11 deletions modules/apps/chargen/char-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,31 @@ export default class CharGenWfrp4e extends FormApplication {
mergeObject(this.actor, expandObject(this.data.misc), {overwrite : true})


// Don't add items inline, as that will not create active effects
// Except skills, as new characters without items create blank skills
// We want to add ours to prevent duplicates
let items = this.actor.items;
this.actor.items = this.actor.items.filter(i => i.type == "skill");
this.actor.items = this.actor.items.filter(i => i.system.advances.value > 0 || // Don't add advanced skills that don't have advancements,
(i.system.advanced.value == "bsc" && i.system.grouped.value == "noSpec") || // Don't add specialisations that don't have advancements
(i.system.advanced.value == "bsc" && i.system.grouped.value == "isSpec" && !i.name.includes("(") && !i.name.includes(")")))

items = items.filter(i => i.type != "skill")
this.actor.items = this.actor.items.filter(i => {
if (i.type == "skill")
{
// Include any skill with advances
if (i.system.advances.value > 0)
{
return true
}
// or include any basic skill that isn't a specialization
if (i.system.advanced.value == "bsc" && i.system.grouped.value == "noSpec")
{
return true;
}
// or include any basic skill that IS a specialisation (but not specialised, i.e. Art, or Ride)
if(i.system.advanced.value == "bsc" && i.system.grouped.value == "isSpec" && !i.name.includes("(") && !i.name.includes(")"))
{
return true
}
else return false;
}
else // Return true if any other item besides skills
{
return true
};
})

if (game.user.isGM || game.settings.get("core", "permissions").ACTOR_CREATE.includes(game.user.role))
{
Expand All @@ -361,7 +376,13 @@ export default class CharGenWfrp4e extends FormApplication {
localStorage.removeItem("wfrp4e-chargen")
}
else {
const payload = {id : game.user.id, data : this.actor, items : items.map(i => i instanceof Item ? i.toObject() : i)}
// Create temp actor to handle any immediate scripts
let tempActor = await Actor.create(this.actor, {temporary: true})
for(let i of tempActor.items.contents)
{
await i._preCreate(i._source, {}, game.user.id);
}
const payload = {id : game.user.id, data : tempActor.toObject()}
let id = await game.wfrp4e.socket.executeOnUserAndWait("GM", "createActor", payload);
let actor = game.actors.get(id);
if (actor && actor.isOwner) {
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/chargen/skills-talents.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class SkillsTalentsStage extends ChargenStage {
}

table.rolled = true;
this.updateMessage("Rolled", { rolled: this.#reduceRandomTalents().join(", ") })
this.updateMessage("Rolled", { rolled: table.talents.join(", ") })
this.render(true);
}
}
2 changes: 0 additions & 2 deletions modules/system/socket-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ export default class SocketHandlers {
[id] : 3
}
let actor = await Actor.implementation.create(actorData)
let items = payload.items
await actor.createEmbeddedDocuments("Item", items)
return actor.id;
}

Expand Down
4 changes: 2 additions & 2 deletions static/templates/actors/actor-inventory.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<div class="encumbrance-counter-block">
<span class="encumbrance-label">{{system.status.encumbrance.current}} /</span>
{{#if actor.flags.autoCalcEnc}}
<a class="encumbrance-max auto-calc-toggle" toggle-type="encumbrance">{{system.status.encumbrance.max}}</a>
<a class="encumbrance-max" toggle-type="encumbrance">{{system.status.encumbrance.max}}</a>
{{else}}
<input type="text" name="system.status.encumbrance.max" value="{{system.status.encumbrance.max}}"
class="encumbrance-max auto-calc-toggle input" toggle-type="encumbrance" data-dtype="Number" />
class="encumbrance-max input" data-dtype="Number" />
{{/if}}
</div>
</div>
Expand Down
20 changes: 10 additions & 10 deletions static/templates/actors/character/character-main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
<div class="move-section">
<div class="move-value">
{{#if actor.flags.autoCalcWalk}}
<a class="auto-calc-toggle" toggle-type="walk">{{system.details.move.walk}} {{localize "yds"}}</a>
<a >{{system.details.move.walk}} {{localize "yds"}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="walk" name="system.details.move.walk" type="text" value="{{system.details.move.walk}}" data-dtype="String">
<input name="system.details.move.walk" type="text" value="{{system.details.move.walk}}" data-dtype="String">
{{/if}}
</div>
<div class="move-name">
Expand All @@ -91,9 +91,9 @@
<div class="move-section">
<div class="move-value">
{{#if actor.flags.autoCalcRun}}
<a class="auto-calc-toggle" toggle-type="run">{{system.details.move.run}} {{localize "yds"}}</a>
<a >{{system.details.move.run}} {{localize "yds"}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="run" name="system.details.move.run" type="text"
<input name="system.details.move.run" type="text"
value="{{system.details.move.run}}" data-dtype="String">
{{/if}}
</div>
Expand Down Expand Up @@ -142,9 +142,9 @@
</div>
<div id="wounds-max">
{{#if actor.flags.autoCalcWounds}}
<a class="auto-calc-toggle" toggle-type="wounds">{{system.status.wounds.max}}</a>
<a toggle-type="wounds">{{system.status.wounds.max}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="wounds" name="system.status.wounds.max" type="text"
<input name="system.status.wounds.max" type="text"
value="{{system.status.wounds.max}}" data-dtype="{{system.status.wounds.type}}">
{{/if}}
</div>
Expand All @@ -166,9 +166,9 @@
</div>
<div id="criticalWounds-max">
{{#if actor.flags.autoCalcCritW}}
<a class="auto-calc-toggle" toggle-type="critW">{{system.status.criticalWounds.max}}</a>
<a toggle-type="critW">{{system.status.criticalWounds.max}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="critW" name="system.status.criticalWounds.max" type="text"
<input name="system.status.criticalWounds.max" type="text"
value="{{system.status.criticalWounds.max}}">
{{/if}}
</div>
Expand All @@ -188,9 +188,9 @@
</div>
<div id="corruption-max">
{{#if actor.flags.autoCalcCorruption}}
<a class="auto-calc-toggle" toggle-type="corruption">{{system.status.corruption.max}}</a>
<a toggle-type="corruption">{{system.status.corruption.max}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="corruption" name="system.status.corruption.max" type="text" value="{{system.status.corruption.max}}" data-dtype="Number">
<input name="system.status.corruption.max" type="text" value="{{system.status.corruption.max}}" data-dtype="Number">
{{/if}}
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions static/templates/actors/creature/creature-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
<div class="move-section">
<div class="move-value">
{{#if actor.flags.autoCalcWalk}}
<a class="auto-calc-toggle" toggle-type="walk">{{system.details.move.walk}} {{localize "yds"}}</a>
<a toggle-type="walk">{{system.details.move.walk}} {{localize "yds"}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="walk" name="system.details.move.walk" type="text"
<input name="system.details.move.walk" type="text"
value="{{system.details.move.walk}}" data-dtype="String">
{{/if}}
</div>
Expand All @@ -72,9 +72,9 @@
<div class="move-section">
<div class="move-value">
{{#if actor.flags.autoCalcRun}}
<a class="auto-calc-toggle" toggle-type="run">{{system.details.move.run}} {{localize "yds"}}</a>
<a toggle-type="run">{{system.details.move.run}} {{localize "yds"}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="run" name="system.details.move.run" type="text"
<input name="system.details.move.run" type="text"
value="{{system.details.move.run}}" data-dtype="String">
{{/if}}
</div>
Expand All @@ -96,9 +96,9 @@
</div>
<div id="wounds-max">
{{#if actor.flags.autoCalcWounds}}
<a class="auto-calc-toggle" toggle-type="wounds">{{system.status.wounds.max}}</a>
<a toggle-type="wounds">{{system.status.wounds.max}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="wounds" name="system.status.wounds.max" type="text"
<input name="system.status.wounds.max" type="text"
value="{{system.status.wounds.max}}" data-dtype="{{system.status.wounds.type}}">
{{/if}}
</div>
Expand Down
12 changes: 6 additions & 6 deletions static/templates/actors/npc/npc-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
<div class="move-section">
<div class="move-value">
{{#if actor.flags.autoCalcWalk}}
<a class="auto-calc-toggle" toggle-type="walk">{{system.details.move.walk}} {{localize "yds"}}</a>
<a toggle-type="walk">{{system.details.move.walk}} {{localize "yds"}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="walk" name="system.details.move.walk" type="text"
<input name="system.details.move.walk" type="text"
value="{{system.details.move.walk}}" data-dtype="String">
{{/if}}
</div>
Expand All @@ -71,9 +71,9 @@
<div class="move-section">
<div class="move-value">
{{#if actor.flags.autoCalcRun}}
<a class="auto-calc-toggle" toggle-type="run">{{system.details.move.run}} {{localize "yds"}}</a>
<a toggle-type="run">{{system.details.move.run}} {{localize "yds"}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="run" name="system.details.move.run" type="text"
<input name="system.details.move.run" type="text"
value="{{system.details.move.run}}" data-dtype="String">
{{/if}}
</div>
Expand All @@ -95,9 +95,9 @@
</div>
<div id="wounds-max">
{{#if actor.flags.autoCalcWounds}}
<a class="auto-calc-toggle" toggle-type="wounds">{{system.status.wounds.max}}</a>
<a toggle-type="wounds">{{system.status.wounds.max}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="wounds" name="system.status.wounds.max" type="text"
<input name="system.status.wounds.max" type="text"
value="{{system.status.wounds.max}}" data-dtype="{{system.status.wounds.type}}">
{{/if}}
</div>
Expand Down
4 changes: 2 additions & 2 deletions static/templates/actors/vehicle/vehicle-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
</div>
<div class="max value">
{{#if actor.flags.autoCalcCritW}}
<a class="auto-calc-toggle" toggle-type="critW">{{system.status.criticalWounds.max}}</a>
<a toggle-type="critW">{{system.status.criticalWounds.max}}</a>
{{else}}
<input class="auto-calc-toggle" toggle-type="critW" name="system.status.criticalWounds.max" type="text" value="{{system.status.criticalWounds.max}}" data-dtype="{{system.status.criticalWounds.type}}">
<input name="system.status.criticalWounds.max" type="text" value="{{system.status.criticalWounds.max}}" data-dtype="{{system.status.criticalWounds.type}}">
{{/if}}
</div>
</div>
Expand Down