etriebe / dnd-randomizer Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
should be await window.Gametime.clearTimeout(rmEncounter.timeout_id)
instead of GameTime
... this was causing a lot of errors.
Start with https://2e.aonprd.com/Rules.aspx?ID=988 to get the base gold value.
Look for some random items. If the item is consumable, make sure its level isn't over the party's level. Otherwise, grab some stuff, spending that gold you have, yay loot! The loot would be what's left plus the random loot. Bonus if you can mark that loot as unidentified.
Thanks for the work, super appreciated!
I know this is a minor thing, but would it be possible to move the cache folder and files to within the module folder itself, rather than the root data folder? I'm not sure if there's a technical reason for it's location, but it would just be cleaner and more inline with most mods if you could. Again, I know it's a small thing but if possible, when you have time, it would be appreciated.
Foundry 10.291
PF2e 4.12.9
module 1.0.32
I have confirmed that there are actors available.
Generating with treasure but no enemies. All entries show "Needs -15 XP adjustment"
Sometimes generation instead hangs with the below error immediately showing up in the Console:
dialog.js:239
Uncaught (in promise) TypeError: undefined. npcActorObject.analyzeActor is not a function
[Detected 1 package: dnd-randomizer]
at SFDialog.populateEncounters (dialog.js:239:26)
at async HTMLButtonElement. (dialog.js:331:4)
populateEncounters @ dialog.js:239
await in populateEncounters (async)
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
This module would be very valuable if it were to integrate with a random dungeon generators. At the click of a button, not only a dungeon but its encounters and monster positioning would be taken care of, making mapmaking that much faster.
I can't seem to generate any bbeg + combo. It can't find anything that fits it seems. Is this just that the srd doesn't have enough options?
I have disabled all other modules: True
Module(s) Stochastic, Fantastic! 1.0.53
Conflicting Module(s)
Foundry and System version Fvtt V11 build 315
OS, Hosting, Browser (if applicable) Windows 11 hosting
commons.js:1256
Error: You are accessing the Actor5e#data object which is no longer used. Since V10 the Document class and its contained DataModel are merged into a combined data structure. You should now reference keys which were previously contained within the data object directly.
at logCompatibilityWarning (commons.js:1245:19)
at Actor5e._logV10CompatibilityWarning (commons.js:6166:14)
at get data [as data] (commons.js:6066:24)
at dialog.js:56:66
at Array.filter (<anonymous>)
at SFDialog.getDefaultsFromScene (dialog.js:56:47)
at SFDialog.activateListeners (dialog.js:240:25)
at SFDialog._render (foundry.js:5044:10)
at async SFDialog._render (foundry.js:5739:5)
PF2, when clicking to generate encounters, it takes quite a bit of time, like 10sh minutes. Any way to speed this up? Love the module, just to be clear. Super fantastic, but if we could fix that...
See issue described here and following 3 messages:
https://discord.com/channels/170995199584108546/956307084931112960/1049215542101299230
When dropping a spawn circle, the creatures always appear, but the treasure, not always. Placing a circle multiple times can coax the treasure to appear. (PF2)
You put down a circle for things to appear in, things appear properly, yay, but the circle remains.
Here is my dilemma, My player can be anywhere at any time and be attacked at any time. I want to quickly generate an encounter based on the environment and type of encounter when it happens. Example: "They are in the forest and suddenly attacked by a hard beast encounter." I love that your tool gives calculated options based on the players and the draw feature is brilliant, just the filtering options are slow.
In general, opening each filter and scrolling takes way too long. I can wait 5-10 seconds to generate but it takes me 5x as long to adjust the filters. If possible, please add a way to speed up the filter process or allow us to save filters. Especially since it appears to reset most of the filter each time it is opened.
Ideas on how to help:
These are just ideas...hopefully i explained the frustration I am hoping you can improve.
As mentioned, I really like this tool. My 20+ roll tables are getting hard to maintain and this gives some good variety. Just need a better way to speed up the filtering process.
Foundry version: 10
Foundry Build: 303
PF2e System version: 4.12.9
Description:
As stated in the title, if you open the creature codex with a fresh install (not disabling or altering filters) you will receive no actors in the list. If you open the inspection menu, you will notice multiple errors stating that the compendiums could not be indexed. This results in the generator being unable to create encounters with valid actors and the codex being left empty. This was reproducible in a fresh world without any other modules. Images below showing the errors:
First of all, I really like your module. The combat estimate makes it so much easier to not kill or bore the players to death.
But it would be really nice if the monster stats of the current creature would be used instead of its actor.
I prepared a session where the group need to face two golems. One was at full health with all the abilities. The second one had only half of its normal max HP and its attacks were weaker (1d8 instead of 3d8). To make the Combat Estimate work I had to make two actors - a normal golem and a weak golem - instead of one actor with two tokens.
I mean, it is not a big of a deal but got me confused then first time and one will end up with multiple slightly different actors.
I would love to see that improved ❤
Edit: nevermind, i refreshed my server and now im seeing stuff, so its possible that it just needed a ton of time to index my compendiums? which was not indicated in the information here on github or by any sort of pop up. Checking it now.
And now it works.
localmodule.js:275 ReferenceError: SFLOCALCONSTS is not defined
at ActorUtils.getActorEnvironments (ActorUtils.js:99:39)
at new NPCActor5e (NPCActor5e.js:15:39)
at ActorUtils.getActorObject (ActorUtils.js:50:16)
at SFLocalHelpers.populateMonstersFromCompendiums (localmodule.js:256:42)
at async Promise.all (index 1)
at async SFLocalHelpers.populateObjectsFromCompendiums (localmodule.js:63:9)
at async HTMLButtonElement.<anonymous> (compendium.js:85:23)
populateMonstersFromCompendiums @ localmodule.js:275
await in populateMonstersFromCompendiums (async)
populateObjectsFromCompendiums @ localmodule.js:62
(anonymous) @ compendium.js:85
await in (anonymous) (async)
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
localmodule.js:276 Actor id shhHtE7b92PefCWB, name Aboleth failed to get added.
populateMonstersFromCompendiums @ localmodule.js:276
await in populateMonstersFromCompendiums (async)
populateObjectsFromCompendiums @ localmodule.js:62
(anonymous) @ compendium.js:85
await in (anonymous) (async)
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
(Repeated for every actor in the selected compendiums)
PS: (Experienced in version 1.0.13) Treasure hoards magic items are listed as "undefined" entries below encounter monsters, but when the selected encounter is spawned or generated as loot-only, the relative "loot actor" has all the correct defined magic item in it, clickable and draggable.
PPS: (Experienced in version 1.0.13) When selecting the Random encounter type option and generating encounters, the listed actors are clickable but no actor window pops up, while the correct actor window pops up if any other encounter type option is selected.
Let me know if I have to open other issue posts and thanks for your work, this module is quite useful!
`Error: You are accessing the Actor5e#data object which is no longer used. Since V10 the Document class and its contained DataModel are merged into a combined data structure. You should now reference keys which were previously contained within the data object directly.
at logCompatibilityWarning (commons.js:1245:19)
at Actor5e._logV10CompatibilityWarning (commons.js:6166:14)
at get data [as data] (commons.js:6066:24)
at hasProperty (commons.js:1685:41)
at Object.replaceActorArtwork [as fn] (caeora.mjs:55:53)
at #call (foundry.js:688:20)
at Hooks.call (foundry.js:670:38)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:12424:47)
at async ClientDatabaseBackend._createDocuments (foundry.js:12337:22)
at async Actor5e.createDocuments (commons.js:5631:23)
at async Actor5e.create (commons.js:5754:23)
at async EncCreature.getActor (encounter.js:253:7)
at async Encounter.loadActors (encounter.js:152:7)
at async Encounter.spawn (encounter.js:157:5)
logCompatibilityWarning @ commons.js:1256
_logV10CompatibilityWarning @ commons.js:6166
get data @ commons.js:6066
hasProperty @ commons.js:1685
replaceActorArtwork @ caeora.mjs:55
#call @ foundry.js:688
call @ foundry.js:670
_preCreateDocumentArray @ foundry.js:12424
await in _preCreateDocumentArray (async)
_createDocuments @ foundry.js:12337
create @ commons.js:6262
await in create (async)
createDocuments @ commons.js:5631
create @ commons.js:5754
importFromCompendium @ foundry.js:14120
await in importFromCompendium (async)
getActor @ encounter.js:253
loadActors @ encounter.js:152
spawn @ encounter.js:157
(anonymous) @ dialog.js:210
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
commons.js:1256
Error: You are accessing Actor5e#data which has been migrated to Actor5e#system
Deprecated since Version 10
Backwards-compatible support will be removed in Version 12
at logCompatibilityWarning (commons.js:1245:19)
at Actor5e._logDataFieldMigration (commons.js:6155:14)
at Object.get (commons.js:6119:18)
at hasProperty (commons.js:1685:41)
at Object.replaceActorArtwork [as fn] (caeora.mjs:55:53)
at #call (foundry.js:688:20)
at Hooks.call (foundry.js:670:38)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:12424:47)
at async ClientDatabaseBackend._createDocuments (foundry.js:12337:22)
at async Actor5e.createDocuments (commons.js:5631:23)
at async Actor5e.create (commons.js:5754:23)
at async EncCreature.getActor (encounter.js:253:7)
at async Encounter.loadActors (encounter.js:152:7)
at async Encounter.spawn (encounter.js:157:5)
logCompatibilityWarning @ commons.js:1256
_logDataFieldMigration @ commons.js:6155
get @ commons.js:6119
hasProperty @ commons.js:1685
replaceActorArtwork @ caeora.mjs:55
#call @ foundry.js:688
call @ foundry.js:670
_preCreateDocumentArray @ foundry.js:12424
await in _preCreateDocumentArray (async)
_createDocuments @ foundry.js:12337
create @ commons.js:6262
await in create (async)
createDocuments @ commons.js:5631
create @ commons.js:5754
importFromCompendium @ foundry.js:14120
await in importFromCompendium (async)
getActor @ encounter.js:253
loadActors @ encounter.js:152
spawn @ encounter.js:157
(anonymous) @ dialog.js:210
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
caeora.mjs:57 Star-SpawnofCthulhu
commons.js:1256
Error: You are accessing the Actor5e#data object which is no longer used. Since V10 the Document class and its contained DataModel are merged into a combined data structure. You should now reference keys which were previously contained within the data object directly.
at logCompatibilityWarning (commons.js:1245:19)
at Actor5e._logV10CompatibilityWarning (commons.js:6166:14)
at get data [as data] (commons.js:6066:24)
at getProperty (commons.js:1707:41)
at Object.replaceActorArtwork [as fn] (caeora.mjs:58:23)
at #call (foundry.js:688:20)
at Hooks.call (foundry.js:670:38)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:12424:47)
at async ClientDatabaseBackend._createDocuments (foundry.js:12337:22)
at async Actor5e.createDocuments (commons.js:5631:23)
at async Actor5e.create (commons.js:5754:23)
at async EncCreature.getActor (encounter.js:253:7)
at async Encounter.loadActors (encounter.js:152:7)
at async Encounter.spawn (encounter.js:157:5)
logCompatibilityWarning @ commons.js:1256
_logV10CompatibilityWarning @ commons.js:6166
get data @ commons.js:6066
getProperty @ commons.js:1707
replaceActorArtwork @ caeora.mjs:58
#call @ foundry.js:688
call @ foundry.js:670
_preCreateDocumentArray @ foundry.js:12424
await in _preCreateDocumentArray (async)
_createDocuments @ foundry.js:12337
create @ commons.js:6262
await in create (async)
createDocuments @ commons.js:5631
create @ commons.js:5754
importFromCompendium @ foundry.js:14120
await in importFromCompendium (async)
getActor @ encounter.js:253
loadActors @ encounter.js:152
spawn @ encounter.js:157
(anonymous) @ dialog.js:210
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
commons.js:1256
Error: You are accessing Actor5e#data which has been migrated to Actor5e#system
Deprecated since Version 10
Backwards-compatible support will be removed in Version 12
at logCompatibilityWarning (commons.js:1245:19)
at Actor5e._logDataFieldMigration (commons.js:6155:14)
at Object.get (commons.js:6119:18)
at getProperty (commons.js:1707:41)
at Object.replaceActorArtwork [as fn] (caeora.mjs:58:23)
at #call (foundry.js:688:20)
at Hooks.call (foundry.js:670:38)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:12424:47)
at async ClientDatabaseBackend._createDocuments (foundry.js:12337:22)
at async Actor5e.createDocuments (commons.js:5631:23)
at async Actor5e.create (commons.js:5754:23)
at async EncCreature.getActor (encounter.js:253:7)
at async Encounter.loadActors (encounter.js:152:7)
at async Encounter.spawn (encounter.js:157:5)`
The encounter generator successfully creates a list of encounters. However, when clicking Spawn Encounter, and then placing a template, the tokens are not placed on the map and the console generates errors:
ALL OTHER MODULES DISABLED? True
Module: dnd-randomizer v1.0.15
Conflicting Module (if applicable): None
Foundry and System version: Foundry Version 10 build 290. + DnD5e Fifth Edition 2.0.3
OS, Hosting, Browser (if applicable):
Short Description of bug: The encounter generator successfully creates a list of encounters. However, when clicking Spawn Encounter, and then placing a template, the tokens are not placed on the map and the console generates errors:
Simple steps to reproduce the bug:
Please place a Circle Template to Spawn the Encounter
foundry.js:29773 Uncaught (in promise) Error: A valid wall restriction type is required for testCollision.
[Detected 1 package: dnd-randomizer]
at Function.testCollision (foundry.js:29773)
at WallsLayer.checkCollision (foundry.js:37420)
at Function.randomInCircle (spawner.js:80)
at Function.fromTemplate (spawner.js:16)
Clicking the button results in an error in the console with the following message
A subclass of the FormApplication must implement the _updateObject method.
This seems to be caused by the removal of the listener on the button in this diff. It looks like it may have mistakenly been added to the environment chooser, or the reindex button itself hasn't been moved to that dialog yet.
NPCActor5e.js:183
Error parsing attack information for Adult Flame Dragon, nYKQsyDBWMplMPEu. Error: TypeError: Cannot read properties of undefined (reading 'mod')
getCombatDataPerRound @ NPCActor5e.js:183
NPCActor5e @ NPCActor5e.js:16
getActorObject @ ActorUtils.js:50
populateMonstersFromCompendiums @ localmodule.js:239
await in populateMonstersFromCompendiums (async)
populateObjectsFromCompendiums @ localmodule.js:58
(anonymous) @ compendium.js:85
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2
NPCActor5e.js:184
TypeError: Cannot read properties of undefined (reading 'mod')
at eval (eval at getInfoForAttackObject (NPCActor5e.js:405:31), <anonymous>:1:33)
at NPCActor5e.getInfoForAttackObject (NPCActor5e.js:405:31)
at NPCActor5e.getCombatDataPerRound (NPCActor5e.js:96:52)
at new NPCActor5e (NPCActor5e.js:16:32)
at ActorUtils.getActorObject (ActorUtils.js:50:16)
at SFLocalHelpers.populateMonstersFromCompendiums (localmodule.js:239:42)
at async Promise.all (index 1)
at async SFLocalHelpers.populateObjectsFromCompendiums (localmodule.js:59:9)
at async HTMLButtonElement.<anonymous> (compendium.js:85:23)
And rolling using BRT+ instead of a regular roll? Would allow more randomness in the encounters.
Hi there! I'm having a bit of trouble with the 'Stochastic, Fantastic!' module. Whenever I try to load an encounter using a custom compendium, it only returns blank encounters. I figured it might be because the compendium I was using was pretty small and not complete, so I went ahead and imported the names and CRs of everything I would be using and remade the compendium, but that still didn't help. I then made a new compendium of a bunch of random monsters, and I'm still having the same issue. I've tried disabling all other modules, uninstalling and reinstalling, and checked the console, but I've never found anything obviously wrong. Thank you in advance!
Follows up on #43
Hey there @etriebe ! 👋
Thanks so much for all the improvements you brought in with #44
The ensureFolder
call now recognizes when a folder exists in the Forge Assets Library and no longer tries to create new directories every time 🥳
Unfortunately, there's one other issue that I ran into and that is that SFLocalHelpers.loadFile()
doesn't handle absolute paths very well due to code that replaces the cacheFolder (a relative folder) in the path.
const cacheFolder = SFLocalHelpers.getSystemCacheFolder();
await this.ensureFolder(cacheFolder);
if (hasCacheFolderInPath)
{
fileName = fileName.replace(cacheFolder, "").replace("/","");
}
This works well when the path is relative, but when the path returned by FilePicker.browse()
is an absolute URL (starting with https://
and hosted on a server somewhere, the cacheFolder
might be in the middle of the absolute URL, so when the fullFilePath
is reconstructed by inserting the cacheFolder
at the start of the fileName
in
let fullFilePath = this.getCachePath(fileName);
you might end up with something like cacheFolder/https://path.to.json
I think that a good way around this could be to check if the URL is absolute first and if it is, then try to load it directly.
The browser will cache the fetched file, meaning that performance won't be impacted by subsequent fetches.
And if there is a failure, we can catch it and resort to the relative path check with the module's built-in caching as a fallback.
We're close!
The Forge uses distributed storage, meaning that any call to browse() introduces some latency.
The ensureFolder
and fileExists
methods in localmodule
could possibly be improved in two ways:
The searched folder and file name paths could be cached, so that the same run won't make a browse call to the same target multiple times.
The source can be configured. For example, instead of calling against "data"
, you can call directly against "forgevtt"
if you are running on The Forge. This means that there does not need to be a redirect and The Forge can look the folder up in its Assets Library directly.
let source = (typeof ForgeVTT != "undefined" && ForgeVTT.usingTheForge) ? "forgevtt" : "data";
There is one more thing: in fileExists
, there is a check for the file existing by comparing the full file path to the response returned from the browse. This will not work on The Forge, since a relative path is searched for but a full URL to the Assets Library is returned.
If the source
is "forgevtt"
, it could help to use f.endsWith(fullFilePath);
instead of if (cacheDir.files.filter(f => f === fullFilePath).length > 0)
to check for the file existing.
Thanks for reading this issue, I understand that it may not be a high priority but these improvements would greatly increase performance for users on The Forge using this great module. Currently, they're not able to benefit from the caching features and have to reconstruct the index from compendiums every time, which can take a while with network calls.
Work with PF2E to save filter settings too.
This is what the console says:
vTools failed to load source map: Could not load content for https://localhost/modules/dnd-randomizer/scripts/lib/gridjs.umd.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
hello
I am Trying to create an encounter in "Stochastic fantastic encounter generator" and I am trying to create lieutenants and lackeys (moderate) encounter i have 5 lvl2 players in group and the generator only generates single 1st lvl lieutenant encounters
I'll appreciate any help.
Thank you
https://media.discordapp.net/attachments/722566083499786352/1126816605234528319/image.png?width=615&height=700
https://discord.com/channels/170995199584108546/722566083499786352/1126816605461033030
populateMonstersFromCompendiums @ localmodule.js:276
localmodule.js:275 TypeError: Cannot read properties of undefined (reading 'creatureType')
at eval (eval at getSystemVariableForObject (FoundryUtils.js:43:14), :1:16)
at FoundryUtils.getSystemVariableForObject (FoundryUtils.js:43:14)
at ActorUtils.getCreatureTypeForActor (ActorUtils.js:12:44)
at new NPCActorPf2e (NPCActorPf2e.js:8:38)
at ActorUtils.getActorObject (ActorUtils.js:55:16)
at SFLocalHelpers.populateMonstersFromCompendiums (localmodule.js:256:42)
at async Promise.all (index 1)
at async SFLocalHelpers.populateObjectsFromCompendiums (localmodule.js:63:9)
at async HTMLButtonElement. (dialog.js:300:5)
populateMonstersFromCompendiums @ localmodule.js:275
localmodule.js:276 Actor id DM5js1XSiuiPAf3t, name White Dracolisk failed to get added.
--
It is showing this, for a lot of things, in the console as I'm trying to get an encounter.
When generating the encounter and placing it in the scene, at the moment only a circle can be used.
It would be good to have other options when it comes to shapes.
This tool is very interesting when playing RPGs solo, and combines well with random dungeon generators, which often have rectangular shapes.
Icons were moved to core (note sure when, I just recently updated to v11 from v9) and the paths have changed for those
dnd-randomizer/scripts/main.js
Line 33 in 8c6be46
they are now in
icons/containers/bags
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.