Skip to content

Instantly share code, notes, and snippets.

@birdbrainiac
birdbrainiac / createjournal
Created September 14, 2018 08:36 — forked from fmonaca/createjournal
Creates an empty HERO System character sheet in Roll20
on('chat:message', function(msg) {
if(msg.type == 'api' && msg.content.indexOf('!newsheet ') != -1)
{
var name = msg.content.substring(10);
var ocharacter = findObjs({
_type: "character",
_name: name,
});
if(ocharacter.length==0)
@birdbrainiac
birdbrainiac / autocombat
Created September 14, 2018 08:36 — forked from fmonaca/autocombat
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:
@birdbrainiac
birdbrainiac / heroturntracker2.0
Created September 14, 2018 08:35 — forked from fmonaca/heroturntracker2.0
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
@birdbrainiac
birdbrainiac / copycharacter
Created September 14, 2018 08:35 — forked from fmonaca/copycharacter
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;
@birdbrainiac
birdbrainiac / turncounter
Created September 14, 2018 08:35 — forked from fmonaca/turncounter
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.
//
@birdbrainiac
birdbrainiac / turnorder 2.0
Created September 14, 2018 08:35 — forked from fmonaca/turnorder 2.0
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++){
@birdbrainiac
birdbrainiac / Roll20 Random Encounters
Created September 14, 2018 08:34 — forked from anonymous/Roll20 Random Encounters
A script for the roll20 api to pick a random encounter.
// A shorthand to create new events in the encounters table.
var event = function(freq, msg) {
return {message: msg, frequency: freq};
};
// The encounter table. Create a new section and populate it with events. The
// event text will be displayed in the GM chat window if it is selected.
// Events with a frequency of '3' will happen 3 times as often as events with
@birdbrainiac
birdbrainiac / getLibrary.js
Last active September 14, 2018 13:29 — forked from sturtus/gist:8352577
[Roll20 getCharacterObjects] Script Functions to get character and attribute objects #roll20 #roll20library
/*
This is my collection of useful functions to use in other commands/functions. I will keep this top post updated with the list of included functions as I add more.
Library includes:
- removePlus. Takes string or array of strings and returns the integer after the symbol "+". Useful for getting an integer from a string that represents a bonus like +2. Will also convert any numbers in the string/array of strings to integers.
- getAttributeObjects: takes a character object and an array of attribute names, checks the names against the character for existing attributes, error checks them for empty values or existence at all, and returns an array of the attributes' objects.
- getCharacterObj: takes a graphic, attribute, ability, or character object and returns the associated character object.
@birdbrainiac
birdbrainiac / MyHealthAura.js
Last active September 13, 2018 04:38
HealthAura no PC Color Tint
/* global createObj TokenMod spawnFxWithDefinition getObj state playerIsGM sendChat _ findObjs log on*/
/*
My Profile link: https://app.roll20.net/users/262130/dxwarlock
GIT link: https://github.com/dxwarlock/Roll20/blob/master/Public/HeathColors
Roll20Link: https://app.roll20.net/forum/post/4630083/script-aura-slash-tint-healthcolor
My Tweaks:
Lines 31-33, and 64-66 were to allow for Pendragon-style HPs
Lines 46-49 were commented out to disable the colour tint of characters.
*/
@birdbrainiac
birdbrainiac / HeroInitiativeSort.js
Created April 29, 2018 20:48
For use with Darren's HeroTracker
/*
For use with Darren's HeroTracker
By The great Aaron
Type !sorths
*/
on('ready', () => {
const sortHeroSystem = (a,b) => {
const aInt = (parseInt(a.pr)||0);
const aFloat = (parseFloat(a.pr)||0);
const bInt = (parseInt(b.pr)||0);