- Remove Dying when Stable
- Remove Dying, Stable, Unconscious when HP above 0
- Turn off the TempHP, HPdamage and NLD_HP when at max hp and with no temp hp
- I did this so you can update the HP bars by unchecking the mouseover option so, hp bars are only shown for damaged tokens.
||| subUpdateHPStatesBarsAliasmask |||
Code: Select all
[H: gTok = "Lib:GlobalsSRDPF"]
[H: tToken = getStrProp(macro.args, "Token")]
[H: gTokenUncImgChange = getLibProperty("TokenUncImgChange", gTok)]
[H: switchToken(tToken)]
[H, IF(gTokenUncImgChange), CODE: {
[ tImageID = getTokenImage() ]
[ tImageHID = getTokenHandout() ]
[IF( tImageHID != tImageID ): Private = setStrProp(Private, "TokenImageAssetID", tImageID) ]
[ tIAID = getStrProp(Private, "TokenImageAssetID")]
}]
[H: deathpoint = eval( string( getLibProperty( "DeathPoint", gTok ) ) )]
[H: tType = json.get( Race, "type" )]
[H: tSubtype = json.get( Race, "subtype" )]
[H: variantRDP = table( "SysVars", json.get( table( "SysVars", 0 ), "variantRaceDeathPoint" ) ) ]
[H, FOREACH( dp, variantRDP ), CODE: {
[H: tDP = json.get( dp, "deathPoint" )]
[H: typeArray = json.get( dp, "typeArray" )]
[H: subtypeArray = json.get( dp, "subtypeArray" )]
[H, FOREACH( t, typeArray ): deathpoint = if( t == tType, tDP, deathpoint )]
[H, FOREACH( t, subtypeArray ): deathpoint = if( json.contains( tSubtype, t ), tDP, deathpoint )]
}]
[H: tDieHard = getStrProp(Feats, "DieHard")]
[H: tDieHard = if(tDieHard == "", 0, tDieHard)]
[H: disabledPoint = if( tDieHard, deathpoint, 0)]
[H: effectiveHP = HP + HPTemp]
[H: tMaxEffectiveHP = HPmax + HPtemp]
[H: state.Disabled = if((effectiveHP) == 0, 1, 0)]
[H: state.Staggered = if(HPNonLethalDMG == (effectiveHP) && HP > 0, 1, 0)]
[H: active = if( ((effectiveHP) >= HPNonLethalDMG) && ((effectiveHP) >= 0), 1, if( tDieHard, 1, 0) )]
[H: state.Unconscious = if( ( ( (effectiveHP) < 0 ) || ( HPNonLethalDMG > (effectiveHP) ) ) && !tDieHard, 1, state.Unconscious)]
[H: state.Prone = if( active && (state.Prone < 1), 0, 1)]
[H: state.Dying = if(((effectiveHP) > deathpoint) && ((effectiveHP) < 0), 1, 0)]
[H, IF( isNPC() && !tDieHard ): eval(if(state.Dying, 'setLayer("object")', '0'))]
[H: state.StableHP = if(((effectiveHP) >= 0), 0, state.StableHP)]
[H, if(state.StableHP): state.Dying = 0]
[H: state.Dead = if((effectiveHP) <= deathpoint, 1, 0)]
[H, IF(state.Dead), CODE: {
[H: if(isNPC(), setLayer("object"), '0')]
[H: state.Dying = 0]
[H: state.Unconscious = 0]
[H: state.Prone = 0]
[H: state.StableHP = 0]
}]
[H, if(effectiveHP > 0), code: {
[H: state.Dying = 0]
[H: state.Unconscious = 0]
[H: state.StableHP = 0]
};{}]
[H: eval(if(state.Dead, 'removeFromInitiative()', '0'))]
[H, IF( active ): setLayer("token")]
[H: setBarVisible("HP",0)]
[H: setBarVisible("HPM",0)]
[H: setBarVisible("HPNonLethalDMG",0)]
[H: setBarVisible("HPMNonLethalDMG",0)]
[H, if( state.Dead ), code: {
[H: setBarVisible("HPdamage",0)]
[H: setBarVisible("EmptyHP",0)]
};{
[H, if( effectiveHP >= 0 ), code: {
[H: bar.HPdamage = (tMaxEffectiveHP - effectiveHP) / tMaxEffectiveHP]
[H: setBarVisible("EmptyHP",0)]
};{
[H: bar.HPdamage = max(0,(deathPoint - effectiveHP) / deathPoint) ]
[H: bar.EmptyHP = 1]
}]
}]
[H, if( effectiveHP < 0 || state.Dead), code: {
[H: setBarVisible("NLD_HP",0) ]
[H: setBarVisible("TempHP",0) ]
};{
[H: bar.TempHP = bar.HPdamage + (HPtemp / tMaxEffectiveHP) ]
[H: bar.NLD_HP = HPNonLethalDMG / tMaxEffectiveHP ]
}]
[H, if(HP == HPmax && effectiveHP == HP), code: {
[H: "<!-- Turn off all the bars when at max HP with no HP mods -->"]
[H: setBarVisible("TempHP",0)]
[H: setBarVisible("HPdamage",0)]
[H: setBarVisible("NLD_HP",0)]
};{}]
[H, IF(gTokenUncImgChange), CODE: {
[H: tImageID= if( ( state.Dead || state.Unconscious ), getTokenHandout(), tIAID ) ]
[H, IF(tImageID != ""): setTokenImage(tImageID)]
}]