Advertisement
iradap

Autoheal com

Aug 19th, 2018
1,845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.98 KB | None | 0 0
  1. /* Cookie plugin - https://github.com/carhartl/jquery-cookie */
  2. (function (e) {
  3.     e.cookie = function (t, n, r) {
  4.         if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(n)) || n === null || n === undefined)) {
  5.             r = e.extend({}, r);
  6.             if (n === null || n === undefined) {
  7.                 r.expires = -1
  8.             }
  9.             if (typeof r.expires === "number") {
  10.                 var i = r.expires,
  11.                     s = r.expires = new Date;
  12.                 s.setDate(s.getDate() + i)
  13.             }
  14.             n = String(n);
  15.             return document.cookie = [encodeURIComponent(t), "=", r.raw ? n : encodeURIComponent(n), r.expires ? "; expires=" + r.expires.toUTCString() : "", r.path ? "; path=" + r.path : "", r.domain ? "; domain=" + r.domain : "", r.secure ? "; secure" : ""].join("")
  16.         }
  17.         r = n || {};
  18.         var o = r.raw ? function (e) {
  19.                 return e
  20.             } : decodeURIComponent;
  21.         var u = document.cookie.split("; ");
  22.         for (var a = 0, f; f = u[a] && u[a].split("="); a++) {
  23.             if (o(f[0]) === t) return o(f[1] || "")
  24.         }
  25.         return null
  26.     }
  27. })(jQuery);
  28.  
  29. /*
  30.     Ostatnie zmiany: 01-03-2017, dodanie nowych itemow leczacych, pozdrawiam ;)
  31. */
  32.  
  33. g.loadQueue.push({
  34.     fun: function () {
  35.         new(function () {
  36.             this.niceForHealing = [
  37.              
  38.                 /*A*/
  39.               "Ash's Hardness",
  40.               "Adventurer's Soup",
  41.               "Aristocratic Medicament",
  42.               "Aloe Essence",
  43.               "Amethyst Mixture",
  44.  
  45.                 /*B*/
  46.               "Brown Ant Abdomen",
  47.               "Bottle of Hooch",
  48.               "Brown Soldier Ant Abdomen",
  49.               "Beetle Eggs",
  50.               "Brigand Elixir",
  51.               "Bottle of Sweet Vodka",
  52.               "Beekeepers' Honey",
  53.               "Boar's Meat Stew",
  54.               "Balsam Oil",
  55.               "Beech's Reliability",
  56.               "Blue Liquor of Masters",
  57.               "Beginner's Medicine",
  58.               "Billy's Wine",
  59.               "Birch's Firmness",
  60.               "Bog Incense",
  61.               "Bitter Orange Liqueur",
  62.               "Bear Potion",
  63.               "Bottle of Rum",
  64. "Beginner's Potion",
  65.              
  66.                 /*C*/
  67.               "Cadaver Brew",
  68.               "Chokeberry Syrup",
  69.               "Cookie with a Penguin",
  70.               "Caterpillar Larvae",
  71.               "Christmas Tincture",
  72.               "Chapel's Interior Coolness",
  73.               "Crocodile Skin Mixture",
  74.               "Cinnabar Mixture",
  75.               "Chrysoprase Mixture",
  76.               "Can of Dried Crickets",
  77. "Champagne Cocktail",
  78.  
  79.                 /*D*/
  80.               "Dwarven Elixir",
  81.               "Deck Rat Potion",
  82.               "Demon of Soul-binding",
  83.               "Demon of Clean Wounds",
  84.               "Delicious Western Mix",
  85.               "Deity's Serenity",
  86.               "Dumortierite Mixture",
  87. "Demonic Plasma Distillate",
  88.              
  89.                 /*E*/
  90.               "Elixir of Life",
  91.               "Elixir of Ogre Health",
  92.  
  93.  
  94.                 /*F*/
  95.               "Footman's Warming Elixir",
  96.               "Furboberry Juice",
  97.               "Flemona",
  98.               "Funny Smelling Potion",
  99.              
  100.                 /*G*/
  101.               "Gnoll Healing Mixture",
  102.               "Greater Elixir of Life",
  103.               "Greater Macehand Brew",
  104.               "Giant Spider Egg",
  105.               "Glace Cookie",
  106.               "Gingerbread Star of 2017",
  107.               "Gingerbread Xmas Tree of 2017",
  108.               "Green Fairy",
  109.               "Grenadine",
  110.                
  111.                 /*H*/
  112.               "Heather Elixir",
  113.               "Honeycomb",
  114.               "Heros's Ale",
  115.               "Huckleberry Potion",
  116.               "Heterogenous Milk Acid",
  117.               "Blood Mead",
  118.  
  119.                 /*I*/
  120.               "Immoderantiam",
  121.               "Imperial Soldier's Wine",
  122.               "Invigorating Wormwood Potion",
  123. "Interbad's Elixir",
  124.  
  125.                 /*J*/
  126.                 "Juniper Brew",
  127.  
  128.                 /*K*/
  129.  
  130.                 /*L*/
  131.               "Large Orange Mixture",
  132.               "Life-giving Archimother's Milk",
  133.               "Linden's Mildness",
  134.               "Lesser Elixir of Life",
  135.  
  136.                 /*M*/
  137.               "Mysterious Healing Potion",
  138.               "Macehand Magic Brew",
  139.               "Maggot Liver",
  140.               "Mild Purple Infusion",
  141.               "Mysterious Goblin Mixture",
  142.               "Maddok Spring Water",
  143.               "Maddok Tongue",
  144.               "Marona",
  145.               "Maddok Antivenin",
  146.  
  147.                 /*N*/
  148.  
  149.                 /*O*/
  150.               "Oak's Durability",
  151.  
  152.                 /*P*/
  153.               "Paladin Healing Potion",
  154.               "Paladin Healing Potion II",
  155.               "Potion of Vitality",
  156.               "Potent Moss Brew",
  157.               "Propolis",
  158.               "Pirate Rum",
  159.               "Purple Burberine",
  160.               "Potion of Eagerness",
  161.               "Potion of Vigor",
  162.               "Purple Blood",
  163.               "Prickly Pear's Sap",
  164.  
  165.                 /*R*/
  166.               "Ruby Drops",
  167.               "Rabbit Potion",
  168.               "Razuglag's Healing Elixir",
  169.               "Rat Itching",
  170.  
  171.                 /*S*/
  172.               "Sweet Brawnwater",
  173.               "Sweetwater Shark",
  174.               "Soldier's Brew",
  175.               "Stolen Elixir",
  176.               "Slimy Brew",
  177.               "Sparkling Dandelion Brew",
  178.               "Seaweed Jelly",
  179.               "Southern Bear Meat",
  180.               "Squirrel Potion",
  181.              
  182.              
  183.                 /*T*/
  184.               "Tarutaned of the Berserkers",
  185.               "Thin Blood of the Tortured",
  186.               "Traveler's Small Potion",
  187.               "Traveler's Medium Potion",
  188.               "Traveler's Large Potion",
  189.               "Traveler's Safe Haven",
  190.               "Tea with Ginger",
  191.              
  192.  
  193.                 /*U*/
  194.            
  195.                 /*V*/
  196.  
  197.                 /*W*/
  198.               "Wolf Potion",
  199.                
  200.                 /*Z*/
  201.              
  202.             ];
  203.             this.getCookie = function (name) {
  204.                 return $.cookie(name);
  205.             }
  206.             this.setCookie = function (name, value) {
  207.                 $.cookie(name, value, {
  208.                     expires: 365
  209.                 });
  210.             }
  211.             this.isNiceForHealing = function (name) {
  212.                 for (var i in this.niceForHealing)
  213.                     if (this.niceForHealing[i] == name) return true;
  214.                 return false;
  215.             }
  216.             this.isStatOk = function(item) {
  217.                 var stats = item.stat.split(";");
  218.                 for(var i in stats) {
  219.                     var stat = stats[i].split("=");
  220.                     if(stat[0] == "lvl") {
  221.                         if(stat[1] > hero.lvl)
  222.                             return false;
  223.                         else
  224.                             return true;
  225.                     } else if(stat[0] == "timelimit") {
  226.                         var times = stat[1].split(",");
  227.                         if(times.length == 2) {
  228.                             var nextTime = parseInt(times[1]) * 1000;
  229.                             return nextTime - new Date().getTime() < 0;
  230.                         }
  231.                     }
  232.                 }
  233.             return true;
  234.             }
  235.             this.hp = hero.hp;
  236.            
  237.             this.items = new Array();
  238.            
  239.             this.sortItems = function() {
  240.                 var t = this;
  241.                 t.items = new Array();
  242.                 for(var i in g.item){
  243.                     var item = g.item[i];
  244.  
  245.                     if(item.cl != 16 || item.loc != 'g' || item.stat.indexOf('leczy=') == -1 || !t.isNiceForHealing(item.name) || !t.isStatOk(item))
  246.                         continue;
  247.            
  248.                     t.items[t.items.length] = i;
  249.                 }
  250.                 t.items.sort();
  251.             }
  252.            
  253.             this.tryToHeal = function () {
  254.                 var t = this;
  255.                 if (hero.hp == hero.maxhp) return false;
  256.                
  257.                 t.sortItems();
  258.                
  259.                 for( var i in t.items) {
  260.                     var item = g.item[t.items[i]];
  261.                     var healHp = parseInt(item.stat.substr(item.stat.indexOf('leczy') + 6));
  262.                     if (healHp <= 0) return false;
  263.                     if (hero.maxhp - hero.hp >= healHp) {
  264.                         _g("moveitem&st=1&id=" + item.id);
  265.                         t.hp += healHp;
  266.                         setTimeout(function () {
  267.                             if (t.hp != hero.maxhp) t.tryToHeal();
  268.                         }, 700);
  269.                         return false;
  270.                     }
  271.                 }
  272.             }
  273.            
  274.             this.createPanel = function () {
  275.                 var t = this;
  276.                 $('<div></div>')
  277.                     .insertBefore('#centerbox')
  278.                     .attr('id', 'auto-leczenie')
  279.                     .attr('tip', "Kliknij dwukrotnie, aby zobaczyc listeobslugiwanych przedmiotow")
  280.                     .css('padding', '5px')
  281.                     .css('position', 'absolute')
  282.                     .css('top', parseInt(t.getCookie('auto-leczenie-y')))
  283.                     .css('left', parseInt(t.getCookie('auto-leczenie-x')))
  284.                     .css('z-index', 500)
  285.                     .css('background', "url(http://www.margonem.pl/img/menuback.png)")
  286.                     .css('border', '1px solid gold')
  287.                     .css('fontSize', 12)
  288.                     .css('fontFamily', 'Arial')
  289.                     .css('cursor', 'move')
  290.                     .css('width', 50)
  291.                     .css('textAlign', 'center')
  292.                     .html(
  293.                         '<span>Auto Leczenie</span>' +
  294.                         '<input type="checkbox"/>'
  295.                 )
  296.                     .draggable({
  297.                         containment: 'window',
  298.                         start: function (event, ui) {
  299.                             g.lock.add('auto-leczenie');
  300.                         },
  301.                         stop: function (event, ui) {
  302.                             t.setCookie('auto-leczenie-x', ui.position.left);
  303.                             t.setCookie('auto-leczenie-y', ui.position.top);
  304.                             g.lock.remove('auto-leczenie');
  305.                         }
  306.                     })
  307.                     .dblclick(function () {
  308.                         var c = t.niceForHealing.length;
  309.                         var firstLetter = '';
  310.                         var com = '<h2>List obslugiwanych przedmiotow:</h2><br/>';
  311.                         com += 'Jeseli brakuje jakiegos przedmiotu, napisz o tym w komentarzu pod dodatkiem podajac <u>bezposredni link do przedmiotu na <a href="http://www.emargo.pl">emargo.pl</a></u>. Przedmioty z tzw. "pelnym leczeniem" (<i>pozostalo X punktow uleczania</i>) <b>NIE</b> sa obslugiwane! Dokladnie zapoznaj sie z waznymi informacjami zawartymi w opisie dodatku!';
  312.                         com += '<div style="height:300px; overflow-y:auto; margin-top:10px; border: 1px solid #550; background-color:#fff; padding:10px;">';
  313.                         for (var i = 0; i < c; i++) {
  314.                             var m = t.niceForHealing[i];
  315.                             var f = m.substring(0, 1);
  316.                             if (firstLetter != f) {
  317.                                 firstLetter = f;
  318.                                 if(i != 0) com += '<br/>';
  319.                                 com += '<b>' + f + '</b><br/>';
  320.                             }
  321.                             com += m + '<br/>';
  322.                         }
  323.                         com += '</div>';
  324.                         mAlert(com);
  325.                     });
  326.                 if (t.getCookie('auto-leczenie') == 'on')
  327.                     $('#auto-leczenie > input').attr('checked', 'checked');
  328.                 $('#auto-leczenie > input').click(function () {
  329.                     if ($(this).is(':checked')) {
  330.                         t.setCookie('auto-leczenie', 'on');
  331.                     } else {
  332.                         t.setCookie('auto-leczenie', 'off');
  333.                     }
  334.                 });
  335.             }
  336.             this.run = function () {
  337.                 if (!this.getCookie('auto-leczenie')) {
  338.                     this.setCookie('auto-leczenie', 'on');
  339.                     this.setCookie('auto-leczenie-x', 0);
  340.                     this.setCookie('auto-leczenie-y', 0);
  341.                 }
  342.                 this.createPanel();
  343.                 var th = this;
  344.                 var oldBattleMsg = battleMsg;
  345.                 battleMsg = function (c, t) {
  346.                     var ret = oldBattleMsg(c, t);
  347.                     if (c.indexOf("winner=") >= 0 && hero.hp < hero.maxhp && th.getCookie('auto-leczenie') == 'on' && !g.dead) {
  348.                         th.tryToHeal();
  349.                     }
  350.                     return ret;
  351.                 }
  352.             }
  353.         })().run();
  354.     },
  355.     data: ""
  356. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement