From 728c5f2f8e20742c9f7b23a587f38ff9797b4d0e Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 4 Nov 2023 17:48:59 +0100 Subject: [PATCH] Sur creation de personnage, force le lien du token --- module/actor/base-actor.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index 26da375e..f8521926 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -51,7 +51,7 @@ export class RdDBaseActor extends Actor { static onRemoteActorCall(callData, userId) { if (userId == game.user.id) { let actor = game.actors.get(callData?.actorId); - if ( callData.tokenId) { + if (callData.tokenId) { let token = canvas.tokens.placeables.find(t => t.id == callData.tokenId) if (token) { actor = token.actor @@ -111,6 +111,19 @@ export class RdDBaseActor extends Actor { super(docData, context); } + /* -------------------------------------------- */ + async _preCreate(data, options, user) { + await super._preCreate(data, options, user); + + // Configure prototype token settings + const prototypeToken = {}; + if (this.type === "personnage") Object.assign(prototypeToken, { + sight: { enabled: true }, actorLink: true, disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY + }); + this.updateSource({ prototypeToken }); + } + + /* -------------------------------------------- */ isCreatureEntite() { return this.type == 'creature' || this.type == 'entite'; } isCreature() { return this.type == 'creature'; } isEntite() { return this.type == 'entite'; }