Main issue is with the 4th group of code. I tried doing "const" math with the result of a startRoll that has successes as the result rather than a dice total, but idk if that's actually possible. If anyone has any tips for how I'd go about including the result of a dice roll's successes in a math equation, it'd be much appreciated! <div class="resist">
<button type="action" name="act_resist">Resist!</button></div> <rolltemplate class="sheet-rolltemplate-soak">
<div class="sheet-template-container">
<h2>Final Damage</h2>
<div class="sheet-results">
<h2>{{totalabs::rollsoak}}</h2>
</div>
</div>
</rolltemplate> <script type="text/worker">
on("clicked:resist", function() {
getAttrs(["drisk","dr","soakflipswitch"], function(values) {
let soakflipswitch = parseInt(values.soakflipswitch)||0;
let drisk = parseInt(values.drisk)||0;
let dr = parseInt(values.dr)||0;
let dredresult = drisk - dr;
if(dredresult <= 0) {
setAttrs({
"driskdr": 1
});
}
else {
setAttrs({
"driskdr": dredresult
});
}
setAttrs({
"soakflipswitch": 1 + soakflipswitch
});
});
});
</script> <script type="text/worker">
on("change:soakflipswitch", function(info) {
getAttrs(["driskdr","absorption","magicsoakradio","softbody","shelltotal"], function(values) {
let driskdr = parseInt(values.driskdr)||0;
let absorption = parseInt(values.absorption)||0;
if(values.magicsoakradio == 0 && values.softbody == 0 && absorption >= 1) {
startRoll("&{template:soak} {{name=Soak}} {{rollsoak=[[[[floor(@{shelltotal})]]d6s>5]]}}", (results) => {
if(values.shellreroll == "1") {
startRoll("&{template:soakreroll} {{name=SoakR1}} {{rollsoakr1=[[1d6>5]]}}", (results) => {
});
}
const reroll = results.results.rollsoakr1.result;
const roll = results.results.rollsoak.result;
const total = Math.max(roll + reroll - driskdr);
const totalabs = Math.floor(total / absorption) + 1;
finishRoll(
results.rollId,
{
rollsoak: totalabs
}
);
});
}
});
});
</script>