Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tableMagicTemplate = "<table style='max-width: 250px; background-image:url(http://i.imgur.com/pdmAcRi.jpg); background-size: 100% 100%; background-repeat: no-repeat;font-family: \"Century Gothic\", CenturyGothic, AppleGothic, sans-serif;'>"
- +"<tr>"
- +"<td align='center' style='padding-top: 20px;padding-right: 20px;padding-left: 20px;'>"
- +"<h3><<TITLE>></h3>"
- +"</td>"
- +"</tr>"
- +"<tr>"
- +"<td style='padding-left: 20px; padding-right: 20px'>"
- + "<b>Rolling </b><<DICENUMBER>><b> dice.</b><br><b>Difficulty:</b> <<DIFFICULTY>>"
- +"</td>"
- +"</tr>"
- +"<<HASSPECIALITY>>"
- +"<<HASWILLPOWER>>"
- +"<tr>"
- +"<td style='padding-left: 20px; padding-right: 20px'>"
- +"<b>Roll:</b> <<DICEROLL>>"
- +"<br><b>Sucesses:</b> <<GOODROLLS>> <b>Ones:</b> <<ONEROLLS>>"
- +"<br><b>Total:</b> <<TOTALROLL>>"
- +"</td>"
- +"</tr>"
- +"<tr>"
- +"<td style='padding-left: 20px; padding-right: 20px;'>"
- +"<<RESULT>>"
- +"</td>"
- +"</tr>"
- +"<<PARADOXGAIN>>"
- +"<tr>"
- +"<td style='padding-left: 20px; padding-right: 20px; padding-bottom: 20px'>"
- +""
- +"</td>"
- +"</tr>"
- +"</table>";
- var concidentalTemplate = "<span style='color:blue'>Coincidental Magic Roll</span>";
- var vulgarTemplate = "<span style='color:blue'>Vulgar Magic Roll</span>";
- var vulgarWitnessTemplate = "<span style='color:blue'>Vulgar with Witness Magic Roll</span>";
- var hasMagicSpecialTemplate = "<tr><td style='padding-left: 20px; padding-right: 20px'><b>Speciality:</b> 10 counts as two successes.</td></tr>";
- var successMagicDiceTemplate = "<img src='http://i.imgur.com/vZRADbK.png' title='<<DIE>>' height='20' width='20'/> ";
- var botchMagicDiceTemplate = '<img src="http://i.imgur.com/vyMMvoD.png" title="BOTCH" height="20" width="20"/> ';
- var successMagicResultTemplate = '<span style="color:green"><b>SUCCESS</b></span>';
- var failureMagicResultTemplate = '<span style="color:red"><b>FAILURE</b></span>';
- var botchMagicResultTemplate = '<img src="http://i.imgur.com/vyMMvoD.png" title="BOTCH" height="20" width="20"/><span style="color:red"><b>BOTCH!!!</b></span><img src="http://i.imgur.com/vyMMvoD.pngg" title="BOTCH" height="20" width="20"/>'
- var paradoxGainVulgarTemplate = "<tr>"
- +"<td style='padding-left: 20px; padding-right: 20px;'>"
- +'<span style="color:red"><b>You gained One Paradox point for Vulgar Magic!</b></span>'
- +"</td>"
- +"</tr>";
- var paradoxGainTemplate = "<tr>"
- +"<td style='padding-left: 20px; padding-right: 20px;'>"
- +"<<BOTCHMAGIC>>"
- +"</td>"
- +"</tr>";
- var paradoxGainBotchConcidentalTemplate = '<span style="color:red"><b>You gained One point of Paradox per dot in highest Sphere!</b></span>';
- var paradoxGainBotchVulgarTemplate = '<span style="color:red"><b>You gained One point of Paradox and One point per dot in highest Sphere!</b></span>';
- var paradoxGainBotchVulgarWitnessTemplate = '<span style="color:red"><b>You gained Two points of Paradox and Two points per dot in highest Sphere!</b></span>';
- function MAGICdice(char, player, num, diff, spec, willpower, hidden, magic, whoSent){
- var suc = 0;
- var one = 0;
- var wp = willpower;
- var rolls = new Array();
- var rr = false;
- var mg = magic;
- if (num > 0)
- {
- if( diff == null ){diff = 6}
- if( diff > 10 ){diff = 10}
- if( diff < 3 ){diff = 3}
- if( num > 10 ){num = 10}
- if( spec != 1 && spec != 0 ){spec = 0}
- if( wp != 1 && wp != 0 ){wp = 0}
- if(mg > 2 || mg < 0) {mg = 0}
- var startText = "/w gm ";
- var tableCreation = tableMagicTemplate;
- if (mg == 0)
- {
- tableCreation = tableCreation.replace("<<TITLE>>",concidentalTemplate);
- }
- else if (mg == 1)
- {
- tableCreation = tableCreation.replace("<<TITLE>>", vulgarTemplate);
- }
- else
- {
- tableCreation = tableCreation.replace("<<TITLE>>", vulgarWitnessTemplate);
- }
- tableCreation = tableCreation.replace("<<DICENUMBER>>", num);
- tableCreation = tableCreation.replace("<<DIFFICULTY>>", diff);
- if ( spec == 1)
- {
- tableCreation = tableCreation.replace("<<HASSPECIALITY>>", hasMagicSpecialTemplate);
- }
- else
- {
- tableCreation = tableCreation.replace("<<HASSPECIALITY>>", "");
- }
- if (wp == 1)
- {
- suc=suc+1;
- tableCreation = tableCreation.replace("<<HASWILLPOWER>>", "<tr><td style='padding-left: 20px; padding-right: 20px;'><b>Willpower Used:</b> At least 1 success guaranteed.</td></tr>");
- }
- else
- {
- tableCreation = tableCreation.replace("<<HASWILLPOWER>>", "");
- }
- ten = 0;
- var strrolls = "";
- var checked = false;
- for ( var i=0; i<num; i++) {
- var roll = Math.floor((Math.random()*10)+1);
- rolls[i] = roll;
- checked = false;
- if ( roll>=diff )
- {
- checked = true;
- suc = suc+1;
- strrolls = strrolls + successMagicDiceTemplate.replace("<<DIE>>",roll);
- }
- if ( roll==1 && rr == false )
- {
- checked = true;
- one = one+1;
- strrolls = strrolls + botchMagicDiceTemplate;
- }
- if ( roll==10 && spec==1)
- {
- suc=suc+1;
- }
- if (checked == false)
- {
- strrolls = strrolls + roll + ' ';
- }
- }
- tableCreation = tableCreation.replace("<<DICEROLL>>", strrolls);
- rolls = new Array();
- var temp = suc-one;
- tableCreation = tableCreation.replace("<<GOODROLLS>>", suc);
- tableCreation = tableCreation.replace("<<ONEROLLS>>", one);
- tableCreation = tableCreation.replace("<<TOTALROLL>>", temp);
- if( (suc>one && suc >0) || wp == 1 )
- {
- tableCreation = tableCreation.replace("<<RESULT>>", successMagicResultTemplate);
- if (mg != 0)
- {
- tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainVulgarTemplate);
- }
- else
- {
- tableCreation = tableCreation.replace("<<PARADOXGAIN>>", "");
- }
- }
- else if( suc<one && suc==0 && wp == 0)
- {
- tableCreation = tableCreation.replace("<<RESULT>>", botchMagicResultTemplate);
- if (mg == 0)
- {
- tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainTemplate.replace("<<BOTCHMAGIC>>",paradoxGainBotchConcidentalTemplate));
- }
- if (mg == 1)
- {
- tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainTemplate.replace("<<BOTCHMAGIC>>",paradoxGainBotchVulgarTemplate));
- }
- if (mg == 2)
- {
- tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainTemplate.replace("<<BOTCHMAGIC>>",paradoxGainBotchVulgarWitnessTemplate));
- }
- }
- else
- {
- tableCreation = tableCreation.replace("<<RESULT>>", failureMagicResultTemplate);
- tableCreation = tableCreation.replace("<<PARADOXGAIN>>", "");
- }
- if (hidden==2)
- {
- var tempText = "/w " + whoSent + " "+tableCreation;
- if (player==1) sendChat("player|"+char, tempText);
- else sendChat("character|"+char, tempText);
- }
- if (hidden >= 1) tableCreation = "/w gm " + tableCreation;
- if (player==1) sendChat("player|"+char, tableCreation);
- else sendChat("character|"+char, tableCreation);
- }
- };
- on("chat:message", function(msg) {
- if( msg.type != 'api' ) return;
- var cmd = msg.content.toLowerCase().split(' ');
- if( cmd[0] == "!magic" ) {
- var inputName = msg.who;
- var list = findObjs({
- _type: "character",
- name: inputName
- });
- if (list.length == 0)
- {
- MAGICdice( msg.playerid, 1, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], inputName );
- }
- else
- {
- MAGICdice( list[0].id, 0, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], inputName );
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement