diff --git a/img/token/abilities/SOURCES.txt b/img/token/abilities/SOURCES.txt index 583383b..7d97530 100644 --- a/img/token/abilities/SOURCES.txt +++ b/img/token/abilities/SOURCES.txt @@ -4,4 +4,7 @@ dex.png: https://game-icons.net/1x1/darkzaitzev/acrobatic.html cons.png: https://game-icons.net/1x1/zeromancer/heart-plus.html int.png: https://game-icons.net/1x1/lorc/bookmarklet.html wis.png: https://game-icons.net/1x1/delapouite/wisdom.html -cha.png: https://game-icons.net/1x1/lorc/icicles-aura.html \ No newline at end of file +cha.png: https://game-icons.net/1x1/lorc/icicles-aura.html +fort.png: https://game-icons.net/1x1/delapouite/rock-golem.html +ref.png: https://game-icons.net/1x1/lorc/dodging.html +will.png: https://game-icons.net/1x1/lorc/meditation.html \ No newline at end of file diff --git a/img/token/abilities/fort.png b/img/token/abilities/fort.png new file mode 100644 index 0000000..33dee76 Binary files /dev/null and b/img/token/abilities/fort.png differ diff --git a/img/token/abilities/ref.png b/img/token/abilities/ref.png new file mode 100644 index 0000000..c78ce39 Binary files /dev/null and b/img/token/abilities/ref.png differ diff --git a/img/token/abilities/will.png b/img/token/abilities/will.png new file mode 100644 index 0000000..e78273c Binary files /dev/null and b/img/token/abilities/will.png differ diff --git a/img/token/skills/SOURCES.txt b/img/token/skills/SOURCES.txt index 0d2fb22..a3317cf 100644 --- a/img/token/skills/SOURCES.txt +++ b/img/token/skills/SOURCES.txt @@ -3,17 +3,22 @@ acr.png: https://game-icons.net/1x1/delapouite/contortionist.html ani.png: https://game-icons.net/1x1/delapouite/cavalry.html arc.png: https://game-icons.net/1x1/delapouite/spell-book.html ath.png: https://game-icons.net/1x1/lorc/muscle-up.html +cra.png: https://game-icons.net/1x1/lorc/sword-smithing.html dec.png: https://game-icons.net/1x1/delapouite/convince.html +dip.png: https://game-icons.net/1x1/delapouite/shaking-hands.html his.png: https://game-icons.net/1x1/delapouite/backward-time.html ins.png: https://game-icons.net/1x1/lorc/light-bulb.html itm.png: https://game-icons.net/1x1/lorc/one-eyed.html inv.png: https://game-icons.net/1x1/lorc/magnifying-glass.html med.png: https://game-icons.net/1x1/delapouite/first-aid-kit.html nat.png: https://game-icons.net/1x1/delapouite/forest.html +occ.png: https://game-icons.net/1x1/skoll/pentacle.html prc.png: https://game-icons.net/1x1/lorc/semi-closed-eye.html prf.png: https://game-icons.net/1x1/lorc/sing.html per.png: https://game-icons.net/1x1/delapouite/public-speaker.html rel.png: https://game-icons.net/1x1/lorc/holy-grail.html +soc.png: https://game-icons.net/1x1/delapouite/trumpet-flag.html slt.png: https://game-icons.net/1x1/lorc/snatch.html ste.png: https://game-icons.net/1x1/lorc/cloak-dagger.html -sur.png: https://game-icons.net/1x1/delapouite/pyre.html \ No newline at end of file +sur.png: https://game-icons.net/1x1/delapouite/pyre.html +thi.png: https://game-icons.net/1x1/delapouite/lock-picking.html \ No newline at end of file diff --git a/img/token/skills/cra.png b/img/token/skills/cra.png new file mode 100644 index 0000000..0b1115e Binary files /dev/null and b/img/token/skills/cra.png differ diff --git a/img/token/skills/dip.png b/img/token/skills/dip.png new file mode 100644 index 0000000..ed17945 Binary files /dev/null and b/img/token/skills/dip.png differ diff --git a/img/token/skills/occ.png b/img/token/skills/occ.png new file mode 100644 index 0000000..d92dda5 Binary files /dev/null and b/img/token/skills/occ.png differ diff --git a/img/token/skills/soc.png b/img/token/skills/soc.png new file mode 100644 index 0000000..cf85e97 Binary files /dev/null and b/img/token/skills/soc.png differ diff --git a/img/token/skills/thi.png b/img/token/skills/thi.png new file mode 100644 index 0000000..ac12c64 Binary files /dev/null and b/img/token/skills/thi.png differ diff --git a/src/systems/pf2e.js b/src/systems/pf2e.js index 6cf531d..f020adf 100644 --- a/src/systems/pf2e.js +++ b/src/systems/pf2e.js @@ -31,17 +31,23 @@ export class pf2e{ } getSpeed(token) { - let speed = token.actor.data.data.attributes.speed.breakdown; + let speed = `${token.actor.data.data.attributes.speed.total}'`; const otherSpeeds = token.actor.data.data.attributes.speed.otherSpeeds; if (otherSpeeds.length > 0) - for (let i=0; i= 0) ? `+${initiative}` : initiative; + let initiativeModifier = token.actor.data.data.attributes?.initiative.totalModifier; + let initiativeAbility = token.actor.data.data.attributes?.initiative.ability; + if (initiativeModifier > 0) { + initiativeModifier = `+${initiativeModifier}`; + } else { + initiativeModifier = this.getPerception(token); //NPCs won't have a valid Initiative value, so default to use Perception + } + return (initiativeAbility != '') ? `(${initiativeAbility}): ${initiativeModifier}` : `(perception): ${initiativeModifier}`; } toggleInitiative(token) { @@ -56,6 +62,11 @@ export class pf2e{ return; } + getPerception(token) { + let perception = token.actor.data.data.attributes?.perception.totalModifier; + return (perception >= 0) ? `+${perception}` : perception; + } + getAbility(token, ability) { if (ability == undefined) ability = 'str'; return token.actor.data.data.abilities?.[ability].value; @@ -78,10 +89,24 @@ export class pf2e{ getSkill(token, skill) { if (skill == undefined) skill = 'acr'; + if (skill.startsWith('lor')) { + const index = parseInt(skill.split('_')[1])-1; + const loreSkills = this.getLoreSkills(token); + if (loreSkills.length > index) { + return `${loreSkills[index].name}: +${loreSkills[index].totalModifier}`; + } else { + return ''; + } + } const val = token.actor.data.data.skills?.[skill].totalModifier; return (val >= 0) ? `+${val}` : val; } + getLoreSkills(token) { + const skills = token.actor.data.data.skills; + return Object.keys(skills).map(key => skills[key]).filter(s => s.lore == true); + } + getProficiency(token) { return; } @@ -157,20 +182,33 @@ export class pf2e{ * Roll */ roll(token,roll,options,ability,skill,save) { - if (roll == undefined) roll = 'ability'; + if (roll == undefined) roll = 'skill'; if (ability == undefined) ability = 'str'; if (skill == undefined) skill = 'acr'; if (save == undefined) save = 'fort'; - - if (roll == 'ability') token.actor.data.data.abilities?.[ability].roll(options); + if (roll == 'perception') token.actor.data.data.attributes.perception.roll(options); + if (roll == 'initiative') token.actor.rollInitiative(options); + if (roll == 'ability') token.actor.rollAbility(options, ability); else if (roll == 'save') { let ability = save; if (ability == 'fort') ability = 'fortitude'; else if (ability == 'ref') ability = 'reflex'; else if (ability == 'will') ability = 'will'; - token.actor.data.data.saves?.[ability].roll(options); + token.actor.rollSave(options, ability); + } + else if (roll == 'skill') { + if (skill.startsWith('lor')) { + const index = parseInt(skill.split('_')[1])-1; + const loreSkills = this.getLoreSkills(token); + if (loreSkills.length > index) { + let loreSkill = loreSkills[index]; + skill = loreSkill.shortform == undefined? loreSkills[index].expanded : loreSkills[index].shortform; + } else { + return; + } + } + token.actor.data.data.skills?.[skill].roll(options); } - else if (roll == 'skill') token.actor.data.data.skills?.[skill].roll(options); } /** diff --git a/src/systems/tokenHelper.js b/src/systems/tokenHelper.js index 028dd0c..72e44f0 100644 --- a/src/systems/tokenHelper.js +++ b/src/systems/tokenHelper.js @@ -221,6 +221,11 @@ export class TokenHelper{ return this.system.getResilience(token) } + /* PF2E */ + getPerception(token) { + return this.system.getPerception(token) + } + /** * Conditions */ diff --git a/src/token.js b/src/token.js index 664b8a8..617644a 100644 --- a/src/token.js +++ b/src/token.js @@ -153,6 +153,7 @@ export class TokenControl{ else if (stats == 'Advantage') txt += tokenHelper.getAdvantage(token) /* WFRP4e */ else if (stats == 'Resolve') txt += tokenHelper.getResolve(token) /* WFRP4e */ else if (stats == 'Resilience') txt += tokenHelper.getResilience(token) /* WFRP4e */ + else if (stats == 'Perception') txt += tokenHelper.getPerception(token) /* PF2E */ else if (stats == 'Condition') { /* PF2E */ const valuedCondition = tokenHelper.getConditionValue(token, settings.condition); if (valuedCondition != undefined) {