Skip to content

Commit

Permalink
soak update with new system property path for bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
SalieriC committed May 27, 2023
1 parent be7d2c6 commit 31a9a2f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
☮️ Peace in the world, or the world in pieces. 🕊️
### Added
- New translation strings, Radiation Centre is now fully localised.
- Support for the Soak Bonus modifier in SWADE. The Soak macro tries to exclude edges which are already set up with an Active Effect but that's not a fuzzy search so it will only exclude its own Edge findings if the edges corresponding AE is named *exactly* like the edge itself. Otherwise it will add the bonus twice. There is no real way around it as it could cause false matchings if I were to introduce a fuzzy search.
### Changed
- Mighty Summoner will now summon tokens without actor link to prevent changes to the original actor. This means GMs don't have to unlink the prototype tokens manually anymore.
- Overhauled the Radiation Centre Macro:
- - Radiation Centre doesn't add a condition for Fatigue from radiation any longer (see below). This deprecation was needed as the new SUCC version doesn't currently have API support to add conditions. This makes the macro work closer to RAW however.
- - Radiation Centre *does* however add an Active Effect if the actor becomes Incapacitated from radiation: As in core this AE represents a chronic disease. A chat message will be created in this case.
### Fixed
- Bug in the Radiation Centre which made it non-functional for NPCs.
- Bugs in Ammo Management resulting from the overhaul in SWADE.
### Deprecated
- The Irradiated condition was deprecated to suit the new SUCC version better.
- Combat setup button as the function behind it is a little buggy and due for an overhaul. Let me know if anyone ever used it, otherwise it won't be a priority.
Expand Down
50 changes: 47 additions & 3 deletions swim/scripts/swim_modules/soak_damage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************
* Soak Damage
* v. 5.2.5
* v. 5.3.0
* Code by SalieriC#8263.
*******************************************/
export async function soak_damage_script(effect = false) {
Expand Down Expand Up @@ -75,9 +75,53 @@ export async function soak_damage_script(effect = false) {
});
let rollWithEdge = r.total;
let edgeText = "";

//Get generic actor unstun bonus and check if it is from an AE:
const soakBonus = token.actor.system.attributes.vigor.soakBonus
let effectName = []
let effectIcon = []
let effectValue = []
let soakBonusFromEffects = 0
if (token.actor.effects.size > 0) {
for (let effect of token.actor.effects) {
if (effect.disabled === false && !edgeNames.includes(effect.label)) { // only apply changes if effect is enabled and not made by a recognised Edge.
for (let change of effect.changes) {
if (change.key === "system.attributes.vigor.soakBonus") {
//Building array of effect names and icons that affect the unStunBonus
effectName.push(effect.label)
effectIcon.push(effect.icon)
effectValue.push(change.value)
soakBonusFromEffects += change.value
}
}
}
}
for (let i = 0; i < effectName.length; i++) {
// Apply mod using parseFloat() to make it a Number:
rollWithEdge += parseFloat(effectValue[i]);
// Change indicator in case the modifier from AE is negative:
let indicator = "+";
let effectMod = effectValue[i];
if (parseFloat(effectValue[i]) < 0) {
indicator = "-";
effectMod = effectValue[i].replace("-", "");
}
edgeText += `<br/><i>${indicator} ${effectMod} <img src="${effectIcon[i]}" alt="" width="15" height="15" style="border:0" />${effectName[i]}</i>`;
}
} if (soakBonus > soakBonusFromEffects) { //Add remaining UnstunBonus if it is bigger than those from AEs:
const remainingBonus = soakBonus - soakBonusFromEffects
rollWithEdge += parseFloat(remainingBonus);
edgeText += `<br/><i>+ ${remainingBonus} Generic Bonus</i>`;
}

//Now check for edges but don't include them if they are already covered by AEs:
for (let edge of edges) {
rollWithEdge += 2;
edgeText += `<br/><em>+ 2 <img src="${edge.img}" alt="" width="15" height="15" style="border:0" />${edge.name}</em>`;
//Only add if the edge name is not included in effect names:
const lowercaseEffectNames = effectName.map(element => element.toLowerCase())
if (!lowercaseEffectNames.includes(edge.name.toLowerCase())) { //This is deliberately not a fuzzy search as that could cause issues.
rollWithEdge += 2;
edgeText += `<br/><em>+ 2 <img src="${edge.img}" alt="" width="15" height="15" style="border:0" />${edge.name}</em>`;
}
}

// If Holy Warrior or Unholy Warrior is used: Include the amount of PPs used as a bonus to the roll.
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 6887d4 to 9ed27c

0 comments on commit 31a9a2f

Please sign in to comment.