Advertisement
Belazor

Materia Scrip Farming

Aug 27th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Original paste: https://pastebin.com/W0GVicBX
  3.     Original paste credits: Kirie @ The Balance
  4.  
  5.     Modified to produce list of the Scrip cost for every estimated materia you need in addition to the raw gil.
  6. */
  7.  
  8.  
  9. var labels = {
  10.     "CMS:0": {label: "Craftsmanship +3", price: 800, priceLabel: "Gil"},
  11.     "CMS:1": {label: "Craftsmanship +4", price: 800, priceLabel: "Gil"},
  12.     "CMS:2": {label: "Craftsmanship +5", price: 800, priceLabel: "Gil"},
  13.     "CMS:3": {label: "Craftsmanship +6", price: 25, priceLabel: "Yellow Crafter's Scrip"},
  14.     "CMS:4": {label: "Craftsmanship +11", price: 200, priceLabel: "Yellow Crafter's Scrip"},
  15.     "CMS:5": {label: "Craftsmanship +16", price: 250, priceLabel: "Yellow Crafter's Scrip"},
  16.     "CMS:6": {label: "Craftsmanship +14", price: 250, priceLabel: "Yellow Crafter's Scrip"},
  17.     "CMS:7": {label: "Craftsmanship +21", price: 500, priceLabel: "White Crafter's Scrip"},
  18.     "CRL:0": {label: "Control +1", price: 400, priceLabel: "Gil"},
  19.     "CRL:1": {label: "Control +2", price: 600, priceLabel: "Gil"},
  20.     "CRL:2": {label: "Control +3", price: 500, priceLabel: "Gil"},
  21.     "CRL:3": {label: "Control +4", price: 25, priceLabel: "Yellow Crafter's Scrip"},
  22.     "CRL:4": {label: "Control +7", price: 200, priceLabel: "Yellow Crafter's Scrip"},
  23.     "CRL:5": {label: "Control +10", price: 250, priceLabel: "Yellow Crafter's Scrip"},
  24.     "CRL:6": {label: "Control +9", price: 250, priceLabel: "Yellow Crafter's Scrip"},
  25.     "CRL:7": {label: "Control +13", price: 500, priceLabel: "White Crafter's Scrip"},
  26.     "CP:0": {label: "CP +1", price: 1500, priceLabel: "Gil"},
  27.     "CP:1": {label: "CP +2", price: 18000, priceLabel: "Gil"},
  28.     "CP:2": {label: "CP +3", price: 2500, priceLabel: "Gil"},
  29.     "CP:3": {label: "CP +4", price: 25, priceLabel: "Yellow Crafter's Scrip"},
  30.     "CP:4": {label: "CP +6", price: 200, priceLabel: "Yellow Crafter's Scrip"},
  31.     "CP:5": {label: "CP +8", price: 250, priceLabel: "Yellow Crafter's Scrip"},
  32.     "CP:6": {label: "CP +7", price: 250, priceLabel: "Yellow Crafter's Scrip"},
  33.     "CP:7": {label: "CP +9", price: 500, priceLabel: "White Crafter's Scrip"},
  34.  
  35.     "PCP:0": {label: "Perception +3", price: 2000, priceLabel: "Gil"},
  36.     "PCP:1": {label: "Perception +4", price: 1000, priceLabel: "Gil"},
  37.     "PCP:2": {label: "Perception +5", price: 2000, priceLabel: "Gil"},
  38.     "PCP:3": {label: "Perception +6", price: 25, priceLabel: "Yellow Gatherer's Scrip"},
  39.     "PCP:4": {label: "Perception +10", price: 200, priceLabel: "Yellow Gatherer's Scrip"},
  40.     "PCP:5": {label: "Perception +15", price: 250, priceLabel: "Yellow Gatherer's Scrip"},
  41.     "PCP:6": {label: "Perception +12", price: 250, priceLabel: "Yellow Gatherer's Scrip"},
  42.     "PCP:7": {label: "Perception +20", price: 500, priceLabel: "White Gatherer's Scrip"},
  43.     "GTH:0": {label: "Gathering +3", price: 25000, priceLabel: "Gil"},
  44.     "GTH:1": {label: "Gathering +4", price: 2000, priceLabel: "Gil"},
  45.     "GTH:2": {label: "Gathering +5", price: 3000, priceLabel: "Gil"},
  46.     "GTH:3": {label: "Gathering +6", price: 25, priceLabel: "Yellow Gatherer's Scrip"},
  47.     "GTH:4": {label: "Gathering +10", price: 200, priceLabel: "Yellow Gatherer's Scrip"},
  48.     "GTH:5": {label: "Gathering +15", price: 250, priceLabel: "Yellow Gatherer's Scrip"},
  49.     "GTH:6": {label: "Gathering +12", price: 250, priceLabel: "Yellow Gatherer's Scrip"},
  50.     "GTH:7": {label: "Gathering +20", price: 500, priceLabel: "White Gatherer's Scrip"},
  51.     "GP:0": {label: "GP +1", price: 2500, priceLabel: "Gil"},
  52.     "GP:1": {label: "GP +2", price: 1000, priceLabel: "Gil"},
  53.     "GP:2": {label: "GP +3", price: 2600, priceLabel: "Gil"},
  54.     "GP:3": {label: "GP +4", price: 25, priceLabel: "Yellow Gatherer's Scrip"},
  55.     "GP:4": {label: "GP +6", price: 200, priceLabel: "Yellow Gatherer's Scrip"},
  56.     "GP:5": {label: "GP +8", price: 250, priceLabel: "Yellow Gatherer's Scrip"},
  57.     "GP:6": {label: "GP +7", price: 250, priceLabel: "Yellow Gatherer's Scrip"},
  58.     "GP:7": {label: "GP +9", price: 500, priceLabel: "White Gatherer's Scrip"}
  59. }
  60.  
  61. function cash() {
  62.     var prices = {
  63.                   "CP:7":300000*0, "CMS:7":400000*0, "CRL:7":800000*0,
  64.                   "CP:6":18000, "CMS:6":60000, "CRL:6":50000,
  65.                   "CP:5":14000, "CMS:5":30000, "CRL:5":50000,
  66.                   "CP:4":45000, "CMS:4":12000, "CRL:4":25000,
  67.                   "CP:3":3000, "CMS:3":1050, "CRL:3":4000,
  68.                   "CP:2":2500, "CMS:2":800, "CRL:2":500,
  69.                   "CP:1":18000, "CMS:1":800, "CRL:1":600,
  70.                   "CP:0":1500, "CMS:0":800, "CRL:0":400,
  71.                  
  72.                   "GP:7":50000, "PCP:7":220000, "GTH:7":220000,
  73.                   "GP:6":50000, "PCP:6":155000, "GTH:6":90000,
  74.                   "GP:5":7000, "PCP:5":60000, "GTH:5":60000,
  75.                   "GP:4":15000, "PCP:4":15000, "GTH:4":10500,
  76.                   "GP:3":5000,  "PCP:3":5050,   "GTH:3":5000,
  77.                   "GP:2":2600,  "PCP:2":2000,   "GTH:2":3000,
  78.                   "GP:1":1000,  "PCP:1":1000,   "GTH:1":2000,
  79.                   "GP:0":2500,  "PCP:0":2000,   "GTH:0":25000,
  80.     };
  81.     var counts = new Proxy({}, {
  82.       get: (target, name) => name in target ? target[name] : 0
  83.     })
  84.     var md = characterData.currentSet.materiaData;
  85.     var grandtotal = 0;
  86.  
  87.     function binom(p, r) {
  88.         for(var i = 0; i < 10000; i++) {
  89.             var prob = 1 - Math.pow(1 - p, i);
  90.             if(prob > r) {
  91.                 return i;
  92.             }
  93.         }
  94.     }
  95.  
  96.     for (let itemid in md) {
  97.         var itemtotal = 0;
  98.         var slotname = itemid.split('-')[0];
  99.        
  100.         console.log(md[itemid]);
  101.         var itemdata = characterData.currentSet.items[slotname];
  102.         var item = md[itemid];
  103.         for(var i = 0; i < item.length; i++) {
  104.            
  105.             var materia = item[i];
  106.             var grade = materia.split(':')[1];
  107.             var overmeld_count = i - itemdata.materiaSlots;
  108.             if(overmeld_count >= 0) {
  109.                 var rate = ToolkitData.MateriaSuccessRates[overmeld_count][grade] / 100.0;
  110.                 var price = prices[materia];
  111.                 var ev = binom(rate, .95);
  112.                 var meldtotal = price * ev;
  113.                 itemtotal += meldtotal;
  114.                 counts[materia] = counts[materia] + ev;
  115.                 console.log(slotname + ' ' + i + ' ' + rate + ' ' + ev + ' ' + meldtotal.toLocaleString()  + ' gil');
  116.             } else {
  117.                 var price = prices[materia];
  118.                 var rate = 100;
  119.                 var ev = 1;
  120.                 var meldtotal = price;
  121.                 itemtotal += meldtotal;
  122.                 counts[materia] = counts[materia] + ev;
  123.                 console.log(slotname + ' ' + i + ' ' + rate + ' ' + ev + ' ' + meldtotal.toLocaleString() + ' gil');
  124.             }
  125.         }      
  126.         console.log(slotname + ' ' + itemtotal.toLocaleString());
  127.         grandtotal += itemtotal;
  128.     }
  129.     console.log("grand total: " + grandtotal.toLocaleString() + ' gil');
  130.     return counts;
  131. }
  132.  
  133. var res = cash();
  134.  
  135. console.log("\nScrip:");
  136.  
  137. Object.keys(labels).forEach(function (item) {
  138.     var count = res[item];
  139.     if (count > 0)
  140.     {
  141.         var materia = labels[item];
  142.  
  143.         console.log((materia.price * count) + ' ' + materia.priceLabel + ' (' + count + 'x ' + materia.label + ')');
  144.     }
  145. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement