Simple script I wrote this afternoon, full of holes but whatever. Probably already exists but it was fast to write so again whatever. - just click on a token that represents a monster/npc that uses the 5e ogl sheet(npc option only). - type !hpgen (or make a macro button) voila the script rolls the npc health by reading the hit point formula and then assigns the roll result to bar 1's max/current as a number value (not directly attached to the sheet's hit point value). Keep your players guessing! no more figuring out that the gerblins all have 7 hp! on('chat:message',function(msg){
if(msg.type == 'api'){
if(msg.content == '!hpgen'){
if(msg.selected == null){
sendChat('HP Gen','/w gm Nothing selected');
}else{
msg.selected.forEach(function(Sel){
var tokenObj = getObj('graphic',Sel._id);
//log(tokenObj);
var CharObj = getObj('character',tokenObj.get('represents'));
//log(CharObj);
var diceRoll = getAttrByName(tokenObj.get('represents'),'npcd_hpformula');
//log(diceRoll);
sendChat('', '/r '+diceRoll, function(ops) {
//log(ops);
//log(ops[0].content);
//log(JSON.parse(ops[0].content).total);
var Hp = JSON.parse(ops[0].content).total;
//log(tokenObj);
tokenObj.set('bar1_value',Hp);
tokenObj.set('bar1_max',Hp);
//log(Hp);
//log(tokenObj);
//log(ops.content.total);
});
//log(maxHealth);
});
};
};
};
});