Added custom grenade to the grenade roll template! Freaking awesome that it works! :D

This commit is contained in:
Peter Bjerg Lidegaard
2021-11-23 14:48:34 +01:00
parent 108df1ac0c
commit 531a12b5e8
17 changed files with 126 additions and 64 deletions
+54 -32
View File
@@ -1738,7 +1738,7 @@
</tr>
</table>
</fieldset>
<button type="action" name="act_grenade-miss" class="btn" style="display: none;">Test grenade miss!</button>
<button type="action" name="act_grenade-miss" class="btn" >Test grenade miss!</button>
<br>
<h4><b>Ammunition</b></h4>
@@ -19598,7 +19598,7 @@
<th class="sheet-template-title1 sheet-ignore-inlineroll">Grenadelike miss for {{computed::grenade}}</th>
</tr>
<tr>
<th><img src="https://raw.githubusercontent.com/Roll20/roll20-character-sheets/master/AD&D 2E Revised/img/rolltemplate-scatter-diagram.png" style="width: 100%;" alt="scatter diagram"/></th>
<th><img src="https://raw.githubusercontent.com/Roll20/roll20-character-sheets/master/ADnD 2E Revised/img/rolltemplate-scatter-diagram.png" style="width: 100%;" alt="scatter diagram"/></th>
</tr>
</table>
</div>
@@ -19615,23 +19615,29 @@
<tr>
<td class="sheet-grenade-c1 sheet-ignore-inlineroll">Direct hit:<br>({{aoe}} feet diameter)</td>
{{#^rollBetween() computed::hit 0 0}}
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::hitdmg}}</span></td>
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::hitdmg}}!</span></td>
{{/^rollBetween() computed::hit 0 0}}
{{#rollBetween() computed::hit 0 0}}
<td class="sheet-grenade-c4">Miss!<br><span class="sheet-hit-text">({{computed::hitdmg}})</span></td>
<td class="sheet-grenade-c4 sheet-ignore-inlineroll">Miss!<br><span class="sheet-miss-text">({{computed::hitdmg}})</span></td>
{{/rollBetween() computed::hit 0 0}}
</tr>
{{#rollBetween() computed::hit 0 0}}
<tr>
<td class="sheet-grenade-c1 sheet-ignore-inlineroll">Splash hit:<br>({{computed::aoe}} feet diameter)</td>
{{#^rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::splashdmg}}</span></td>
{{/^rollBetween() computed::splash 0 0}}
{{#rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c4">Miss!<br><span class="sheet-hit-text">({{computed::splashdmg}})</span></td>
{{/rollBetween() computed::splash 0 0}}
<!-- Direct hit is true -->
{{#^rollBetween() computed::hit 0 0}}
<td class="sheet-grenade-c5 sheet-ignore-inlineroll sheet-hit-text">Info<br><span class="sheet-miss-text">{{computed::splashdmg}}</span></td>
{{/^rollBetween() computed::hit 0 0}}
<!-- Direct hit is false -->
{{#rollBetween() computed::hit 0 0}}
{{#^rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::splashdmg}}!</span></td>
{{/^rollBetween() computed::splash 0 0}}
{{#rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c4 sheet-ignore-inlineroll">Miss!<br><span class="sheet-miss-text">({{computed::splashdmg}})</span></td>
{{/rollBetween() computed::splash 0 0}}
{{/rollBetween() computed::hit 0 0}}
</tr>
{{/rollBetween() computed::hit 0 0}}
</table>
</div>
</div>
@@ -31112,45 +31118,61 @@ on('change:repeating_ammo:ammoname', function(eventInfo){
setAttrs(weaponInfo);
});
let validGrenade = /1Acid|1Holy water|3Oil (lit)|1Poison|(\d*)#(.*)#(.*)#(.*)/
on('clicked:grenade-miss', function (eventInfo) {
startRoll('&{template:2Egrenademiss} {{grenade=?{What grenade have been thrown?|Acid,[[1Acid]]|Holy water,[[1Holy water]]|Oil (lit),[[3Oil (lit)]]|Poison,[[1Poison]]}}} {{direction=[[1d10]]}} {{distance=?{How far was it throw?|Short,[[1d6]]|Medium,[[1d10]]|Long,[[2d10]]}}} {{aoe=?{What grenade have been thrown?}}} {{hit=[[0]]}} {{hitdmg=[[0]]}} {{splash=[[0]]}} {{splashdmg=[[0]]}}', function(results) {
startRoll('&{template:2Egrenademiss} {{grenade=[[?{What grenade have been thrown?|Acid,1Acid|Holy water,1Holy water|Oil (lit),3Oil (lit)|Poison,1Poison|Other,?{Area of effect&#124;1&#125;#?{Grenade name&#125;#?{Direct damage&#124;1d6&#125;#?{Splash damage&#124;1d3&#125;}]]}} {{direction=[[1d10]]}} {{distance=?{How far was it throw?|Short,[[1d6]]|Medium,[[1d10]]|Long,[[2d10]]}}} {{aoe=[[?{What grenade have been thrown?}]]}} {{hit=[[0]]}} {{hitdmg=[[0]]}} {{splash=[[0]]}} {{splashdmg=[[0]]}}', function(results) {
console.log(results);
let distance = results.results.distance;
let expression = distance.expression;
let displayDistance = '';
switch (expression) {
case '1d6': displayDistance = 'Short'; break;
case '1d10': displayDistance = 'Medium'; break;
case '2d10': displayDistance = 'Long'; break;
default: displayDistance = 'Invalid'; break;
}
let aoeSplash = results.results.aoe.result+6;
let displayGrenade = results.results.grenade.expression.substring(1);
let computedRolls = {
distance: displayDistance,
grenade: displayGrenade,
aoe: aoeSplash,
hit: 0,
splash: 0
};
let grenadeExpression = results.results.grenade.expression;
let match = grenadeExpression.match(validGrenade);
console.log(match);
if (!match) {
finishRoll(results.rollId, computedRolls);
return;
}
switch (grenadeExpression) {
case '1Acid': computedRolls.grenade = 'Acid'; break;
case '1Holy water': computedRolls.grenade = 'Holy water'; break;
case '3Oil (lit)': computedRolls.grenade = 'Oil (lit)'; break;
case '1Poison': computedRolls.grenade = 'Poison'; break;
default: computedRolls.grenade = match[3]; break;
}
let distance = results.results.distance;
switch (distance.expression) {
case '1d6': computedRolls.distance = 'Short'; break;
case '1d10': computedRolls.distance = 'Medium'; break;
case '2d10': computedRolls.distance = 'Long'; break;
default: computedRolls.distance = 'Invalid'; break;
}
let hitDiameter = results.results.aoe.result;
let aoeSplash = computedRolls.aoe = hitDiameter+6;
// See if monster is within direct hit
if (distance.result < results.results.aoe.result / 2) {
if (distance.result <= hitDiameter / 2) {
computedRolls.hit = 1;
} else if (distance.result < aoeSplash / 2) {
} else if (distance.result <= aoeSplash / 2) {
let splashDamage;
computedRolls.splash = 1;
}
switch (displayGrenade) {
switch (grenadeExpression) {
case 'Acid': computedRolls.hitdmg = '2d4 Acid damage'; break;
case 'Holy water': computedRolls.hitdmg = '1d6+1 damage'; break;
case 'Oil (lit)': computedRolls.hitdmg = '2d6/1d6 Fire damage'; break;
case 'Poison': computedRolls.hitdmg = 'Special'; break;
default: computedRolls.hitdmg = match[4]; break;
}
switch (displayGrenade) {
switch (grenadeExpression) {
case 'Acid': computedRolls.splashdmg = '1 Acid damage'; break;
case 'Holy water': computedRolls.splashdmg = '2 damage'; break;
case 'Oil (lit)': computedRolls.splashdmg = '1d3 Fire damage'; break;
case 'Poison': computedRolls.splashdmg = 'Special'; break;
default: computedRolls.splashdmg = match[5]; break;
}
finishRoll(results.rollId, computedRolls);
});
@@ -31447,7 +31469,7 @@ function migrateOtherValuables() {
newValue['othervalue'] = total;
valuablesFields.forEach(field => {
let oldValue = values[field];
let oldValue = values[field] || '';
if (oldValue) {
if (valuablesString) {
valuablesString += '\n\n';
+18
View File
@@ -1262,6 +1262,21 @@ button {
margin: 0;
}
.sheet-rolltemplate-2Esave td.sheet-save-c5,
.sheet-rolltemplate-2Echeck td.sheet-check-c5,
.sheet-rolltemplate-2Egrenademiss td.sheet-grenade-c5 {
background-color: #001BB5;
border: none;
font-size: 12pt;
font-weight: bold;
font-style: italic;
font-family: "verdana", sans-serif;
text-align: center;
color: #ffffff;
padding: 4px;
margin: 0;
}
/*/ Styles for the 2Egrenade Template /*/
.sheet-rolltemplate-2Egrenademiss div.sheet-grenade-head {
background: #B7A64E;
@@ -1270,6 +1285,9 @@ button {
.sheet-rolltemplate-2Egrenademiss .sheet-hit-text {
font-size: 10pt;
}
.sheet-rolltemplate-2Egrenademiss .sheet-miss-text {
font-size: 8pt;
}
/*/ Overwrite inline roll styling /*/
.sheet-rolltemplate-2Egrenademiss .sheet-ignore-inlineroll .inlinerollresult {
+1 -1
View File
@@ -1738,7 +1738,7 @@
</tr>
</table>
</fieldset>
<button type="action" name="act_grenade-miss" class="btn" style="display: none;">Test grenade miss!</button>
<button type="action" name="act_grenade-miss" class="btn" >Test grenade miss!</button>
<br>
<h4><b>Ammunition</b></h4>
+17 -11
View File
@@ -699,7 +699,7 @@
<th class="sheet-template-title1 sheet-ignore-inlineroll">Grenadelike miss for {{computed::grenade}}</th>
</tr>
<tr>
<th><img src="https://raw.githubusercontent.com/Roll20/roll20-character-sheets/master/AD&D 2E Revised/img/rolltemplate-scatter-diagram.png" style="width: 100%;" alt="scatter diagram"/></th>
<th><img src="https://raw.githubusercontent.com/Roll20/roll20-character-sheets/master/ADnD 2E Revised/img/rolltemplate-scatter-diagram.png" style="width: 100%;" alt="scatter diagram"/></th>
</tr>
</table>
</div>
@@ -716,23 +716,29 @@
<tr>
<td class="sheet-grenade-c1 sheet-ignore-inlineroll">Direct hit:<br>({{aoe}} feet diameter)</td>
{{#^rollBetween() computed::hit 0 0}}
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::hitdmg}}</span></td>
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::hitdmg}}!</span></td>
{{/^rollBetween() computed::hit 0 0}}
{{#rollBetween() computed::hit 0 0}}
<td class="sheet-grenade-c4">Miss!<br><span class="sheet-hit-text">({{computed::hitdmg}})</span></td>
<td class="sheet-grenade-c4 sheet-ignore-inlineroll">Miss!<br><span class="sheet-miss-text">({{computed::hitdmg}})</span></td>
{{/rollBetween() computed::hit 0 0}}
</tr>
{{#rollBetween() computed::hit 0 0}}
<tr>
<td class="sheet-grenade-c1 sheet-ignore-inlineroll">Splash hit:<br>({{computed::aoe}} feet diameter)</td>
{{#^rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::splashdmg}}</span></td>
{{/^rollBetween() computed::splash 0 0}}
{{#rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c4">Miss!<br><span class="sheet-hit-text">({{computed::splashdmg}})</span></td>
{{/rollBetween() computed::splash 0 0}}
<!-- Direct hit is true -->
{{#^rollBetween() computed::hit 0 0}}
<td class="sheet-grenade-c5 sheet-ignore-inlineroll sheet-hit-text">Info<br><span class="sheet-miss-text">{{computed::splashdmg}}</span></td>
{{/^rollBetween() computed::hit 0 0}}
<!-- Direct hit is false -->
{{#rollBetween() computed::hit 0 0}}
{{#^rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c3 sheet-ignore-inlineroll">Hit!<br><span class="sheet-hit-text">{{computed::splashdmg}}!</span></td>
{{/^rollBetween() computed::splash 0 0}}
{{#rollBetween() computed::splash 0 0}}
<td class="sheet-grenade-c4 sheet-ignore-inlineroll">Miss!<br><span class="sheet-miss-text">({{computed::splashdmg}})</span></td>
{{/rollBetween() computed::splash 0 0}}
{{/rollBetween() computed::hit 0 0}}
</tr>
{{/rollBetween() computed::hit 0 0}}
</table>
</div>
</div>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 256 KiB

+35 -19
View File
@@ -1062,45 +1062,61 @@ on('change:repeating_ammo:ammoname', function(eventInfo){
setAttrs(weaponInfo);
});
let validGrenade = /1Acid|1Holy water|3Oil (lit)|1Poison|(\d*)#(.*)#(.*)#(.*)/
on('clicked:grenade-miss', function (eventInfo) {
startRoll('&{template:2Egrenademiss} {{grenade=?{What grenade have been thrown?|Acid,[[1Acid]]|Holy water,[[1Holy water]]|Oil (lit),[[3Oil (lit)]]|Poison,[[1Poison]]}}} {{direction=[[1d10]]}} {{distance=?{How far was it throw?|Short,[[1d6]]|Medium,[[1d10]]|Long,[[2d10]]}}} {{aoe=?{What grenade have been thrown?}}} {{hit=[[0]]}} {{hitdmg=[[0]]}} {{splash=[[0]]}} {{splashdmg=[[0]]}}', function(results) {
startRoll('&{template:2Egrenademiss} {{grenade=[[?{What grenade have been thrown?|Acid,1Acid|Holy water,1Holy water|Oil (lit),3Oil (lit)|Poison,1Poison|Other,?{Area of effect&#124;1&#125;#?{Grenade name&#125;#?{Direct damage&#124;1d6&#125;#?{Splash damage&#124;1d3&#125;}]]}} {{direction=[[1d10]]}} {{distance=?{How far was it throw?|Short,[[1d6]]|Medium,[[1d10]]|Long,[[2d10]]}}} {{aoe=[[?{What grenade have been thrown?}]]}} {{hit=[[0]]}} {{hitdmg=[[0]]}} {{splash=[[0]]}} {{splashdmg=[[0]]}}', function(results) {
console.log(results);
let distance = results.results.distance;
let expression = distance.expression;
let displayDistance = '';
switch (expression) {
case '1d6': displayDistance = 'Short'; break;
case '1d10': displayDistance = 'Medium'; break;
case '2d10': displayDistance = 'Long'; break;
default: displayDistance = 'Invalid'; break;
}
let aoeSplash = results.results.aoe.result+6;
let displayGrenade = results.results.grenade.expression.substring(1);
let computedRolls = {
distance: displayDistance,
grenade: displayGrenade,
aoe: aoeSplash,
hit: 0,
splash: 0
};
let grenadeExpression = results.results.grenade.expression;
let match = grenadeExpression.match(validGrenade);
console.log(match);
if (!match) {
finishRoll(results.rollId, computedRolls);
return;
}
switch (grenadeExpression) {
case '1Acid': computedRolls.grenade = 'Acid'; break;
case '1Holy water': computedRolls.grenade = 'Holy water'; break;
case '3Oil (lit)': computedRolls.grenade = 'Oil (lit)'; break;
case '1Poison': computedRolls.grenade = 'Poison'; break;
default: computedRolls.grenade = match[3]; break;
}
let distance = results.results.distance;
switch (distance.expression) {
case '1d6': computedRolls.distance = 'Short'; break;
case '1d10': computedRolls.distance = 'Medium'; break;
case '2d10': computedRolls.distance = 'Long'; break;
default: computedRolls.distance = 'Invalid'; break;
}
let hitDiameter = results.results.aoe.result;
let aoeSplash = computedRolls.aoe = hitDiameter+6;
// See if monster is within direct hit
if (distance.result < results.results.aoe.result / 2) {
if (distance.result <= hitDiameter / 2) {
computedRolls.hit = 1;
} else if (distance.result < aoeSplash / 2) {
} else if (distance.result <= aoeSplash / 2) {
let splashDamage;
computedRolls.splash = 1;
}
switch (displayGrenade) {
switch (grenadeExpression) {
case 'Acid': computedRolls.hitdmg = '2d4 Acid damage'; break;
case 'Holy water': computedRolls.hitdmg = '1d6+1 damage'; break;
case 'Oil (lit)': computedRolls.hitdmg = '2d6/1d6 Fire damage'; break;
case 'Poison': computedRolls.hitdmg = 'Special'; break;
default: computedRolls.hitdmg = match[4]; break;
}
switch (displayGrenade) {
switch (grenadeExpression) {
case 'Acid': computedRolls.splashdmg = '1 Acid damage'; break;
case 'Holy water': computedRolls.splashdmg = '2 damage'; break;
case 'Oil (lit)': computedRolls.splashdmg = '1d3 Fire damage'; break;
case 'Poison': computedRolls.splashdmg = 'Special'; break;
default: computedRolls.splashdmg = match[5]; break;
}
finishRoll(results.rollId, computedRolls);
});
+1 -1
View File
@@ -163,7 +163,7 @@ function migrateOtherValuables() {
newValue['othervalue'] = total;
valuablesFields.forEach(field => {
let oldValue = values[field];
let oldValue = values[field] || '';
if (oldValue) {
if (valuablesString) {
valuablesString += '\n\n';