PDA

View Full Version : Copy the hit location roll button



peterb
March 9th, 2023, 10:09
This is a "hack" that inserts a hit-location roll button on the main tab of the character sheet that I'd like to share. The solution is not perfect. Since the button is tied to the frame you will have to resize the character sheet if you add a lot of weapons. But it will save some time since there are fewer mouse clicks and the user needs to move the mouse pointer less.

Note. This feature doesn't, of course, make any sense if you don't use hit locations, only use it if you do. Also, when using the extension you have to click once on the button on the armor tab before the button on the main tab works, why that is I don't know.

Either use the provided extension (BRP Hit Location Button.ext) at the bottom of this post or use the method described below.

How-to
1) Preparations
1.1) Start by making a backup copy of the ruleset file (Basic Roleplaying.pak).
1.2) Then create a dev directory somewhere. Mine is called "dev" and it's in the root of the Fantasy Grounds folder.
1.3) Copy Basic Roleplaying.pak to the dev folder.
1.4) Change the name of Basic Roleplaying.pak to Basic Roleplaying.zip
1.5) Unzip the zip-file


2) Copy existing code
2.1) Open campaign/record_char_armor.xml in an editor (such as notepad++)
2.2) From record_char_armor.xml copy this code:


<genericcontrol name="hitlocationbutton">
<anchored to="mainframe" position="insidebottomright" offset="17,16" width="20" height="21" />
<icon>indicator_hitlocation</icon>
<script>
function onClickDown(...)
rollHitLocation(Input.isShiftPressed());
return true;
end

function rollHitLocation(flag)
local charnode = window.getDatabaseNode();
local name = charnode.getChild("name").getValue();
local listnode = charnode.getChild("hitlocations");
if listnode then
Global.RollHitLocation(name,listnode,flag);
end
end
</script>
<tooltip>
<text>Roll hit location</text>
</tooltip>
</genericcontrol>


3) Paste into record_char_main
3.1) Open campaign/record_char_main.xml
3.2) Insert in record_char_main.xml, under weaponFrame", like this:


<frame_char name="weaponframe">
<anchored>
<left parent="" anchor="left" offset="15" />
<top parent="statframe" anchor="bottom" />
<right parent="" anchor="right" offset="-25" />
<bottom anchor="bottom" />
</anchored>
</frame_char>
<genericcontrol name="hitlocationbutton">
<anchored to="mainframe" position="insidebottomright" offset="17,16" width="20" height="21" />
<icon>indicator_hitlocation</icon>
<script>
function onClickDown(...)
rollHitLocation(Input.isShiftPressed());
return true;
end

function rollHitLocation(flag)
local charnode = window.getDatabaseNode();
local name = charnode.getChild("name").getValue();
local listnode = charnode.getChild("hitlocations");
if listnode then
Global.RollHitLocation(name,listnode,flag);
end
end
</script>
<tooltip>
<text>Roll hit location</text>
</tooltip>
</genericcontrol>

3.3) Save

4) Save and re-package the ruleset.
4.1) Zip the contents of the ruleset folder. Do this when "inside" the folder.
4.2) Rename the zip-file to Basic Roleplaying.pak

5) Replace the existing pak
5.1) Move the Basic Roleplaying.pak to the ruleset folder

6) Reload the ruleset
6.1) Type "/reload" in the chat window

damned
March 9th, 2023, 11:48
Hi peterb you could make this into an extension and not have to keep re-editing the PAK.

peterb
March 9th, 2023, 13:37
I know, I have just not mastered joining/merging... This is a piece of code that sits inside a big chunk of code, so either I override record_char_main or I do some joining. There's an example in record_char_inventory but I have never been able to duplicate it. Also, I use a layered ruleset on top of Basic Roleplaying for my changes (including this one), and those are extensive since I added text resource strings so that I can translate the ruleset to, in my case, Swedish. So for me, it's not much of a problem.

peterb
March 9th, 2023, 14:21
Tested creating an extension with a join. This time I got it right. I'm going to update the first post.

peterb
March 9th, 2023, 14:38
Use this extension instead of the process described in the first post. Oddly you have to click on the button on the armor tab once and then the button on the main tab starts working. Don't really know why this is.

superteddy57
March 9th, 2023, 14:43
Might be best to attach the extension to the first post and add a comment that either option is available.

peterb
March 9th, 2023, 14:52
Couldn't find a "attach file" button on the first post, so I did a work around.

superteddy57
March 9th, 2023, 15:06
edit Post > Go advanced and it should be available.

peterb
March 9th, 2023, 15:10
Aha, I didn't scroll far down enough...