Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Hero System Recoveries?

I'm looking to work up an API script for a mechanic in the Hero System. Hero characters have two combat stats, END and STUN. END is the amount of energy left for the character to use his powers, and STUN is the amount of damage he takes till knockout. A Recovery action taken by a character adds the number of a separate stat, REC, to the value of END and STUN, up to his maximum. So a guy with a current END 20, STUN 20, and a REC of 10, who takes a recovery action, would have END 30, STUN 30 at the end of that action. He can only recover up to his max, however, so if his max STUN was 35, another REC would put him at STUN 35, not 40. Characters take regular recoveries in the course of a battle, so this mechanic would be perfect to automate. I have placed values for END, STUN and REC on each player's character sheet and would like to call those values in the script. I've tried using the Heal script from the API repository and modifying it, because it seems very close to what I want to do, but that script doesn't seem to work correctly. Pasted into the parser, the existing script returns "Unrecognized token IF" Any thoughts?
Don't know how github works. on("chat:message", function(msg) { if(msg.type == "api" && msg.content.indexOf("!recover") !== -1) { var selected = msg.selected; _.each(selected, function(obj) { var tok = getObj("graphic", obj._id); var controller = getObj("character", tok.get("represents")); var REC = findObjs ({name: "REC",_type: "attribute", _characterid: controller.id}, {caseInsensitive: true})[0]; var END = findObjs ({name: "END",_type: "attribute", _characterid: controller.id}, {caseInsensitive: true})[0]; var STUN = findObjs ({name: "STUN",_type: "attribute", _characterid: controller.id}, {caseInsensitive: true})[0]; var RECnum=parseInt(REC.get("current")); var ENDCur=parseInt(END.get("current")); var ENDMax=parseInt(END.get("max")); var STUNCur=parseInt(STUN.get("current")); var STUNMax=parseInt(STUN.get("max")); if(ENDCur+RECnum <= ENDMax ) {END.set("current", ENDCur+=RECnum);} else {END.set("current", ENDMax);} if(STUNCur+RECnum <= STUNMax ) {STUN.set("current", STUNCur+=RECnum);} else {STUN.set("current", STUNMax);} }) } });
That works great! Thank you very much, Brandon. You rock!