PDA

View Full Version : Easy Do It Yourself – All free 5E Monsters for PAR5E (from WoTC website)



valeros
May 15th, 2016, 06:51
To get all monsters from the free DM's Rules posted on the Wizards of the Coast website, you can use the powershell commands below to get an "npcs.txt" file for PAR5E for creating a module. (That will also give you a bunch of examples that work for creating your own monsters.)

Note: since this will access the WoTC website, when running this you may get one or two popups asking about cookies. You can select yes or no.

1) Open a command prompt (In Windows 10, right click the start button and select "Command Prompt")
2) In the command prompt, type or copy/paste the following:


powershell
$HTML = Invoke-WebRequest -Uri "https://dnd.wizards.com/products/tabletop/dm-basic-rules"
$monsters = ($HTML.ParsedHtml.body.getElementsByTagName('dl') | Where {$_.getAttributeNode('class').Value -eq 'monster-list'}).innerHTML
$monsters = $monsters -replace "(</TH>|</TD>|</THEAD>)`r`n", " " # For abilities (STR, DEX, etc.)
$monsters = $monsters -replace "<H5>Actions</H5>", "ACTIONS"
$monsters = $monsters -replace "<H5>Reactions</H5>", "REACTIONS"
$monsters = $monsters -replace "<H5>Legendary Actions</H5>", "LEGENDARY ACTIONS"
$monsters = $monsters -replace "<H5>|<H6>", "<h>" # For headers in lore
$monsters = $monsters -replace "</H5>|</H6>", "</h>" # For headers in lore
$monsters = $monsters -replace "<BR>", " "
$monsters = $monsters -replace "<LI>(Cantrip.|1st|2nd|3rd|.th)", '\r$1' # For spell lists
$monsters = $monsters -replace "<LI>", "" # In lore or actions (e.g., spectator & adult red dragon)
$monsters = $monsters -replace "<P class=lore>", "##;`r`n"
$monsters = $monsters -replace "</*(UL|LI|DD|OL|HR|THEAD|TR|TBODY|P|STRONG|EM|TH|TD| DIV|DD|TABLE|(P|DT|DIV|UL)([^>]*))>", ""
$monsters = $monsters -replace "`r`n(`r`n)+", "`r`n" # remove blank lines
$monsters = $monsters -replace " CHA `r`n", " CHA " # remove line between ability description & values
$monsters = $monsters -replace "<SPAN>([^>]+)</SPAN>", "`r`n`$1" # Make sure blank line before monster name
$monsters | Out-File -encoding UTF8 "npcs.txt"



You now have an "npcs.txt" file that you can copy into your PAR5E input directory.

kp9911
May 15th, 2016, 09:12
This is some cool use of power shell!

damned
May 15th, 2016, 09:30
Valeros - you are one clever fella!

LordEntrails
May 16th, 2016, 01:20
Are these monsters that are not included in the SRD or MM? Or are they duplicated if I already have those? Cuz I though FG already included everything from the basic rules... (but, I'm fairly ignorant as to the details)

damned
May 16th, 2016, 02:12
I believe it is a bit of POC for Valeros. But it also creates raw input files useful as a reference for those people who are wanting to add their own content.
These are the same as what Valeros excellent Basic Rules Parser created - just made with such a beautifully tight script.