PDA

View Full Version : Basic success counting extension



Trenloe
May 12th, 2016, 16:25
I checked in with DMFirmy (the creator of the drop lowest extension (https://www.fantasygrounds.com/forums/showthread.php?22637-DMFirmy-s-Drop-Lowest-Extension)I mentioned above) and he was very happy for me to do a quick success reporting extension based off the framework he used in his extension. Thanks very much DMFirmy! :)

Attached is a very basic success reporting extension. This should work in all rulesets based on CoreRPG and uses a basic slashhandler to roll dice and report on the number of successes.


Download the attached CountSuccesses.ext file and install in your <FG App Data>\extensions directory.
Load up a CoreRPG based campaign and select the "Count Successes" extension.
Once in your campaign you can use the success count extension through a slash command in the chat window - see usage below.


Usage

Use the /successes chat slashhandler as follows:

/successes XdY Z Where XdY is the dice string to roll, e.g. 5d10, 25d12, etc. and Z is the target success number (each dice equal to or above this number will be counted as a success).

Fantasy Grounds will count the number of successes and report these in the chat window as part of the roll result.

For example: /successes 10d10 7 will roll ten 10 sided dice and report the total number of dice that were 7 or more.

Example screenshot:
https://www.fantasygrounds.com/forums/attachment.php?attachmentid=14054

There's no further integration into any ruleset, this is just a quick extension to show what can be done - and to provide some use to people who want this basic functionality.

The /successes string can be dragged to a FG hotkey to allow quick rolling of frequently used rolls.

I'll expand on this/provide further documentation (probably in extension comments) at some point...

EDIT: Minor edit to extension to allow active identity (PC, GM ID, etc.) to be shown in the roll.

Trenloe
May 12th, 2016, 16:26
Reserved.

damned
June 13th, 2016, 08:42
Hey Trenloe when you roll usin this extension it reports the Username and not the Character name as making the roll.
I had a look but I cant work out what to change :)

Trenloe
June 13th, 2016, 18:12
Hey Trenloe when you roll usin this extension it reports the Username and not the Character name as making the roll.
Remove rRoll.sUser = User.getUsername(); from count_successes.lua, and don't put anything in for rRoll.sUser. This will leave it to the ChatManager.createBaseMessage function to create the right name.

damned
June 14th, 2016, 08:18
Much obliged Trenloe that fixed both this one and DMFirmys Drop Lowest extension.

damned
September 21st, 2016, 03:36
Hi Trenloe is it possible (how would you go about) setting this up to report the Successes and not the Sum? It already reports the Success Count but I would like to know how you would report this number as a the draggable number.

Trenloe
September 21st, 2016, 03:41
https://www.fantasygrounds.com/refdoc/Comm.xcp dicedisplay = 0 stops the total being displayed.

You'd then have to construct any drag data separately - and code in the value/s you want to be available in a drag action: https://www.fantasygrounds.com/refdoc/dragdata.xcp

damned
September 21st, 2016, 03:47
Hi Trenloe - can you think of anywhere that I can see an example of setting your own dragdata?

Trenloe
September 21st, 2016, 04:03
Hi Trenloe - can you think of anywhere that I can see an example of setting your own dragdata?
CoreRPG, campaign\record_char_main.xml - line 111, you need to put the info together in the onDragStart function. Do other searches for onDragStart for other examples. You'll need to get info out of the chat info when the drag starts, so you may need to use some coding in [] or something in the description to easily get to the info you want. Info on the onDragStart event here: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#onDragStart There's a bunch of stuff already there (related to the comm data structure: https://www.fantasygrounds.com/refdoc/Comm.xcp) you'll probably want to do lots of Debug.console commands to see exactly what is available when you start the drag.

Trenloe
September 21st, 2016, 04:33
Depending on what you want to do (as I'm not sure what you're wanting to do), you might not even need the onDragStart code. Set the info in the chat message and then it will come across in the draginfo, and decode in the onDrop function on the control/window where you drop the drag: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#onDrop

I do this for damage in the Star Wars ruleset. I send a line of [Damage: X] to the chat window, where X is the amount of damage done. This message is constructed using:

local damagemsg = {};
damagemsg.font = "msgfont";
damagemsg.type = "wounds";
local sDamage = "";
sDamage = string.match(description, "%[DAMAGE:%s*(%w+)%]");
local totaldamage = tonumber(sDamage) + resultSummary.success
damagemsg.text = "[Damage: " .. totaldamage .. "]";
deliverMessage(damagemsg);

The key thing here is the .type data of "wounds". When this chat entry is dragged and then dropped somewhere (in this specific case on a PC or NPC record) the onDrop function has access to the message data in the dragdata record. I use if draginfo.isType("wounds") as part of the onDrop function to see if the drag/drop is doing damage and then run the code to extract the damage info and apply it:

if draginfo.isType("wounds") then
if draginfo.getDescription() then
sDamage = string.match(draginfo.getDescription(), "%[Damage:%s*(%w+)%]");
end
end
It then uses the description text (the damagemsg.text from the chat message) and uses that to extract the wounds value using sDamage = string.match(draginfo.getDescription(), "%[Damage:%s*(%w+)%]"); You'd have to write something similar to get the numerical value from your chat message text. https://www.fantasygrounds.com/refdoc/dragdata.xcp#getDescription

Trenloe
September 21st, 2016, 04:43
To continue on from what I've been saying. Attached is an extension that removes the total from the dice roll result, sets the .type to be successes instead of dice.

Then, you can drag/drop the "Successes = XX" line and drop it somewhere.

You'll need to put onDrop code in the control/window script to handle the drop (checking for dragdata.type = "successes") and extract the number of successes from the dragdata description field using something like: sSuccesses = string.match(draginfo.getDescription(), "Successes%s*=%s*(%w+)");

(I haven't tested this string.match regular expression so don't know if that is 100% correct.)

damned
September 21st, 2016, 09:00
Hi Trenloe - thanks for your help.

15402

At the moment it is still displaying the SUM and the dragdata also contains the SUM.




https://www.fg-con.com/wp-content/uploads/2016/09/fgcon9-sig8.jpg (https://www.fg-con.com/events/)
FG Con 9 – Fantasy Grounds Online RPG Convention - October 14-16 2016
Register at www.fg-con.com (https://www.fg-con.com/) for all the latest info.

frostbyte000jm
September 21st, 2016, 12:40
Thanks everyone. I will be playing with this after work today.

Trenloe
September 21st, 2016, 13:27
At the moment it is still displaying the SUM and the dragdata also contains the SUM.
Sounds like you're using the old extension, not the new one I attached in post #11.

And yes, just drag/dropping the roll in the chat window will show the sum - as I mentioned the dragdata will contain most of the data from the comm message structure. You need to code in the target onDrop function on the target window/controlwhat you do with the message data you have available.

damned
September 21st, 2016, 13:55
I *had* deleted the original one and downloaded the new one but I made a mistake I have made 72x already (and still counting) I still had an unpacked copy...
Im positive Ive only got the one... and I still see the same behaviour... well Im pretty positive anyway!


EDIT: And comprehension dawns... It is doing exactly what you say it. Let me keep working on it :)


https://www.fg-con.com/wp-content/uploads/2016/09/fgcon9-sig7.jpg (https://www.fg-con.com/events/)
FG Con 9 – Fantasy Grounds Online RPG Convention - October 14-16 2016
Register at www.fg-con.com (https://www.fg-con.com/) for all the latest info.

zarlor
September 21st, 2016, 15:12
I've been playing around with this (absolutely love it,thank you) as my group is playing with the beta of Katanas & Trenchcoats. I am wondering if it would be particularly difficult to add the ability to either read the bonus or just include the ability to include a bonus in the syntax? For example doing:

/successes 3d10+1 7

In order to count the number of dice with a result of 7 or higher and adding 1 success to the result. I tried to take a quick look at the files in the extension but my lua coding skills are rather... non-existent. :(

frostbyte000jm
September 21st, 2016, 15:40
What is the +1 success from? is this a common thing in K&T? I haven't played yet.

I am currently hijacking Trenloe's code to add a fail target number so 1's can take away (OWoD style). I was going to see about adding a way to give a +1 success for willpower.

I hacked the modifier window to adjust the difficulty. Since I was building it with White Wolf in mind, this is a super common thing that changes at the feelings of the storyteller. Since the code is super similar, I can make another version of what I am doing (aka hacking) to let the Mod stack add to successes when it gives the final results.

I noticed if you double click the modifier window (why? I am clicker and I find things, that is why.) it will read "Adjustment". Is there a way for me to access the adjustment modifier separately from the regular modifier?

I was allowing my eyes to dry out yesterday as I was reading just about every line of code in the CORE ruleset. I think I saw something about this, but I wasn't sure if I could access it or not.

Trenloe
September 21st, 2016, 17:36
I *had* deleted the original one and downloaded the new one but I made a mistake I have made 72x already (and still counting) I still had an unpacked copy...
Im positive Ive only got the one... and I still see the same behaviour... well Im pretty positive anyway!


EDIT: And comprehension dawns... It is doing exactly what you say it. Let me keep working on it :)
Depending on what you are trying to do, you may want to report the successes on a separate chat line (like I do for damage in the Star Wars:EotE ruleset) so you don't have all of the dice results included in the resulting dragdata object.

zarlor
September 21st, 2016, 17:38
It's common for Damage for Immortals (roll 3d10, each 7 or above is a success and add 1 to the successes which the book lists as 3d10+1) and some Edges might provide that kind of bonus as well. Other than that, however, I wouldn't say it's necessarily "common" for K&T form what I've seen so far.

Trenloe
September 21st, 2016, 17:51
I noticed if you double click the modifier window (why? I am clicker and I find things, that is why.) it will read "Adjustment". Is there a way for me to access the adjustment modifier separately from the regular modifier?.
The "adjusting" label is just telling you that you've selected the modifier box and can manually type in the adjustment - this is in addition to any other modifiers that might have been added to the six modifier slots. https://www.fantasygrounds.com/wiki/index.php/Modifier_Stack

All of the different modifiers are stored in the slots table (array) in desktop\scripts\modifierstack_base.lua. The actual "adjusting" number is the freeadjustment variable in desktop\scripts\modifierstack.lua which is a global package called ModifierStack, so you should be able to access this with ModifierStack.freeadjustment

frostbyte000jm
September 21st, 2016, 19:44
Cool. Thanx Trenloe. I will play with that.

Zarlor, do the bonus successes come in more than just +1 do you sometimes get a +3? Is it static or random when you get bonus successes?

zarlor
September 21st, 2016, 21:50
I had to dig through the PDF but the only instance I could find of guaranteed successes like that is for "Greater Weapons" (which includes an Immortal's weapon) which have a flat 3d+1 damage, minimum of 1 success. I didn't find any other official rules or examples where there was a definitive + or - to the successes other than that, but that doesn't mean I didn't miss something. It seems to me, though, that it would be pretty overpowering to probably add or remove more than 1 success to a roll, but if some SM (their term for a GM) had some great reason to do it I suppose they could, of course.

antaskidayo
December 10th, 2016, 11:19
how do you code the extension into the npc rolls/attack box?

damned
December 10th, 2016, 12:08
how do you code the extension into the npc rolls/attack box?

In what ruleset? Most rulesets wont allow you to do that. Every field expects data in specific formats. You can have a look at MoreCore as it has incorporated this extension and you can add it in the Rolls sections for PCs and NPCs.

Trenloe
December 10th, 2016, 15:27
If you're not using MoreCore the best you can do is drag the chat entry to a hotkey.

antaskidayo
December 10th, 2016, 19:33
Can you show me how to code it on the rolls?

damned
December 10th, 2016, 23:07
Can you show me how to code it on the rolls?

As in code it into a ruleset? No. You would have to look at how the current rolls for that ruleset work and what automation happens as a result of it and then determine how best to include this. If its for MoreCore click on the help file link in the chat window (on startup or type /morecorehelp) and it will show you the syntax for the various rolls.

Trenloe
December 11th, 2016, 05:10
@antaskidayo what ruleset are you using? As damned mentions, this can be done in the MoreCore ruleset, so I'd recommend using that. Available here: https://www.fantasygrounds.com/forums/showthread.php?34860-MoreCore-Ruleset

seycyrus
February 25th, 2017, 03:24
@antaskidayo what ruleset are you using? As damned mentions, this can be done in the MoreCore ruleset, so I'd recommend using that. Available here: https://www.fantasygrounds.com/forums/showthread.php?34860-MoreCore-Ruleset

Trenloe, how difficult would it be to modify this extension to make it a bit more GURPSY? Instead of a single die rolls, I'd like to throw groups of d6s (3d6 to be specific) and record the number of results BELOW a certain number.

damned
February 25th, 2017, 03:46
Have a look at /rollunder in MoreCore
/rollunder 3d6x3
https://www.fantasygrounds.com/forums/attachment.php?attachmentid=18039&d=1487994365

18039

seycyrus
February 25th, 2017, 17:37
Have a look at /rollunder in MoreCore ...
[/ATTACH]

Thanks, I'm taking a look at it.

BTW, just screwing around with I notice that despite the number of rolls you call for, the max number of rolls is 60.

Trenloe
February 25th, 2017, 17:45
BTW, just screwing around with I notice that despite the number of rolls you call for, the max number of rolls is 60.
That's a physical limit set in the FG app itself. See the release notes for v3.1.6 here: https://www.fantasygrounds.com/filelibrary/patchnotes.html

damned
February 25th, 2017, 22:53
That's a physical limit set in the FG app itself. See the release notes for v3.1.6 here: https://www.fantasygrounds.com/filelibrary/patchnotes.html

and you only asked for 3!


Trenloe, how difficult would it be to modify this extension to make it a bit more GURPSY? Instead of a single die rolls, I'd like to throw groups of d6s (3d6 to be specific) and record the number of results BELOW a certain number.

izex
March 5th, 2017, 00:44
Thank you for this extension :)

LordEntrails
March 5th, 2017, 04:08
Welcome izex! Hope you are enjoying the community.

Thanks for letting the OP know you appreciate his extension. Thanks and self-enjoyment are the only rewards most of the community devs ever get :)

nad3ooo
March 10th, 2017, 16:31
trenloe- thanks so much for this awesome extension...

i saw someone mention that they would like the ability to add [for instance] a '+1' to all the dice in a /success roll.

i would like similar functionality in the 3.5 ruleset...can you give me any guidance on the easiest way to do this?

thanks,

nadam



The "adjusting" label is just telling you that you've selected the modifier box and can manually type in the adjustment - this is in addition to any other modifiers that might have been added to the six modifier slots. https://www.fantasygrounds.com/wiki/index.php/Modifier_Stack

All of the different modifiers are stored in the slots table (array) in desktop\scripts\modifierstack_base.lua. The actual "adjusting" number is the freeadjustment variable in desktop\scripts\modifierstack.lua which is a global package called ModifierStack, so you should be able to access this with ModifierStack.freeadjustment

Trenloe
March 10th, 2017, 16:33
i would like similar functionality in the 3.5 ruleset...can you give me any guidance on the easiest way to do this?
Well, its going to require coding - so you'll need to break out the extension and change the code in the LUA script. It's going to need parsing of the dice string to extract the modifier and apply it to the end successes.

Time to get into some LUA!

Some pointers here: https://www.fantasygrounds.com/forums/showthread.php?20651-Modifying-the-CoreRPG-ruleset

And some info on an extension here: https://www.fantasygrounds.com/forums/showthread.php?20449-Tutorial-Creating-a-Basic-Extension

There are plenty of examples of the various dice strings/rolling processes in the MoreCore ruleset.

For the Count Successes extension, the count_successes.lua file does all the work. Line 54 extracts the dice string and success level from the slash handler parameters: local sNum, sSize, sSuccessLevel = sParams:match("(%d+)d([%dF]+)%s(%d+)"); You'd need to modify this to include any further parameters.

Then the function dropDiceResults is used to calculate the number of successes. You could pass the additional parameter to this (as part of the rRoll record) and adjust the rRoll.successes data appropriately.

nad3ooo
March 10th, 2017, 16:42
thanks for the quick reply. im not a coder but im not afraid of taking a crack at this either.

thanks again for your help.


Well, its going to require coding - so you'll need to break out the extension and change the code in the LUA script. It's going to need parsing of the dice string to extract the modifier and apply it to the end successes.

Time to get into some LUA!

Some pointers here: https://www.fantasygrounds.com/forums/showthread.php?20651-Modifying-the-CoreRPG-ruleset

And some info on an extension here: https://www.fantasygrounds.com/forums/showthread.php?20449-Tutorial-Creating-a-Basic-Extension

There are plenty of examples of the various dice strings/rolling processes in the MoreCore ruleset.

Trenloe
March 10th, 2017, 16:44
im not a coder but im not afraid of taking a crack at this either.
Game on! I've edited my post above with some more info.