Skip to content

Instantly share code, notes, and snippets.

@Kamanar Kamanar/gist:8070970
Last active Jan 1, 2016

Embed
What would you like to do?
Quick Attack Script
on("chat:message", function(msg) {
if(msg.type == "api" && msg.content.indexOf("!Attack") !== -1) {
//log("SR Started")
var selected = msg.selected;
//log (selected)
_.each(selected, function(obj) {
var tok = getObj("graphic", obj._id);
//log(tok);
var controller = getObj("character", tok.get("represents"));
//log (controller.get("name"));
var Attr1 = findObjs ({name: "Attr1",_type: "attribute", _characterid: controller.id}, {caseInsensitive: true})[0];
var CurrentAttr1 = parseInt(Attr1.get("current"));
log(CurrentAttr1);
var MaxAttr1 = Attr1.get("max");
var Attr2 = findObjs ({name: "Attr2",_type: "attribute", _characterid: controller.id}, {caseInsensitive: true})[0];
var CurrentAttr2 = Attr2.get("current");
log(CurrentAttr2);
var Damage= parseInt(randomInteger(6) + randomInteger(6) + CurrentAttr1); //2d6 damage + the value of CurrentAttr1
log(Damage);
var Health = CurrentAttr2-Damage;
Attr2.set("current",Health);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.