This is a HP announcement that is whispered to GM when a player changes their HP up or down. Sometimes, I have caught cheater during the off week fudge their hp. But other than that - to ensure the correct amount has been added/removed during gameplay is the main usage. I'd like for it to also include AC and "Durability". Basically - the 3 bars are as followed: Bar 1 (Green) = HP Bar 2 (Blue) = Durability (This is a attribute that I will be adding to their character sheet) Bar 3 (Red) = AC So I'd like the api to do the same as it does with HP, but with the other 2 bars as well. I tried copy/pasting the HP section and changing what it needed to be and failed miserably. on("change:attribute", function(obj, prev) {
if(obj.get("name") !== "hp") return;
var damageTaken = 0;
var currenthp =0;
var oldhp = 0;
var max = 0;
var charName = getObj("character", obj.get("_characterid"));
currenthp = obj.get("current");
oldhp = prev["current"];
max = obj.get("max");
if (currenthp > max) {
currenthp = currenthp;
obj.set("current", currenthp);
}
damageTaken = currenthp - oldhp;
if (damageTaken < 0 ) {
sendChat(charName.get("name"), "/w gm has taken " + -1 * damageTaken + " damage");
}
if (damageTaken > 0 ) {
sendChat(charName.get("name"), "/w gm has healed " + damageTaken + " damage");
}
});
on("change:graphic:bar1_value", function(obj, prev) {
//Ignores players, handled above
if(obj.get("represents") != "") return;
if (Campaign().get("initiativepage") == false) return;
var damageTaken = 0;
var currenthp =0;
var oldhp = 0;
var max = 0;
var charName = obj.get("name");
currenthp = obj.get("bar1_value");
oldhp = prev["bar1_value"];
max = obj.get("bar1_max");
if (currenthp > max) {
currenthp = currenthp;
obj.set("bar1_value", currenthp);
}
damageTaken = currenthp - oldhp;
if (damageTaken < 0 ) {
sendChat(charName, "/me has taken " + -1 * damageTaken + " damage");
}
if (damageTaken > 0 ) {
sendChat(charName, "/me has healed " + damageTaken + " damage");
}
});