Added support for Lore Skills, Perception and Initiative. Additional skill and saves icons

This commit is contained in:
kyamsil
2021-08-25 23:10:39 +01:00
parent 7bd06d7797
commit c01f9ec566
13 changed files with 64 additions and 12 deletions

View File

@@ -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
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
img/token/abilities/ref.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -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
sur.png: https://game-icons.net/1x1/delapouite/pyre.html
thi.png: https://game-icons.net/1x1/delapouite/lock-picking.html

BIN
img/token/skills/cra.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/token/skills/dip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
img/token/skills/occ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
img/token/skills/soc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
img/token/skills/thi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -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<otherSpeeds.length; i++)
speed += `\n${otherSpeeds[i].type}: ${otherSpeeds[i].value}`;
for (let os of otherSpeeds)
speed += `\n${os.type} ${os.total}'`;
return speed;
}
getInitiative(token) {
let initiative = token.actor.data.data.attributes.init.value;
return (initiative >= 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);
}
/**

View File

@@ -221,6 +221,11 @@ export class TokenHelper{
return this.system.getResilience(token)
}
/* PF2E */
getPerception(token) {
return this.system.getPerception(token)
}
/**
* Conditions
*/

View File

@@ -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) {