Iob Cris

try to take over the world!

  1. // ==UserScript==
  2. // @name Iob Cris
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://oib.io/
  8. // @grant none
  9. // ==/UserScript==
  10. //player.army.v
  11. //
  12. ( function ()
  13. {
  14. 'use strict';
  15. //Decode Lapa
  16. var decodeVar = [];
  17. var ArmyMaxLvl = 4;
  18. for ( var l = 0; 40000 > l; l++ )
  19. {
  20. var decode = "lapa" + l + "mauve";
  21. try
  22. {
  23. if ( typeof window[ decode ] != "undefined" )
  24. {
  25. decodeVar.push( window[ decode ] );
  26. console.log( decode );
  27. }
  28. }
  29. catch ( err )
  30. {
  31. console.log( err.message );
  32. }
  33. }
  34.  
  35. function loop ()
  36. {
  37. player.select.split = true;
  38. player.select.feed = true;
  39. player.select.regroup = true;
  40. for ( var k = 0; decodeVar[ 9 ].units.length > k; k++ )
  41. {
  42. decodeVar[ 9 ].units[ k ].info_delay = 9999999;
  43. }
  44. }
  45. setInterval( loop );
  46. // Control Keys
  47. var spawn = 49; //1
  48. var regroup = 50; //2
  49. var split = 51; //3
  50. var feed = 52; //4
  51. var spell = 53; //5
  52. var camera = 82; //r
  53. var select_oibs = 86; //v
  54. var select_queen = 66; //b
  55. var xPos = 0; //Mouse Position
  56. var yPos = 0; //Mouse Position
  57. //Script Keys
  58. // space 32
  59. // l 76
  60. // k 75
  61. // i 73
  62. // o 79
  63. // p 80
  64. // u 85
  65. var ScrptKeys = {
  66. StackOibs: 220,
  67. MakeArmy: 222,
  68. FeedQueen: 221,
  69. SplitIobs: 192,
  70. ClearActions: 32,
  71. MoveAll: 79,
  72. HealIobs:186
  73.  
  74. };
  75. var flag_ClearActions = false;
  76. var flag_FeedQueen = false;
  77. var flag_HealIobs = false;
  78. var flag_MakeArmy = false;
  79. var flag_MoveAll = false;
  80. var flag_SplitIobs = false;
  81. var flag_StackOibs = false;
  82. var spawner = setInterval( function ()
  83. {
  84. SendKey( spawn );
  85. }, 50 );
  86. var IntervalKeyHandle = setInterval( function ()
  87. {
  88. if ( flag_MakeArmy == true )
  89. {
  90. var k = 0;
  91. var iobarray = [];
  92. setTimeout( () =>
  93. {
  94. player.select.clean();
  95. }, 1 );
  96. //aquire my units
  97. for ( k = 0; decodeVar[ 9 ].units.length > k; k++ )
  98. {
  99. if ( decodeVar[ 9 ].units[ k ].id == player.id && decodeVar[ 9 ].units[ k ].queen == false && decodeVar[ 9 ].units[ k ].life > 0 )
  100. {
  101. iobarray.push( decodeVar[ 9 ].units[ k ] );
  102. }
  103. }
  104. //separate low level ones
  105. for ( k = 0; k < iobarray.length; k++ )
  106. {
  107. if ( iobarray[ k ].level < ArmyMaxLvl )
  108. {
  109. player.select.units.push( iobarray[ k ] );
  110. }
  111. }
  112. decodeVar[ 1 ][ "regroup" ]();
  113. }
  114. if ( flag_StackOibs == true )
  115. {
  116. SendKey( select_queen );
  117. SendRButton( xPos, yPos );
  118. SendKey( camera );
  119. }
  120. if ( flag_FeedQueen == true )
  121. {
  122. SendKey( select_oibs );
  123. SendKey( feed);
  124. SendKey( split );
  125. SendKey( select_oibs );
  126. SendKey( split );
  127. SendKey( select_oibs );
  128. SendKey( split );
  129. SendKey( select_oibs );
  130. SendKey( split );
  131. SendKey( select_oibs );
  132. SendKey( split );
  133. SendKey( select_oibs );
  134. SendKey( split );
  135. SendKey( select_oibs );
  136. SendKey( split );
  137. SendKey( select_oibs );
  138. SendKey( split );
  139. SendKey( select_oibs );
  140. SendKey( split );
  141. SendKey( select_oibs );
  142. SendKey( split );
  143. SendKey( select_oibs );
  144. SendKey( split );
  145. SendKey( feed );
  146. }
  147. if ( flag_MoveAll == true )
  148. {
  149. SendKey( select_oibs );
  150. SendKey( split );
  151. SendKey( split );
  152. SendKey( split );
  153. SendKey( select_oibs );
  154. SendKey( split );
  155. SendKey( split );
  156. SendKey( split );
  157. SendKey( select_oibs );
  158. SendRButton( xPos, yPos );
  159.  
  160. }
  161. if ( flag_HealIobs == true )
  162. {
  163. var MinHealth = Infinity;
  164. var MinLevel = Infinity;
  165. //split bigger
  166. var MyIobs = [];
  167. var IobIndexMinLife = -1;
  168. var IobIndexMinLevel = -1;
  169. //Get My Iobs
  170. for ( k = 0; decodeVar[ 9 ].units.length > k; k++ )
  171. {
  172. if ( decodeVar[ 9 ].units[ k ].id == player.id && decodeVar[ 9 ].units[ k ].queen == false && decodeVar[ 9 ].units[ k ].life > 0 )
  173. {
  174. MyIobs.push( decodeVar[ 9 ].units[ k ] );
  175. }
  176. }
  177. // - determine min health
  178. for ( let index = 0; index < MyIobs.length; index++ )
  179. {
  180. if ( MinHealth > MyIobs[ index ].life && MyIobs[ index ].level >= 3 )
  181. {
  182. MinHealth = MyIobs[ index ].life;
  183. IobIndexMinLife = index;
  184. }
  185. }
  186. player.select.clean();
  187. for ( let index = 0; index < MyIobs.length; index++ )
  188. {
  189. if ( MyIobs[ index ].level <= 2 )
  190. {
  191. player.select.units.push( MyIobs[ index ] );
  192. }
  193. }
  194. player.select.units.push( MyIobs[ IobIndexMinLife ] );
  195. decodeVar[ 1 ][ "regroup" ]();
  196. }
  197. }, 1 );
  198.  
  199. function CaptureKeyPress ( a )
  200. {
  201. if ( a.keyCode == ScrptKeys.StackOibs )
  202. {
  203. flag_ClearActions = false;
  204. flag_FeedQueen = false;
  205. flag_HealIobs = false;
  206. flag_MakeArmy = false;
  207. flag_MoveAll = false;
  208. flag_SplitIobs = false;
  209. SendKey( select_oibs );
  210. SendKey( feed );
  211. SendKey( select_queen );
  212. SendKey( camera );
  213. SendRButton( xPos, yPos );
  214. flag_StackOibs = true;
  215. return
  216. }
  217. if ( a.keyCode == ScrptKeys.MakeArmy )
  218. {
  219. flag_ClearActions = false;
  220. flag_FeedQueen = false;
  221. flag_HealIobs = false;
  222. flag_MoveAll = false;
  223. flag_SplitIobs = false;
  224. flag_StackOibs = false;
  225. if ( flag_MakeArmy == true )
  226. {
  227. flag_MakeArmy = false;
  228. return
  229. }
  230. if ( flag_MakeArmy == false )
  231. {
  232. player.select.clean();
  233. flag_MakeArmy = true;
  234. return
  235. }
  236. }
  237. if ( a.keyCode == ScrptKeys.HealIobs )
  238. {
  239. flag_ClearActions = false;
  240. flag_FeedQueen = false;
  241. flag_MakeArmy = false;
  242. flag_MoveAll = false;
  243. flag_SplitIobs = false;
  244. flag_StackOibs = false;
  245. if ( flag_HealIobs == true )
  246. {
  247. flag_HealIobs = false;
  248. return
  249. }
  250. if ( flag_HealIobs == false )
  251. {
  252. player.select.clean();
  253. flag_HealIobs = true;
  254. return
  255. }
  256. }
  257. if ( a.keyCode == ScrptKeys.FeedQueen )
  258. {
  259. flag_ClearActions = false;
  260. flag_HealIobs = false;
  261. flag_MakeArmy = false;
  262. flag_MoveAll = false;
  263. flag_SplitIobs = false;
  264. flag_StackOibs = false;
  265. if ( flag_FeedQueen == true )
  266. {
  267. flag_FeedQueen = false;
  268. return
  269. }
  270. if ( flag_FeedQueen == false )
  271. {
  272. flag_FeedQueen = true;
  273. return
  274. }
  275. }
  276. if ( a.keyCode == ScrptKeys.SplitIobs )
  277. {
  278. flag_ClearActions = false;
  279. flag_FeedQueen = false;
  280. flag_HealIobs = false;
  281. flag_MakeArmy = false;
  282. flag_MoveAll = false;
  283. flag_SplitIobs = false;
  284. flag_StackOibs = false;
  285. SendKey( select_oibs );
  286. SendKey( split );
  287. SendKey( split );
  288. SendKey( split );
  289. SendKey( split );
  290. SendKey( select_oibs );
  291. SendKey( split );
  292. SendKey( split );
  293. SendKey( split );
  294. SendKey( split );
  295. SendKey( select_oibs );
  296. SendKey( split );
  297. SendKey( split );
  298. SendKey( split );
  299. SendKey( split );
  300. SendKey( select_oibs );
  301. SendKey( split );
  302. SendKey( split );
  303. SendKey( split );
  304. SendKey( split );
  305. SendKey( select_oibs );
  306. SendRButton( xPos, yPos );
  307. }
  308. if ( a.keyCode == ScrptKeys.ClearActions )
  309. {
  310. flag_ClearActions = false;
  311. flag_FeedQueen = false;
  312. flag_HealIobs = false;
  313. flag_MakeArmy = false;
  314. flag_MoveAll = false;
  315. flag_SplitIobs = false;
  316. flag_StackOibs = false;
  317. return
  318. }
  319. if ( a.keyCode == ScrptKeys.MoveAll )
  320. {
  321. flag_ClearActions = false;
  322. flag_FeedQueen = false;
  323. flag_HealIobs = false;
  324. flag_MakeArmy = false;
  325. flag_SplitIobs = false;
  326. flag_StackOibs = false;
  327. if ( flag_MoveAll == true )
  328. {
  329. flag_MoveAll = false;
  330. return
  331. }
  332. if ( flag_MoveAll == false )
  333. {
  334. flag_MoveAll = true;
  335. return
  336. }
  337. }
  338. }
  339. var captureMousePos = function ( event )
  340. {
  341. xPos = event.clientX;
  342. yPos = event.clientY;
  343. }
  344. /*
  345. var onMousedown = function ( e )
  346. {
  347. if ( e.which === 1 ) //LeftMouse
  348. {
  349. SendKey( select_queen );
  350. SendRButton( xPos, yPos );
  351. SendKey( camera );
  352. }
  353. else if ( e.which === 3 ) // RightMouse
  354. {
  355. SendKey( select_oibs );
  356. SendRButton( xPos, yPos );
  357. SendKey( camera );
  358. }
  359. }
  360. */
  361. function SelectHighLevel ()
  362. {
  363. player.select.clean();
  364. //split bigger
  365. var iobarray = [];
  366. var splitiob = [];
  367. for ( k = 0; decodeVar[ 9 ].units.length > k; k++ )
  368. {
  369. if ( decodeVar[ 9 ].units[ k ].id == player.id && decodeVar[ 9 ].units[ k ].queen == false && decodeVar[ 9 ].units[ k ].life > 0 )
  370. {
  371. iobarray.push( decodeVar[ 9 ].units[ k ] );
  372. }
  373. }
  374. for ( k = 0; k < iobarray.length; k++ )
  375. {
  376. if ( iobarray[ k ].level > ArmyMaxLvl )
  377. {
  378. splitiob.push( iobarray[ k ] );
  379. }
  380. }
  381. if ( splitiob.length == 0 )
  382. {
  383. return false
  384. }
  385. else
  386. {
  387. for ( k = 0; k < splitiob.length; k++ )
  388. {
  389. if ( splitiob[ k ].level > ArmyMaxLvl )
  390. {
  391. player.select.units.push( splitiob[ k ] );
  392. }
  393. }
  394. return true
  395. }
  396. }
  397.  
  398. function SendKey ( k )
  399. {
  400. var ev = new KeyboardEvent( 'keydown',
  401. {
  402. 'keyCode': k,
  403. 'which': k
  404. } );
  405. window.dispatchEvent( ev );
  406. ev = new KeyboardEvent( 'keyup',
  407. {
  408. 'keyCode': k,
  409. 'which': k
  410. } );
  411. window.dispatchEvent( ev );
  412. }
  413.  
  414. function SendRButton ( x, y )
  415. {
  416. var ev = new window.MouseEvent( "mouseup",
  417. {
  418. clientX: x,
  419. clientY: y,
  420. button: 2
  421. } );
  422. window.dispatchEvent( ev );
  423. }
  424.  
  425. function SendLButton ( x, y )
  426. {
  427. var ev = new window.MouseEvent( "mouseup",
  428. {
  429. clientX: x,
  430. clientY: y,
  431. button: 1
  432. } );
  433. window.dispatchEvent( ev );
  434. }
  435. window.addEventListener( "keydown", CaptureKeyPress );
  436. window.addEventListener( "mousemove", captureMousePos );
  437. //window.addEventListener( "mousedown", onMousedown );
  438. } )();