The problem you have is there's no way to calculate the attack modifier from those damage values. So you need to change the way the select works. I'm going to make two posts. The first is to modify the code you have, and the second will show a way to make your code more efficient. So, the first method: Step one - option values Change every instance of this <option value="1">Bash</option> <option value="2">Slash/Stab</option> <option value="4">Thru Heart</option> <option value="5">Vampire Heart</option> <option value="05">Decapitate</option> </select> to this <option value="bash">Bash</option> <option value="slash">Slash/Stab</option> <option value="heart">Thru Heart</option> <option value="vampire">Vampire Heart</option> <option value="decapitate">Decapitate</option>
</select>
<input type="hidden" name="attr_melee_weapon_attack_penalty-6" value="0" />
notice the new input at the end there. You'll need to change the -6 at the end to match the numbers for the attack its linked with. Step two - Button Code Change the button as follows: <th class="sheet-lb"><button type='roll' class="sheet-skillbutton" name="roll_melee_attack-6" value="&{template:default} {{name=@{character_name} attacks with @{melee_weapon_name-6} }} [[ [[{9,11,13,15,17,21,24,27,30}<[[1d10+@{melee_weapon_attack_rating-6} -@{melee_weapon_attack_penalty-6} +?{Modifiers|0}]] ]]*@{melee_weapon_damage_Multiplier-6}+ @{melee_weapon_damage_base-6} ]] {{Roll=$[[0]]}} {{Levels=$[[1]]}} {{Damage=$[[2]]}}"></button> Note parts in bold - they are new, and you'll need to change the -6 part to match each section. Step 3 - the Multiplier fix Change this <th><input type="number" class="sheet-numberbox" name="attr_melee_weapon_damage_Multiplier-6" value="@{melee_weapon_damage_type-6}" disabled="true" /></th> to this <th><input type="number" class="sheet-numberbox" name="attr_melee_weapon_damage_Multiplier-6" value="0" readonly /></th> This is to make it work with the next step. Step four - the sheet worker The magic that makes this work. Add the following to the end of your html file: <script type="text/worker">
[0, 1, 2, 3, 4, 5, 6].forEach(i => { on(`change:melee_weapon_damage_type-${i}`, ()=> { getAttrs([`melee_weapon_damage_type-${i}`], v => { const type = v[`melee_weapon_damage_type-${i}`]; const modifiers = { bash: {attack: 0, damage: 1}, slash: {attack: 0, damage: 2}, heart: {attack: 3, damage: 4}, vampire: {attack: 3, damage: 5}, decapitate: {attack: 5, damage: 5} }; const output = {}; output[`melee_weapon_type_penalty-${i}`] = modifiers[type].attack; output[`melee_weapon_damage_Multiplier-${i}`] = modifiers[type].damage; setAttrs(output); }); }); }); </script>
Two things to note about this: The second line starts [0, 1, 2, 3, 4, 5, 6]. If you have more than 6 melee weapon sections, expand that to the correct amount. so if you have 9, it would look like [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(i => { Secondly, if your text already has a script block (a section starting with <script and ending with </script>, then out the above code - without the script lines - inside that block. If your text doesnt have a script block ignore this. Conclusion The above changes should get your attack type and attack and damage modifiers working properly.