23 lines
982 B
JavaScript
23 lines
982 B
JavaScript
export default class KHHooks {
|
|
static async onCreateActor(actor, options, userId) {
|
|
if (actor.data.type == "character") {
|
|
const actorbaseSkills = actor.data.data.baseSkills;
|
|
|
|
// Check if skill already exists by some chance
|
|
const existingSkills = actor.items.filter((i) => i.type === ItemType.Skill).map((i) => i.name);
|
|
const skillsToAdd = actorbaseSkills.filter((s) => !existingSkills.includes(s));
|
|
|
|
// Load Skills Compendium skills
|
|
const skillIndex = await game.packs.get("kopparhavet.skills").getContent();
|
|
|
|
// Filter skillIndex array to include only skills for Actor Type.
|
|
let _skillsList = skillIndex.filter((i) => skillsToAdd.includes(i.data.name));
|
|
|
|
await actor.createEmbeddedEntity("OwnedItem", _skillsList);
|
|
} else {
|
|
setTimeout(async function () {
|
|
await actor.sheet.render(true);
|
|
}, 500);
|
|
}
|
|
}
|
|
} |