PDA

View Full Version : Keep Highest/Drop Lowest ?



ImaTarget
September 18th, 2014, 10:25
After giving up on my own extension due to limited time and abillity I am now just looking for a way to roll 3d6 + modifier and drop the highest or drop the lowest. It is for Barbarians of Lemuria. has anyone build that for Basic RPG?

Valarian
September 18th, 2014, 12:29
MoonWizard is working on adding additional dice command functionality, including keeping dice. This may help once it's in.

VenomousFiligree
September 18th, 2014, 12:56
Hi ImaTarget, whilst it's not available now an FG ruleset for BoL should be available towards the end of the year.

damned
September 18th, 2014, 13:59
https://www.fantasygrounds.com/forums/showthread.php?21488-Dice-features&p=179724&viewfull=1#post179724

its not yet in the v3.0.8 beta so not sure what JPGs plans are just yet...

VenomousFiligree will hopefully be adding BoL to the store late in the year :)

Moon Wizard
September 19th, 2014, 06:24
Those features got bumped into the Unity version, so they are a ways off. I had to bite the bullet and start the Unity version or it would be next year before we started.

So, for now, it will need to be baked into the ruleset as a custom roll type.

Cheers,
JPG

damned
September 19th, 2014, 06:26
could you share the code *as is* and maybe one of the smarty pants around here might be able to make it into a CoreRPG extension?

Moon Wizard
September 20th, 2014, 00:22
The stuff I was working on was built into the FG client, not ruleset code. Also, there were a lot of new features necessary to support. So, it can't be adapted to Lua code.

