Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $=window.jQuery,loc={},player={};
- var hits;
- var statSTR = $("#pro-stats span").contents()[0];
- var statDEX = $("#pro-stats span").contents()[1];
- var statINT = $("#pro-stats span").contents()[2];
- function getHits(){
- return hits;
- }
- function addHits(){
- hits++;
- }
- function getStats(stat,type) {
- var initial = 5;
- var current = stat;
- var hits = getHits();
- var stats;
- var compmod;
- if (initial==5) { compmod=0.005; } else { compmod=0; }
- var diff=current-initial-compmod;
- var mod, modmax, modin;
- var max, minmax;
- var i, j, g;
- if (type == "str") {
- mod=0.0009954;
- max=11;
- modmax=0.0012947;
- minmax=9;
- modin=0.0000014965;
- }
- else if (type == "dex") {
- mod=0.00057334;
- max=10;
- modmax=0.00072171;
- minmax=8;
- modin=0.0000007418493;
- }
- else if (type == "int") {
- mod=0.0001414791;
- max=10;
- modmax=0.000199425;
- minmax=8;
- modin=0.0000002897295;
- }
- max=(evalmaxStats(initial, current, hits, diff, stats, mod, modmax, modin, max, minmax, i, j, g)+evalminStats(initial, current, hits, diff, stats, mod, modmax, modin, max, minmax, i, j, g))/2;
- return max;
- }
- function evalmaxStats(initial, current, hits, diff, stats, mod, modmax, modin, max, minmax, i, j, g, modmod, maxmod, moddub) {
- j=mod;
- for (g=max; g>=minmax; g=g-0.01) {
- initial = 5;
- for (i=1; i<=hits; i++) {
- stats=initial+(g-initial)*j;
- initial=stats;
- if (((Math.round(stats*100))/100)==current && i==hits) {
- return g;
- }
- }
- j=j+modin;
- }
- }
- function evalminStats(initial, current, hits, diff, stats, mod, modmax, modin, max, minmax, i, j, g, modmod, maxmod, moddub) {
- j=modmax;
- for (g=minmax; g<=max; g=g+0.01) {
- initial = 5;
- for (i=1; i<=hits; i++) {
- stats=initial+(g-initial)*j;
- initial=stats;
- if (((Math.round(stats*100))/100)==current && i==hits) {
- return g;
- }
- }
- j=j-modin;
- }
- }
- var StatCalculator = function(){
- var statSTR = $("#pro-stats span").contents()[0];
- var statDEX = $("#pro-stats span").contents()[1];
- var statINT = $("#pro-stats span").contents()[2];
- getStats(statSTR,"str");
- getStats(statDEX,"dex");
- getStats(statINT,"int");
- };
- function keepPunching() {
- //for a more CircleMUD feel
- if(IPOptions.AUTO_SWING) {
- if(player.health<IPOptions.AUTO_SWING_THRESHOLD)
- {
- combatMessage("Your health is below the auto-swing threshold", "AUTO-SWING");
- return;
- }
- if(loc.type==="in combat!" && window.urlParams.type==="attack" && player.health>IPOptions.AUTO_FLEE)
- {
- setTimeout(function() {
- if(window.urlParams.hand==="RightHand") {addHits(); window.combatAttackWithRightHand();} else {addHits(); window.combatAttackWithLeftHand();}
- combatMessage("Attacking with "+window.urlParams.hand,"AUTO-SWING");
- }, IPOptions.COMBAT_DELAY);
- }
- if(loc.type==="in a fight!" && window.urlParams.type==="attack" && player.health>IPOptions.AUTO_FLEE)
- {
- setTimeout(function() {
- if(window.urlParams.hand==="RightHand") {addHits(); window.combatAttackWithRightHand();} else {addHits(); window.combatAttackWithLeftHand();}
- combatMessage("Attacking with "+window.urlParams.hand,"AUTO-SWING");
- addHits();
- }, IPOptions.INSTANCE_DELAY);
- }
- }
- if(IPOptions.AUTO_FLEE>0) {
- if((loc.type==="in combat!" || loc.type==="in a fight!") && player.health<=IPOptions.AUTO_FLEE) {
- combatMessage("Your health is below "+IPOptions.AUTO_FLEE+"%, trying to gtfo!","AUTO-FLEE");
- window.combatEscape();
- }
- }
- if(IPOptions.AUTO_REST && loc.rest===true && player.health<100) window.doRest();
- if(IPOptions.AUTO_LEAVE_FORGET && loc.type==="combat site") {
- if(IPOptions.AUTO_GOLD) {
- setTimeout(function() {
- if(window.gotGold===true) {
- $('a[onclick^="leaveAndForgetCombatSite"]').click();
- } else {
- location.reload();//we didn't get gold, reload and try again.
- }
- }, 7000); //reload after a wait to make sure we got gold
- } else {
- $('a[onclick^="leaveAndForgetCombatSite"]').click();
- }
- }
- }
- //display stats
- function statDisplay() {
- var settingKeys = Object.keys(IPOptions);
- var settingsHtml = $(settingKeys).map(function(idx, name) {
- if(typeof IPOptions[name] === "function") return "";
- var sVal = IPOptions[name];
- // Sanitize the setting value by checking if it's a checkbox, and converting value to a boolean.
- var cb = sVal === "true" || sVal === "false";
- if(cb) sVal = sVal === "true";
- return "<div class='row'>" +
- "<div class='cell'>" + name + "</div>" +
- "<div class='cell value'><input id='" + name + "' type='" +
- (typeof sVal === "boolean" ? ("checkbox" + (sVal ? "' checked='checked" : "")) : "text' value='" + sVal) + "'></div>" +
- "</div>";
- }).get().join("");
- $(".header-stats a:last").before("<span class='hint' rel='#InitiumProSettings'><img id='gear_icon' src='"+window.IMG_GEAR+"' border='0'></span>");
- $(".header-stats").append(
- "<div class='hiddenTooltip' id='InitiumProSettings'>" +
- "<div class='header'><h5>InitiumPro Settings</h5></div>" +
- "<div class='table'>" +
- settingsHtml +
- "</div><br/><center><a id='resetSettings'>Default Settings</a><center></div>");
- $("#resetSettings").on("click", resetDefaultSettings);
- // Have to attach at the body, since cluetip functionality is done after load.
- $("body").on("change", "#cluetip #InitiumProSettings input", function(event) {
- var element = $(event.currentTarget);
- var settingId = element.attr("id");
- // We have to modify the original hidden cluetip div as well, otherwise our UI settings won't stick
- if(element.is(":checkbox"))
- {
- // prop returns the correctly typed value of whatever property we're dealing with (in this case, bool)
- $("#InitiumProSettings #"+settingId).not(element).prop("checked", element.prop("checked"));
- IPOptions.ChangeSetting(settingId, element.prop("checked"));
- }
- else
- {
- // Only update the value if it's a valid number. Use + prefix to convert to number, which results in NaN if
- // it's not a valid integer value. Textboxes only "change" when focus is lost.
- if(!isNaN(+element.val()))
- {
- $("#InitiumProSettings #"+settingId).not(element).val(+element.val());
- IPOptions.ChangeSetting(settingId, +element.val());
- }
- }
- });
- $.ajaxQueue({
- url: $(".character-display-box:eq(0)").children().first().attr("rel"),
- }).done(function(data) {
- var stats = $(data).find('.main-item-subnote');
- $(".character-display-box:eq(0) > div:eq(1)").append("<div id='pro-stats' class='buff-pane'>"+
- //getStats(statSTR,"str").text();
- "<img src='"+window.IMG_STAT_SWORD+"'><span>"+$( stats[0] ).text().split(" ")[0]+"</span>"+//str
- "<img src='"+window.IMG_STAT_SHIELD+"'><span>"+$( stats[1] ).text().split(" ")[0]+"</span>"+//def
- "<img src='"+window.IMG_STAT_POTION+"'><span>"+$( stats[2] ).text().split(" ")[0]+"</span>"+//int
- "</a></div>");
- $('.header-stats a:nth-child(2)').children().html("Inv<span style=\"color:#AAA;margin-left:4px;margin-right:-5px;\">("+$( stats[3] ).text().split(" ")[0]+")</span> ");//carry
- $(".character-display-box:eq(0) > div:eq(1)").append("<div id='pro-stats' class='buff-pane'>"+
- //getStats(statSTR,"str").text();
- "<img src='"+window.IMG_STAT_SWORD+"'><span>"+"Hits:"+hits+"</span>"+//str
- "<img src='"+window.IMG_STAT_SHIELD+"'><span>"+$( stats[1] ).text().split(" ")[0]+"</span>"+//def
- "<img src='"+window.IMG_STAT_POTION+"'><span>"+$( stats[2] ).text().split(" ")[0]+"</span>"+//int
- "</a></div>");
- $('.header-stats a:nth-child(2)').children().html("Inv<span style=\"color:#AAA;margin-left:4px;margin-right:-5px;\">("+$( stats[3] ).text().split(" ")[0]+")</span> ");//carry
- });
- }
- //utility stuff
- function getThisPartyStarted() {
- //flags
- window.FLAG_LOADSHOPS=false;
- window.FLAG_LOADSHOPITEMS=false;
- window.gotGold=false;
- window.localItems={};
- window.urlParams=getUrlParams();
- //init stuff
- updateCSS();
- statDisplay();
- getLocalGold();
- getLocalStuff();
- //mutation observer watches the dom
- MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
- //setting up observers
- observe(["#instanceRespawnWarning",".popup_confirm_yes","#popups","#page-popup-root"],{childList:true,characterData:true,attributes:true,subtree:true});
- //finish up when page ready
- $(document).ready(function () {
- $("#page-popup-root").on("click", ".page-popup-Reload", function(event){
- var reloadPopup = $(event.target).parent().find(".page-popup:last");
- console.log(reloadPopup);
- if(reloadPopup.find("div[src^='/odp/ajax_viewstore.jsp']").length > 0)
- {
- console.log("Reloading store items...");
- window.ITEM_CACHE = {};
- var contentUrlParams = getUrlParams(reloadPopup.find("div[src^='/odp/ajax_viewstore.jsp']").attr("src"));
- if(contentUrlParams["characterId"]) delete window.MERCHANT_CACHE[contentUrlParams["characterId"]];
- setTimeout(loadShopItemDetails, 500);
- }
- else if(reloadPopup.find("div[src^='locationmerchantlist.jsp']").length > 0){
- console.log("Reloading merchant list...");
- window.MERCHANT_CACHE = {};
- setTimeout(loadLocalMerchantDetails, 500);
- }
- });
- player=getPlayerStats();
- loc=getLocation();
- updateLayouts();
- putHotkeysOnMap();
- keepPunching();
- StatCalculator();
- });
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement