PDA

View Full Version : Trying to store alternate token image for NPC and swap out dynamically



alloowishus
June 23rd, 2023, 23:05
What I would like to do is the following:

1. Store two relative image paths somewhere in the "notes" section for an NPC (or wherever appropriate), one for melee and one for missile. This should probably be xml or json as in <images><image type="melee">/path/figher_sword.png</image><image type="missile">/path/fighter_bow.png</image></images>
2. When the weapon attack roll is clicked, the token image of the NPC should be automatically set depending on whether the weapon is a melee or missile weapon.

Getting the weapon type is pretty straight forward, just wondering how to set the image of the actor? Thanks!

Moon Wizard
June 24th, 2023, 00:22
The overall system isn't really set up for that, so you're basically writing a feature from scratch.

Each creature is assumed to have one token in the combat tracker, which is used to place them on the map. This is stored as a single "token" field in the database.

If you are talking about swapping the token out; you would need to update the "token" field in the database for the creature record, and if it is in the combat tracker, you would need to replace the token with a new one. (Use APIs to save token position, delete old token, create new token at old position) This would also clear any FoW history, since that is tied to a token instance.

Regards,
JPG

YAKO SOMEDAKY
June 24th, 2023, 00:22
It would be awesome, especially if this was set through CoreRPG

alloowishus
June 24th, 2023, 01:32
The overall system isn't really set up for that, so you're basically writing a feature from scratch.

Each creature is assumed to have one token in the combat tracker, which is used to place them on the map. This is stored as a single "token" field in the database.

If you are talking about swapping the token out; you would need to update the "token" field in the database for the creature record, and if it is in the combat tracker, you would need to replace the token with a new one. (Use APIs to save token position, delete old token, create new token at old position) This would also clear any FoW history, since that is tied to a token instance.

Regards,
JPG

Ok, I thought I could just swap it in the CT, delete the token on the map then drag back in again. I guess it would clear anyone who had the NPC targetted but I don't see any other drawbacks. That's still better than searching around for assets. Is that possible?

Moon Wizard
June 24th, 2023, 01:51
It's not something that is built-in. It would require an extension to create fields to store the extra tokens, and allow them to be swapped in.

Regards,
JPG

LordEntrails
July 3rd, 2023, 21:30
I think some of the wildshape/polymorph extensions are capable of swapping out tokens. But not sure as I don't use them.