Skip to content

Commit 482a0fc

Browse files
committed
improve chargen creation, warn for old species tables, version number
1 parent 73f8e6b commit 482a0fc

6 files changed

Lines changed: 40 additions & 33 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ npm run pack
168168

169169
- [Places & Perils](https://foundryvtt.com/packages/wfrp4e-owb3/) - Contains seven more titles previously released as short PDF only options that will help expand your WFRP adventures, this time focused on various locations and people.
170170

171+
- [Deft Steps Light Fingers](https://foundryvtt.com/packages/wfrp4e-dslf/) - A supplement for playing Characters in the Rogue or Ranger class.
172+
171173
**Unofficial**
172174

173175
- [The GM Toolkit](https://foundryvtt.com/packages/wfrp4e-gm-toolkit) - Adds advantage automation, extends the Token HUD for more information, and adds useful macros!

src/apps/chargen/char-gen.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ export default class CharGenWfrp4e extends FormApplication {
128128
ui.notifications.warn(game.i18n.localize("CHARGEN.NoGMWarning"), {permanent : true})
129129
}
130130

131+
let speciesTable = game.wfrp4e.tables.findTable("species");
132+
133+
if (speciesTable.results.some(i => !i.name))
134+
{
135+
ui.notifications.warn("The configured Species table is from an older version and may not be compatible with character creation in V13. To ensure it works correctly, please delete and reimport the table from the compendium.", {permanent : true})
136+
}
131137

132138
Hooks.call("wfrp4e:chargen", this)
133139
}
@@ -353,38 +359,36 @@ export default class CharGenWfrp4e extends FormApplication {
353359
return i instanceof Item.implementation ? i.toObject() : i
354360
})
355361

362+
363+
// Must create items separately so preCreate scripts run
364+
let actorItems = this.actor.items;
365+
this.actor.items = [];
366+
356367
if (game.user.isGM || game.settings.get("core", "permissions").ACTOR_CREATE.includes(game.user.role))
357368
{
358-
// Must create items separately so preCreate scripts run
359-
let actorItems = this.actor.items;
360-
this.actor.items = [];
361-
let document = await Actor.create(this.actor, {skipItems : true});
369+
370+
let document = await Actor.implementation.create(this.actor, {skipItems : true});
362371
await document.createEmbeddedDocuments("Item", actorItems, {skipSpecialisationChoice : true})
363-
for(let i of document.items.contents)
364-
{
365-
// Run onCreate scripts
366-
await i._onCreate(i._source, {}, game.user.id);
367-
}
372+
// for(let i of document.items.contents)
373+
// {
374+
// // Run onCreate scripts
375+
// await i._onCreate(i._source, {}, game.user.id);
376+
// }
368377
document.sheet.render(true);
369378
localStorage.removeItem("wfrp4e-chargen")
370379
}
371380
else {
372-
// Create temp actor to handle any immediate scripts
373-
let tempActor = await Actor.create(this.actor, {temporary: true})
374-
for(let i of tempActor.items.contents)
375-
{
376-
// Run preCreate scripts
377-
await i._preCreate(i._source, {skipSpecialisationChoice : true}, game.user.id);
378-
}
379-
const payload = {id : game.user.id, data : tempActor.toObject(), options : {skipSpecialisationChoice : true}}
381+
const payload = {id : game.user.id, data : this.actor, options : {skipSpecialisationChoice : true}}
380382
let id = await SocketHandlers.executeOnUserAndWait("GM", "createActor", payload);
381383
let actor = game.actors.get(id);
382-
if (actor && actor.isOwner) {
383-
for(let i of actor.items.contents)
384-
{
385-
// Run onCreate scripts
386-
await i._onCreate(i._source, {}, game.user.id);
387-
}
384+
await actor.createEmbeddedDocuments("Item", actorItems, {skipSpecialisationChoice : true})
385+
if (actor && actor.isOwner)
386+
{
387+
// for(let i of actor.items.contents)
388+
// {
389+
// // Run onCreate scripts
390+
// await i._onCreate(i._source, {}, game.user.id);
391+
// }
388392
actor.sheet.render(true)
389393
localStorage.removeItem("wfrp4e-chargen")
390394
}

src/apps/chargen/species.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ export class SpeciesStage extends ChargenStage {
4848

4949
for (let result of speciesTable.results)
5050
{
51-
let speciesKey = warhammer.utility.findKey(result.text, game.wfrp4e.config.species)
51+
let speciesKey = warhammer.utility.findKey(result.name, game.wfrp4e.config.species)
5252
if (speciesKey)
5353
{
54-
data.species[speciesKey] = result.text
54+
data.species[speciesKey] = result.name
5555
}
5656
}
5757

@@ -139,8 +139,8 @@ export class SpeciesStage extends ChargenStage {
139139
this.context.exp = 20;
140140
this.context.roll = await game.wfrp4e.tables.rollTable("species");
141141
this.context.choose = false;
142-
this.updateMessage("Rolled", {rolled : this.context.roll.result})
143-
this.setSpecies(findKey(this.context.roll.result, game.wfrp4e.config.species));
142+
this.updateMessage("Rolled", {rolled : this.context.roll.name})
143+
this.setSpecies(findKey(this.context.roll.name, game.wfrp4e.config.species));
144144
}
145145

146146
// Set chosen species, but don't unset "roll" (prevents users from rolling again after they've rolled once)

src/system/tables-wfrp4e.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export default class WFRP_Tables {
9696
result : rollResult?.getChatText(),
9797
roll : displayTotal,
9898
total : rollValue,
99+
name : rollResult?.name,
99100
object : rollResult?.toObject(),
100101
title : table.name,
101102
}

static/templates/apps/chargen/species.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{{#if context.choose}}
2929
<div><b>{{localize "Choose"}}:</b> {{configLookup "species" context.choose}}</div>
3030
{{else if context.roll}}
31-
<div><b>{{localize "Roll"}}:</b> {{context.roll.roll}} - {{context.roll.result}}</div>
31+
<div><b>{{localize "Roll"}}:</b> {{context.roll.roll}} - {{context.roll.name}}</div>
3232
{{/if}}
3333

3434

system.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "wfrp4e",
33
"title": "Warhammer Fantasy Roleplay 4th Edition",
44
"description": "A comprehensive system for running grim and perilous games of Warhammer Fantasy Roleplay in the Foundry VTT environment.",
5-
"version": "9.0.6",
5+
"version": "9.1.0",
66
"authors" : [
77
{
88
"name": "Moo Man",
@@ -63,15 +63,15 @@
6363
"requires": [{
6464
"id": "warhammer-lib",
6565
"type": "module",
66-
"manifest": "https://raw.githubusercontent.com/moo-man/WarhammerLibrary-FVTT/2.0.4/module.json",
66+
"manifest": "https://raw.githubusercontent.com/moo-man/WarhammerLibrary-FVTT/2.0.5/module.json",
6767
"compatibility": {
68-
"minimum" : "2.0.4",
69-
"verified": "2.0.4"
68+
"minimum" : "2.0.5",
69+
"verified": "2.0.5"
7070
}
7171
}]
7272
},
7373
"socket": true,
7474
"manifest" : "https://github.com/moo-man/WFRP4e-FoundryVTT/releases/latest/download/system.json",
75-
"download" : "https://github.com/moo-man/WFRP4e-FoundryVTT/releases/download/9.0.6/wfrp4e.zip",
75+
"download" : "https://github.com/moo-man/WFRP4e-FoundryVTT/releases/download/9.1.0/wfrp4e.zip",
7676
"url" : "https://github.com/moo-man/WFRP4e-FoundryVTT"
7777
}

0 commit comments

Comments
 (0)