- Damage is of two types: Stun, or Lethal
- There are three types of 'Hit Points'; Armor, Stun, and Lethal
- Most attacks deal armor damage first, but there are some that ignore armor.
- Attacks that ignore armor have an 'AA' rating. This is a portion of the damage that ignores armor. It can equal the total damage, but not exceed (obviously).
- There is a 'Toughness' score that reduces all damage before applying to any hit points. Some attacks ignore toughness, so this should be a checkbox.
- Stun damage, after depleting armor, carries over into Stun hit points.
- Lethal damage, after depleting armor, skips stun damage, and goes straight to lethal, with one exception - Hardness.
- Hardness is a property that converts X amount of carried over lethal damage, to stun damage (after depleting armor).
- AA damage is unaffected by Hardness; so 3 AA would go straight to lethal, regardless of Hardness.
- Any damage delivered in excess to current Stun Hit Points carries over to Lethal.
Another might be 10 Lethal Damage, ignoring Toughness. So that'd have to skip Toughness, go to armor first, and then if there is hardness go to stun. If there is no hardness, it skips stun and goes to Lethal.
If this is too annoying for anyone to tackle, I understand - I spent an hour on my clunky spam of if statements to get it to work myself, but if anyone would have some cleaner concept or 'smart' way of doing this, I'd appreciate the insight.
EDIT: I thought I'd include my own code, so if you'd rather critique, it's here.
The Code
Code: Select all
[h, if(macro.args==""), CODE:{
[h: tokenName=getName(getSelected())]
};{
[h: tokenName=macro.args]
}]
[h: carryOver=0]
[h: sendToStun=0]
[h: sendToLethal=0]
[h, token(tokenName), CODE:{
[h: current_lethal=getProperty("Health_Current")]
[h: maximum_lethal=getProperty("Health_Maximum")]
[h: current_armor=getProperty("Armor_Current")]
[h: maximum_armor=getProperty("Armor_Maximum")]
[h: current_stun=getProperty("Stun_Current")]
[h: maximum_stun=getProperty("Stun_Maximum")]
[h: tgt_toughness=getProperty("Toughness")]
[h: isHealed=getState("Healed")]
[h: isRepaired=getState("Repaired")]
[h: isHardened=getProperty("Hardened")]
}]
[h: status=input(
"setDamage|0|Damage Value|TEXT|WIDTH=4",
"setDamageType|Stun,Lethal|Damage Type|RADIO|ORIENT=H SELECT=1",
"setArmor|1|Apply Armor|CHECK",
"setToughness|" +tgt_toughness +"|Apply Toughness (" +tgt_toughness +")|CHECK",
"setHardened|" +isHardened +"|Apply Hardness (" +isHardened +")|CHECK")]
[h: abort(status)]
[h: setDamage=if(setToughness>0, sum(setDamage,-tgt_toughness),setDamage)]
[h: setDamage=max(0,setDamage)]
[h, if(setArmor), CODE:{
[h: carryOver=if(setDamage>current_armor,sum(setDamage,-current_armor),0)]
[h: carryOver=max(0,carryOver)]
[h: current_armor=sum(current_armor,-setDamage)]
[h: current_armor=min(current_armor,maximum_armor)]
[h: current_armor=max(0,current_armor)]
[h: isRepaired=0]
};{
[h: carryOver=setDamage]
}]
[h: sendToStun=if(carryOver>0 && setHardened>0 && setDamageType==1,min(carryOver,isHardened),0)]
[h: sendToStun=if(carryOver>0 && setDamageType==0,carryOver,sendToStun)]
[h: sendToLethal=if(carryOver>0 && setHardened>0 && setDamageType==1,sum(carryOver,-isHardened),0)]
[h: sendToLethal=if(carryOver>0 && setDamageType==1 && setHardened==0,carryOver,sendToLethal)]
[h: sendToLethal=max(0,sendToLethal)]
[h: sendToStun=max(0,sendToStun)]
[h: carryOver=0]
[h, if(sendToStun>0 ), CODE:{
[h: carryOver=if(sendToStun>current_stun,sum(sendToStun,-current_stun),0)]
[h: current_stun=sum(current_stun,-sendToStun)]
[h: current_stun=min(current_stun,maximum_stun)]
[h: current_stun=max(0,current_stun)]
[h: isHealed=0]
};{}]
[h: setLethalDamage=sum(sendToLethal,carryOver)]
[h, if(setLethalDamage>0), CODE:{
[h: current_lethal=sum(current_lethal,-setLethalDamage)]
[h: current_lethal=min(current_lethal,maximum_lethal)]
[h: current_lethal=max(0,current_lethal)]
[h: isHealed=0]
};{}]
[h: woundedCheck=if(current_lethal<maximum_lethal,1,0)]
[h: debilitatedCheck=if(current_stun<maximum_stun,1,0)]
[h: deadCheck=if(current_lethal<1,1,0)]
[h, token(tokenName), CODE:{
[h: setProperty("Health_Current",current_lethal)]
[h: setProperty("Stun_Current",current_stun)]
[h: setProperty("Armor_Current",current_Armor)]
[h: setState("Healed",isHealed)]
[h: setState("Wounded",woundedCheck)]
[h: setState("Debilitated",debilitatedCheck)]
[h: setState("Repaired",isRepaired)]
[h: setState("Dead",deadCheck)]
[h: bar.Lethal = current_lethal / maximum_lethal]
[h: bar.Stun = current_stun / maximum_stun]
[h: bar.Armor = current_armor / maximum_armor]
}]