Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Need help with toggling strength modifier

1689410514

Edited 1689410530
Hello, I am once again here to seek aid with automating the convoluting mess that is fatal. Unlike other weapon types, agility based weapon doesn't get modified by strength and I wish to have the roll button to automatically add the modifier when it should be used. I've been trying to solve it on my own but I'm pretty stumped this time. The weapon types are in the format of DamageType:SkillType and looks like H:SA for example. All of them that doesn't use strength has an A after the colon. The damage roll currently looks like this [[@{weapon_dmg}*(1+(@{phys_dmg}/100))]] . Here's is a link to the sheet as it's a custom one I'm tweaking to be more easy to use and accurate to the system. Any help in this matter will be much appreciated. Thanks for reading the pleas of a poor soul, cheers!
1689422656
GiGs
Pro
Sheet Author
API Scripter
With those files, I'd advise changing the extension from .txt to .html and .css - it makes it easy to open the files in the correct format. Also, when sharing the full file, include the relevant line numbers. I think you are having an issue with the select starting on line 407. But I don't know exactly what you want to do. If you are trying to find a way to incorporate strangth and agility based damage, you'd need to describe what stats are used for those, and how they are determined. When asking for advice, always assume that people know nothing about the system you are asking for help on, even if it's a really popular system ike D&D. Describe everything relevant to the question.
1689423384
GiGs
Pro
Sheet Author
API Scripter
By the way when you have a select where the value is identical to the label, you don't need to include a value. You can do thsi: <select name="attr_wea_type"> <option>S:S</option> <option>S:SA</option> <option>S:A</option> <option>H:S</option> <option>H:SA</option> <option>H:A</option> <option>P:S</option> <option>P:SA</option> <option>P:A</option> <option>Brawling</option> </select> You can also have a value that is different from the visible label, to make it more useful <select name="attr_wea_type"> <option value="@{str}">S:S</option> <option value="@{str}">S:SA</option> <option value="@{agl}">S:A</option> <option value="@{str}">H:S</option> <option value="@{str}">H:SA</option> <option value="@{agl}">H:A</option> <option value="@{str}">P:S</option> <option value="@{agl}">P:SA</option> <option value="@{str}">P:A</option> <option value="@{str}">Brawling</option> </select> Though I wouldn't recommend doing this, since HTML will display the lael the first matching value. If you selected H:A, that has a value of @{agl} so whenever you returned to it, it would have a label of S:A, which is the first entry with a value of @{agl}. One extra thing you can do is use a sheet worker, to react to changes in the select value then update one or more other attributes. This kind of approach works well with the first select above.
Thanks for the quick reply. I've updated the files that's linked to .css and .html. On line 407 to 417 I have a list of all weapon types. I wanted to use that as an attribute that the attack button on line 431 can use to know if the strength modifier should be used or not. Currently, the damage modifier is added to the roll. I'm no proper coder but what I want is that I click the button, the sheet checks if the attribute at line 407 is either one of H:A , S:A , P:A or not. If it is I want the roll to just be @{weapon_dmg} (an attribute on line 427 which contains the number and kind dice that should be rolled for the weapons damage). If it's one of the other weapon types I want it to roll the formula I listed in my original post. I've looked into the sheet worker a little but I couldn't figure out how to make it change the damage formula. I will also shorten the list as you've shown. I'll don't know how in depth you need the explanation to be, but the system is pretty complex. To explain the relevant parts of the system as thoroughly as possible. All weapons have a damage type and a skill type. All weapon list their own dice that should be rolled. The damage types are Hacking, Stabbing and Pounding. The skill types are S (strength), SA (average of strength and agility) and A (Agility). The skill types tells which combination Hand-Eye Coordination and Agility should be used for the Weapon skill, and if the percentile modifier from Strength should be applied. Agility does not modify damage in any way, only Strength. The percentile bonus from Strength is determined by a table on page 77-80 in the fatal pdf. For clarity it is the second edition I'm running.
Question, can multiple options in the select have the same value? If so it could simplify to give all agility types the same value and the other ones their own.
1689426011
GiGs
Pro
Sheet Author
API Scripter
Styrud said: Question, can multiple options in the select have the same value? If so it could simplify to give all agility types the same value and the other ones their own. They can, but see the caveat in my previous comment. If you want to have the ame value, you need to find ways to either use different values + a sheet worker, or different values that look the same. The value is an attribute, you can include a variable number of spaces to make them different - for roll20 macros, the spaces are invisible, but to the HTML they are not. So something like this would work: <select name="attr_wea_type"> <option value="@{str}">S:S</option> <option value="@{str} ">S:SA</option> <option value="@{agl}">S:A</option> <option value="@{str} ">H:S</option> The values are all distinct as far as the HTML is concerned, but work identically in a calculation.
1689426275
GiGs
Pro
Sheet Author
API Scripter
Styrud said: I'll don't know how in depth you need the explanation to be, but the system is pretty complex. To explain the relevant parts of the system as thoroughly as possible. All weapons have a damage type and a skill type. All weapon list their own dice that should be rolled. The damage types are Hacking, Stabbing and Pounding. The skill types are S (strength), SA (average of strength and agility) and A (Agility). The skill types tells which combination Hand-Eye Coordination and Agility should be used for the Weapon skill, and if the percentile modifier from Strength should be applied. Agility does not modify damage in any way, only Strength. The percentile bonus from Strength is determined by a table on page 77-80 in the fatal pdf. For clarity it is the second edition I'm running. That sounds pretty complex to do, and might be ideal for a sheet worker. I don;t have the rules so cant really calculate anything specific to the game. It might be best to have a hidden attribute which stores the attribute value, basee on a change in the select value. Then the actual damage value use that hidden attribute instead of the strength value (and it ill sometimes be the strength value, or the agility value, or the combination of the two - calculated in the sheet worker).
I don't think you'll need to worry about the calculation too much. the percent is listen in an attribute named @phys_dmg on line 186. The formula in the original post is how it should be if it isn't an agility weapon. I don't really know how to write up a sheet worker that can change the roll but if you're able to do it you can let the ones with the original formula be 1 and the agility weapons be 2. so 1 would use [[@{weapon_dmg}*(1+(@{phys_dmg}/100))]] and 2 would use [[@{weapon_dmg}]] In completely improper syntax it should be something like this: if @wea_type === 1 {     Roll [[@{weapon_dmg}*(1+(@{phys_dmg}/100))]]     }; else {     Roll [[@{weapon_dmg}]]     };
1689428291
GiGs
Pro
Sheet Author
API Scripter
I just noticed this calculation is going to have sub-1 values [[@{weapon_dmg}*(1+(@{phys_dmg}/100))]] (like 23.45). Should it be rounded off, and if so, rounded which way - down, up, or nearest?
It should be rounded down but I didn't know how to do that and it wasn't a high priority.
1689430586
GiGs
Pro
Sheet Author
API Scripter
If you want to do the calculation in place, you can use floor() to round down, like [[floor(@{weapon_dmg}*(1+(@{phys_dmg}/100)))]]
1689430825
GiGs
Pro
Sheet Author
API Scripter
To add a sheet worker, you'd add this to the end of your HTML file < script type = "text/worker" >     on ( 'change:repeating_weapons_wea_type' , () => {         getAttrs ([ ' [[repeating_weapons_wea_type' ], values => {             const weapon = values . repeating_weapons_wea_type ;             /* a calculation goes here */         });     }); </ script > I'd avoiid a name like "wea_type" - you can use "weapon_type" - there's no practical length limit.
Okay, so from looking at the sheet worker I can't really see where it checks the value of wea_type or how it swaps the damage roll. Is all that in the /* a calculation goes here */ ?
1689431777

Edited 1689431793
I found a creative solution. I added the (1+(@{phys_dmg}/100) part of the formula as the value for the non agility weapon types and just 1 to the agility weapons. Then I changed the formula to [[floor(@{weapon_dmg}*(@{wea_type}))]] . It does exactly what it should and I'm happy. Couldn't do it without your explanation of the select and testing if it would work.
1689432289
GiGs
Pro
Sheet Author
API Scripter
That sounds like the direction I was going in. I didn't post the full sheet worker because I was off to get lunch and had more questions - yes, there'd be calculation in that /* calculation goes here  */ comment :)