Active Effects - toastygm/HarnMaster-3-FoundryVTT GitHub Wiki
Macros
When writing macros for Active Effects, you must understand the data structures under the Active Effects. Please review the Foundry VTT API documentation for Active Effects:
- ActiveEffect: The top-level Active Effect class.
- ActiveEffectData: The data structure defining an Active Effect.
- EffectChangeData: The data structure defining the specific effects (see below).
- EffectDurationData: The data structure defining the duration of the Active Effect.
EffectChangeData Data Structure
This data structure defines what affects to apply. The ActiveEffectData takes an array of these EffectChangeData records. This data structure is composed of three parts (key, value, mode, and optionally priority).
Key
This is the specific field that needs to be modified by the effect. The following fields are defined:
| Field | Key |
|---|---|
| Melee Attacks | data.eph.meleeAMLMod |
| Melee Defenses | data.eph.meleeDMLMod |
| Missile Attacks | data.eph.missileAMLMod |
| Outnumbered | data.eph.outnumbered |
| Weapon Attack ML | data.eph.itemAMLMod |
| Weapon Defense ML | data.eph.itemDMLMod |
| Communication Skills EML | data.eph.commSkillsMod |
| Physical Skills EML | data.eph.physicalSkillsMod |
| Combat Skills EML | data.eph.combatSkillsMod |
| Craft Skills EML | data.eph.craftSkillsMod |
| Ritual Skills EML | data.eph.ritualSkillsMod |
| Magic Skills EML | data.eph.magicSkillsMod |
| Psionic Talents EML | data.eph.psionicTalentsMod |
| Universal Penalty | data.universalPenalty |
| Physical Penalty | data.physicalPenalty |
| Fatigue | data.eph.fatigue |
| Encumbrance | data.encumbrance |
| Endurance | data.endurance |
| Injury Level | data.eph.totalInjuryLevels |
| Move | data.eph.move |
| Strength | data.eph.strength |
| Stamina | data.eph.stamina |
| Dexterity | data.eph.dexterity |
| Agility | data.eph.agility |
| Eyesight | data.eph.eyesight |
| Hearing | data.eph.hearing |
| Smell | data.eph.smell |
| Voice | data.eph.voice |
| Intelligence | data.eph.intelligence |
| Will | data.eph.will |
| Aura | data.eph.aura |
| Morality | data.eph.morality |
| Comeliness | data.eph.comeliness |
Mode
This is one of the following values:
| Mode | Value |
|---|---|
| MULTIPLY | 1 |
| ADD | 2 |
| DOWNGRADE | 3 |
| UPGRADE | 4 |
| OVERRIDE | 5 |
Example 1: Create a new Active Effect
In this example we create a new active effect on actor "targetActor" that represents a sort of berserk mode:
- Lasts 10 rounds
- Reduced sensitivity to injury (only affected by 50% of Injury Levels)
- Increase Melee AML by 20
- Decrease Melee DML by 20
const result = await ActiveEffect.create({
label: "Berserk",
icon: "systems/hm3/images/icons/svg/beams-aura.svg",
origin: targetActor.uuid,
duration: {
startTurn: game.combat.data.turn,
startRound: game.combat.data.round,
rounds: 10
},
changes: [
{ key: 'data.eph.totalInjuryLevels', value: 0.5, mode: 1 },
{ key: 'data.eph.meleeDMLMod', value: -20, mode: 2 },
{ key: 'data.eph.meleeAMLMod', value: 20, mode: 2 }
]
}, {parent: targetActor});
if (result) console.log(`Active Effect Berserk created!`);
Example 2: Enable an existing Active Effect
In this example, we find an existing Active Effect named "Berserk" on targetActor and activate it. If "Berserk" is not found, nothing happens.
const ae = targetActor.effects.find(m => m.data.label === "Berserk");
if (ae) {
// Enable the Active Effect
const result = await ae.update({
disabled: false
duration: {
startTurn: game.combat.data.turn,
startRound: game.combat.data.round,
}
});
if (result) console.log(`Active Effect Berserk activated!`);
}