mclemente / fvtt-condition-lab-triggler

Condition Lab & Triggler module for Foundry Virtual Tabletop
GNU General Public License v3.0
6 stars 4 forks source link

Incapacitated and Poisoned applied twice. #42

Closed aecorn closed 6 months ago

aecorn commented 6 months ago

Describe the bug When running a macro to add "inebration points", which should apply conditions at certain levels, the existing "Poisoned" and "Incapacitated" conditions are added twice.

To Reproduce Steps to reproduce the behavior:

  1. Make the conditions "Tipsy", "Drunk" and "Wasted" in Conditions Lab
  2. Select an actor in a scene
  3. Run the following macro a number of times till you hit the actors con-score. (See level update in console.)
  4. See that certain conditions are added twice
const con_mod = token.actor.system.abilities.con.mod;
const con_score = token.actor.system.abilities.con.value;
let level = token.actor.inebriation_level;

if (level === undefined || level === 0) {
    token.actor.inebriation_level = 1;
    level = 1;
    if (con_mod === 0){
        await game.clt.applyCondition("Tipsy", token.actor, {allowDuplicates: false, replaceExisting: true});
        console.log("Added Tipsy");
    }
}
else {
    level = 1 + level;
    token.actor.inebriation_level = level;
}
if (level === con_mod && con_mod > 0){
    await game.clt.applyCondition("Tipsy", token.actor, {allowDuplicates: false, replaceExisting: true});
    console.log("Added Tipsy");
}
if (level === Math.floor(con_score / 2)){
    await game.clt.applyCondition("Drunk", token.actor, {allowDuplicates: false, replaceExisting: true});
    console.log("Added Drunk");
}
if (level === (10 + con_mod)){
    await game.clt.applyCondition(["Wasted", "Poisoned"], token.actor, {allowDuplicates: false, replaceExisting: true});
    console.log("Added Wasted and Poisoned");
}
if (level === con_score){
    await game.clt.applyCondition("Incapacitated", token.actor, {allowDuplicates: false, replaceExisting: true});
    console.log("Adding incapacitated.");
}
console.log(token.actor.inebriation_level);

Expected behavior Expect that Incapacitated and Poisoned are added only once

Screenshots

Screenshot 2024-03-19 at 08 21 50

Environment Info (please complete the following information):

Additional context Tips on where to store the "inebration_level" attribute in the actor is welcomed.

aecorn commented 6 months ago

Found the correct setting. "Remove default status effects"