timmaugh said: I think the metascripts can help. Just to make sure we're not leaving something behind, though, you say there is a "manual field for the intensity", but I don't see any sort of "intensity" reflected in your macro. Does that number affect the roll we are creating, here, and if so, how? Pending any sort of change to my understanding based on that answer, it sounds like you want to translate a rank designation (Feeble, Poor, Typical, etc.) into a number without having to use a query, and it looks like you need to do it inside an inline roll. That said, you are also feeding to your command line an extra argument ("select Action"), which the script is not set up to do anything with... which makes me wonder if I have the right understanding of what you're trying to do. If I don't, post back. Right, I forgot to address these two questions, on my side. First, intensity would be the range of numbers within the rank. They are only applied to things like damage dealt or resisted. So, easiest example to demonstrate this would be TY06. When you start your character, you get the average of the range. Typical ranges from 5 to 7. So, you start at 06. If you try to get to a Good rank, you would need to get to 8. Even so, a GD08 and a GD10 would still be a Good rank. So, it those little numbers only matter when you get down to details. Second, the action that I reference is part of a newer version of the API. It gets degrees of success and bases the results on the CS and the action response. So, the instead of seeing "Fumble" on a roll of 01 for "Stun", you would see "K.O.". And, if I am understanding what The Aaron provided, I think that the API would look like this: const CS = (() => {
const version = '0.1.0';
const successText = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"]; //not used
let CS9 = [2, 06, 31, 56];
let CS8 = [2, 11, 36, 61];
let CS7 = [2, 16, 41, 66];
let CS6 = [2, 21, 46, 71];
let CS5 = [2, 26, 51, 76];
let CS4 = [2, 31, 56, 81];
let CS3 = [2, 36, 61, 86];
let CS2 = [2, 41, 66, 91];
let CS1 = [2, 46, 71, 96];
let CS0 = [2, 51, 76, 98];
let CS_1 = [2, 56, 81, 100];
let CS_2 = [2, 61, 86, 100];
let CS_3 = [2, 66, 91, 100];
let CS_4 = [2, 71, 96, 100];
let CS_5 = [6, 76, 98, 100];
let CS_6 = [11, 81, 98, 100];
let CS_7 = [16, 86, 98, 100];
let CS_8 = [21, 91, 98, 100];
let CS_9 = [26, 96, 98, 100];
let featRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let bluntAttack = ["Fumble", "Miss", "Hit", "Slam", "Stun"];
let edgedAttack = ["Fumble", "Miss", "Hit", "Stun", "Kill"];
let shooting = ["Fumble", "Miss", "Hit", "Bullseye", "Kill"];
let throwingEdged = ["Fumble", "Miss", "Hit", "Bullseye", "Kill"];
let throwingBlunt = ["Fumble", "Miss", "Hit", "Bullseye", "Stun"];
let energy = ["Fumble", "Miss", "Hit", "Bullseye", "Kill"];
let force = ["Fumble", "Miss", "Hit", "Bullseye", "Stun"];
let grappling = ["Fumble", "Miss", "Hit", "Partial", "Hold"];
let grabbing = ["Fumble", "Miss", "Take", "Grab", "Break"];
let escaping = ["Fumble", "Miss", "Miss", "Escape", "Reverse"];
let charging = ["Fumble", "Miss", "Hit", "Slam", "Stun"];
let dodging = ["Autohit", "None", "-1CS", "-2CS", "-4CS"];
let evading = ["+Stun", "Autohit", "Evasion", "+1CS", "+2CS"];
let blocking = ["+Stun", "-6CS", "-4CS", "-2CS", "-1CS"];
let catching = ["+Stun", "Autohit", "Miss", "Damage", "Catch"];
let stun = ["+K.O.", "1-10", "1", "No", "No"];
let slam = ["+Stun", "Grand Slam", "1 Area", "Prone", "No"];
let ko = ["+Kill", "Knockout", "+Stun", "No", "No"];
let bleed = ["+Kill", "Bleed", "-1", "No", "No"];
let kill = ["KIA", "Endurance Loss", "E/S", "No", "No"];
let rollWithTheBlow = ["+1CS", "No", "-1CS", "-2CS", "-3CS"];
let bounceBack = ["+Stun", "No", "-1CS", "End", "+1CS"];
let fightingRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let agilityRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let strengthRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let enduranceRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let reasonRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let intuitionRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let psycheRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let dynamicRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let resourcesRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let miscRoll = ["Fumble", "Miss", "Partial Success", "Success", "Critical Success"];
let oneextraAction = ["Fumble", "Miss", "Success", "Success", "Success"];
let twoextraActions = ["Fumble", "Miss", "Success", "Success", "Success"];
let threeextraActions = ["Fumble", "Miss", "Success", "Success", "Success"];
let firstTry = ["Failure", "Failure", "Failure", "Failure", " First Success"];
let oneSuccess = ["Failure", "Failure", "Failure", "Second Success", "Second Success"];
let twoSuccesses = ["Failure", "Failure", "Third Success", "Third Success", "Third Success"];
let threeSuccesses = ["Failure", "Failure", "Fourth Success", "Fourth Success", "Fourth Success"];
let fourSuccesses = ["Failure", "Failure", "Fifth Success", "Fifth Success", "Fifth Success"];
let fiveSuccesses = ["Failure", "Failure", "Sixth Success", "Sixth Success", "Sixth Success"];
let sixSuccesses = ["Failure", "Failure", "Seventh Success", "Seventh Success", "Seventh Success"];
let sevenSuccesses = ["Failure", "Failure", "Eighth Success", "Eighth Success", "Eighth Success"];
let eightSuccesses = ["Failure", "Failure", "Ninth Success", "Ninth Success", "Ninth Success"];
let nineSuccesses = ["Failure", "Failure", "Final Success", "Final Success", "Final Success"];
const checkInstall = () => {
log('-=> CS v'+version);
};
//sendChat output formatting styles
const _h = {
fumble: (...o) => `<span style="font-weight: bold;padding: .2em .2em; background-color:rgba(1,178,240,1);">${o.join('')}</span>`,
miss: (...o) => `<span style="font-weight: bold;padding: .2em .2em; background-color:rgba(255,255,255,1);">${o.join('')}</span>`,
partial: (...o) => `<span style="font-weight: bold;padding: .2em .2em; background-color:rgba(1,192,1,1);">${o.join('')}</span>`,
success: (...o) => `<span style="font-weight: bold;padding: .2em .2em; background-color:rgba(255,254,1,1);">${o.join('')}</span>`,
crit: (...o) => `<span style="font-weight: bold;padding: .2em .2em; background-color:rgba(255,62,62,1);">${o.join('')}</span>`
};
const formattedResult = function (successLevel, text) {
switch(successLevel){
case 0:
return _h.fumble(text);
break;
case 1:
return _h.miss(text);
break;
case 2:
return _h.partial(text);
break;
case 3:
return _h.success(text);
break;
case 4:
return _h.crit(text);
break;
}
}
const getSuccessLevel = function (tableArr, roll) {
if (roll>=tableArr[3]) {return 4} //"Critical Success"
if (roll>=tableArr[2] && roll<tableArr[3]) {return 3} //"Success"
if (roll>=tableArr[1] && roll<tableArr[2]) {return 2} //"Partial Success"
if (roll>=tableArr[0] && roll<tableArr[1]) {return 1} //"Miss"
if (roll<tableArr[0]) {return 0} //"Fumble"
};
const processInlinerolls = (msg) => {
if(msg.hasOwnProperty('inlinerolls')){
return msg.inlinerolls
.reduce((m,v,k) => {
let ti=v.results.rolls.reduce((m2,v2) => {
if(v2.hasOwnProperty('table')){
m2.push(v2.results.reduce((m3,v3) => [...m3,(v3.tableItem||{}).name],[]).join(", "));
}
return m2;
},[]).join(', ');
return [...m,{k:`$[[${k}]]`, v:(ti.length && ti) || v.results.total || 0}];
},[])
.reduce((m,o) => m.replace(o.k,o.v), msg.content);
} else {
return msg.content;
}
};
const handleInput = (msg) => {
const scriptName = 'CS';
let roll = 0;
let tableName;
let tableArr;
let actionArr;
let action = "";
let successLevel;
let result;
if(msg.type=="api" && msg.content.indexOf("!CS") === 0 ) {
try {
who = getObj('player',msg.playerid).get('_displayname');
let args = msg.content.split(/\s+/);
if (args[1]>=0) {
tableName = 'CS' + parseInt(args[1]);
} else {
tableName = 'CS_' + -1*parseInt(args[1]);
}
//Get Success Level Array
switch(tableName){
case "CS9":
tableArr = CS9;
break;
case "CS8":
tableArr = CS8;
break;
case "CS7":
tableArr = CS7;
break;
case "CS6":
tableArr = CS6;
break;
case "CS5":
tableArr = CS5;
break;
case "CS4":
tableArr = CS4;
break;
case "CS3":
tableArr = CS3;
break;
case "CS2":
tableArr = CS2;
break;
case "CS1":
tableArr = CS1;
break;
case "CS0":
tableArr = CS0;
break;
case "CS_1":
tableArr = CS_1;
break;
case "CS_2":
tableArr = CS_2;
break;
case "CS_3":
tableArr = CS_3;
break;
case "CS_4":
tableArr = CS_4;
break;
case "CS_5":
tableArr = CS_5;
break;
case "CS_6":
tableArr = CS_6;
break;
case "CS_7":
tableArr = CS_7;
break;
case "CS_8":
tableArr = CS_8;
break;
case "CS_9":
tableArr = CS_9;
break;
}
//Get Action Array
action = args[2];
switch(args[2]){
case "FeatRoll":
actionArr = featRoll;
break;
case "BluntAttack":
actionArr = bluntAttack;
break;
case "EdgedAttack":
actionArr = edgedAttack;
break;
case "Shooting":
actionArr = shooting;
break;
case "ThrowingEdged":
actionArr = throwingEdged;
break;
case "ThrowingBlunt":
actionArr = throwingBlunt;
break;
case "Energy":
actionArr = energy;
break;
case "Force":
actionArr = force;
break;
case "Grappling":
actionArr = grappling;
break;
case "Grabbing":
actionArr = grabbing;
break;
case "Escaping":
actionArr = escaping;
break;
case "Charging":
actionArr = charging;
break;
case "Dodging":
actionArr = dodging;
break;
case "Evading":
actionArr = evading;
break;
case "Blocking":
actionArr = blocking;
break;
case "Catching":
actionArr = catching;
break;
case "Stun":
actionArr = stun;
break;
case "Slam":
actionArr = slam;
break;
case "KO":
actionArr = ko;
break;
case "Bleed":
actionArr = bleed;
break;
case "Kill":
actionArr = kill;
break;
case "RollWithTheBlow":
actionArr = rollWithTheBlow;
break;
case "BounceBack":
actionArr = bounceBack;
break;
case "FightingRoll":
actionArr = fightingRoll;
break;
case "AgilityRoll":
actionArr = agilityRoll;
break;
case "StrengthRoll":
actionArr = strengthRoll;
break;
case "EnduranceRoll":
actionArr = enduranceRoll;
break;
case "ReasonRoll":
actionArr = reasonRoll;
break;
case "IntuitionRoll":
actionArr = intuitionRoll;
break;
case "PsycheRoll":
actionArr = psycheRoll;
break;
case "DynamicRoll":
actionArr = dynamicRoll;
break;
case "ResourcesRoll":
actionArr = resourcesRoll;
break;
case "Misc":
actionArr = miscRoll;
break;
case "OneExtraAction":
actionArr = oneextraAction;
break;
case "TwoExtraActions":
actionArr = twoextraActions;
break;
case "ThreeExtraActions":
actionArr = threeextraActions;
break;
case "FirstTry":
actionArr = firstTry;
break;
case "1Success":
actionArr = oneSuccess;
break;
case "2Successes":
actionArr = twoSuccesses;
break;
case "3Successes":
actionArr = threeSuccesses;
break
case "4Successes":
actionArr = fourSuccesses;
break
case "5Successes":
actionArr = fiveSuccesses;
break
case "6Successes":
actionArr = sixSuccesses;
break
case "7Successes":
actionArr = sevenSuccesses;
break
case "8Successes":
actionArr = eightSuccesses;
break
case "9Successes":
actionArr = nineSuccesses;
break
default:
sendChat(scriptName,`/w "${who}" `+ 'Error: Action \"' + action + '\" not found.');
break
}
tableName = tableName.replace("_", "-");
roll = randomInteger(100);
successLevel = getSuccessLevel(tableArr, roll);
result = actionArr[successLevel];
//let output = '&{template:default} {{name=' + tableName + '}} {{Roll=[[' + roll + ']]}} {{SuccessLevel=' + _h.inlineResult(result) + '}}';
let output = '&{template:default} {{name=' + action + ' ' + tableName + '}} {{Roll=[[' + roll + ']]}} {{Result=' + formattedResult(successLevel, result) + '}}';
sendChat(scriptName, output);
}
catch(err) {
sendChat(scriptName,`/w "${who}" `+ 'Error: ' + err.message);
}
};
};
const registerEventHandlers = () => {
on('chat:message', handleInput);
};
on('ready', () => {
checkInstall();
registerEventHandlers();
});
})(); At least, that is what I am hoping. ETA: Macros have failed and I get this message: