Updated the dmg system. Small typo fixes.

This commit is contained in:
Ricky Martinez
2023-03-16 17:01:17 -05:00
parent 7fd3c16cff
commit 6230d3ec58
+41 -50
View File
@@ -59,13 +59,14 @@
<label title="Tuf. Rolled for life saving throws (poison, drowning, etc.), Strength throws, HPx2, and Inventory slots (if used)">Toughness </label>
<label title="Dex. Rolled for physical feats (attack, climbing/falling, picking locks, etc.)">Dexterity </label>
<label title="IQ. Rolled for magic and mental feats (perception, puzzles, knowledge, etc.)">Intelligence </label>
<label title="F. Rolled for breaking inanaimate objects. Adds to all damage dealt, and is the minimum damage you can do.&#10;1 : d2 | 11 : 2d8&#10;2 : d4 | 12 : d20&#10;3 : d6 | 13 : 2d10&#10;4 : d8 | 14 : 2d11&#10;5 : 2d4 | 15 : 2d12&#10;6 : d10 | 16 : 2d20&#10;7 : 2d5 | | : ''&#10;8 : d12 | | : ''&#10;9 : 2d6 | v : ''&#10;10 : 2d7 | 40 : ''">Ferocity </label>
<label title="F. Rolled for breaking inanaimate objects. Adds to all damage dealt, and is the minimum damage you can do.&#10;0 : d2 | 11 : 2d7&#10;1 : d4 | 12 : 2d8&#10;2 : 2d2 | 13 : d20&#10;3 : d6 | 14 : 2d10&#10;4 : 2d3 | 15 : 2d11&#10;5 : d8 | 16 : 2d12&#10;6 : 2d4 | 17 : 2d13&#10;7 : d10 | 18 : 2d14&#10;8 : 2d5 | 19 : 2d15&#10;9 : d12 | 20 : 2d16&#10;10 : 2d6 | 21+: 2d20">Ferocity </label>
</div>
<div class="valuecolumn">
<input type="number" min="0" max="40" name="attr_con" value="0">
<input type="number" min="0" max="40" name="attr_dx" value="0">
<input type="number" min="0" max="40" name="attr_iq" value="0">
<input type="number" min="0" max="40" name="attr_dmg" value="0">
<input type="hidden" name="attr_dmgroll" value="1d2">
</div>
<div class="valuecolumn">
<button style="height: 18px;" type="roll" title="Roll stat." value="&{template:roll}{{name=@{character_name}}}{{total=[[ [[1d20]] + @{con}[Tuf] ]]}}{{roll=$[[0]]}}{{target=[[@{targetr}]]}}{{stat='Toughness'}}"></button>
@@ -96,9 +97,9 @@
<label title="HP. The hit points you have left.">Hit Points </label>
<label title="This cannot be lower than 5. Derived form Tuf*2">Max HP </label>
<label title="Def, total from Defensive Gear + Dex">Total Defense </label>
<label title="MR. Increases difficulty of Effects that target you (2 points)">Magic Resistance </label>
<label title="The amount of mana you have left. Also listed in your Effects page">Mana </label>
<label title="Used to cast spells. IQ + Bonus (1 point)">Max Mana </label>
<label title="MR. Increases difficulty of Spells that target you (2 points)">Magic Resistance </label>
<label title="The amount of mana you have left. Also listed in your Spells page">Mana </label>
<label title="Used to cast Spells. IQ + Bonus (1 point)">Max Mana </label>
<br>
<label>Silver </label>
</div>
@@ -126,10 +127,10 @@
<label title="The points you have spent on Stats">Stats </label>
<label title="The points you spent on Gear">Gear </label>
<label title="The points you have spent on abilites">Abilities </label>
<label title="Total number of spells. All spells cost 1">Spells </label>
<label title="Total number of Spells. All Spells cost 1">Spells </label>
</div>
<div class="valuecolumn">
<input type="number" name="attr_tw" value="100" style="width: 100px;">
<input type="number" name="attr_tw" value="200" style="width: 100px;">
<input type="number" disabled name="attr_totalspent" value="(@{stats} + @{gears} + @{abilities} + @{spells})" class="x">
<input type="number" disabled name="attr_avail" value="(@{tw}-@{totalspent})" class="x">
<input type="number" disabled name="attr_stats" title="5 points for each stat + 2 points for each MR + a point for each mana." value="((@{con})*5 + (@{dx})*5 + (@{iq})*5 + (@{dmg})*5 + (@{mr})*2 + @{manamax} - @{iq})" class="x">
@@ -139,7 +140,7 @@
<input type="hidden" name="attr_foo_abils" value="0" />
<input type="number" disabled name="attr_abilities" value="@{foo_abils}" class="x">
<input type="hidden" name="attr_foo_spells" value="0" />
<input type="number" title="Total number of spells. All spells cost 1" disabled name="attr_spells" value="@{foo_spells}" class="x">
<input type="number" title="Total number of Spells. All Spells cost 1" disabled name="attr_spells" value="@{foo_spells}" class="x">
</div>
</div>
</div>
@@ -149,7 +150,7 @@
<h3>Attacks</h3>
<div class="weapon">
<label title="Name of the Weapon">Name</label>
<label style="width: 63px;" title="Damage bonus this weapon gives (2 points)&#10;1 : d2 | 11 : 2d8&#10;2 : d4 | 12 : d20&#10;3 : d6 | 13 : 2d10&#10;4 : d8 | 14 : 2d11&#10;5 : 2d4 | 15 : 2d12&#10;6 : d10 | 16 : 2d20&#10;7 : 2d5 | | : ''&#10;8 : d12 | | : ''&#10;9 : 2d6 | v : ''&#10;10 : 2d7 | 40 : ''">Dmg</label>
<label style="width: 63px;" title="Min Dmg this Attack does (2 points) (can't be higher than max possible roll)">Dmg</label>
<label style="width: 68px;" title="Bonus to hit (2 points)">Hit</label>
<label title="Point cost of this weapon">Cost</label>
</div>
@@ -158,7 +159,7 @@
<div class="weapon">
<input type="text" name="attr_weaponname">
<input type="number" name="attr_damage" min="0" value="0">
<button type="roll" style="color: red;" name="attr_dmgbtn" title="Damage after hit" value="[[1d2]]"></button>
<button type="roll" style="color: red;" name="attr_dmgbtn" title="Damage after hit" value="&{template:weapondmg}{{weaponname=@{weaponname}}}{{mindmg=[[@{damage}+?{Mod? (Applies after roll)|0}[Mod]]]}}{{damage=[[@{dmgroll}[F]+?{Mod? (Applies after roll)|0}[Mod]]]}}"></button>
<input type="number" name="attr_acc" value="0">
<button type="roll" title="Use the Weapon" value="&{template:weapon}{{name=@{character_name}}}{{weaponname=@{weaponname}}}{{total=[[ [[1d20]] + @{dx}[Dex] + @{acc}[Acc] ]]}}{{roll=$[[0]]}}"></button>
<button type="roll" style="color: orange;" title="Use the Weapon with mods" value="&{template:weapon}{{name=@{character_name}}}{{weaponname=@{weaponname}}}{{total=[[ [[1d20]] + ?{Modifiers?|0}[Mod] + @{dx}[Dex] + @{acc}[Acc] ]]}}{{roll=$[[0]]}}"></button>
@@ -208,9 +209,9 @@
<div class="weapon">
<label style="width: 170px">Name</label>
<label style="width: 190px" title="Makes ure to put all details in this box (length, bonus, rolls, multipliers, levels, all of it)">Effect</label>
<label style="width: 62px" title="Damage bonus (leave blank if the spell does no damage, put 0 for base damage)">Damage</label>
<label style="width: 63px" title="What you must roll (+ penalties) to use the spell">Difficulty</label>
<label style="width: 85px" title="Cost to cast the spell, derived from difficulty (5-9 = 0, 10-14 = 1, 15-19 = 2, 20-24 = 3, etc.).">Mana/Action Cost</label>
<label style="width: 62px" title="Min Dmg this Spell does (2 points) (can't be higher than max possible roll)">Damage</label>
<label style="width: 63px" title="What you must roll (+ penalties) to use the Spell">Difficulty</label>
<label style="width: 85px" title="Cost to cast the Spell, derived from difficulty (5-9 = 0, 10-14 = 1, 15-19 = 2, 20-24 = 3, etc.).">Mana/Action Cost</label>
</div>
<div class="weapon">
<button title="This will set all uses to their max use" type="action" name="act_restoreall">Restore Mana</button>
@@ -222,11 +223,11 @@
<input type="text" name="attr_weaponname" title="Name of the Spell">
<textarea type="text" name="attr_spelleffect" title="Effect of the Spell"></textarea>
<input type="number" name="attr_damage" min="0" value="">
<button style="height: 24px; color: red;" type="roll" name="attr_dmgbtn" title="Damage after hit" value="[[1d2]]]"></button>
<button style="height: 24px; color: red;" type="roll" name="attr_dmgbtn" title="Damage after hit" value="&{template:weapondmg}{{weaponname=@{weaponname}}}{{mindmg=[[@{damage}+?{Mod? (Applies after roll)|0}[Mod]]]}}{{damage=[[@{dmgroll}[F]+?{Mod? (Applies after roll)|0}[Mod]]]}}"></button>
<button style="height: 24px;" type="roll" title="Use the Spell" value="&{template:spell}{{name=@{character_name}}}{{weaponname=@{weaponname}}}{{cost=@{cost}}}{{total=[[ [[1d20]] + ?{Modifiers?|0}[Mod] + @{iq}[IQ] ]]}}{{roll=$[[0]]}}{{diff=[[@{spelldiff}]]}}{{effect=@{spelleffect}}}"></button>
<input type="number" min="5" max="60" name="attr_spelldiff" value="5">
<input type="hidden" name="attr_foo_cost" value="0">
<input type="number" disabled name="attr_cost" title="Cost to cast the spell, derived from difficulty." value="@{foo_cost}">
<input type="number" disabled name="attr_cost" title="Cost to cast the Spell, derived from difficulty." value="@{foo_cost}">
</div>
</fieldset>
</div>
@@ -269,26 +270,10 @@
});
});
const dmgTable = ["1d2","1d4","1d6","1d8","2d4","1d10","2d5","1d12","2d6","2d7","2d8","1d20","2d10","2d11","2d12","2d20"];
//const spellCostTable = [.1, .2, .2, .333333, .333333, .333333, .5, .5, .5, .5, 1, 1, 1, 1, 1, 2, 3,3,3,3,3, 4,4,4,4,4, 5,5,5,5,5 ,6,6,6,6,6 ,7,7,7,7,7 ,8,8,8,8,8,8
//,9,9,9,9,9 ,10,10,10,10,10];
function getDamageRollStr(dmgAttr, callback){
getAttrs([
"dmg", dmgAttr
]
, function(values) {
const dmgV = Math.min(15, Math.max(0, sumFieldValues(values)-1));
callback(dmgTable[dmgV]);
});
}
const dmgTable = ["1d2","1d4","2d2","1d6", "2d3","1d8","2d4","1d10","2d5","1d12","2d6","2d7","2d8","1d20","2d10","2d11","2d12","2d13", "2d14", "2d15", "2d16", "2d20"];
function getCostOfSpell(spellDiff){
return Math.floor(parseInt(spellDiff)/5) - 1;
//const mult = spellCostTable[parseInt(spellDiff)-5];
//const fullCost = Math.ceil(mult*parseInt(maxUses))
//return [fullCost, Math.max(1,Math.round(fullCost*(1/mult)))];
}
@@ -296,10 +281,6 @@
getAttrs( ["mana", "iq", "manamax"]
, function(values) {
const minMana = Math.max(parseInt(values.iq), parseInt(eventInfo.newValue));
console.log(minMana);
console.log(parseInt(values.iq));
console.log(parseInt(values.manamax));
console.log(parseInt(values.mana));
setAttrs({"mana": (parseInt(values.mana) + (minMana - (parseInt(eventInfo.previousValue)||0))), "manamax":minMana}, {silent:true});
});
});
@@ -320,19 +301,28 @@
});
});
// Changing f
on("change:dmg", function(eventInfo) {
setAttrs({
"dmgroll": dmgTable[Math.min(21, eventInfo.newValue)]
}
, {silent:true}
);
});
// Changing damage
on("change:repeating_weapons change:repeating_spells", function(eventInfo) {
const btndmgAttr = eventInfo.triggerName + "_dmgbtn";
//document.getElementsByName(btndmgAttr)[0].disabled = false;
// set the attribute to a template with the updated die roll
let templateStr = "&{template:weapondmg}{{weaponname=@{weaponname}}}{{mindmg=[[@{dmg}+?{Mod? (Applies to min & dmg)|0}]]}}{{damage=[[";
getDamageRollStr(eventInfo.triggerName + "_damage", function(dmgroll){
templateStr += dmgroll + "+?{Mod? (Applies to min & dmg)|0}]]}}";
setAttrs({
[btndmgAttr]: templateStr
on("change:repeating_weapons:damage change:repeating_spells:damage", function(eventInfo) {
getAttrs( ["dmgroll"]
, function(values) {
const splitVal = values.dmgroll.split("d");
const maxMinDmg = parseInt(splitVal[0])*parseInt(splitVal[1]);
if(parseInt(eventInfo.newValue) > maxMinDmg){
let attrsToSend = {};
attrsToSend[eventInfo.sourceAttribute] = maxMinDmg;
setAttrs(attrsToSend
, {silent:true}
);
}
, {silent:true}
);
});
});
@@ -535,9 +525,10 @@
<td>
{{damage}}
{{#rollLess() damage mindmg}}
Damage cannot be below Ferocity: {{mindmg}}
Damage cannot be below Ferocity: <strong style="color: green;">{{mindmg}}</strong>
{{/rollLess() damage mindmg}}
- DR
<br>
Subtract location DR
</td>
</tr>
</table>
@@ -579,7 +570,7 @@
<table>
<tr>
<th>
{{name}} attempts to cast spell {{weaponname}} Difficulty: {{diff}}
{{name}} attempts to cast Spell {{weaponname}} Difficulty: {{diff}}
</th>
</tr>
<tr>
@@ -599,7 +590,7 @@
{{#rollTotal() roll 1}}
<strong style="color: red;">CRIT FAIL!</strong> ({{roll}}) <br>
Your attack auto fails, succeed a "high or low" or your spell backfires. This also wastes mana.
Your attack auto fails, succeed a "high or low" or your Spell backfires. This also wastes mana.
{{/rollTotal() roll 1}}
{{#rollBetween() roll 2 19}}