hwmmapmove

перемещение по карте в один клик без коня

  1. // (c) 2008-2010, xo4yxa
  2. // (c) 2014-2016, Ded Moroz
  3. //
  4. // ==UserScript==
  5. // @name hwmmapmove
  6. // @namespace ded_moroz
  7. // @description перемещение по карте в один клик без коня
  8. // @version 3.0.4
  9. // @homepage https://greasyfork.org/users/7571-ded-moroz
  10. // @include http://www.heroeswm.ru/map.php*
  11. // @include http://www.lordswm.com/map.php*
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_deleteValue
  15. // @grant GM_xmlhttpRequest
  16. // ==/UserScript==
  17.  
  18. if (typeof GM_getValue != 'function')
  19. {
  20. this.GM_getValue = function (key, def) {return localStorage[key] || def;};
  21. this.GM_setValue = function (key, value) {return localStorage[key] = value;};
  22. this.GM_deleteValue = function (key) {return delete localStorage[key];};
  23. }
  24.  
  25. // get language based on domain
  26. var eng = location.hostname.contains('lordswm');
  27.  
  28. // copyright banner
  29. var coop = '<center style="font-size:10px;">&#169; <a href="mailto:ded_moroz@mail.com" style="font-size:10px;" target="_top">Ded Moroz</a> <a href="https://greasyfork.org/users/7571-ded-moroz" style="font-size:10px;">hwm map move</a> v. ' + GM_info.script.version + '. <span style="text-decoration:underline;cursor:pointer;font-weight:bold;" id="hwmmm_options">' + (eng ? 'Settings' : 'Настройки') + '</span></center>';
  30.  
  31. // current url
  32. var url = 'http://' + location.hostname + '/';
  33. // places with mercenary guild
  34. var loc_merc = [2, 6, 16, 21];
  35. var road = [];
  36.  
  37. // get player's nickname
  38. var nick = document.querySelector("object > param[value*='heart.swf']").parentNode.querySelector("param[name='FlashVars']").value.split('|')[3];
  39.  
  40. // generate GM variables based on player's nickname
  41. var GM_IS_MOVING = "hwm_map_move_is_moving_" + nick;
  42. var GM_LOC_TO = "hwm_map_move_loc_to_" + nick;
  43. var GM_LOC_RETURN = "hwm_map_move_loc_return_" + nick;
  44. var GM_TRANSPORT = 'hwm_map_move_transport_' + nick;
  45. var GM_CHECK_PATROL = 'hwm_map_move_check_patrol_' + nick;
  46. var GM_CHECK_HUNT = 'hwm_map_move_check_hunt_' + nick;
  47. var GM_CHECK_MERC = 'hwm_map_move_check_merc_' + nick;
  48. var GM_CHECK_HIDE_MAP = 'hwm_map_move_check_hide_map_' + nick;
  49. var GM_CHECK_VIEW_LOC = 'hwm_map_move_check_view_loc_' + nick;
  50. /*
  51. 0 - cur place
  52. 1 - view place
  53. 2-10 - have move
  54. 11 - hunter's guild
  55. 12 - thief's guild
  56. 13 - mercenary guild
  57. 14 - loc from move (only move)
  58. 15 - last time move (only move)
  59. 16 - all time move (only move)
  60. 17 - have transport with complex path
  61. 18 - magic number for moving
  62. 19 - ?
  63. 20 - clan id
  64. */
  65. var MapParams = {
  66. LOC_CURRENT : 0,
  67. LOC_VIEW : 1,
  68. LOC_MOVE_FIRST : 2,
  69. LOC_MOVE_LAST : 10,
  70. HUNT : 11,
  71. THIEF : 12,
  72. MERC : 13,
  73. LOC_FROM : 14,
  74. LAST_TIME : 15,
  75. COMPLEX_PATH : 17,
  76. MAGIC_NUMBER : 18
  77. };
  78.  
  79. // find flash map params
  80. var map_swf = document.querySelector("object[data*='map.swf']");
  81. var map_url = map_swf.data;
  82. var par = map_swf.querySelector("param[name='FlashVars']").value.split('=')[1].split(':');
  83.  
  84. // fix param 0
  85. if (par[0].contains('*english*')) par[0] = par[MapPar0].split('*english*')[1];
  86. if (par[0].contains('*')) par[0] = par[0].split('*')[1];
  87.  
  88. // hide map
  89. if (GM_getValue(GM_CHECK_HIDE_MAP) == 1) map_swf.style.display = 'none';
  90.  
  91. // move up the tree to the parent table
  92. var map_elem = map_swf.parentNode;
  93. while (map_elem.cellSpacing != '1' || map_elem.tagName.toLowerCase() != 'table') map_elem = map_elem.parentNode;
  94. // remove cell padding
  95. map_elem.cellSpacing = '0';
  96. // move to parent element to add sibling on it later
  97. map_elem = map_elem.parentNode;
  98.  
  99. // locations and its explicit paths
  100. var loc =
  101. [
  102. // name, row, col, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
  103. [], // 00
  104. [[ "Empire Capital", 2, 2], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 00, 00, 11, 00, 00, 00, 00, 00, 00, 00, 00, 05, 00], // 01
  105. [[ "East River", 2, 3], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 00, 15, 15, 00, 00, 19, 19, 00, 00, 00, 00, 00], // 02
  106. [[ "Tiger's Lake", 1, 2], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 15, 15, 00, 00, 00, 00, 00, 00, 00, 00, 05, 00], // 03
  107. [[ "Rogue's Wood", 1, 3], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 15, 15, 00, 00, 00, 19, 19, 00, 00, 00, 00, 00], // 04
  108. [[ "Wolf's Dale", 3, 2], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 00, 00, 11, 00, 10, 10, 10, 10, 00, 00, 00, 00, 00], // 05
  109. [[ "Peaceful Camp", 0, 2], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 00, 00, 00, 00, 00, 00, 00, 00, 05, 00], // 06
  110. [[ "Lizard's Lowland", 3, 1], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 00, 00, 11, 00, 00, 00, 00, 00, 00, 00, 00, 05, 00], // 07
  111. [[ "Green Wood", 2, 1], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 00, 00, 11, 00, 00, 00, 00, 00, 00, 00, 00, 05, 00], // 08
  112. [[ "Eagle's Nest", 0, 1], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 09
  113. [[ "Portal's ruins", 4, 2] ], // 10
  114. [[ "Dragon's Caves", 3, 3], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 19, 19, 00, 00, 00, 00, 00], // 11
  115. [[ "Shining Spring", 1, 1], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 15, 15, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 12
  116. [[ "Sunny City", 1, 0], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 15, 15, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 13
  117. [[ "Magma Mines", 2, 4], 11, 15, 15, 15, 00, 15, 00, 11, 15, 00, 00, 15, 15, 00, 00, 00, 00, 15, 00, 00, 11, 11, 15, 15, 00, 00, 11], // 14
  118. [[ "Bear' Mountain", 1, 4] ], // 15
  119. [[ "Fairy Trees", 0, 4], 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 00, 00, 00, 00, 00, 15, 15, 00, 00, 15, 15, 00, 15, 15], // 16
  120. [[ "Harbor City", 2, 5], 00, 15, 00, 00, 14, 00, 14, 00, 00, 14, 14, 00, 00, 00, 00, 00, 00, 00, 14, 14, 14, 14, 00, 00, 00, 14, 00], // 17
  121. [[ "Mythril Coast", 1, 5], 15, 15, 00, 00, 15, 15, 15, 15, 15, 15, 15, 00, 00, 15, 00, 00, 00, 00, 15, 15, 15, 15, 15, 15, 00, 15, 15], // 18
  122. [[ "Great Wall", 4, 3], 11, 00, 11, 00, 11, 11, 10, 11, 11, 00, 00, 11, 11, 11, 11, 11, 11, 11, 00, 00, 00, 00, 11, 00, 00, 00, 10], // 19
  123. [[ "Titans' Valley", 5, 3], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 11, 11, 11, 11, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 20
  124. [[ "Fishing village", 5, 4], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 11, 11, 11, 11, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 21
  125. [[ "Kingdom Castle", 6, 4], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, 11, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 22
  126. [[ "Ungovernable Steppe", 0, 0], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00], // 23
  127. [[ "Crystal Garden", 0, 3], 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 15, 00, 00, 00, 00, 19, 19, 00, 00, 00, 00, 00], // 24
  128. [], // 25
  129. [[ "The Wilderness", 4, 1], 00, 00, 00, 00, 00, 00, 05, 05, 05, 00, 00, 05, 05, 00, 00, 00, 00, 00, 00, 10, 10, 10, 05, 00, 00, 00, 05], // 26
  130. [[ "Sublime Arbor", 2, 0] ], // 27
  131. ];
  132.  
  133. // choose the right transport
  134. var transp = GM_getValue(GM_TRANSPORT, 0);
  135. if (par[MapParams.COMPLEX_PATH] == '')
  136. {
  137. // when moving COMPLEX_PATH is empty, so retrieve last saved
  138. par[MapParams.COMPLEX_PATH] = transp >= 3 ? 1 : 0;
  139. }
  140. else if (par[MapParams.COMPLEX_PATH] == 0)
  141. {
  142. if (transp >= 3)
  143. {
  144. // set default simple transport
  145. GM_setValue(GM_TRANSPORT, 0);
  146. transp = 0;
  147. }
  148. }
  149. else
  150. {
  151. if (transp < 3)
  152. {
  153. // set default advanced transport
  154. GM_setValue(GM_TRANSPORT, 3);
  155. transp = 3;
  156. }
  157. }
  158.  
  159. // map as 2D grid
  160. var map_square =
  161. [
  162. // 0 1 2 3 4 5
  163. [23, 09, 06, 24, 16, 00], // 0
  164. [13, 12, 03, 04, 15, 18], // 1
  165. [27, 08, 01, 02, 14, 17], // 2
  166. [00, 07, 05, 11, 00, 00], // 3
  167. [00, 26, 10, 19, 00, 00], // 4
  168. [00, 00, 00, 20, 21, 00], // 5
  169. [00, 00, 00, 00, 22, 00] // 6
  170. ];
  171.  
  172. // generate html code for the map
  173. var map_html = "";
  174. for (i = 0; i < map_square.length; i++)
  175. {
  176. map_html += '<tr>';
  177. for (j = 0; j < map_square[i].length; j++)
  178. {
  179. map_html += '<td>';
  180. if (map_square[i][j] != 0) map_html += '<div id="loc_' + map_square[i][j] + '"></div>';
  181. }
  182. }
  183.  
  184. if (par[MapParams.COMPLEX_PATH] == 0 && GM_getValue(GM_IS_MOVING) == 1)
  185. {
  186. // continue moving along the complex path
  187. move(parseInt(par[MapParams.LOC_CURRENT]), GM_getValue(GM_LOC_TO), false);
  188. }
  189. else
  190. {
  191. init();
  192. }
  193.  
  194. function init()
  195. {
  196. // find out where to return
  197. loc_return = GM_getValue(GM_LOC_RETURN);
  198. loc_return = GM_getValue(GM_CHECK_PATROL) == 1 ? loc_return : 0;
  199.  
  200. if (par[MapParams.LOC_FROM] != 0)
  201. {
  202. // currently moving, just update the destination info
  203. dst = GM_getValue(GM_LOC_TO);
  204. // create div and set its info text
  205. div = document.createElement('div');
  206. div_text = '<br><table><tr><td>' + (eng ? 'Moving to:' : 'Перемещение в:') + '<td><b>' + loc[par[MapParams.LOC_CURRENT]][0][0] +
  207. '</b><tr><td>' + (eng ? 'Destination:' : 'Пункт назначения:') + '<td><div id="hint_move"><b>' +
  208. loc[dst][0][0] + (loc_return > 0 ? ' —> ' + loc[loc_return][0][0] : '') + '</b>';
  209. // cancellation possible only if not arriving to destination
  210. if (loc_return > 0 || (par[MapParams.LOC_CURRENT] != dst && par[MapParams.COMPLEX_PATH] == 0))
  211. {
  212. div_text += ' [<a href="javascript: void(0)" id="a_stop_move">' + (eng ? 'cancel' : 'отмена') + '</a>]';
  213. }
  214. // assign text to div
  215. div_text += '</div></table><br>' + coop;
  216. div.innerHTML = div_text;
  217. // append div to the DOM tree
  218. map_elem.appendChild(div);
  219.  
  220. // cancellation possible only if not arriving to destination
  221. if (loc_return > 0 || (par[MapParams.LOC_CURRENT] != dst && par[MapParams.COMPLEX_PATH] == 0))
  222. {
  223. $('a_stop_move').addEventListener("click", function(){
  224. stop();
  225. $('hint_move').innerHTML = '<b>' + loc[par[MapParams.LOC_CURRENT]][0][0] + '</b>';
  226. }, false);
  227. }
  228. // setup callback for settings
  229. $("hwmmm_options").addEventListener("click", settings_open, false);
  230. // update countdown time in window title
  231. update_time(new Date().getTime(), document.title);
  232. }
  233. else
  234. {
  235. // currently not moving
  236.  
  237. // insert map into DOM
  238. div = document.createElement('div');
  239. div.innerHTML = '<br><table>' + map_html + '</table><br>' + coop + '<br>';
  240. map_elem.appendChild(div);
  241. // setup callback for settings
  242. $("hwmmm_options").addEventListener("click", settings_open, false);
  243.  
  244. // create a grid of map locations with the moving links
  245. for (l = 1; l < loc.length; l++)
  246. {
  247. var d = $('loc_' + l);
  248. // skip non-existing locations
  249. if (d == null) continue;
  250. d.parentNode.style.textAlign = 'center';
  251. d.style.padding = '1px 3px';
  252. d.style.fontSize = '11px';
  253. d.parentNode.style.border = par[MapParams.LOC_VIEW] == l ? '1px solid #00f' : '1px solid #abc';
  254.  
  255. if (l == par[MapParams.LOC_CURRENT])
  256. {
  257. // current location
  258. d.style.fontWeight = 'bold';
  259. d.parentNode.style.backgroundColor = 'FFF8DC';
  260. if (l == par[MapParams.MERC]) d.style.color = 'FF0000';
  261. d.innerHTML = loc[l][0][0];
  262. }
  263. else
  264. {
  265. // not current location
  266. // create a link and set attributes
  267. a = document.createElement('a');
  268. a.style.fontSize = '11px';
  269. a.innerHTML = loc[l][0][0];
  270. a.setAttribute('tz', l);
  271. a.id = "a" + l;
  272. // highlight locations with mercenaries' guild
  273. if (l == par[MapParams.MERC]) a.style.color = 'FF0000';
  274. a.href = 'javascript: void(0)';
  275. a.addEventListener("click", setMXY, false);
  276. a.addEventListener("mouseover", viewPath, false);
  277. a.addEventListener("mouseout", hidePath, false);
  278.  
  279. d.appendChild(a);
  280. }
  281.  
  282. // highlight locations with mercenaries' guild
  283. if (par[MapParams.MERC] == -1 && loc_merc.indexOf(l) != -1)
  284. {
  285. b = document.createElement('b');
  286. b.style.color = '#00F';
  287. b.innerHTML = ' X';
  288. d.appendChild(b);
  289. }
  290.  
  291. // view sector
  292. if (GM_getValue(GM_CHECK_VIEW_LOC) == 1 && par[MapParams.LOC_VIEW] != l)
  293. {
  294. a = document.createElement('a');
  295. a.href = url + 'map.php?cx=' + (48 + loc[l][0][2]) + '&cy=' + (48 + loc[l][0][1]);
  296. a.style.display = 'block';
  297. a.style.width = '100%';
  298. a.title = (eng ? 'View sector ' : 'Осмотреть сектор ') + loc[l][0][0];
  299. vi = document.createElement('img');
  300. vi.src = "data:image/gif,GIF89a%10%00%10%00%D5%00%00B%40B%15%15%18((-PPUzz%7FHHJ%5D%5D_--.zz%7BWWX23%3BEHS%80%88%A2rx%8C%DA%DD%E7bj%80sx%87%88%8C%97%7D%85%98HO_%7D%85%97%88%8C%95psz%DC%DD%DF%D4%D5%D7x%7F%8C%2B-0%C2%DF%FF%DF%F4%FFMOPmop%EF%F1%F2%E7%F9%FF%EA%FD%FF%E7%FF%FF%13%15%15%E9%FF%FF%18%1A%1A%FA%FF%FFmoo%FC%FF%FF%FD%FF%FFZ%5B%5B%5D%5D%5B%40%3F%3F%FF%FF%FF%16%16%16%10%10%10%05%05%05%00%00%00%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%002%00%2C%00%00%00%00%10%00%10%00%00%06%5C%40%99pH%2C%12%13%01%8D%80e%24%02ZP%A8%A2)k%C8%A2%D1As%01Ma'%CDF%D4%14%7D4!-%94%A8%95%BAJ%9A%07P%8B%E4mm%2C%D4H(%CA%A9%AC%A82%05%19%0C%14%041*%17%80E0%1D%18%8AD%2F%06%89%8FB%25'%1F%94B.%08-%992%23%1E%9ECA%00%3B";
  301. vi.style.border = '0px';
  302. a.appendChild(vi);
  303. d.parentNode.appendChild(a);
  304. }
  305. }
  306.  
  307. // report completed mercenaries' task if needed
  308. if (par[MapParams.MERC] == -1 && loc_merc.indexOf(parseInt(par[MapParams.LOC_CURRENT])) != -1 && GM_getValue(GM_CHECK_MERC) == 1)
  309. {
  310. window.location.href = url + 'mercenary_guild.php';
  311. return;
  312. }
  313. // dont move futher if there is a hunt
  314. if (par[MapParams.HUNT] != '' && GM_getValue(GM_CHECK_HUNT) == 1) return;
  315. // return if patrolling
  316. if (loc_return > 0) $("a" + loc_return).click();
  317. }
  318. }
  319.  
  320. function update_time(start, title)
  321. {
  322. s = par[MapParams.LAST_TIME] - ~~((new Date().getTime() - start) / 1000);
  323. if (s < 0) return;
  324. m = ~~(s / 60);
  325. s = s % 60;
  326.  
  327. if (s < 10) s = "0" + s;
  328. if (m < 10) m = "0" + m;
  329.  
  330. document.title = " [" + m + ":" + s + "] " + title;
  331. setTimeout(function(){update_time(start, title);}, 1000);
  332. }
  333.  
  334. function move(from, to, force_move)
  335. {
  336. // exit early if currently moving
  337. if (par[MapParams.LOC_FROM] != 0) return init();
  338. // stop if arrived or hunt is available
  339. if (to == from || (par[MapParams.HUNT] != '' && GM_getValue(GM_CHECK_HUNT) == 1 && !force_move))
  340. {
  341. // arrived
  342. GM_setValue(GM_IS_MOVING, 0);
  343. return init();
  344. }
  345. // check if can move directly with advanced transport
  346. if (par[MapParams.COMPLEX_PATH] != 0)
  347. {
  348. location.href = url + 'move_sector.php?id=' + to;
  349. return;
  350. }
  351.  
  352. // intercept wrong moves
  353. new_id = loc[from][to];
  354. if (new_id && new_id > 0) return move(from, new_id, force_move);
  355.  
  356. A = loc[from][0];
  357. B = loc[to][0];
  358.  
  359. row = B[1] > A[1] ? A[1] + 1 : (B[1] == A[1] ? A[1] : A[1] - 1);
  360. col = B[2] > A[2] ? A[2] + 1 : (B[2] == A[2] ? A[2] : A[2] - 1);
  361. go(map_square[row][col]);
  362. }
  363.  
  364. var warned = false;
  365. function go(to)
  366. {
  367. // check if move is legal
  368. if (par.slice(MapParams.LOC_MOVE_FIRST, MapParams.LOC_MOVE_LAST + 1).indexOf(to.toString()) != -1)
  369. {
  370. GM_xmlhttpRequest({
  371. method: "GET",
  372. url: map_url,
  373. onload: function (response)
  374. {
  375. /* ! Map checks enabled by default. Do NOT change it unless you know what you are doing. */
  376. map_swf_passed = false;
  377. /* Flash-maps which generate links as below */
  378. maps = [
  379. [225734, '4d0a16069039ebfa54983d5a67b63559'],
  380. [225624, 'a7fea5be847c93117af571b1878de374'],
  381. [224528, '016d1a1e22b572ea81527e13ee2f351d'],
  382. [223231, '2aa1b10e23ef9cd5ae43d3b3621b99ce'],
  383. [226207, 'cd22402c2e3d288cb29f4cdbd91ef3be'],
  384. [223243, '649adb9305afcb90862e32f550fd1828'],
  385. [220039, 'b441f0ac541408a809ec907b54cc0060'],
  386. ];
  387. new_size = response.responseText.length;
  388. new_hash = CryptoJS.MD5(response.responseText);
  389. for (i = 0; i < maps.length; i++)
  390. {
  391. if (new_size == maps[i][0] && new_hash == maps[i][1])
  392. {
  393. map_swf_passed = true;
  394. break;
  395. }
  396. }
  397. if (map_swf_passed)
  398. {
  399. rand = ((par[MapParams.LOC_CURRENT] * 153 + to * 234) % 333 * 234 + par[MapParams.MAGIC_NUMBER] % 346234 - 142) % 10000 / 10000;
  400. location.href = url + 'move_sector.php?id=' + to + '&rand=' + rand;
  401. return;
  402. }
  403. else
  404. {
  405. console.log("New map size: " + response.responseText.length);
  406. console.log("New map hash: " + new_hash);
  407. if (!warned)
  408. {
  409. warn = document.createElement('div');
  410. warn.innerHTML += "<center style='font-size:10px;color:red;'>" +
  411. (eng ? "Flash-map has been changed, generation of links for moving currently disabled" :
  412. "Flash-карта была изменена, генерация ссылок для перемещения отключена") + "</center>";
  413. map_elem.appendChild(warn);
  414. warned = true;
  415. }
  416. }
  417. // reset path
  418. stop();
  419. }
  420. });
  421. }
  422. else
  423. {
  424. if (eng) alert('No direct way from "' + loc[par[MapParams.LOC_CURRENT]][0][0] + '" to "' + loc[to][0][0] + '"');
  425. else alert('Нет прямого пути из "' + loc[par[MapParams.LOC_CURRENT]][0][0] + '" в "' + loc[to][0][0] + '"');
  426. // reset path
  427. stop();
  428. }
  429. }
  430.  
  431. function setMXY()
  432. {
  433. // save where to return if patrolling
  434. if (GM_getValue(GM_CHECK_PATROL) == 1) GM_setValue(GM_LOC_RETURN, par[MapParams.LOC_CURRENT]);
  435. // save destination and start moving
  436. GM_setValue(GM_LOC_TO, this.getAttribute('tz'))
  437. GM_setValue(GM_IS_MOVING, 1);
  438. move(parseInt(par[MapParams.LOC_CURRENT]), GM_getValue(GM_LOC_TO), true);
  439. }
  440.  
  441. function stop()
  442. {
  443. // prevent following the path
  444. GM_setValue(GM_IS_MOVING, 0);
  445. // prevent returning
  446. GM_setValue(GM_LOC_RETURN, 0);
  447. }
  448.  
  449. function setCheck()
  450. {
  451. // switch checkbox state
  452. name = this.getAttribute('id');
  453. if (GM_getValue(name) && GM_getValue(name) == 1)
  454. GM_setValue(name, 0);
  455. else
  456. GM_setValue(name, 1);
  457. }
  458.  
  459. function viewPath()
  460. {
  461. to = this.getAttribute('tz');
  462. return path(par[MapParams.LOC_CURRENT], to);
  463. function path(from, to)
  464. {
  465. if (to == from) return;
  466.  
  467. A = loc[from][0];
  468. B = loc[to][0];
  469. new_id = loc[from][to];
  470. if (new_id && new_id > 0) B = loc[new_id][0];
  471. drow = B[1] > A[1] ? 1 : (B[1] == A[1] ? 0 : -1);
  472. dcol = B[2] > A[2] ? 1 : (B[2] == A[2] ? 0 : -1);
  473. id = map_square[A[1] + drow][A[2] + dcol];
  474.  
  475. td = $('loc_' + id)
  476. td.parentNode.style.backgroundColor = 'F0E68C';
  477. road[road.length] = id;
  478. return path(id, to);
  479. }
  480. }
  481.  
  482. function hidePath()
  483. {
  484. for (i = 0; i < road.length; i ++)
  485. {
  486. $('loc_' + road[i]).parentNode.style.backgroundColor = 'DDD9CD';
  487. }
  488. road = [];
  489. }
  490.  
  491.  
  492. function settings_close()
  493. {
  494. bg = $('bgOverlay');
  495. bgc = $('bgCenter');
  496. if (bg) bg.style.display = bgc.style.display = 'none';
  497. // remove returning location
  498. if (GM_getValue(GM_CHECK_PATROL) != 1) GM_deleteValue(GM_LOC_RETURN);
  499. // show/hide map
  500. if (GM_getValue(GM_CHECK_HIDE_MAP) == 1) map_swf.style.display = 'none';
  501. else map_swf.style.display = '';
  502. }
  503.  
  504. function settings_open()
  505. {
  506. bg = $('bgOverlay');
  507. bgc = $('bgCenter');
  508. if (!bg)
  509. {
  510. bg = document.createElement('div');
  511. bg.id = 'bgOverlay';
  512. document.body.appendChild(bg);
  513. bg.style.position = 'absolute';
  514. bg.style.left = '0';
  515. bg.style.width = '100%';
  516. bg.style.height = '100%';
  517. bg.style.background = "#000000";
  518. bg.style.opacity = "0.5";
  519. bg.style.zIndex = '99999';
  520. bg.addEventListener("click", settings_close, false);
  521.  
  522. bgc = document.createElement('div');
  523. bgc.id = 'bgCenter';
  524. document.body.appendChild(bgc);
  525. bgc.style.position = 'absolute';
  526. bgc.style.width = '400px';
  527. bgc.style.background = "#F6F3EA";
  528. bgc.style.zIndex = bg.style.zIndex;
  529. bgc.style.left = ((document.body.offsetWidth - 400) / 2) + 'px';
  530. }
  531. if (eng)
  532. {
  533. var title = 'Settings';
  534. var check_patrol = 'patrolling mode';
  535. var check_hunt = 'stop on hunt';
  536. var check_merc = 'report Mercenaries\' guild tasks';
  537. var check_hide_map = 'hide flash-map';
  538. var check_view_loc = 'show buttons for viewing sectors';
  539. }
  540. else
  541. {
  542. var title = 'Настройки';
  543. var check_patrol = 'патрулирование';
  544. var check_hunt = 'останавливаться при охоте';
  545. var check_merc = 'сдавать задания Гильдии Наемников';
  546. var check_hide_map = 'не отображать flash-карту';
  547. var check_view_loc = 'отображать кнопки осмотра секторов';
  548. }
  549.  
  550. bgc.innerHTML = '<div style="border:1px solid #abc;padding:5px;margin:2px;"><div style="float:right;border:1px solid #abc;width:15px;height:15px;text-align:center;cursor:pointer;" id="bt_close" title="Close">x</div><center><table><tr><td><b>' + title + '</b></td></tr><tr><td>' +
  551. '<div><label style="cursor:pointer;"><input type="checkbox" id="' + GM_CHECK_PATROL + '"> ' + check_patrol + '</label></div>' +
  552. '<div><label style="cursor:pointer;"><input type="checkbox" id="' + GM_CHECK_HUNT + '"> ' + check_hunt + '</label></div>' +
  553. '<div><label style="cursor:pointer;"><input type="checkbox" id="' + GM_CHECK_MERC + '"> ' + check_merc + '</label></div>' +
  554. '<div><label style="cursor:pointer;"><input type="checkbox" id="' + GM_CHECK_HIDE_MAP + '"> ' + check_hide_map + '</label></div>' +
  555. '<div><label style="cursor:pointer;"><input type="checkbox" id="' + GM_CHECK_VIEW_LOC + '"> ' + check_view_loc + '</label></div>' +
  556. '</table>';
  557. $("bt_close").addEventListener("click", settings_close, false);
  558. check_id = [GM_CHECK_PATROL, GM_CHECK_HUNT, GM_CHECK_MERC, GM_CHECK_HIDE_MAP, GM_CHECK_VIEW_LOC];
  559. for (i = 0; i < check_id.length; i++)
  560. {
  561. checkbox = $(check_id[i]);
  562. checkbox.checked = GM_getValue(check_id[i], 0) == 1 ? 'checked' : '';
  563. checkbox.addEventListener("click", setCheck, false);
  564. }
  565.  
  566. bg.style.top = (-document.body.scrollTop) + 'px';
  567. bgc.style.top = (document.body.scrollTop + 150) + 'px';
  568. bg.style.display = bgc.style.display = 'block';
  569. }
  570.  
  571. function $(id) { return document.getElementById(id); }
  572.  
  573. /*
  574. CryptoJS v3.1.2
  575. code.google.com/p/crypto-js
  576. (c) 2009-2013 by Jeff Mott. All rights reserved.
  577. code.google.com/p/crypto-js/wiki/License
  578. */
  579. var CryptoJS=CryptoJS||function(s,p){var m={},l=m.lib={},n=function(){},r=l.Base={extend:function(b){n.prototype=this;var h=new n;b&&h.mixIn(b);h.hasOwnProperty("init")||(h.init=function(){h.$super.init.apply(this,arguments)});h.init.prototype=h;h.$super=this;return h},create:function(){var b=this.extend();b.init.apply(b,arguments);return b},init:function(){},mixIn:function(b){for (var h in b)b.hasOwnProperty(h)&&(this[h]=b[h]);b.hasOwnProperty("toString")&&(this.toString=b.toString)},clone:function(){return this.init.prototype.extend(this)}},
  580. q=l.WordArray=r.extend({init:function(b,h){b=this.words=b||[];this.sigBytes=h!=p?h:4*b.length},toString:function(b){return(b||t).stringify(this)},concat:function(b){var h=this.words,a=b.words,j=this.sigBytes;b=b.sigBytes;this.clamp();if (j%4)for (var g=0;g<b;g++)h[j+g>>>2]|=(a[g>>>2]>>>24-8*(g%4)&255)<<24-8*((j+g)%4);else if (65535<a.length)for (g=0;g<b;g+=4)h[j+g>>>2]=a[g>>>2];else h.push.apply(h,a);this.sigBytes+=b;return this},clamp:function(){var b=this.words,h=this.sigBytes;b[h>>>2]&=4294967295<<
  581. 32-8*(h%4);b.length=s.ceil(h/4)},clone:function(){var b=r.clone.call(this);b.words=this.words.slice(0);return b},random:function(b){for (var h=[],a=0;a<b;a+=4)h.push(4294967296*s.random()|0);return new q.init(h,b)}}),v=m.enc={},t=v.Hex={stringify:function(b){var a=b.words;b=b.sigBytes;for (var g=[],j=0;j<b;j++){var k=a[j>>>2]>>>24-8*(j%4)&255;g.push((k>>>4).toString(16));g.push((k&15).toString(16))}return g.join("")},parse:function(b){for (var a=b.length,g=[],j=0;j<a;j+=2)g[j>>>3]|=parseInt(b.substr(j,
  582. 2),16)<<24-4*(j%8);return new q.init(g,a/2)}},a=v.Latin1={stringify:function(b){var a=b.words;b=b.sigBytes;for (var g=[],j=0;j<b;j++)g.push(String.fromCharCode(a[j>>>2]>>>24-8*(j%4)&255));return g.join("")},parse:function(b){for (var a=b.length,g=[],j=0;j<a;j++)g[j>>>2]|=(b.charCodeAt(j)&255)<<24-8*(j%4);return new q.init(g,a)}},u=v.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(g){throw Error("Malformed UTF-8 data");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}},
  583. g=l.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(b){"string"==typeof b&&(b=u.parse(b));this._data.concat(b);this._nDataBytes+=b.sigBytes},_process:function(b){var a=this._data,g=a.words,j=a.sigBytes,k=this.blockSize,m=j/(4*k),m=b?s.ceil(m):s.max((m|0)-this._minBufferSize,0);b=m*k;j=s.min(4*b,j);if (b){for (var l=0;l<b;l+=k)this._doProcessBlock(g,l);l=g.splice(0,b);a.sigBytes-=j}return new q.init(l,j)},clone:function(){var b=r.clone.call(this);
  584. b._data=this._data.clone();return b},_minBufferSize:0});l.Hasher=g.extend({cfg:r.extend(),init:function(b){this.cfg=this.cfg.extend(b);this.reset()},reset:function(){g.reset.call(this);this._doReset()},update:function(b){this._append(b);this._process();return this},finalize:function(b){b&&this._append(b);return this._doFinalize()},blockSize:16,_createHelper:function(b){return function(a,g){return(new b.init(g)).finalize(a)}},_createHmacHelper:function(b){return function(a,g){return(new k.HMAC.init(b,
  585. g)).finalize(a)}}});var k=m.algo={};return m}(Math);
  586. (function(s){function p(a,k,b,h,l,j,m){a=a+(k&b|~k&h)+l+m;return(a<<j|a>>>32-j)+k}function m(a,k,b,h,l,j,m){a=a+(k&h|b&~h)+l+m;return(a<<j|a>>>32-j)+k}function l(a,k,b,h,l,j,m){a=a+(k^b^h)+l+m;return(a<<j|a>>>32-j)+k}function n(a,k,b,h,l,j,m){a=a+(b^(k|~h))+l+m;return(a<<j|a>>>32-j)+k}for (var r=CryptoJS,q=r.lib,v=q.WordArray,t=q.Hasher,q=r.algo,a=[],u=0;64>u;u++)a[u]=4294967296*s.abs(s.sin(u+1))|0;q=q.MD5=t.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878])},
  587. _doProcessBlock:function(g,k){for (var b=0;16>b;b++){var h=k+b,w=g[h];g[h]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var b=this._hash.words,h=g[k+0],w=g[k+1],j=g[k+2],q=g[k+3],r=g[k+4],s=g[k+5],t=g[k+6],u=g[k+7],v=g[k+8],x=g[k+9],y=g[k+10],z=g[k+11],A=g[k+12],B=g[k+13],C=g[k+14],D=g[k+15],c=b[0],d=b[1],e=b[2],f=b[3],c=p(c,d,e,f,h,7,a[0]),f=p(f,c,d,e,w,12,a[1]),e=p(e,f,c,d,j,17,a[2]),d=p(d,e,f,c,q,22,a[3]),c=p(c,d,e,f,r,7,a[4]),f=p(f,c,d,e,s,12,a[5]),e=p(e,f,c,d,t,17,a[6]),d=p(d,e,f,c,u,22,a[7]),
  588. c=p(c,d,e,f,v,7,a[8]),f=p(f,c,d,e,x,12,a[9]),e=p(e,f,c,d,y,17,a[10]),d=p(d,e,f,c,z,22,a[11]),c=p(c,d,e,f,A,7,a[12]),f=p(f,c,d,e,B,12,a[13]),e=p(e,f,c,d,C,17,a[14]),d=p(d,e,f,c,D,22,a[15]),c=m(c,d,e,f,w,5,a[16]),f=m(f,c,d,e,t,9,a[17]),e=m(e,f,c,d,z,14,a[18]),d=m(d,e,f,c,h,20,a[19]),c=m(c,d,e,f,s,5,a[20]),f=m(f,c,d,e,y,9,a[21]),e=m(e,f,c,d,D,14,a[22]),d=m(d,e,f,c,r,20,a[23]),c=m(c,d,e,f,x,5,a[24]),f=m(f,c,d,e,C,9,a[25]),e=m(e,f,c,d,q,14,a[26]),d=m(d,e,f,c,v,20,a[27]),c=m(c,d,e,f,B,5,a[28]),f=m(f,c,
  589. d,e,j,9,a[29]),e=m(e,f,c,d,u,14,a[30]),d=m(d,e,f,c,A,20,a[31]),c=l(c,d,e,f,s,4,a[32]),f=l(f,c,d,e,v,11,a[33]),e=l(e,f,c,d,z,16,a[34]),d=l(d,e,f,c,C,23,a[35]),c=l(c,d,e,f,w,4,a[36]),f=l(f,c,d,e,r,11,a[37]),e=l(e,f,c,d,u,16,a[38]),d=l(d,e,f,c,y,23,a[39]),c=l(c,d,e,f,B,4,a[40]),f=l(f,c,d,e,h,11,a[41]),e=l(e,f,c,d,q,16,a[42]),d=l(d,e,f,c,t,23,a[43]),c=l(c,d,e,f,x,4,a[44]),f=l(f,c,d,e,A,11,a[45]),e=l(e,f,c,d,D,16,a[46]),d=l(d,e,f,c,j,23,a[47]),c=n(c,d,e,f,h,6,a[48]),f=n(f,c,d,e,u,10,a[49]),e=n(e,f,c,d,
  590. C,15,a[50]),d=n(d,e,f,c,s,21,a[51]),c=n(c,d,e,f,A,6,a[52]),f=n(f,c,d,e,q,10,a[53]),e=n(e,f,c,d,y,15,a[54]),d=n(d,e,f,c,w,21,a[55]),c=n(c,d,e,f,v,6,a[56]),f=n(f,c,d,e,D,10,a[57]),e=n(e,f,c,d,t,15,a[58]),d=n(d,e,f,c,B,21,a[59]),c=n(c,d,e,f,r,6,a[60]),f=n(f,c,d,e,z,10,a[61]),e=n(e,f,c,d,j,15,a[62]),d=n(d,e,f,c,x,21,a[63]);b[0]=b[0]+c|0;b[1]=b[1]+d|0;b[2]=b[2]+e|0;b[3]=b[3]+f|0},_doFinalize:function(){var a=this._data,k=a.words,b=8*this._nDataBytes,h=8*a.sigBytes;k[h>>>5]|=128<<24-h%32;var l=s.floor(b/
  591. 4294967296);k[(h+64>>>9<<4)+15]=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360;k[(h+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;a.sigBytes=4*(k.length+1);this._process();a=this._hash;k=a.words;for (b=0;4>b;b++)h=k[b],k[b]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;return a},clone:function(){var a=t.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=t._createHelper(q);r.HmacMD5=t._createHmacHelper(q)})(Math);