Skip to content

Instantly share code, notes, and snippets.

@fmonaca
fmonaca / turnorder
Last active September 14, 2018 08:38
Automatic Turn Order in Turn Tracker for HERO system campaigns
on('chat:message', function(msg) {
var command = msg.content.toLowerCase();
if (msg.type == "api" && command == "!combatstart"){
sendChat("GM", "Combat begins!");
var selected = msg.selected;
var aChars = new Array();
var nCount = 0;
_.each(selected, function(obj) {
if(obj._type != 'graphic') return;
@fmonaca
fmonaca / turnorder 2.0
Created November 15, 2013 07:46
Turn Tracker for the HERO system, showing by phase
var iii = iii || {};
var iTurn = iTurn || {};
var combatBegun = combatBegun || {};
var aChars = new Array();
var aSPDchart = new Array();
aSPDchart = ['','12','6,12','4,8,12','3,6,9,12','3,5,8,10,12','2,4,6,8,10,12','2,4,6,7,9,11,12','2,3,5,6,8,9,11,12','2,3,4,6,7,8,10,11,12','2,3,4,5,6,8,9,10,11,12','2,3,4,5,6,7,8,9,10,11,12','1,2,3,4,5,6,7,8,9,10,11,12'];
function recoveryAll(tokens) {
for(var idCounter=0; idCounter<tokens.length; idCounter++){
@fmonaca
fmonaca / turncounter
Last active September 14, 2018 08:39
Turn Counter
/* --------------------------------------------------------------------------------------------------- */
// Initiative Script
//
// Usage: Select the tokens you want the initiative to be rolled for and use the command "!initiative"
// This command rolls a die of the type specified using the "initiativeDie" variable, adds
// the result to the attribute specified using the "initiativeAttribute" variable (for each
// token), then sorts the tokens by the total achieved (higher to lower) and puts them into
// the Turn Tracker. Use the command "!nextround" to move to the next round and increase the
// counter.
//
@fmonaca
fmonaca / copycharacter
Last active September 14, 2018 08:39
Creates a copy of a Character object in case more tokens are linked to it, then assigns the newly created Character to the selected token
on("chat:message", function(msg) {
if(msg.type == "api" && msg.content == "!spawn") {
var selected = msg.selected;
_.each(selected, function(obj) {
var newID = spawnCharacter(obj._id);
var oAttrib = findObjs({name: "STR",_type: "attribute", _characterid: newID}, {caseInsensitive: true})[0];
var attrib = parseInt(oAttrib.get('current'));
attrib += 10;
@fmonaca
fmonaca / heroturntracker2.0
Last active September 14, 2018 08:39
HERO turn and phase tracker, part of the HERO combat system scripts for Roll20
/*
USAGE:
Select tokens and
!combatstart Initiate combat
!nextphase Advance to next phase in which at least one of the tokens in combat acts
!combatend End combat
!combatadd Add token(s) into combat
!combatremove Remove token(s) from combat
@fmonaca
fmonaca / autocombat
Last active September 14, 2018 08:39
HERO autocombat script - supports weapon and some spells through macros and descriptor strings to be put in gmnotes - part of the HERO combat system scripts for Roll20
/*
The macro sends the ID or name of the attacker, the ID or name of the defender, and optionally some other modifiers to the script:
attmod - Default = 0, optional OCV modifier (because of status like SET, BRACE or various types of bonus/malus);
distance - Default = 0, optional distance (in meters) - In case you have to manually specify a distance in metres;
shots - optional modifiers - can be: shots[n] - Number of shots firing for that phase for weapons with selective autofire [1 (max = autofire value)];
abort - optional modifier needed for "abort" type maneuvers like block and dodge.
manualroll - optional in case players want to roll manually to hit
macro example:
@fmonaca
fmonaca / effects
Last active September 14, 2018 08:39
HERO Effects script, manages timed effects and spells like Drain, Aid, Entangle. Part of the HERO combat system scripts for Roll20
// {effect}[id]|[type:n[fixed/dice]]|[attribute]|[defence]|[frequency(type)][duration(number and type)][counter(0)][active][description][marker]{/effect}
// id a numeric, unique id - It is auto-generated when the Effect is applied by the macro
// dam:n[d/f]|aid:n[d/f]|fla:n[d]|ent:n[d] dam = damage (can also be used as a drain), aid = aid, fla = flash (not implemented yet), ent = entangle,
// n = number of dice | fixed value of effect, I.e. 3 dice of damage is dam:3d
// Special: if dam is set to 0 fixed, it means the attribute(s) is zeroed, if it is set to -1 fixed, the attribute(s) is halved - i.e. dam:0f, dam:-1f
// normal|killing|body|stun|str|dex|con|int|ego|pre|run|ocv|dcv|omcv|dmcv|end|pd|ed|rec|spd stat affected, can be more than one separated by "/". Type and hasDef are then common to all attributes in the list, though.
// hasdef:[pd][ed][rpd][red][powerdef][flashdef][mentaldef][no]
@fmonaca
fmonaca / instructions
Last active September 14, 2018 08:38
Notes and instructions (sort of) about the HERO combat system scripts for Roll20
HERO combat system scripts for Roll20
There are 5 scripts in total: heroturntracker2.0, autocombat, effects, recovery, locations.
The first manages the turn tracker, subdividing the turns into phases in which it shows only the tokens acting during those phases depending on their SPD attribute. It supports delayed actions (by putting a "d" in place of the Dex of the token). It also keeps track of status like stunned, deeply stunned, bleeding, movement, actions, etc.
The second manages the weapon and their effects (or spells that damage the opponent). It can be used for modern weapons and for fantasy ones. Any spell that does damage can be
emulated by this script.
@fmonaca
fmonaca / recovery
Last active September 14, 2018 08:38
recovery for HERO Combat System for Roll20 - NEEDED as some commands are parsed here
on('chat:message', function(msg) {
if(msg.type != 'api') return; // We're only deal with API commands
//var parts = msg.content.toLowerCase().split(' ');
var parts = msg.content.split(';');
var command = parts.shift();
if(command == '!recovery')
{
//var page = getObj('page', Campaign().get('playerpageid'));
var selected = msg.selected;
@fmonaca
fmonaca / locations
Last active September 14, 2018 08:39
HERO System combat locations (rollable table) for Roll20
on("chat:message", function(msg) {
if(msg.type == "api" && msg.content == "!tableread") {
var locsMalus = [8,6,5,5,3,7,8,4,6,8];
var oTable = findObjs({name: "locs",_type: "rollabletable"});
var oItems = findObjs({_type: "tableitem", _rollabletableid: oTable[0].id});
for(var i=0;i<oItems.length;i++)
{
log("aLocsModifier["+i+"] = ["+locsMalus[i]+",'"+oItems[i].get('avatar')+"'];");
}
}