Basically, you would setup custom roll and custom roll result handler (similar to attack/damage/Init/save in 3.5E/4E/5E). In the code generating the roll, I would add a [KEEP #] or [DROP #] tag in the roll description. Then, in the code handling the result, look for those tags to strip out the appropriate dice. Perhaps adding another note to description text stating which dice/results dropped.

Cheers,
JPG

DMFirmy
September 20th, 2014, 03:32
Basically, you would setup custom roll and custom roll result handler (similar to attack/damage/Init/save in 3.5E/4E/5E). In the code generating the roll, I would add a [KEEP #] or [DROP #] tag in the roll description. Then, in the code handling the result, look for those tags to strip out the appropriate dice. Perhaps adding another note to description text stating which dice/results dropped.

I was considering something similar to this for the ruleset that I have been working on. If I manage to get something working, I will try and package it up as an extension and share my code here.

damned
September 20th, 2014, 14:50
that would be great DMFirmy

DMFirmy
September 20th, 2014, 20:07
I was putting a little bit of thought into this today, and my initial thought would be to add a couple of new options to the dice roll radial menu for Drop Lowest and Drop Highest, in the same way there are buttons to negate, half, and double the total currently. I started digging around in the CoreRPG ruleset to see how these radial menus are defined, but it seems like they are hard-coded in FG's core code. Is it possible to modify this radial menu to add this functionality? I cannot seem to find anywhere in the ruleset code that I can modify the menu, and I also haven't been able to find any info in the documentation. This feature is something that I am sure a lot of people would find useful, so I am anxious to play around with it to see if I can get it working. If it is not possible, I can try and think of another way to introduce the functionality, but adding it to the radial menu seems the most natural option to me.

Ikael
September 20th, 2014, 22:36
I was putting a little bit of thought into this today, and my initial thought would be to add a couple of new options to the dice roll radial menu for Drop Lowest and Drop Highest, in the same way there are buttons to negate, half, and double the total currently. I started digging around in the CoreRPG ruleset to see how these radial menus are defined, but it seems like they are hard-coded in FG's core code. Is it possible to modify this radial menu to add this functionality? I cannot seem to find anywhere in the ruleset code that I can modify the menu, and I also haven't been able to find any info in the documentation. This feature is something that I am sure a lot of people would find useful, so I am anxious to play around with it to see if I can get it working. If it is not possible, I can try and think of another way to introduce the functionality, but adding it to the radial menu seems the most natural option to me.

Unfortunately that is hardcoded in FG all right. I also wanted to fudge these dice rolled options as well but still they are beyond possible :(

DMFirmy
November 22nd, 2014, 20:54
I was considering something similar to this for the ruleset that I have been working on. If I manage to get something working, I will try and package it up as an extension and share my code here.

I have just completed my first draft of a "Drop Lowest" extension, which you can download from here (https://dmfirmy.com/sites/default/files/downloads/DropLowest.zip). It is still a very simple implementation, but before I get much further along in development I have come to a point where I don't quite know what I am doing wrong.

With this extension activated, typing "/rolld" in the chat window will trigger a roll of 4d6. The lowest roll is determined and removed, and a message is sent to the chat window with the results. Everything seems to work perfectly. Here is an image that shows the results of using the "/die 3d6" command on one line and the "/rolld" command on the next: 8004

The problem I am having is when I drag the results onto the ability score on the character sheet. The result from the first command can be dropped onto the Strength score and it will be automatically applied. The result from the "/rolld" command, however, will not be applied if I try the same thing. I can, however, drag the result from "/rolld" back into the chat window, in which case it will come back with only the total, as in this image: 8005.

I have no problem dragging the total onto my character sheet, so technically this functionality works... at least to a point. I cannot seem to figure out why the results from my custom command can't be dragged like the results of the "/die" command can. It seems to me that I have everything wired up correctly. If anyone who might be able to give me a hand wants to take a look at my code to see where I went wrong, I would really appreciate the advice. This module is something my players have strongly requested from me, and I really learned quite a lot just getting it this far. If I can figure out what I am doing wrong I am planning to modify the functionality so that the new slash command will accept parameters for the dice to be rolled and the number to be dropped, so instead of just having it always roll 4d6 drop lowest, you could instead do something like "/rolld 5d8 2" to roll 5d8 dropping the 2 lowest results.

NOTE: These screenshots and all of my testing have been done using the 3.5E ruleset.

DMFirmy
November 23rd, 2014, 19:50
I just posted an update to this extension on my website (the original link still works) that now allows you to pass in the number of dice, dice type, and number of results to be dropped, though the same issue mentioned in my previous post is still present. It is also a known issue that, at the moment, the handling for d100 rolls is not properly implemented, but I will get around to that at some later time when I find the time and energy to do so. Once I figure out how to make the roll results draggable onto the character sheet, I think this extension will be pretty close to ready to release in the main forums, so again, any help would be appreciated.

damned
November 23rd, 2014, 22:02
@DMFirmy - good work.
Give it a couple of days and hopefully one of the more experienced programmers will spot your thread and have a look.

DMFirmy
November 23rd, 2014, 22:41
Thanks damned...

I actually just added support for d100's, so I think this little extension is pretty close to complete. Even with the annoying extra step of having to drag the totals back into chat to make them draggable, it is certainly faster and easier than having to mentally do the drops.

Trenloe
November 26th, 2014, 07:04
Is the extension file still available for download?

DMFirmy
November 26th, 2014, 16:17
Is the extension file still available for download?

Yeah, sorry about that. I didn't realize my website modified the file name when I uploaded the updated version.
Here (https://dmfirmy.com/downloads/dmfirmys-drop-lowest-extension-fantasy-grounds) is a link to the download page on my website as opposed to a direct link to the file. I will always attempt to keep the most up-to-date version uploaded to this page.

Trenloe
November 26th, 2014, 18:48
The problem I am having is when I drag the results onto the ability score on the character sheet. The result from the first command can be dropped onto the Strength score and it will be automatically applied. The result from the "/rolld" command, however, will not be applied if I try the same thing. I can, however, drag the result from "/rolld" back into the chat window, in which case it will come back with only the total...
The ability score number field only accepts drops that are a number. It doesn't recognise your customer type of "rolld" as having a number portion and so doesn't do anything with it. A quick fix is to change the rMessage.type in the createChatMessage function to be "dice", i.e. rMessage.type = "dice"; This will allow you to drag a rolld result to an ability score field and the total of the roll will be populated in the field.

DMFirmy
November 26th, 2014, 19:56
The ability score number field only accepts drops that are a number. It doesn't recognise your customer type of "rolld" as having a number portion and so doesn't do anything with it. A quick fix is to change the rMessage.type in the createChatMessage function to be "dice", i.e. rMessage.type = "dice"; This will allow you to drag a rolld result to an ability score field and the total of the roll will be populated in the field.

I will give this fix a try later today when I get home, but I am curious how I would implement the "not-so-quick-fix" and actually make it so my rolld result IS recognized as a number. Thanks a million for the advice though... this one was driving me bananas.

DMFirmy
November 26th, 2014, 20:12
@Trenloe: Thanks, that fix does the trick!

Trenloe
November 26th, 2014, 20:30
I will give this fix a try later today when I get home, but I am curious how I would implement the "not-so-quick-fix" and actually make it so my rolld result IS recognized as a number. Thanks a million for the advice though... this one was driving me bananas.
See the supported types in the dragdata entry - 2nd paragraph here: https://www.fantasygrounds.com/refdoc/dragdata.xcp

The not-so-quick-fix would be to write an onDrop() handler on the target control/s to get the correct data out of your custom dragdata object - this is a lot of work and would require messing around with base ruleset templates/definitions for a controls. It's much better to simply change the resulting chat message type to "dice" so that any control in the ruleset that can accept a number from a dice dragdata object will be able to accept it. And the result of your rolld code is a set of dice anyway, so this makes sense... :)

DMFirmy
November 26th, 2014, 21:42
See the supported types in the dragdata entry - 2nd paragraph here: https://www.fantasygrounds.com/refdoc/dragdata.xcp

The not-so-quick-fix would be to write an onDrop() handler on the target control/s to get the correct data out of your custom dragdata object - this is a lot of work and would require messing around with base ruleset templates/definitions for a controls. It's much better to simply change the resulting chat message type to "dice" so that any control in the ruleset that can accept a number from a dice dragdata object will be able to accept it. And the result of your rolld code is a set of dice anyway, so this makes sense... :)

I agree, that is a lot more work than would fit this extension. Thank you again for the help. I plan on putting together an updated version of this extension file and posting a release in the main forums some time later this evening. I am sure this is a bit of functionality that will find good use amongst the community.

JohnD
November 27th, 2014, 17:39
Will this work with the current version of Castles & Crusades?

Trenloe
November 27th, 2014, 18:15
Will this work with the current version of Castles & Crusades?
Yeah it will. Get the latest extension from here: https://www.fantasygrounds.com/forums/showthread.php?22637-DMFirmy-s-Drop-Lowest-Extension and add Castles and Crusades as a ruleset to extension.xml.

DMFirmy
November 27th, 2014, 22:20
Yeah it will. Get the latest extension from here: https://www.fantasygrounds.com/forums/showthread.php?22637-DMFirmy-s-Drop-Lowest-Extension and add Castles and Crusades as a ruleset to extension.xml.

I just updated the download file on my website to include "Castles and Crusades" in the ruleset list, but since I don't own this ruleset myself I cannot confirm for sure that this will work. I certainly can't see why it wouldn't, but it is the first one included I myself didn't test on my machine. Other than that, the only other change is a minor type-o correction.

damned
November 27th, 2014, 22:25
Hi DMFirmy - I just tested with C&C and it works there also.

DMFirmy
November 27th, 2014, 22:26
@damned: Thanks a ton!

damned
November 28th, 2014, 02:03
DMFirmy - what is the code that makes your Dice Result draggable?
I have a need to be able to drag some dice rolls for my Maelstrom ruleset.
I can drag your Dice Result into the target field ok - but my particular rolls dont drag.

DMFirmy
November 28th, 2014, 03:15
DMFirmy - what is the code that makes your Dice Result draggable?
I have a need to be able to drag some dice rolls for my Maelstrom ruleset.
I can drag your Dice Result into the target field ok - but my particular rolls dont drag.

@damned: This is the thing that I had the hardest time figuring out as well. Trenloe pointed my at the answer further up the thread:


The ability score number field only accepts drops that are a number. It doesn't recognise your customer type of "rolld" as having a number portion and so doesn't do anything with it. A quick fix is to change the rMessage.type in the createChatMessage function to be "dice", i.e. rMessage.type = "dice"; This will allow you to drag a rolld result to an ability score field and the total of the roll will be populated in the field.

damned
November 28th, 2014, 04:04
hes kinda helpful isnt he...

I/we might need him again to point me in teh right direction....

My campaign\template_char.xml contains:

<!-- PC Init Roll -->
<template name="number_pcinitroll">
<basicnumber>
<tooltip><text>Initiative. Double Click to Roll. 2d10+Speed. Highest Initiative Acts First.</text></tooltip>
<rollable />
<anchored width="40" height="20" offset="0,100">
</anchored>

</basicnumber>
</template>
<!-- END Init Roll -->

and my campaign\record_char_combat.xml contains:

<number_pcinitroll name="pcinit" source="char.init">
<anchored to="initframe" position="insidetopleft" offset="85,17" />

<script>
function action(draginfo)
local nodeWin = window.getDatabaseNode();
if nodeWin then
local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
Debug.console("rActor:");
Debug.console(rActor);
Debug.console("end rActor!");
local nSpeed = window.Speed.getValue();
Debug.console("nSpeed:" .. nSpeed .. "!");
Debug.console(nSpeed);
local nPenalty = window.penalty.getValue();
Debug.console("nPenalty:" .. nPenalty .. "!");
Debug.console(nPenalty);
local nTotal = getValue();
local sDesc = "[INIT 2d10 + Speed - Armour Penalty] result ";
local rRoll = { sType = "init", sDesc = sDesc, aDice = {"d10","d10"}, nMod = nSpeed-nPenalty };
ActionsManager.performAction(draginfo, rActor, rRoll);

end
return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end
</script>
</number_pcinitroll>
<number_charabilitytemp name="Speed" source="abilities.speed.temp">
<anchored to="initframe" position="right" offset="100"/>
</number_charabilitytemp>
<number_armourpenalty name="penalty" source="ac.totals.penalty" />

So Im having some difficulty identifying the right type to change....

Moon Wizard
November 28th, 2014, 04:57
The roll "type" set in the dragdata objects used to roll will be used as the same type when the result is dragged from the chat window.

Regards,
JPG

DMFirmy
November 28th, 2014, 05:06
@damned: Yeah... I did a bit of looking over the manager_actions.lua file at the performAction() function, and I honestly am having a hard time following it too. In my code I am not calling performAction(), I call roll() directly, but for a test I changed the code to the following and it still worked like expected:


local rRoll = createRoll(sParams);
ActionsManager.performAction(nil, nil, rRoll);

I think the step that you are missing is the addition of this line of code right here:


ActionsManager.registerResultHandler("rolld", onRoll);

I run this line of code during initialization, and here is the code in my onRoll function:


function onRoll(rSource, rTarget, rRoll)
rRoll = dropDiceResults(rRoll);
rMessage = createChatMessage(rSource, rRoll);
rMessage.type = "dice";
Comm.deliverChatMessage(rMessage);
end

damned
November 29th, 2014, 08:02
sadly my code looks completely different... im still stumped.

Trenloe
November 30th, 2014, 15:38
Moved damned's ruleset development questions to a new thread: https://www.fantasygrounds.com/forums/showthread.php?22661-Damned-s-Init-Combat-tracker-questions