mr-ice / maptool-macros

place for maptool macros
2 stars 3 forks source link

can we auto-pop a monster from https://api.open5e.com/ #95

Closed mr-ice closed 4 years ago

mr-ice commented 4 years ago

https://api.open5e.com/ has a lot of monsters at https://api.open5e.com/monsters/, for example https://api.open5e.com/monsters/imp

Found via https://tetra-cube.com/dnd/dnd-statblock.html

trey-kirk-sp commented 4 years ago

Yes, but some things aren't straight forward:

 {
                    "attack_bonus": 9,
                    "damage_dice": "3d8+6",
                    "desc": "Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 19 (3d8 + 6) piercing damage.",
                    "name": "Gore"
                }

Doesn't conveniently separate damage type. But if it's consistent, regex could tease it out.

 "strength_save": null,
            "dexterity_save": null,
            "constitution_save": null,
            "intelligence_save": null,
            "wisdom_save": null,
            "charisma_save": null,

Saves are disappointing, but abilities can derive the base, which I assume is the intent. Look for examples where these are non-null and see if they're literal values or bonuses.

Should be in a new library (Lib:open5e?). If we build it in the same format as BasicToon, Reset Properties is a shoe-in to transfer token properties.

trey-kirk-sp commented 4 years ago

Also, DMs should chime in with what they might want to see on an NPC stat sheet. We can create a different Token type for these and show a different view of properties

trey-kirk-sp commented 4 years ago

Need a break from Lib:DnDBeyond. Let's see if I can screw this up...

mr-ice commented 4 years ago

Saves are disappointing, but abilities can derive the base, which I assume is the intent.

I think so. this is really only showing saves for which the monster has specials. See https://api.open5e.com/monsters/frost-giant/

havoclad commented 4 years ago

Perhaps you already know this, but saves a monster is proficient in receive half their CR as a bonus (rounded down).

mr-ice commented 4 years ago

interesting, but I'm not seeing that on my frost giant example, nor this: https://www.dndbeyond.com/monsters/frost-giant

havoclad commented 4 years ago

Huh, guess I had that slightly wrong. Their proficiency bonus is determined by their CR, there's a table in the front of the monster manual. CR5-CR8 is a +3

trey-kirk-sp commented 4 years ago

W/ Frosty as the use case, looks like calculation is not my problem. His API reports exactly what the value should be:

"constitution_save": 8,
    "intelligence_save": null,
    "wisdom_save": 3,
    "charisma_save": 4,
mr-ice commented 4 years ago

Their proficiency bonus is determined by their CR

Correct: "A saving throw bonus is the sum of a monster’s relevant ability modifier and its proficiency bonus, which is determined by the monster’s challenge rating (as shown in the Proficiency Bonus by Challenge Rating table)." https://dnd.wizards.com/products/tabletop/dm-basic-rules

the table referenced is just below that.

mr-ice commented 4 years ago

looks like calculation is not my problem

Also correct. The proficient saves are calculated for you, the non-proficient saves are straight ability modifier.

havoclad commented 4 years ago

My two cents, (worth diddly as a guy not coding much in this) I'd rather this stuff had the brains, so when I go diddling with things, the numbers stay right. IE, if I bump the wisdom, the save should go up. If I alter the CR, changes flow thru, etc.

trey-kirk-sp commented 4 years ago

Goddammit, Pat

trey-kirk-sp commented 4 years ago

Search: https://api.open5e.com/monsters/?search=Gold%20Dragon https://api.open5e.com/monsters/?search=gold+dragon

Specific Monster: https://api.open5e.com/monsters/adult-gold-dragon/

Filter widget provides many other examples of searchables and ordering. Don't anticipate the macro should be so advanced. Thinking the nominal use case is a creature is already in mind and the user need only populate the token of that creature. So basic by-name search will do.

To accommodate "live" changes when abilities are adjusted, saves need to be derived. Something like:

Charisma Bonus: 4 Charisma Save: {CharismaBonus + ProfBonus}

But to accomplish this, we have to first:

Actions (attacks) aren't so easy to associate to ability properties. Ideally we'd leverage already written macros, however they rely on an JSON expression with pre-built values. Perhaps this might be an opportunity to bring them closer to the state of the token.

trey-kirk-sp commented 4 years ago

User experience should be:

trey-kirk-sp commented 4 years ago

There's some good stuff in the damage description that'd be really nice to pull out. Some examples

Melee Weapon Attack: +12 to hit, reach 5 ft., one target. Hit: 14 (2d6 + 7) slashing damage.
Melee Weapon Attack: +11 to hit, reach 15 ft., one target. Hit: 15 (2d12 + 6) bludgeoning damage.
Melee Weapon Attack: +17 to hit, reach 5 ft., one target. Hit: 38 (12d6 + 10) piercing damage plus 7 (2d6) fire damage, and the target must make a successful DC 22 Constitution saving throw or have its Strength score reduced by 1d4. A creature reduced to 0 Strength dies.
Melee Weapon Attack: +13 to hit, reach 15 ft., one target. Hit: 18 (3d6 + 8) plus 3 (1d6) poison damage.
Ranged Weapon Attack: +9 to hit, range 150/600 ft., one target. Hit: 9 (1d8 + 5) piercing damage plus 12 (3d6) fire damage.
Ranged Weapon Attack: +9 to hit, range 150/600 ft., one target. Hit: 9 (1d8 + 5) piercing damage.
Ranged Weapon Attack: +6 to hit, range 150/600 ft., one target. Hit: 8 (1d8 + 4) piercing damage

This isn't an exhaustive list of all types of actions, but for the bread 'n butter attacks, there's an apparent pattern. I can regex this... probably.

Example (vim) regex:

\(Melee\|Ranged\) Weapon Attack: \(+\d\+\) to hit, \(range\|reach\) \(\d\+\/\?\d*\) ft., .* target\. Hit: \(\d\+\) \((\d\+d\d\+\s*+\s*\d*)\) \(.*\)

\1 Melee|Ranged \2 to hit bonus \3 range|reach \4 reach distance | range/long range \5 damage avg \6 damage roll (1d8 + 5) (not including the parens) \7 trailing data to parse more delicately

For one facet of the trailing group

plus \(\d\+\) (\d\+d\d\+) \(\S\+\) damage
trey-kirk-sp commented 4 years ago

In order to associate attacks to abilities such that a property change can adjust the next roll, the attack information has to be stored as just a data map that is is stripped of ability bonuses. At attack time, roll expression has to be built on the fly.

Pushing the edit feature; I have a better idea.

trey-kirk-sp commented 4 years ago

TODO: against my better judgement, I'm getting good at regex in MT. So it shouldn't be too hard to:

trey-kirk-sp commented 4 years ago

Coming together, but a few gaps:

Push:

trey-kirk-sp commented 4 years ago

DMs are gonna want DC values restricted from the output. Create a preference that drives RollExpression_getSaveDC.

trey-kirk-sp commented 4 years ago

Bugs:

trey-kirk-sp commented 4 years ago

A few more monsters to test with before claiming victory:

https://open5e.com/monsters/aboleth-nihilith https://open5e.com/monsters/ankou-soul-herald https://open5e.com/monsters/androsphinx https://open5e.com/monsters/adult-void-dragon https://open5e.com/monsters/adult-sea-dragon https://open5e.com/monsters/adult-rime-worm

trey-kirk-sp commented 4 years ago

image