Skip to content

Commit

Permalink
await more in effect application
Browse files Browse the repository at this point in the history
depending on lag, if no await here could cause midi to remove an effect as things were not resolved in the right order, this was typoically when midi is doing concentration automation
  • Loading branch information
MrPrimate committed May 26, 2023
1 parent 575d657 commit e54ac3d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,8 @@ Spikegrowth example macro fixed.
# 0.6.1

- Effects which had previously been marked as active auras and had ignore self checked, but were no longer marked as active effects would cause the effect to not be applied to the actor.

# 0.6.2

- When applying effects via a template and targetting larger numbers of creatures, due to some timing issues, midi could decide that the effect had expired and remove the effect. Certain auras will now await more, which might increase some auras processing time.
- ActiveAuras was not exported through the legacy window mode.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- Auras will only work in combat unless the setting is turned off in the module settings
- Auras will only work on the Active Scene

Active Auras will propagate Active Effects that are labeled as auras onto nearby tokens.
Active Auras will propagate Active Effects that are labeled as auras onto nearby tokens.
The distance and targeting of the aura are both configurable.
Any ```@``` fields from DAE will be correctly parsed before being applied to the effected token.
Macros from DAE will fire once when applied and once when removed (work is being done for damage over time effects)
Expand All @@ -16,7 +16,7 @@ The "Apply while inactive" option allows for effects to propagate to other token
- We set the radius as 10 (measure in ft)
![Active Auras setup](https://github.com/kandashi/Active-Auras/blob/main/Images/Aura%20of%20protection.PNG)

- We then move to Effect tab and add the relevant field. Make sure to use `+` in the field.
- We then move to Effect tab and add the relevant field. Make sure to use `+` in the field.
![Active Auras setup 2](https://github.com/kandashi/Active-Auras/blob/main/Images/Aura%20of%20protection%202.PNG)

-Finally we can see the effect has been transfered over to a nearly allied PC, and the `@` field has been converted to the correct value
Expand All @@ -31,15 +31,15 @@ The "Apply while inactive" option allows for effects to propagate to other token
![Active Aura Test](https://github.com/kandashi/Active-Auras/blob/main/Images/ActiveAuras%20test2.gif)

## DAE Macro Executes
- Using `@token` as a macro argument will now refer to the token the aura is applied to, you can use this in any DAE auras as normal
- Using `@token` as a macro argument will now refer to the token the aura is applied to, you can use this in any DAE auras as normal


## Compatability
- Works with DAE as far as I know
- Works with DAE
- Multi Level Token should work fine, clones actors are ignored for purposes of calculating auras

## Templates and drawings
- Any template effect can now call a AA macro (included in the compendium) in the Midi QoL OnUse field to apply any active effects to the template rather than the targeted tokens.
- Any template effect can now call a AA macro (included in the compendium) in the Midi QoL OnUse field to apply any active effects to the template rather than the targeted tokens.
- This template will then act as its own source of an aura, any tokens that move inside the template will have the aura applied to them (not radius from the placement)
- For setting up auras like this, simply call the "AA ApplyEffectsToTemplate" macro in Midi QoL OnUse, any effects in the item will be applied to the aura
- Auras can now be added to drawings through macros and will apply via the same logic as templates
Expand Down
6 changes: 3 additions & 3 deletions src/lib/AAHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ export class AAHelpers {
}
}

static UserCollateAuras(sceneID, checkAuras, removeAuras, source) {
static async UserCollateAuras(sceneID, checkAuras, removeAuras, source) {
CONFIG.AA.GM = game.users.find((u) => u.isGM && u.active);
CONFIG.AA.Socket.executeAsUser("userCollate", CONFIG.AA.GM.id, sceneID, checkAuras, removeAuras, source);
await CONFIG.AA.Socket.executeAsUser("userCollate", CONFIG.AA.GM.id, sceneID, checkAuras, removeAuras, source);
}

/**
Expand Down Expand Up @@ -365,7 +365,7 @@ export class AAHelpers {
}
Logger.debug("Applying template effect", templateEffectData);
await template.document.setFlag("ActiveAuras", "IsAura", templateEffectData);
AAHelpers.UserCollateAuras(canvas.scene.id, true, false, "spellCast");
await AAHelpers.UserCollateAuras(canvas.scene.id, true, false, "templateApply");
return { haltEffectsApplication: true };
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/AAMeasure.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AAMeasure {
const grid = canvas?.scene?.grid?.size;
if (!grid) return false;
const templatePos = { x: templateDetails.x, y: templateDetails.y };
// Check for center of each square the token uses.
// Check for center of each square the token uses.
// e.g. for large tokens all 4 squares
const startX = token.document.width >= 1 ? 0.5 : token.document.width / 2;
const startY = token.document.height >= 1 ? 0.5 : token.document.height / 2;
Expand Down
7 changes: 4 additions & 3 deletions src/lib/CollateAuras.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function CollateAuras(sceneID, checkAuras, removeAuras, source) {
);
return;
}
Logger.debug(source);
Logger.debug(`CollateAuras called for ${source}`);
const effectArray = [];

for (const t of canvas.tokens.placeables) {
Expand Down Expand Up @@ -92,12 +92,13 @@ export async function CollateAuras(sceneID, checkAuras, removeAuras, source) {
Logger.debug("CONFIG.AA.Map", CONFIG.AA.Map);

if (checkAuras) {
ActiveAuras.MainAura(undefined, "Collate auras", canvas.id);
await ActiveAuras.MainAura(undefined, "Collate auras", canvas.id);
}
if (removeAuras) {
Logger.debug("CollateAuras delete", { map: CONFIG.AA.Map });
AAHelpers.RemoveAppliedAuras();
await AAHelpers.RemoveAppliedAuras();
}
Logger.debug(`CollateAuras finished for ${source}`);
}

function RetrieveTemplateAuras(effectArray) {
Expand Down

0 comments on commit e54ac3d

Please sign in to comment.