PDA

View Full Version : Access to NPC and PC values for modules/extensions development



snupy
December 16th, 2023, 14:26
I am wondering how accessible are all the values in a PC and NPC sheet for retrieval and use in the development of extensions/modules, and, since I fear the current situation is not the best possible, what could be done to improve on it. At this point this is mostly out of curiosity, while I have some programming experience I don't have any specific one about FG or immediate plans to work on it.

Let me mention two examples (I am thinking of PFRPG but it probably applies more generally)

- speed. It would be nice if FG could read the creature speed and give a visual indication if you are exceeding the allowed movement (not preventing anything, just give the info). For example, when on a gridded map and while dragging or when movement is locked one could see different colour codings for the allowed movements, e.g. for a 30ft speed green up to 30 (only using move action) yellow 30-60 (move+standard) red beyond 60. I know Foundry can do that and what I described is the behaviour of a popular extension. It would be helpful especially as a GM since I can't remember the speed of any random npc/monster.

- applying templates. I bought the advanced bestiary to see how this plays out, and while the extension has its pros it still feels half-baked in what it accomplishes. E.g. changes to strength don't change attacks or damage. Even fully automatising the simple advanced template of bestiary 1 is not possible. I am not complaining about the purchase per se since this is explicitly said somewhere in the product video. Although, as with many things FG, it would be nice to have a place where everything which is and isn't done by something is clearly written down rather than having to hunt for info here and there and having to test most stuff.

Anyway, the advanced bestiary limitations probably (?) come from difficulties in accessing the data. I imagine that e.g. if you could easily access attack data as a pair (dice, attack_bonus) it would not be too hard to code something which make a change of strength affect it. For example code along the lines of attack_bonus = attack_bonus + floor(strength_change/2) (yes this is not correct because one should check if the unmodified strength value is even or odd, I am not trying to code it for real).

Btw I know there would be fringe cases where a strength increase should not affect the damage, e.g. finesse weapons. Of course one cannot code for every possibility, but I feel that the most common case (increase in strength gives increase damage on melee attacks) should be covered automatically, while for fringe instances you can always do manual edits.

Trenloe
December 16th, 2023, 17:25
I am wondering how accessible are all the values in a PC and NPC sheet for retrieval and use in the development of extensions/modules...
Yes, absolutely. FG code can access NPC/PC data values through the database or the GUI.

I suggest you read up on FG development in the Wiki, starting with this section here: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644401/Developer+Guide+-+Rulesets

snupy
December 16th, 2023, 20:01
Thanks Trenloe, I will read that.

Just to get an idea, how hard do you think the things I mentioned (color coding speed and automatising the advanced template)? I imagine you are very experienced with FG, would it be a matter of days/weeks/months for you? (I am not asking you to do it, just trying to get an idea)

Trenloe
December 16th, 2023, 21:57
1) Colour coding may not be possible via an extension as I believe there aren't API commands available for that.

2) The advanced template, whereas on the surface may appear relatively straightforward, is actually quite involved as it touches so many areas of an NPC statblock. IT was discussed in this thread: https://www.fantasygrounds.com/forums/showthread.php?22918-Advanced-Bestiary-Update and see my comment in post #7 and the comment from the Advanced Bestiary extension dev in post #6.