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 .
×

Compendium Adding Extra (x)d6 to Weapons - Diagnosis and Potential Solution

Detailed description of the problem When playing Starfinder in Roll20 and adding a weapon to a character sheet via dropping from the Compendium, Roll20 will add a number of d6 (varies from case to case) that should not ordinarily be applied. This happens regardless of character class/race. Minimum number of steps to reproduce the problem Create a character, then drop a weapon of known damage into your inventory from the compendium. The resulting damage will have an additional 1d6 (or more) added. Description of setup This occurs across a large number of setups. Diagnosis As part of the code used to add an item to your character sheet, a function called "parseDamageDice" is called. Here's that function:  parseDamageDice = function(attributes,dice) {         TAS.log("Parsing damage dice:");         TAS.log(dice);         let level = attributes["character_level"]; //should be solarian level - character_class_n_* is set by text inputs so can't really check this...         let dmg = String(attributes["character_level"] < 12? (1+Math.floor(Math.abs(level-3)/3)):4+level-12)+"d6";         let match = dice.match(/\+?([^+|[|{]+)/i);         if (match) {             let res = (dmg + "+" + match[1]).replace(/(\[|\])+/i,"");             TAS.log("Parsed as:");             TAS.log(res);             return res;         }         else return dice;     }, The console output from this section looks something like this for a level 3 character (adding a level 7 tactical knife to the inventory): Starfinder-Log: Parsing damage dice: StarfinderByRoll20.js:168 Starfinder-Log: 2d4 StarfinderByRoll20.js:168 Starfinder-Log: Parsed as: StarfinderByRoll20.js:168 Starfinder-Log: 1d6+2d4 In the above code, lines 4 and 5 are the issue. Here's a breakdown of what exactly they're doing (and a pertinent comment in the code). The Issue Line 4 of the die parsing: let level = attributes["character_level"]; //should be solarian level - character_class_n_* is set by text inputs so can't really check this... This is setting the variable "level" to be equal to the character sheet level. (In this case, it's checking TOTAL level, so a multiclass of Technomancer 2, Mechanic 3 would be level 5). The comment elaborates that this should just be a Solarian level check, but due to the class name entry being manual, it's hard to check if someone is a solarian. This is important to figure out what's going on in the next line of code. Line 5: let dmg = String(attributes["character_level"] < 12? (1+Math.floor(Math.abs(level-3)/3)):4+level-12)+"d6"; That's a lot of math, but it basically says this: If the character is LESS than level 12, set the damage to the absolute value of 1+(the character's level-3)/3, rounded down. If the character is level 12 or higher, set the damage to the 4+the character's level-12. The output of this is the following, where the first column is the character's level: IN:OUT 01:1 02:1 03:1 04:1 05:1 06:2 07:2 08:2 09:3 10:3 11:3 12:4 13:5 14:6 15:7 So at level 1 to 5 it adds 1d6, at level 6 it adds 2d6, at level 9 it adds 3d6, at level 12 it adds 4d6, and then an additional d6 for every level thereafter. Referring back to the Solarian comment from line 4, you'll find that Solarians have an ability called "Solar Weapon", which reads as follows: Your Solar weapon functions as a one-handed kinetic advanced melee weapon, and you’re automatically proficient with it. At 1st level, choose whether your Solar weapon deals bludgeoning, piercing, or slashing damage. You can change the damage type each time you gain a new solarian level. Your Solar weapon deals damage equal to 1d6 + your  Strength  modifier. This damage increases by 1d6 at 6th level, 9th level, 12th level, and every level thereafter. Solarian weapon crystals can increase your Solar weapon’s damage. The code is erroneously adding the damage from the Solarian ability "Solar Weapon" to EVERY character sheet, regardless of whether or not they're a Solarian. Potential Solution Currently, this "feature" technically only works properly for a very small number of players (pure solarians, as multiclassing would cause incorrect die addition). The easiest way to fix this would be to comment out the code that calculates the solarian bonus altogether, and simply pass the raw compendium damage value, at least until a way to determine if the player is a Solarian is found.
1623739636
vÍnce
Pro
Sheet Author
Great sleuthing Christopher!  I've noticed that other users have come across this issue as well. Hopefully the sheet will get an update soon... The "Bug Reports & Technical Issues" forum has become a little neglected as of late.  Have you also submitted a report using the help desk ?
Hi Christopher, Thank you for a very detailed report, and going miles above and beyond to detail it. I just wanted to note that I have created an internal ticket for this, and a dev will be assigned to this in short order. I will come back and update this thread once a fix is in place. Happy gaming!
No thanks necessary! My younger brother is a programmer, and I've learned a lot about how to effectively report bugs from him, it's almost like a puzzle to me now. It appears I rolled well for my IRL hacking (I think coffee gave me a +2), I'm happy knowing this issue will soon be resolved :)