Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions Numenera_Natha/Help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,42 @@ Sheet must be in version 4+ : chat outputs and error messages are managed throug
******************************************************
**** RELEASE
******************************************************
Version: 4.0
Date: March 2015
Version: 4.2
Date: 2015-04-20
Authors: Natha (75857)

4.2: By popular demand (of one, Hi Marturin!), stat rolls can be called by macros and a selected character token. See the !nathanum-macroroll chat command below.
Plus added assets handling to stat roll.

4.1: Bug correction on the NPC damage function.

4.0: Refactoring and adaptation to the 4+ version of the character sheets and the new template feature of Roll20.
Functions are now called by the buttons on the sheet, no need for macros.

******************************************************
**** Chat commands
******************************************************
!nathanum-macroroll token_or_character_id|stat name|Difficulty|Cost|Assets|Effort on Roll|Effort on Damage|Bonus
New! Stat roll that can be called easier by macros.
Calls statRoll(character-objet,name-of-the-attibute,who-rolled, difficulty, Stat-expense,Assets,Effort-on-Roll,Effort-on-damage,Bonus-to-roll).
(see the comments of the function below for details).

MIGHT ROLL MACRO EXAMPLE:
!nathanum-macroroll @{selected|token_id}|might|?{Difficulty|0}|?{Cost|0}|?{Assets|0}|?{Effort on Roll|0}|?{Effort on Damage|0}|?{Bonus|0}

SPEED ROLL MACRO EXAMPLE:
!nathanum-macroroll @{selected|token_id}|speed|?{Difficulty|0}|?{Cost|0}|?{Assets|0}|?{Effort on Roll|0}|?{Effort on Damage|0}|?{Bonus|0}

