Skip to content

Instantly share code, notes, and snippets.

@mookman288
Last active August 29, 2015 14:23
Show Gist options
  • Save mookman288/049d5e8025bf1a64118f to your computer and use it in GitHub Desktop.
Save mookman288/049d5e8025bf1a64118f to your computer and use it in GitHub Desktop.
A script just to handle wormhole propagation clumsily.
//Declare variables.
var $worm = jQuery('#abilityitem_26');
var $time = jQuery('#abilityitem_27');
var $gold = jQuery('#abilityitem_22');
var _interval;
//Set an interval to click the worm.
var _MHTH = setInterval(function() {
//Clear old intervals.
clearInterval(_interval);
//Return false if not level ending in 00.
if ((window.g_Minigame.m_CurrentScene.m_rgGameData.level + 1) % 100 !== 0) return doClear();
//Set another interval.
_interval = setInterval(function() {
//Click worm.
clickWorm();
}, Math.floor((Math.random() * 206) + 48));
}, 406);
//Abstract.
function clickTime() {
//Return false if not level ending in 00.
if ((window.g_Minigame.m_CurrentScene.m_rgGameData.level + 1) % 100 !== 0) return doClear();
//If time exists and has no active class.
if ($time.length && !$time.hasClass('active')) {
//Set a timeout.
setTimeout(function() {
//Click.
$time.children('a').click();
console.log('Than Human!');
//Click Worm.
clickWorm();
}, Math.floor((Math.random() * 115) * 51));
}
}
//Abstract.
function clickWorm() {
//Return false if not level ending in 00.
if ((window.g_Minigame.m_CurrentScene.m_rgGameData.level + 1) % 100 !== 0) return doClear();
//If worm exists and worm has no active class.
if ($worm.length && !$worm.hasClass('active')) {
//Click.
$worm.children('a').click();
console.log('More Human!');
} else {
//Click time.
clickTime();
}
//Piggy back to click on treasure, just for kicks.
if ($gold.length && !$gold.hasClass('active')) {
//Click.
$gold.children('a').click();
}
}
//Abstract.
function doClear() {
//Clear old intervals.
clearInterval(_interval);
//Return false.
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment