Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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;'>"
  2.                         +"<tr>"
  3.                             +"<td align='center' style='padding-top: 20px;padding-right: 20px;padding-left: 20px;'>"
  4.                                 +"<h3><<TITLE>></h3>"
  5.                             +"</td>"
  6.                         +"</tr>"
  7.                         +"<tr>"
  8.                             +"<td style='padding-left: 20px; padding-right: 20px'>"
  9.                                 + "<b>Rolling </b><<DICENUMBER>><b> dice.</b><br><b>Difficulty:</b> <<DIFFICULTY>>"
  10.                             +"</td>"
  11.                         +"</tr>"
  12.                         +"<<HASSPECIALITY>>"
  13.                         +"<<HASWILLPOWER>>"
  14.                         +"<tr>"
  15.                             +"<td style='padding-left: 20px; padding-right: 20px'>"
  16.                                 +"<b>Roll:</b> <<DICEROLL>>"
  17.                                 +"<br><b>Sucesses:</b> <<GOODROLLS>> <b>Ones:</b> <<ONEROLLS>>"
  18.                                 +"<br><b>Total:</b> <<TOTALROLL>>"
  19.                             +"</td>"
  20.                         +"</tr>"
  21.                         +"<tr>"
  22.                             +"<td style='padding-left: 20px; padding-right: 20px;'>"
  23.                                 +"<<RESULT>>"
  24.                             +"</td>"
  25.                         +"</tr>"
  26.                         +"<<PARADOXGAIN>>"
  27.                         +"<tr>"
  28.                             +"<td style='padding-left: 20px; padding-right: 20px; padding-bottom: 20px'>"
  29.                                 +""
  30.                             +"</td>"
  31.                         +"</tr>"
  32.                     +"</table>";
  33. var concidentalTemplate = "<span style='color:blue'>Coincidental Magic Roll</span>";
  34. var vulgarTemplate = "<span style='color:blue'>Vulgar Magic Roll</span>";
  35. var vulgarWitnessTemplate = "<span style='color:blue'>Vulgar with Witness Magic Roll</span>";
  36. var hasMagicSpecialTemplate = "<tr><td style='padding-left: 20px; padding-right: 20px'><b>Speciality:</b> 10 counts as two successes.</td></tr>";
  37. var successMagicDiceTemplate = "<img src='http://i.imgur.com/vZRADbK.png' title='<<DIE>>' height='20' width='20'/> ";
  38. var botchMagicDiceTemplate = '<img src="http://i.imgur.com/vyMMvoD.png" title="BOTCH" height="20" width="20"/> ';
  39.  
  40. var successMagicResultTemplate = '<span style="color:green"><b>SUCCESS</b></span>';
  41. var failureMagicResultTemplate = '<span style="color:red"><b>FAILURE</b></span>';
  42. 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"/>'
  43.  
  44. var paradoxGainVulgarTemplate = "<tr>"
  45.                             +"<td style='padding-left: 20px; padding-right: 20px;'>"
  46.                                 +'<span style="color:red"><b>You gained One Paradox point for Vulgar Magic!</b></span>'
  47.                             +"</td>"
  48.                         +"</tr>";
  49. var paradoxGainTemplate = "<tr>"
  50.                             +"<td style='padding-left: 20px; padding-right: 20px;'>"
  51.                                 +"<<BOTCHMAGIC>>"
  52.                             +"</td>"
  53.                         +"</tr>";
  54. var paradoxGainBotchConcidentalTemplate = '<span style="color:red"><b>You gained One point of Paradox per dot in highest Sphere!</b></span>';
  55. var paradoxGainBotchVulgarTemplate = '<span style="color:red"><b>You gained One point of Paradox and One point per dot in highest Sphere!</b></span>';
  56. var paradoxGainBotchVulgarWitnessTemplate = '<span style="color:red"><b>You gained Two points of Paradox and Two points per dot in highest Sphere!</b></span>';
  57.  
  58. function MAGICdice(char, player, num, diff, spec, willpower, hidden, magic, whoSent){
  59.     var suc = 0;
  60.     var one = 0;
  61.     var wp = willpower;
  62.     var rolls = new Array();
  63.     var rr = false;
  64.     var mg = magic;
  65.     if (num > 0)
  66.     {
  67.     if( diff == null ){diff = 6}
  68.     if( diff > 10 ){diff = 10}
  69.     if( diff < 3 ){diff = 3}
  70.     if( num > 10 ){num = 10}
  71.     if( spec != 1 && spec != 0 ){spec = 0}
  72.     if( wp != 1 && wp != 0 ){wp = 0}
  73.     if(mg > 2 || mg < 0) {mg = 0}
  74.    
  75.         var startText = "/w gm ";
  76.         var tableCreation = tableMagicTemplate;
  77.         if (mg == 0)
  78.         {
  79.             tableCreation = tableCreation.replace("<<TITLE>>",concidentalTemplate);
  80.         }
  81.         else if (mg == 1)
  82.         {
  83.             tableCreation = tableCreation.replace("<<TITLE>>", vulgarTemplate);
  84.         }
  85.         else
  86.         {
  87.             tableCreation = tableCreation.replace("<<TITLE>>", vulgarWitnessTemplate);
  88.         }
  89.         tableCreation = tableCreation.replace("<<DICENUMBER>>", num);
  90.         tableCreation = tableCreation.replace("<<DIFFICULTY>>", diff);
  91.         if ( spec == 1)
  92.         {
  93.             tableCreation = tableCreation.replace("<<HASSPECIALITY>>", hasMagicSpecialTemplate);
  94.         }
  95.         else
  96.         {
  97.             tableCreation = tableCreation.replace("<<HASSPECIALITY>>", "");
  98.         }
  99.         if (wp == 1)
  100.         {
  101.             suc=suc+1;
  102.             tableCreation = tableCreation.replace("<<HASWILLPOWER>>", "<tr><td style='padding-left: 20px; padding-right: 20px;'><b>Willpower Used:</b> At least 1 success guaranteed.</td></tr>");
  103.            
  104.         }
  105.         else
  106.         {
  107.             tableCreation = tableCreation.replace("<<HASWILLPOWER>>", "");
  108.         }
  109.         ten = 0;
  110.         var strrolls = "";
  111.         var checked = false;
  112.         for ( var i=0; i<num; i++) {
  113.             var roll = Math.floor((Math.random()*10)+1);
  114.             rolls[i] = roll;
  115.             checked = false;
  116.             if ( roll>=diff )
  117.             {
  118.                 checked = true;
  119.                 suc = suc+1;
  120.                 strrolls = strrolls + successMagicDiceTemplate.replace("<<DIE>>",roll);
  121.             }
  122.             if ( roll==1 && rr == false )
  123.             {
  124.                 checked = true;
  125.                 one = one+1;
  126.                 strrolls = strrolls + botchMagicDiceTemplate;
  127.             }
  128.             if ( roll==10 && spec==1)
  129.             {
  130.                 suc=suc+1;
  131.             }
  132.             if (checked == false)
  133.             {
  134.                 strrolls = strrolls +  roll + ' ';
  135.             }
  136.         }
  137.  
  138.    
  139.             tableCreation = tableCreation.replace("<<DICEROLL>>", strrolls);
  140.         rolls = new Array();
  141.        
  142.        
  143.             var temp = suc-one;
  144.          tableCreation = tableCreation.replace("<<GOODROLLS>>", suc);
  145.          tableCreation = tableCreation.replace("<<ONEROLLS>>", one);
  146.          tableCreation = tableCreation.replace("<<TOTALROLL>>", temp);
  147.          
  148.         if( (suc>one && suc >0) || wp == 1 )
  149.         {  
  150.             tableCreation = tableCreation.replace("<<RESULT>>", successMagicResultTemplate);  
  151.             if (mg != 0)
  152.             {
  153.                 tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainVulgarTemplate);  
  154.                
  155.             }
  156.             else   
  157.             {
  158.                 tableCreation = tableCreation.replace("<<PARADOXGAIN>>", "");  
  159.                 }  
  160.         }
  161.         else if( suc<one && suc==0 && wp == 0)
  162.         {  
  163.             tableCreation = tableCreation.replace("<<RESULT>>", botchMagicResultTemplate);
  164.             if (mg == 0)
  165.             {
  166.                 tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainTemplate.replace("<<BOTCHMAGIC>>",paradoxGainBotchConcidentalTemplate));  
  167.                
  168.             }
  169.             if (mg == 1)
  170.             {
  171.                 tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainTemplate.replace("<<BOTCHMAGIC>>",paradoxGainBotchVulgarTemplate));  
  172.            
  173.             }
  174.             if (mg == 2)
  175.             {
  176.                 tableCreation = tableCreation.replace("<<PARADOXGAIN>>", paradoxGainTemplate.replace("<<BOTCHMAGIC>>",paradoxGainBotchVulgarWitnessTemplate));  
  177.            
  178.             }
  179.         }
  180.         else
  181.         {  
  182.             tableCreation = tableCreation.replace("<<RESULT>>", failureMagicResultTemplate);  
  183.             tableCreation = tableCreation.replace("<<PARADOXGAIN>>", "");                  
  184.         }
  185.      
  186.         if (hidden==2)
  187.         {
  188.             var tempText = "/w " + whoSent + " "+tableCreation;
  189.             if (player==1) sendChat("player|"+char, tempText);
  190.             else sendChat("character|"+char, tempText);
  191.         }
  192.        
  193.         if (hidden >= 1) tableCreation = "/w gm " + tableCreation;
  194.        
  195.         if (player==1) sendChat("player|"+char, tableCreation);
  196.         else sendChat("character|"+char, tableCreation);
  197.     }
  198. };
  199.  
  200. on("chat:message", function(msg) {
  201.     if( msg.type != 'api' ) return;
  202.     var cmd = msg.content.toLowerCase().split(' ');
  203.     if( cmd[0] == "!magic" ) {
  204.        
  205.         var inputName = msg.who;
  206.         var list = findObjs({
  207.             _type: "character",
  208.             name: inputName
  209.         });
  210.        
  211.         if (list.length == 0)
  212.         {
  213.         MAGICdice( msg.playerid, 1, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], inputName );
  214.            
  215.         }
  216.         else
  217.         {
  218.         MAGICdice( list[0].id, 0, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], inputName );
  219.            
  220.         }
  221.     }
  222. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement