Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @id JSModExampleApp
- // @name Purchaser
- // @namespace .
- // @version 1.2
- // @author JackPS9
- // @include http://www.clickerheroes.com/
- // @grant none
- // @require http://code.jquery.com/jquery-2.1.1.min.js
- // @updateURL https://dl.dropboxusercontent.com/u/64858538/ClickerHeroes/Purchaser.js
- // ==/UserScript==
- (function () {
- "use strict";
- var main = function () {
- "use strict";
- //////////////////////
- //Editable variables//
- //////////////////////
- //Integer is in miliseconds
- var pur = 50; //Purchase Interval
- var asd = 30000; //Ascend Interval
- var bs = 135; //Zone Number of the last boss you want to fight
- //List of the IDs of your gilded heroes Cid = 1, Frostleaf = 26 (this link shows the IDs if you show contents http://clickerheroes.wikia.com/wiki/Upgrades)
- var guildedList = [];
- //The level of you dogcog
- var dogcoglvl = 12;
- //Solo Levels - Putting hero IDs in here will cause only these heroes to be leveled
- var tst = [];
- ///////////////////////////////
- //Edit nothing below this!!!!//
- ///////////////////////////////
- var JSMod = null;
- var loadAttempts = 0;
- var maxAttempts = 100;
- var loadTimeout = 10000;
- var baseCosts = [10, 50, 250, 1000, 4000, 20000, 100000, 400000, 2500000, 15000000, 100000000, 800000000, 6500000000, 50000000000, 450000000000, 4000000000000, 36000000000000, 320000000000000, 2700000000000000, 24000000000000000, 300000000000000000, 9000000000000000000, 350000000000000000000, 1.4e+22, 4.19999999999999e+24, 2.1e+27];
- var dogcog = 1 - (dogcoglvl * 0.02);
- var onlyLevels = false;
- //***** implement app here *****
- var App = {
- name: "JSMod Example App",
- onReady: function () {
- //Useless crap for this App
- //stage 1: JSMod has completely loaded. Do stuff like initializing your app here.
- init_app();
- },
- onPlaying: function () {
- //stage 2: User has pressed "play"-button in-game. You can now make calls to the game and receive data.
- //Where all the code really goes
- advance();
- setInterval(purchase, pur);//50 miliseconds
- setInterval(ascend, asd);//30 seconds
- if(tst.length < 0)
- {
- gildedList = tst;
- onlyLevels = true;
- }
- }
- };
- function calculateHeroCost(id, level){
- if (id === 0 && level <= 15) {
- return Math.floor((5 + level) * Math.pow(1.07, level) * dogcog);
- } else if (id === 0) {
- return Math.floor(20 * Math.pow(1.07, level) * dogcog);
- } else {
- return Math.floor(baseCosts[id] * Math.pow(1.07, level) * dogcog);
- }
- }
- function isGuilded(guildedList, heroID){
- var i = guildedList.length;
- while (i--) {
- if (guildedList[i] == heroID) {
- return true;
- }
- }
- return false;
- }
- function levelcheck(){
- var lvl = 10;
- if(onlyLevels == true)
- {
- lvl = 0;
- }
- else
- {
- var save = JSON.parse(JSMod.getUserData());
- if(save.heroCollection.heroes[4].level >= 10){lvl = 25;}//The Wandering Fisherman
- if(save.heroCollection.heroes[9].level >= 25){lvl = 50;}//Alexa, Assassin
- if(save.heroCollection.heroes[14].level >= 50){lvl = 75;}//Sir George II, King's Guard
- if(save.heroCollection.heroes[20].level >= 75){lvl = 100;}//Amenhotep
- if(save.heroCollection.heroes[20].level >= 100){lvl = 150;}
- if(save.heroCollection.heroes[26].level >= 25){lvl = 200;}//Frost Leaf
- if(save.heroCollection.heroes[26].level >= 35){lvl = 300;}
- if(save.heroCollection.heroes[26].level >= 50){lvl = 400;}
- if(save.heroCollection.heroes[26].level >= 65){lvl = 500;}
- if(save.heroCollection.heroes[26].level >= 80){lvl = 60;}
- if(save.heroCollection.heroes[26].level >= 100){lvl = 700;}
- if(save.heroCollection.heroes[26].level >= 120){lvl = 8000;}
- if(save.heroCollection.heroes[26].level >= 150){lvl = 10000;}
- if(save.currentZoneHeight > bs){lvl = 1000;}
- }
- return lvl;
- }
- function Upgrades(){
- try{
- JSMod.buyAllAvailableUpgrades();
- }
- catch(e){};
- }
- function purchase(){
- var save = JSON.parse(JSMod.getUserData());
- var heroCosts = [];
- var currentGold = save.gold;
- var MLevel = levelcheck();
- for (i = 0; i < 26; i++) {
- if(save.heroCollection.heroes[i+1].level < MLevel || isGuilded(guildedList, i))
- {
- try{
- heroCosts[i] = calculateHeroCost(i, save.heroCollection.heroes[i+1].level);
- }catch(e){};
- }
- else
- {
- heroCosts[i] = Number.MAX_VALUE;
- }
- }
- if (currentGold > Math.min.apply(Math,heroCosts))
- {
- try{
- JSMod.levelHero(heroCosts.indexOf(Math.min.apply(Math,heroCosts)) + 1);
- }catch(e){};
- }
- Upgrades();
- }
- function advance(){
- JSMod.setProgressMode(true);
- }
- function ascend(){
- var save = JSON.parse(JSMod.getUserData());
- if(save.currentZoneHeight >= (bs+14))
- {
- JSMod.ascend();
- }
- advance();
- }
- function init_app() {
- //...
- }
- //******************************
- function init() {
- if (window.JSMod === undefined) {
- if (loadAttempts++ < maxAttempts) {
- window.setTimeout(init, loadTimeout/maxAttempts);
- } else {
- alert("Failed to load " + App.name + "! Cannot find JSMod object on global scope");
- }
- } else {
- JSMod = window.JSMod;
- JSMod.loadApp(App);
- }
- }
- init();
- }
- function inject(func) {
- var script = document.createElement("script");
- script.setAttribute("type", "text/javascript");
- script.appendChild(document.createTextNode("(" + func + ")();"));
- $("head").append(script)[0].removeChild(script);
- }
- $(inject(main));
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement