Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Resetting NPCs To Previous Positions

I'm about to begin a game that involves running the same dungeon multiple times, with monsters in the same starting positions each time. I need a way to quickly delete the old instances of the npcs. I believe there is no way to delete objects using an API, but all I really need is to be able to select the npc tokens but nothing else on the token layer. I have several ideas on how this might be achieved, but i think the most likely solution is if there is an API available that can select all tokens linked to a specific character, then I can just press the delete key once for each NPC type in the dungeon and use True Page Copy to import the positions of the NPCs from a separate page. Does anyone have any ideas on this?
I have developed a (rather clunky) work around. I used TokenMod to send all the non-npc tokens to the gmlayer, ctrl-a to select and delete all the tokens left, TruePageCopy to pull the NPCs back in, and TokenMod again to brink the tokens back to the object layer. it works, but it's gonna get unwieldy on larger dungeons
What I do is copy the game once the maps are set up with the tokens, etc. and transmogrify the pages (maps) over to the original (after deleting the 'used' map) as needed. As a pro user, you have access to transmogrify. Very useful tool.
1544838223

Edited 1544838239
Transmogrify doesn't work in this case, but it is a good idea. I have some DynamicLightingRecorder stuff that doesn't seem to stick with the page. Additionally, the only thing i want to reset is the NPCs, since the players can effect the physical dungeon in certain ways (leaving doors open, secret passages etc).
1544847025
GiGs
Pro
Sheet Author
API Scripter
In theory you should be able to do this: Set up all your tokens on the maps With a script, loop through all the tokens that aren't owned by a PC and store their X and Y positions, and save them either to state or handout You could do this on a map by map basis, or loop through all maps. Then when needed, run a script to restore positions I havent done much with scripting token positions, but I know each step in the above process is possible via the API, so a master script to do it all should be possible.
1544847186
GiGs
Pro
Sheet Author
API Scripter
Duncan V. said: I have developed a (rather clunky) work around. I used TokenMod to send all the non-npc tokens to the gmlayer, ctrl-a to select and delete all the tokens left, TruePageCopy to pull the NPCs back in, and TokenMod again to brink the tokens back to the object layer. it works, but it's gonna get unwieldy on larger dungeons You should be able to script each step here too: each token has a "represents" value, you can loop through all the tokens, check if it's owned by a PC, and if not, delete it. That would save you the step of having to move the PCs, and just leave the TruePageCopy step (I don't know that script).
I save the positions and current layers of all tokens in one of my plugins. &nbsp;&nbsp; <a href="https://derammo.github.io/der20/#setup/positions_save" rel="nofollow">https://derammo.github.io/der20/#setup/positions_save</a> After a game session, I can just run the restore command, and all the NPC tokens jump back to their starting positions and usually the GM layer (because I like to reveal things as I got and store all of them on the GM layer.) &nbsp; If you save them on another layer, then obviously that's fine too :) I don't think finding the few PC tokens and removing them manually is that hard, considering they would be the only tokens without a saved position and layer, so you could move everything to some other layer and then reset, and all the unsaved (PC) tokens would remain on that layer. &nbsp;Then you select all and delete :)... It would be pretty easy to change the code to do some of that for you, like moving all the PCs to a designated area and to a specific layer, so you don't have to go hunting. &nbsp; The other thing I find very useful for resetting the dungeon is the '!setup tokens reset' command in the same script. &nbsp;It just removes the HP, PP, and Stealth roll from all the NPC tokens' bars, so that you can roll them again randomly next session. &nbsp;('!setup tokens stat'). Anyways, it is a trivial amount of code if you decide to go that route. &nbsp;
1545039868
Brian C.
Pro
Marketplace Creator
Compendium Curator
Would it work to transmogrify the page to an archive game and then transmogrify it back each time you need to reset it? Admittedly, that would reset everything, not just the NPCs. Alternatively, you could set up the "copy" NPCs&nbsp; on the dynamic lighting layer (assuming you are staging the "real" NPCs on the GM layer). To reset, you could delete all the&nbsp; then shift-click to select all the NPCs on the DL layer and copy-paste them back to the GM layer. Shift-clicking them again on the GM layer would allow you to use the arrow keys to move them all back into position simultaneously (just make sure the paste is in the middle of the map or the NPCs might get clumped together).
1545060032
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Great Idea Brian! I had thought about using a duplicate of the map for that purpose, but the DL layer is much simpler and more elegant.
I hope it doesn't try to traverse all those token objects every time it does DL calculations. &nbsp; Maybe someone from Roll20 can confirm whether it is ok to have 'graphic' objects on the DL layer without any performance penalty?
1545231519
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It is my understanding that graphics on the DL layer are ignored, and only lines and shapes are noticed, but I'll try to get confirmation.
1545268740

Edited 1545279055
The Aaron
Pro
API Scripter
Graphics on the DL layer are only visible to the GM when on that layer and never to players. They do not block light or movement. If they shed light, it is visible to all who can see it. (I’ve never checked to see if a player-controlled token that sheds light only visible to them only shows light to that player and the GM, but now I’m very interested in the answer...) Edit: Tokens on the DL layer that emit light only show that light if they have "all players see light" enabled.&nbsp; If it is disabled, nobody will see light from it except the GM, regardless of who controls it.
Clarification: &nbsp;I am aware they don't block light, but I am wondering if the lighting code has to traverse them anyway. &nbsp; Depending on how it is written, perhaps they get "scanned" by the lighting code, even though it just goes "nope, not one of mine" for each of them. &nbsp; It would be silly, but it would be nice to rule out, before we recommend that people put an extra few hundred tokens on that layer :). &nbsp; Probably a non-issue, but worrying about risks is sort of my thing.
1545328713

Edited 1545328765
Ammo
Pro
regarding your edit: having "all players see light" tokens in their starting positions on the DL layer is a big problem then. &nbsp; so this idea of hiding copies isn't gonna work for all cases. &nbsp;Why don't we just save the token position/state like discussed above; &nbsp;it is super easy.
I was able to use the der20 setup script to do everything that I needed. Works like a charm. Thank you all for your assistance!&nbsp;