diff --git a/Star Wars Saga Edition/StarWarsSagaEdition.html b/Star Wars Saga Edition/StarWarsSagaEdition.html index 4d87bb4e95..f76c48323e 100644 --- a/Star Wars Saga Edition/StarWarsSagaEdition.html +++ b/Star Wars Saga Edition/StarWarsSagaEdition.html @@ -112,6 +112,10 @@  /  +
Second Wind
+ + +
Threshold
Total Defense Misc @@ -3563,6 +3567,36 @@ on("change:armorprof change:armordefense change:imparmordefense change:armorref on("change:armorperception", function() { ArmorPerception(); }); +on("change:hp_max change:con", function() { + //sheetworker triggers on any changes to the "hp_max" or "con" attribute + getAttrs(["hp_max","CON"], function(values) { + //get the values for the two attributes, so they can used. + let hp_max = parseInt(values.hp_max)||0; + let con = parseInt(values.CON)||0; + //saves the current values of the two attributes on two temporary variables, which then can be used easily in calculations. + if(Math.floor((hp_max / 4)) > con) {SecondWindValue = Math.floor((hp_max / 4));} else {SecondWindValue=con} + // Selects which is higher con score of 1/4 of health + setAttrs({ + "Second_Wind": SecondWindValue + // changes the "Second_Wind" sheet attribute to be the value of our temporary variable "SecondWindValue" + }); + }); +}); +on("clicked:SecondWind", function() { + // Check if characters health is below half and if so apply second wind + getAttrs(["hp_max","hp", "Second_Wind"], function(values) { + // get the hp, hp_max, second wind stat, and coerce into a numerical values. + let hp_max = +values.hp_max || 0; + let hp = +values.hp || 0; + let Second_Wind = +values.Second_Wind || 0; + // If the character is equal or less than half health then add the value of second wind to current hit points + if (hp <= (hp_max*0.5)) {hp_value = Second_Wind + hp ;} else {hp_value = hp} + // save the updated attribute to the sheet + setAttrs({ + "hp": hp_value + }); + }); +}); // ====== Vehicle Sheet ====== \\ on("change:vehicle-size", function() { diff --git a/Star Wars Saga Edition/translation.json b/Star Wars Saga Edition/translation.json index 5504acb722..b69217cc10 100644 --- a/Star Wars Saga Edition/translation.json +++ b/Star Wars Saga Edition/translation.json @@ -56,4 +56,5 @@ "int":"INT", "wis":"WIS", "cha":"CHA", -"flatfooted":"Flatfooted"} \ No newline at end of file +"flatfooted":"Flatfooted", +"second-wind":"Second Wind"} \ No newline at end of file