INTELLECT ROLL MACRO EXAMPLE:
!nathanum-macroroll @{selected|token_id}|intellect|?{Difficulty|0}|?{Cost|0}|?{Assets|0}|?{Effort on Roll|0}|?{Effort on Damage|0}|?{Bonus|0}
|-----------------------------------------------------
!nathanum-numeneroll character_id|attribute
Stat roll.
Example: !nathanum-numeneroll @{character_id}|speed
Calls statRoll(character-objet,name-of-the-attibute,who-rolled).
Stat roll (called from the sheet mainly, as it requires a character id).
Example:
!nathanum-numeneroll @{character_id}|might
!nathanum-numeneroll @{character_id}|speed
!nathanum-numeneroll @{character_id}|intellect
Calls statRollFromSheet(character-objet,name-of-the-attibute,who-rolled).
(see the comments of the function below for details).
|-----------------------------------------------------
!nathanum-recoveryroll character_id
Expand Down Expand Up @@ -82,9 +107,12 @@ initRoll(character-object):
Damage track and token state are checked/updated by calling checkCharStates().
Chat output uses the "nathaNumInit" roll template.
|-----------------------------------------------------
statRoll(character-objet,name-of-the-attibute,who-rolled):
statRollFromSheet(character-objet,name-of-the-attibute,who-rolled):
Gets the necessary parameters for this function as attributes from the character sheet (except the stat name).
And then calls statRoll(character-objet,name-of-the-attibute,who-rolled, difficulty, Stat-expense,Assets,Effort-on-Roll,Effort-on-damage,Bonus-to-roll).
|-----------------------------------------------------
statRoll(character-objet,name-of-the-attibute,who-rolled, difficulty, Stat-expense,Assets,Effort-on-Roll,Effort-on-damage,Bonus-to-roll).
Might/speed/intellect roll (with eventual roll effort, additionnal cost, damage effort and bonus) against a difficulty (optional).
Every necessary parameters for this function are attributes of the character sheet (except the stat name).
Difficulty is the level of difficulty, not the target number.
The target number is calculated by the function.
If difficulty is 0, the roll still happens, but is not confronted to any difficulty: instead of calculating success, it calculates the highest difficulty beaten.
Expand Down
79 changes: 59 additions & 20 deletions Numenera_Natha/Numenera_Natha.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* read Help.txt */
var NathaNumenera = NathaNumenera || (function () {
'use strict';
var version = 4.1,
releasedate= "2015-04-17",
schemaversion = 1.0,
var version = 4.2,
releasedate= "2015-04-20",
schemaversion = 1.0,
author="Natha (roll20userid:75857)",
warning = "Sheet must be in version 4+ : chat outputs and error messages are managed through the sheet's templates.",
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -282,8 +282,18 @@ var NathaNumenera = NathaNumenera || (function () {
if(totalCost>0) tmplt+=" {{totalCost="+totalCost+"}} {{attrPool="+speedPool+"}} {{attrPoolInit="+speedPoolInit+"}}";
sendChat("character|"+charId, ""+tmplt);
},
//-----------------------------------------------------------------------------
statRollFromSheet= function (characterObj, statName,whoRolled) {
var difficulty=parseInt(getAttrByName(characterObj.id, "rollVarDiff", "current")) || 0;
var assets=parseInt(getAttrByName(characterObj.id, "rollVarAsset", "current")) || 0;
var statexp=parseInt(getAttrByName(characterObj.id, "rollVarCost", "current")) || 0;
var effortsOnRoll=parseInt(getAttrByName(characterObj.id, "rollVarRollEff", "current")) || 0;
var effortsOnDmg=parseInt(getAttrByName(characterObj.id, "rollVarRollDmg", "current")) || 0;
var rollBonus=parseInt(getAttrByName(characterObj.id, "rollVarBonus", "current")) || 0;
statRoll(characterObj,statName,whoRolled,difficulty,statexp,assets,effortsOnRoll,effortsOnDmg,rollBonus);
},
//-----------------------------------------------------------------------------
statRoll = function (characterObj,statName,whoRolled) {
statRoll = function (characterObj,statName,whoRolled,difficulty,statexp,assets,effortsOnRoll,effortsOnDmg,rollBonus) {
/*
Might/speed/intellect roll with eventual roll effort(s), additionnal cost,
damage effort(s), bonus to the roll (<3), against a difficulty (optional).
Expand All @@ -310,11 +320,6 @@ var NathaNumenera = NathaNumenera || (function () {
sendChat("character|"+charId, "&{template:nathaNumMsg} {{nathaNumeneRoll=1}} {{pcDying=1}}");
return;
};
var difficulty=parseInt(getAttrByName(characterObj.id, "rollVarDiff", "current")) || 0;
var statexp=parseInt(getAttrByName(characterObj.id, "rollVarCost", "current")) || 0;
var effortsOnRoll=parseInt(getAttrByName(characterObj.id, "rollVarRollEff", "current")) || 0;
var effortsOnDmg=parseInt(getAttrByName(characterObj.id, "rollVarRollDmg", "current")) || 0;
var rollBonus=parseInt(getAttrByName(characterObj.id, "rollVarBonus", "current")) || 0;

// checking the stat
var attributeName = "";
Expand Down Expand Up @@ -391,18 +396,19 @@ var NathaNumenera = NathaNumenera || (function () {
// beginning output calculation
var tmplt="&{template:nathaNumRoll} {{"+attributeName+"="+attributeName+"}} {{attrEdge="+attrEdge+"}} {{finalRoll="+finalRoll+"}} {{diceRoll="+diceRoll+"}}";
if (bonusToRoll>0) tmplt += " {{bonusToRoll="+bonusToRoll+"}}";
var assetsUsed = parseInt(0 || assets);
if (assetsUsed>0) tmplt += " {{assets="+assetsUsed+"}}";

//computing target task
var targetRoll = 0;
var target = 0;
var finalDiff=0;
if (parseInt(difficulty) > 0) {
target = (parseInt(difficulty))*3;
targetRoll = (parseInt(difficulty)-effortRoll)*3;
finalDiff= difficulty-effortRoll;
tmplt += "{{difficulty=" + difficulty + "}} {{target="+target+"}} {{finalDiff="+finalDiff+"}} {{targetRoll="+targetRoll+"}}";
var initDiff=parseInt(0 || difficulty);
if (initDiff > 0) {
var target = initDiff*3;
var finalDiff= Math.max(0, initDiff-effortRoll-assetsUsed);
var targetRoll = finalDiff*3;
tmplt += "{{difficulty=" + initDiff + "}} {{target="+target+"}} {{finalDiff="+finalDiff+"}} {{targetRoll="+targetRoll+"}}";
} else {
tmplt += " {{rollBeats="+(Math.floor(finalRoll/3)+effortRoll)+"}}";
var rollBeats=Math.floor(finalRoll/3)+effortRoll+assetsUsed;
tmplt += " {{rollBeats="+rollBeats+" ("+(rollBeats*3)+")"+"}}";
};

// Checking result
Expand All @@ -424,7 +430,7 @@ var NathaNumenera = NathaNumenera || (function () {
tmplt += " {{bonusToRoll=" + bonusToRoll + "}}";
};
// If not an automatic success or a known difficulty
if (difficulty > 0) {
if (initDiff > 0) {
if( finalRoll >= targetRoll) {
tmplt += " {{boolOK=1}}";
}
Expand Down Expand Up @@ -627,7 +633,40 @@ var NathaNumenera = NathaNumenera || (function () {
sendChat("GM", "&{template:nathaNumMsg} {{chatmessage=nathanum-numeneroll}} {{wtfAttribute="+msg.content+"}}");
return false;
};
statRoll(obj,paramArray[1],msg.who);
statRollFromSheet(obj,paramArray[1],msg.who);
break;
case '!nathanum-macroroll':
// macroroll can be called with a token_id or character_id
if(!obj) {
//not a character_id
obj = findObjs({
_pageid: Campaign().get("playerpageid"),
_type: "graphic",
layer:"objects",
_id: paramArray[0]
})[0];
};
if (!obj) {
//not a token either
sendChat("GM", "&{template:nathaNumMsg} {{chatmessage=nathanum-macroroll}} {{noTokNoChar= "+msg.content+"}}");
return false;
} else {
if(obj.get("type")=="graphic") {
// it's a token but does it represents a character ?
obj = getObj("character", obj.get("represents"));
if (!obj) {
//not a token either
sendChat("GM", "&{template:nathaNumMsg} {{chatmessage=nathanum-macroroll}} {{noTokNoChar= "+msg.content+"}}");
return false;
};
};
};
if (paramArray.length != 8) {
//this function requires more parameters
sendChat("GM", "&{template:nathaNumMsg} {{chatmessage=nathanum-macroroll}} {{genericMsg=Requires 8 paramaters : token|stat name|difficulty|assets|Cost|Effort on Roll|Effort on Damage|Roll Bonus}}");
return false;
};
statRoll(obj,paramArray[1],msg.who,paramArray[2],paramArray[3],paramArray[4],paramArray[5],paramArray[6],paramArray[7])
break;
case '!nathanum-recoveryroll':
if (!obj) {
Expand Down
2 changes: 1 addition & 1 deletion Numenera_Natha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Natha's Numenera",
"version": "4.1",
"version": "4.2",
"description": "Enables the use of advance rolls and functions in Natha's Numenera character sheets (both english and french) version 4+. See Help.txt",
"authors": "Natha",
"roll20userid": "75857",
Expand Down