PathCreator

Create path has never been so easy

目前为 2018-01-31 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name PathCreator
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4.6
  5. // @description Create path has never been so easy
  6. // @author Drigtime
  7. // @match https://dofus-map.com/
  8. // @run-at document-idle
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
  10. // @require https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. var icon = {
  17. top: {
  18. move: L.icon({
  19. iconUrl: 'https://svgshare.com/i/54N.svg',
  20. className: 'top-arrow'
  21. }),
  22. gather: L.icon({
  23. iconUrl: 'https://svgshare.com/i/556.svg',
  24. className: 'top-arrow'
  25. }),
  26. fight: L.icon({
  27. iconUrl: 'https://svgshare.com/i/53n.svg',
  28. className: 'top-arrow'
  29. }),
  30. bank: L.icon({
  31. iconUrl: 'https://svgshare.com/i/54G.svg',
  32. className: 'top-arrow'
  33. }),
  34. phoenix: L.icon({
  35. iconUrl: 'https://svgshare.com/i/54x.svg',
  36. className: 'top-arrow'
  37. }),
  38. },
  39. left: {
  40. move: L.icon({
  41. iconUrl: 'https://svgshare.com/i/54m.svg',
  42. className: 'left-arrow'
  43. }),
  44. gather: L.icon({
  45. iconUrl: 'https://svgshare.com/i/555.svg',
  46. className: 'left-arrow'
  47. }),
  48. fight: L.icon({
  49. iconUrl: 'https://svgshare.com/i/54H.svg',
  50. className: 'left-arrow'
  51. }),
  52. bank: L.icon({
  53. iconUrl: 'https://svgshare.com/i/54v.svg',
  54. className: 'left-arrow'
  55. }),
  56. phoenix: L.icon({
  57. iconUrl: 'https://svgshare.com/i/557.svg',
  58. className: 'left-arrow'
  59. }),
  60. },
  61. bottom: {
  62. move: L.icon({
  63. iconUrl: 'https://svgshare.com/i/51x.svg',
  64. className: 'bottom-arrow'
  65. }),
  66. gather: L.icon({
  67. iconUrl: 'https://svgshare.com/i/54b.svg',
  68. className: 'bottom-arrow'
  69. }),
  70. fight: L.icon({
  71. iconUrl: 'https://svgshare.com/i/54o.svg',
  72. className: 'bottom-arrow'
  73. }),
  74. bank: L.icon({
  75. iconUrl: 'https://svgshare.com/i/53x.svg',
  76. className: 'bottom-arrow'
  77. }),
  78. phoenix: L.icon({
  79. iconUrl: 'https://svgshare.com/i/54q.svg',
  80. className: 'bottom-arrow'
  81. }),
  82. },
  83. right: {
  84. move: L.icon({
  85. iconUrl: 'https://svgshare.com/i/53t.svg',
  86. className: 'right-arrow'
  87. }),
  88. gather: L.icon({
  89. iconUrl: 'https://svgshare.com/i/54p.svg',
  90. className: 'right-arrow'
  91. }),
  92. fight: L.icon({
  93. iconUrl: 'https://svgshare.com/i/527.svg',
  94. className: 'right-arrow'
  95. }),
  96. bank: L.icon({
  97. iconUrl: 'https://svgshare.com/i/54w.svg',
  98. className: 'right-arrow'
  99. }),
  100. phoenix: L.icon({
  101. iconUrl: 'https://svgshare.com/i/543.svg',
  102. className: 'right-arrow'
  103. }),
  104. },
  105. havenbag: {
  106. move: L.icon({
  107. iconUrl: 'https://svgshare.com/i/58M.svg',
  108. className: 'havenbag-icon'
  109. }),
  110. gather: L.icon({
  111. iconUrl: 'https://svgshare.com/i/58N.svg',
  112. className: 'havenbag-icon'
  113. }),
  114. fight: L.icon({
  115. iconUrl: 'https://svgshare.com/i/5BW.svg',
  116. className: 'havenbag-icon'
  117. }),
  118. bank: L.icon({
  119. iconUrl: 'https://svgshare.com/i/5BL.svg',
  120. className: 'havenbag-icon'
  121. }),
  122. phoenix: L.icon({
  123. iconUrl: 'https://svgshare.com/i/5BB.svg',
  124. className: 'havenbag-icon'
  125. }),
  126. }
  127. };
  128.  
  129. $(function preloader() {
  130. if (document.images) {
  131. var img1 = new Image();
  132. var img2 = new Image();
  133. var img3 = new Image();
  134. var img4 = new Image();
  135. var img5 = new Image();
  136. var img6 = new Image();
  137. var img7 = new Image();
  138. var img8 = new Image();
  139. var img9 = new Image();
  140. var img10 = new Image();
  141. var img11 = new Image();
  142. var img12 = new Image();
  143. var img13 = new Image();
  144. var img14 = new Image();
  145. var img15 = new Image();
  146. var img16 = new Image();
  147. var img17 = new Image();
  148. var img18 = new Image();
  149. var img19 = new Image();
  150. var img20 = new Image();
  151. var img21 = new Image();
  152. var img22 = new Image();
  153. var img23 = new Image();
  154. var img24 = new Image();
  155. var img25 = new Image();
  156. img1.src = "https://svgshare.com/i/54N.svg";
  157. img2.src = "https://svgshare.com/i/54m.svg";
  158. img3.src = "https://svgshare.com/i/51x.svg";
  159. img4.src = "https://svgshare.com/i/53t.svg";
  160. img5.src = "https://svgshare.com/i/556.svg";
  161. img6.src = "https://svgshare.com/i/555.svg";
  162. img7.src = "https://svgshare.com/i/54b.svg";
  163. img8.src = "https://svgshare.com/i/54p.svg";
  164. img9.src = "https://svgshare.com/i/53n.svg";
  165. img10.src = "https://svgshare.com/i/54H.svg";
  166. img11.src = "https://svgshare.com/i/54o.svg";
  167. img12.src = "https://svgshare.com/i/527.svg";
  168. img13.src = "https://svgshare.com/i/54G.svg";
  169. img14.src = "https://svgshare.com/i/54w.svg";
  170. img15.src = "https://svgshare.com/i/54v.svg";
  171. img16.src = "https://svgshare.com/i/53x.svg";
  172. img17.src = "https://svgshare.com/i/54x.svg";
  173. img18.src = "https://svgshare.com/i/557.svg";
  174. img19.src = "https://svgshare.com/i/54q.svg";
  175. img20.src = "https://svgshare.com/i/543.svg";
  176. img21.src = "https://svgshare.com/i/58M.svg";
  177. img22.src = "https://svgshare.com/i/58N.svg";
  178. img23.src = "https://svgshare.com/i/5BW.svg";
  179. img24.src = "https://svgshare.com/i/5BL.svg";
  180. img25.src = "https://svgshare.com/i/5BB.svg";
  181. }
  182. });
  183.  
  184. var actualMap;
  185. var pathData = [];
  186. var pathLinearData = [];
  187. var bankData = [];
  188. var phenixData = [];
  189. var havenBagData = [];
  190.  
  191. var ressources = [
  192. [1, "Frêne"],
  193. [8, "Chêne"],
  194. [17, "Fer"],
  195. [24, "Argent"],
  196. [25, "Or"],
  197. [26, "Pierre de Bauxite"],
  198. [28, "If"],
  199. [29, "Ebène"],
  200. [30, "Orme"],
  201. [31, "Erable"],
  202. [32, "Charme"],
  203. [33, "Châtaignier"],
  204. [34, "Noyer"],
  205. [35, "Merisier"],
  206. [37, "Pierre de Kobalte"],
  207. [38, "Blé"],
  208. [39, "Houblon"],
  209. [42, "Lin"],
  210. [43, "Orge"],
  211. [44, "Seigle"],
  212. [45, "Avoine"],
  213. [46, "Chanvre"],
  214. [47, "Malt"],
  215. [52, "Etain"],
  216. [53, "Pierre Cuivrée"],
  217. [54, "Manganèse"],
  218. [55, "Bronze"],
  219. [61, "Edelweiss"],
  220. [66, "Menthe Sauvage"],
  221. [67, "Trèfle à 5 feuilles"],
  222. [68, "Orchidée Freyesque"],
  223. [71, "Greuvette"],
  224. [74, "Truite"],
  225. [75, "Goujon"],
  226. [76, "Poisson-Chaton"],
  227. [77, "Crabe"],
  228. [78, "Poisson Pané"],
  229. [79, "Carpe d'Iem"],
  230. [80, "Truite Vaseuse"],
  231. [81, "Sardine Brillante"],
  232. [84, "Puits"],
  233. [98, "Bombu"],
  234. [100, "Pichon"],
  235. [101, "Oliviolet"],
  236. [108, "Bambou"],
  237. [109, "Bambou sombre"],
  238. [110, "Bambou sacré"],
  239. [111, "Riz"],
  240. [112, "Pandouille"],
  241. [113, "Dolomite"],
  242. [114, "Silicate"],
  243. [121, "Kaliptus"],
  244. [131, "Perce-neige"],
  245. [132, "Poisskaille"],
  246. [133, "Tremble"],
  247. [134, "Frostiz"],
  248. [135, "Obsidienne"],
  249. [169, "Bar Akouda"],
  250. [254, "Ortie"],
  251. [255, "Sauge"],
  252. [256, "Ginseng"],
  253. [257, "Belladone"],
  254. [258, "Mandragore"],
  255. [259, "Noisetier"],
  256. [260, "Maïs"],
  257. [261, "Millet"],
  258. [263, "Brochet"],
  259. [264, "Kralamoure"],
  260. [265, "Anguille"],
  261. [266, "Dorade Grise"],
  262. [267, "Perche"],
  263. [268, "Raie"],
  264. [269, "Lotte"],
  265. [270, "Requin Marteau-Faucille"],
  266. [271, "Bar Rikain"],
  267. [272, "Morue"],
  268. [273, "Tanche"],
  269. [274, "Espadon"],
  270. [281, "Trèfle à 4 feuilles"],
  271. [283, "Chathon"],
  272. [287, "Aquajou"],
  273. [288, "Salikrone"],
  274. [289, "Quisnoa"],
  275. [290, "Patelle"],
  276. [291, "Écume de mer"],
  277. [293, "Écume de mer"],
  278. [294, "Aquajou"],
  279. [295, "Salikrone"],
  280. [296, "Quisnoa"],
  281. [297, "Patelle"],
  282. ];
  283. var picker = 4;
  284. var gatherData = [];
  285. var loadingFile = false;
  286. var havenToggle = false;
  287.  
  288. var css = document.createElement('style');
  289. css.type = 'text/css';
  290. css.textContent = 'body{font-family:"Open Sans",sans-serif!important;font-size:12px!important}#pathcreator{background:#212121;border-radius:5px;padding:10px;color:#fff;box-shadow:0 0 10px 0 rgba(0,0,0,0.6);font-family:arial;opacity:.95}.form-group input[type="radio"],.form-group input[type="checkbox"]{display:none}.form-group input[type="checkbox"] + .btn-group > label,.form-group input[type="radio"] + .btn-group > label{white-space:normal}.form-group input[type="checkbox"] + .btn-group > label.btn-default,.form-group input[type="radio"] + .btn-group > label.btn-default{color:#333;background-color:#fff;border-color:#ccc}.form-group input[type="checkbox"] + .btn-group > label.btn-primary,.form-group input[type="radio"] + .btn-group > label.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.form-group input[type="checkbox"] + .btn-group > label.btn-success,.form-group input[type="radio"] + .btn-group > label.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.form-group input[type="checkbox"] + .btn-group > label.btn-info,.form-group input[type="radio"] + .btn-group > label.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.form-group input[type="checkbox"] + .btn-group > label.btn-warning,.form-group input[type="radio"] + .btn-group > label.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.form-group input[type="checkbox"] + .btn-group > label.btn-danger,.form-group input[type="radio"] + .btn-group > label.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.form-group input[type="checkbox"] + .btn-group > label.btn-link,.form-group input[type="radio"] + .btn-group > label.btn-link{font-weight:400;color:#428bca;border-radius:0}.form-group input[type="radio"] + .btn-group > label span:first-child,.form-group input[type="checkbox"] + .btn-group > label span:first-child{display:none}.form-group input[type="radio"] + .btn-group > label span:first-child + span,.form-group input[type="checkbox"] + .btn-group > label span:first-child + span{display:inline-block}.form-group input[type="radio"]:checked + .btn-group > label span:first-child,.form-group input[type="checkbox"]:checked + .btn-group > label span:first-child{display:inline-block}.form-group input[type="radio"]:checked + .btn-group > label span:first-child + span,.form-group input[type="checkbox"]:checked + .btn-group > label span:first-child + span{display:none}.form-group input[type="checkbox"] + .btn-group > label span[class*="fa-"],.form-group input[type="radio"] + .btn-group > label span[class*="fa-"]{width:15px;float:left;margin:4px 0 2px -2px}.form-group input[type="checkbox"] + .btn-group > label span.content,.form-group input[type="radio"] + .btn-group > label span.content{margin-left:10px}.path-selector{padding-top:.5rem!important;padding-left:1rem!important;margin-right:0!important;margin-left:0!important}.no-gutters{margin-right:0!important;margin-left:0!important}.col-xs-6,.col-xs-12{padding-right:0!important;padding-left:0!important}.checkbox{padding-left:20px;margin-top:0!important;margin-bottom:5px!important}.checkbox label{display:inline-block;position:relative;padding-left:5px!important}.checkbox label::before{content:"";display:inline-block;position:absolute;width:17px;height:17px;left:0;margin-left:-20px;border:1px solid #ccc;border-radius:3px;background-color:#fff;-webkit-transition:border .15s ease-in-out,color .15s ease-in-out;-o-transition:border .15s ease-in-out,color .15s ease-in-out;transition:border .15s ease-in-out,color .15s ease-in-out}.checkbox label::after{display:inline-block;position:absolute;width:16px;height:16px;left:0;top:0;margin-left:-20px;padding-left:3px;padding-top:1px;font-size:11px;color:#555}.checkbox input[type="checkbox"]{opacity:0}.checkbox input[type="checkbox"]:checked + label::after{font-family:"FontAwesome";content:"\\f00c"}.checkbox input[type="checkbox"]:disabled + label{opacity:.65}.checkbox input[type="checkbox"]:disabled + label::before{background-color:#eee;cursor:not-allowed}.checkbox.checkbox-circle label::before{border-radius:50%}.checkbox.checkbox-inline{margin-top:0}.checkbox-primary input[type="checkbox"]:checked + label::before{background-color:#428bca;border-color:#428bca}.checkbox-primary input[type="checkbox"]:checked + label::after{color:#fff}.radio{padding-left:20px;margin-top:0!important;margin-bottom:5px!important}.radio label{display:inline-block;position:relative;padding-left:5px!important}.radio label::before{content:"";display:inline-block;position:absolute;width:17px;height:17px;left:0;margin-left:-20px;border:1px solid #ccc;border-radius:50%;background-color:#fff;-webkit-transition:border .15s ease-in-out;-o-transition:border .15s ease-in-out;transition:border .15s ease-in-out}.radio label::after{display:inline-block;position:absolute;content:" ";width:11px;height:11px;left:3px;top:3px;margin-left:-20px;border-radius:50%;background-color:#555;-webkit-transform:scale(0,0);-ms-transform:scale(0,0);-o-transform:scale(0,0);transform:scale(0,0);-webkit-transition:-webkit-transform .1s cubic-bezier(0.8,-0.33,0.2,1.33);-moz-transition:-moz-transform .1s cubic-bezier(0.8,-0.33,0.2,1.33);-o-transition:-o-transform .1s cubic-bezier(0.8,-0.33,0.2,1.33);transition:transform .1s cubic-bezier(0.8,-0.33,0.2,1.33)}.radio input[type="radio"]{opacity:0}.radio input[type="radio"]:checked + label::after{-webkit-transform:scale(1,1);-ms-transform:scale(1,1);-o-transform:scale(1,1);transform:scale(1,1)}.radio input[type="radio"]:disabled + label{opacity:.65}.radio input[type="radio"]:disabled + label::before{cursor:not-allowed}.radio.radio-inline{margin-top:0}.radio-primary input[type="radio"] + label::after{background-color:#428bca}.radio-primary input[type="radio"]:checked + label::before{border-color:#428bca}.radio-primary input[type="radio"]:checked + label::after{background-color:#428bca}.radio-danger input[type="radio"] + label::after{background-color:#d9534f}.radio-danger input[type="radio"]:checked + label::before{border-color:#d9534f}.radio-danger input[type="radio"]:checked + label::after{background-color:#d9534f}.radio-phenix input[type="radio"] + label::after,.radio-phenix input[type="radio"]:checked + label::after{background-color:#ab37c8}.radio-phenix input[type="radio"]:checked + label::before{border-color:#ab37c8}.radio-success input[type="radio"] + label::after{background-color:#5cb85c}.radio-success input[type="radio"]:checked + label::before{border-color:#5cb85c}.radio-success input[type="radio"]:checked + label::after{background-color:#5cb85c}.btn-flex{display:flex!important;align-items:stretch;align-content:stretch}.btn-flex .btn:first-child{flex-grow:1}.btn{outline:none!important}.btn-dark{color:#fff;background-color:#343a40;border-color:#343a40}.btn-dark:hover,.btn-dark:focus,.btn-dark:active,.btn-dark.active,.open .dropdown-toggle.btn-dark{color:#fff;background-color:#23272b;border-color:#343a40}.btn-dark:active,.btn-dark.active,.open .dropdown-toggle.btn-dark{background-image:none}.btn-dark.disabled,.btn-dark[disabled],fieldset[disabled] .btn-dark,.btn-dark.disabled:hover,.btn-dark[disabled]:hover,fieldset[disabled] .btn-dark:hover,.btn-dark.disabled:focus,.btn-dark[disabled]:focus,fieldset[disabled] .btn-dark:focus,.btn-dark.disabled:active,.btn-dark[disabled]:active,fieldset[disabled] .btn-dark:active,.btn-dark.disabled.active,.btn-dark[disabled].active,fieldset[disabled] .btn-dark.active{background-color:#343a40;border-color:#343a40}.btn-dark .badge{color:#343a40;background-color:#fff}.btn-flex{display:flex;align-items:stretch;align-content:stretch}.btn-flex .btn:first-child{flex-grow:1}.btn{outline:none!important}.btn-dark{color:#fff;background-color:#343a40;border-color:#343a40}.btn-dark:hover,.btn-dark:focus,.btn-dark:active,.btn-dark.active,.open .dropdown-toggle.btn-dark{color:#fff;background-color:#23272b;border-color:#343a40}.btn-dark:active,.btn-dark.active,.open .dropdown-toggle.btn-dark{background-image:none}.btn-dark.disabled,.btn-dark[disabled],fieldset[disabled] .btn-dark,.btn-dark.disabled:hover,.btn-dark[disabled]:hover,fieldset[disabled] .btn-dark:hover,.btn-dark.disabled:focus,.btn-dark[disabled]:focus,fieldset[disabled] .btn-dark:focus,.btn-dark.disabled:active,.btn-dark[disabled]:active,fieldset[disabled] .btn-dark:active,.btn-dark.disabled.active,.btn-dark[disabled].active,fieldset[disabled] .btn-dark.active{background-color:#343a40;border-color:#343a40}.btn-dark .badge{color:#343a40;background-color:#fff}#mapContainer[data-zoom="7"] .top-arrow{width:145px;margin-left:528.5px}#mapContainer[data-zoom="6"] .top-arrow{width:75px;margin-left:262.5px}#mapContainer[data-zoom="5"] .top-arrow{width:36px;margin-left:131.5px}#mapContainer[data-zoom="4"] .top-arrow{width:19px;margin-left:65.75px}#mapContainer[data-zoom="3"] .top-arrow{width:15px;margin-left:30.13px}#mapContainer[data-zoom="2"] .top-arrow{width:9.9px;margin-left:13.86px}#mapContainer[data-zoom="1"] .top-arrow{width:7px;margin-left:5.91px}#mapContainer[data-zoom="0"] .top-arrow{width:5.38px;margin-left:5.01px}#mapContainer[data-zoom="7"] .havenbag-icon{width:500.83px;margin-left:350.5833333px;margin-top:135.8px}#mapContainer[data-zoom="6"] .havenbag-icon{width:250px;margin-left:175px;margin-top:67.5px}#mapContainer[data-zoom="5"] .havenbag-icon{width:124.58px;margin-left:87.20833333px;margin-top:33.35px}#mapContainer[data-zoom="4"] .havenbag-icon{width:61.88px;margin-left:43.3125px;margin-top:16.28px}#mapContainer[data-zoom="3"] .havenbag-icon{width:30.52px;margin-left:21.36458333px;margin-top:7.74px}#mapContainer[data-zoom="2"] .havenbag-icon{width:14.84px;margin-left:10.390625px;margin-top:3.47px}#mapContainer[data-zoom="1"] .havenbag-icon{width:7.01px;margin-left:4.903645833px;margin-top:1.33px}#mapContainer[data-zoom="0"] .havenbag-icon{width:3.09px;margin-left:2.16015625px;margin-top:.27px}#mapContainer[data-zoom="7"] .left-arrow{width:324.26px;margin-top:356.5px}#mapContainer[data-zoom="6"] .left-arrow{width:161.59px;margin-top:177.75px}#mapContainer[data-zoom="5"] .left-arrow{width:80.53px;margin-top:88.38px}#mapContainer[data-zoom="4"] .left-arrow{width:40.13px;margin-top:44.19px}#mapContainer[data-zoom="3"] .left-arrow{width:30.87px;margin-top:19.34px}#mapContainer[data-zoom="2"] .left-arrow{width:23.75px;margin-top:7.42px}#mapContainer[data-zoom="1"] .left-arrow{width:18.27px;margin-top:1.86px}#mapContainer[data-zoom="0"] .left-arrow{width:14.05px;margin-top:1px}#mapContainer[data-zoom="7"] .right-arrow{width:324.26px;margin-left:878.74px;margin-top:356.5px}#mapContainer[data-zoom="6"] .right-arrow{width:161.59px;margin-left:439.41px;margin-top:177.75px}#mapContainer[data-zoom="5"] .right-arrow{width:80.53px;margin-left:219.47px;margin-top:88.38px}#mapContainer[data-zoom="4"] .right-arrow{width:40.13px;margin-left:110.37px;margin-top:44.19px}#mapContainer[data-zoom="3"] .right-arrow{width:30.87px;margin-left:43.38px;margin-top:19.34px}#mapContainer[data-zoom="2"] .right-arrow{width:23.75px;margin-left:12.88px;margin-top:7.42px}#mapContainer[data-zoom="1"] .right-arrow{width:18.27px;margin-left:1px;margin-top:1.86px}#mapContainer[data-zoom="0"] .right-arrow{width:14.05px;margin-left:1px;margin-top:1px}#mapContainer[data-zoom="7"] .bottom-arrow{width:145px;margin-left:528.5px;margin-top:648.2px}#mapContainer[data-zoom="6"] .bottom-arrow{width:75px;margin-left:262.5px;margin-top:319.5px}#mapContainer[data-zoom="5"] .bottom-arrow{width:36px;margin-left:131.5px;margin-top:160.91px}#mapContainer[data-zoom="4"] .bottom-arrow{width:19px;margin-left:65.75px;margin-top:78.02px}#mapContainer[data-zoom="3"] .bottom-arrow{width:15px;margin-left:30.13px;margin-top:31.09px}#mapContainer[data-zoom="2"] .bottom-arrow{width:9.9px;margin-left:13.86px;margin-top:11.59px}#mapContainer[data-zoom="1"] .bottom-arrow{width:7px;margin-left:5.91px;margin-top:3px}#mapContainer[data-zoom="0"] .bottom-arrow{width:5.38px;margin-left:5.01px;margin-top:0}#mapContainer[data-zoom="7"] .leaflet-popup{margin-left:601px}#mapContainer[data-zoom="6"] .leaflet-popup{margin-left:3005px}#mapContainer[data-zoom="5"] .leaflet-popup{margin-left:149.5px}#mapContainer[data-zoom="4"] .leaflet-popup{margin-left:74.25px}#mapContainer[data-zoom="3"] .leaflet-popup{margin-left:36.625px}#mapContainer[data-zoom="2"] .leaflet-popup{margin-left:17.8125px}#mapContainer[data-zoom="1"] .leaflet-popup{margin-left:8.40625px}#mapContainer[data-zoom="0"] .leaflet-popup{margin-left:3.703125px}';
  291. document.getElementsByTagName('head')[0].appendChild(css);
  292. var contenu = '';
  293. contenu = `
  294. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
  295. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  296. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.9.0/css/flag-icon.css">
  297. <div id="pathcreator" class="container" style="width: 186px;">
  298. <div class="row no-gutters" style="text-align: right; margin-right: 0rem;">
  299. <div class="btn-group">
  300. <button type="button" class="btn dropdown-toggle btn-dark" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div id="keyboardLayout" class="fa fa-keyboard-o"></div>
  301. </button>
  302. <ul class="dropdown-menu dropdown-menu-right">
  303. <li><a class="dropdown-item" href="#" id="azerty">
  304. <span class="fa fa-keyboard-o"></span> AZERTY</a></li>
  305. <li><a class="dropdown-item" href="#" id="qwerty">
  306. <span class="fa fa-keyboard-o"></span> QWERTY</a></li>
  307. </ul>
  308. </div>
  309. <div class="btn-group">
  310. <button type="button" class="btn dropdown-toggle btn-dark" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div id="languageDisplayer" class="flag-icon flag-icon-fr"></div>
  311. </button>
  312. <ul class="dropdown-menu dropdown-menu-right">
  313. <li><a class="dropdown-item" href="#" id="fr">
  314. <span class="flag-icon flag-icon-fr"></span> Français</a></li>
  315. <li><a class="dropdown-item" href="#" id="en">
  316. <span class="flag-icon flag-icon-gb"></span> English</a></li>
  317. <li><a class="dropdown-item" href="#" id="es">
  318. <span class="flag-icon flag-icon-es"></span> Español</a></li>
  319. </ul>
  320. </div>
  321. </div>
  322. <div class="path-selector">
  323. <div class="row no-gutters">
  324. <div class="col-xs-6">
  325. <div class="checkbox checkbox-primary">
  326. <input type="checkbox" id="pathTop">
  327. <label id="top" for="pathTop">Haut</label>
  328. </div>
  329. </div>
  330. <div class="col-xs-6">
  331. <div class="checkbox checkbox-primary">
  332. <input type="checkbox" id="pathBottom">
  333. <label id="bottom" for="pathBottom">Bas</label>
  334. </div>
  335. </div>
  336. </div>
  337. <div class="row no-gutters">
  338. <div class="col-xs-6">
  339. <div class="checkbox checkbox-primary">
  340. <input type="checkbox" id="pathLeft">
  341. <label id="left" for="pathLeft">Gauche</label>
  342. </div>
  343. </div>
  344. <div class="col-xs-6">
  345. <div class="checkbox checkbox-primary">
  346. <input type="checkbox" id="pathRight">
  347. <label id="right" for="pathRight">Droite</label>
  348. </div>
  349. </div>
  350. </div>
  351. <div class="row no-gutters">
  352. <div class="col-xs-12">
  353. <div class="checkbox checkbox-primary">
  354. <input type="checkbox" id="pathHavenBag">
  355. <label id="havenBag" for="pathHavenBag">Havre-sac</label>
  356. </div>
  357. </div>
  358. </div>
  359. </div>
  360. <button id="moveOption" class="btn btn-dark btn-block" data-toggle="collapse" data-target="#demo">More <span class="caret"></span></button>
  361. <div id="demo" class="collapse">
  362. <div class="form-group row" style="margin-top: 5px;margin-bottom: 5px;margin-left: 0px;">
  363. <div class="col-xs-12">
  364. <input type="checkbox" id="linear" />
  365. <div class="btn-group">
  366. <label for="linear" class="btn btn-default">
  367. <span class="fa fa-check-square-o fa-lg"></span>
  368. <span class="fa fa-square-o fa-lg"></span>
  369. <span id="linearButtonText" class="content">Linéaire</span>
  370. </label>
  371. <button type="button" class="btn btn-default dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  372. <span class="fa fa-info-circle"></span>
  373. </button>
  374. <div class="dropdown-menu" style="color: #111;padding: 10px">
  375. <p id="infoLinear">L'option linéaire permet de créer des trajet avec plusieur actions différente dans un ordre précis sur une même map</p>
  376. </div>
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. <hr style="border-top: 3px solid #111;margin-top:7px;margin-bottom:7px;" />
  382. <form>
  383. <div class="path-selector">
  384. <div class="row no-gutters">
  385. <div class="col-xs-6">
  386. <div class="radio radio-success">
  387. <input type="radio" id="gather" name="radioOption">
  388. <label id="tdgather" for="gather">Recolte</label>
  389. </div>
  390. </div>
  391. <div class="col-xs-6">
  392. <div class="radio radio-danger">
  393. <input type="radio" id="fight" name="radioOption">
  394. <label id="tdfight" for="fight">Combat</label>
  395. </div>
  396. </div>
  397. </div>
  398. <div class="row no-gutters">
  399. <div class="col-xs-6">
  400. <div class="radio radio-primary">
  401. <input type="radio" id="bank" name="radioOption">
  402. <label id="tdbank" for="bank">Banque</label>
  403. </div>
  404. </div>
  405. <div class="col-xs-6">
  406. <div class="radio radio-phenix">
  407. <input type="radio" id="phenix" name="radioOption">
  408. <label id="tdphoenix" for="phenix">Phenix</label>
  409. </div>
  410. </div>
  411. </div>
  412. <div class="row no-gutters">
  413. <div class="col-xs-12">
  414. <div class="radio">
  415. <input type="radio" id="move" name="radioOption" checked>
  416. <label id="tdMove" for="move">Deplacement</label>
  417. </div>
  418. </div>
  419. </div>
  420. </div>
  421. </form>
  422. <hr style="border-top: 3px solid #111;margin-top:7px;margin-bottom:7px;" />
  423. <p style="text-align: center;" id="restogather">Ressources à récolter</p>
  424. <div id="ressourcePickerBot" style="text-align: center;"><span id="ressourcePickerCreator" class="pickRessource" style="background-color: #0000008a; background-position: -260px 0px;">+</span></div>
  425. <hr style="border-top: 3px solid #111;margin-top:7px;margin-bottom:7px;" />
  426. <div class="btn-group btn-flex" style="margin-bottom: .5rem">
  427. <button type="button" class="btn btn-dark" id="saveFile">Sauvegarder</button>
  428. <button type="button" class="btn btn-dark dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  429. <span class="caret"></span>
  430. </button>
  431. <div class="dropdown-menu dropdown-menu-right">
  432. <input type="text" style="color: black;" placeholder="Nom du trajet" id="fileName">
  433. </div>
  434. </div>
  435. <button class="btn btn-dark btn-block" id="deletePath">Supprimer</button>
  436. <label class="btn btn-dark btn-block btn-file"><div id="loadAFile">Charger</div><input id="file" type="file" style="display: none;">
  437. </label>
  438. </div>
  439. <!-- Modal -->
  440. <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="top: 300px;">
  441. <div class="modal-dialog" role="document">
  442. <div class="modal-content">
  443. <div class="modal-header">
  444. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  445. <h4 class="modal-title" id="myModalLabel">Zaap : </h4>
  446. </div>
  447. <div class="modal-body">
  448. <label>Zaap d'arrivée :</label>
  449. <select class="form-control" id="sel1">
  450. <option value='{"map": "4,-19", "mapid": "84674563"}'>Astrub | 4,-19</option>
  451. <option value='{"map": "-32,-56", "mapid": "147768"}'>Bonta | -32,-56</option>
  452. <option value='{"map": "-26,35", "mapid": "144419"}'>Brâkmar | -26,35</option>
  453. <option value='{"map": "-1,13", "mapid": "88212746"}'>Amakna (Bord de la forêt maléfique) | -1,13</option>
  454. <option value='{"map": "3,-5", "mapid": "68552706"}'>Amakna (Château d'Amakna) | 3,-5</option>
  455. <option value='{"map": "5,7", "mapid": "88082704"}'>Amakna (Coins des Bouftous) | 5,7</option>
  456. <option value='{"map": "7,-4", "mapid": "68419587"}'>Amakna (Port de Madrestam) | 7,-4</option>
  457. <option value='{"map": "-2,0", "mapid": "88213271"}'>Amakna (Village d'Amakna) | -2,0</option>
  458. <option value='{"map": "-1,24", "mapid": "88212481"}'>Amakna (Plaîne des Scarafeuilles) | -1,24</option>
  459. <option value='{"map": "10,22", "mapid": "88085249"}'>Baie de Sufokia (Rivage Sufokien) | 10,22</option>
  460. <option value='{"map": "13,26", "mapid": "95422468"}'>Baie de Sufokia (Sufokia) | 13,26</option>
  461. <option value='{"map": "-46,18", "mapid": "154642"}'le d'Otomaïl (Village côtier) | -46,18</option>
  462. <option value='{"map": "-79,-41", "mapid": "54172969"}'le de Frigost (La Bourgade) | -79,-41</option>
  463. <option value='{"map": "-77,-73", "mapid": "54172489"}'le de Frigost (Village enseveli) | -77,-73</option>
  464. <option value='{"map": "35,12", "mapid": "156762120"}'le de Moon (Plage de la Tortue) | 35,12</option>
  465. <option value='{"map": "-16,1", "mapid": "73400320"}'>Montagne des Koalaks (Village des Eleveurs) | -16,1</option>
  466. <option value='{"map": "26,-37", "mapid": "13605"}'>Pandala Neutre (Faubourgs de Pandala) | 26,-37</option>
  467. <option value='{"map": "29,-49", "mapid": "15153"}'>Pandala Feu (Village de Feudala) | 29,-49</option>
  468. <option value='{"map": "-27,-36", "mapid": "142087694"}'>Plaine de Cania (Champs de Cania) | -27,-36</option>
  469. <option value='{"map": "-3,-42", "mapid": "156240386"}'>Plaine de Cania (Lac de Cania) | -3,-42</option>
  470. <option value='{"map": "-13,-28", "mapid": "165152263"}'>Plaine de Cania (Massif de Cania) | -13,-28</option>
  471. <option value='{"map": "-5,-23", "mapid": "84806401"}'>Plaine de Cania (Plaine des Porkass) | -5,-23</option>
  472. <option value='{"map": "-17,-47", "mapid": "147590153"}'>Plaine de Cania (Plaines Rocheuses) | -17,-47</option>
  473. <option value='{"map": "-20,-20", "mapid": "164364304"}'>Plaine de Cania (Route Rocailleuse) | -20,-20</option>
  474. <option value='{"map": "15,-58", "mapid": "173278210"}'>Saharach (Dunes des ossements) | 15,-58</option>
  475. <option value='{"map": "-25,12", "mapid": "171967506"}'>Landes de Sidimote (Route des Roulottes) | -25,12</option>
  476. </select>
  477. </div>
  478. <div class="modal-footer">
  479. <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
  480. <button type="button" class="btn btn-primary">Valider</button>
  481. </div>
  482. </div>
  483. </div>
  484. </div>`;
  485. $('#pickRessourceContainer').append(contenu);
  486.  
  487.  
  488. function checkMaps(mapcoord, array) {
  489. for (let key = 0; key < array.length; key++) {
  490. if (array[key].map == mapcoord) {
  491. return true;
  492. }
  493. }
  494. return false;
  495. }
  496.  
  497. function getMapIndex(mapcoord, array) {
  498. for (let key = 0; key < array.length; key++) {
  499. if (array[key].map == mapcoord) {
  500. return key;
  501. }
  502. }
  503. }
  504.  
  505. function onMapClick() {
  506.  
  507. if (!loadingFile)
  508. actualMap = $('#mapCoordinates').html();
  509.  
  510. if (RegExp(/<span>/).test(actualMap)) {
  511. actualMap = $('#mapCoordinates').html().split(/<span>/)[0];
  512. }
  513.  
  514. if ($('#pathHavenBag').is(":checked")) {
  515. $('#pathTop').prop('checked', false);
  516. $('#pathLeft').prop('checked', false);
  517. $('#pathBottom').prop('checked', false);
  518. $('#pathRight').prop('checked', false);
  519. if (!havenToggle) {
  520. if (!checkMaps(actualMap.split(', ')[0] + ',' + actualMap.split(', ')[1], havenBagData)) {
  521. havenToggle = true;
  522. $('#exampleModal').appendTo("body").modal('show');
  523. return;
  524. } else {
  525. havenBagData.splice(getMapIndex(actualMap.split(', ')[0] + ',' + actualMap.split(', ')[1], havenBagData), 1);
  526. }
  527. } else {
  528. havenToggle = false;
  529. }
  530. }
  531. if ($('#bank').is(":checked")) {
  532. if (!checkMaps(actualMap, bankData)) {
  533. if ($('#pathHavenBag').is(":checked")) {
  534. if (checkMaps(actualMap, pathData)) {
  535. removeArrow(getMapIndex(actualMap, pathData), pathData);
  536. deleteEmptyPath(pathData);
  537. return;
  538. } else if (checkMaps(actualMap, phenixData)) {
  539. removeArrow(getMapIndex(actualMap, phenixData), phenixData);
  540. deleteEmptyPath(phenixData);
  541. return;
  542. }
  543. }
  544. bankData.push({
  545. map: actualMap,
  546. top: {
  547. path: false,
  548. icon: undefined
  549. },
  550. bottom: {
  551. path: false,
  552. icon: undefined
  553. },
  554. right: {
  555. path: false,
  556. icon: undefined
  557. },
  558. left: {
  559. path: false,
  560. icon: undefined
  561. },
  562. havenbag: {
  563. path: false,
  564. icon: undefined
  565. },
  566. bank: false
  567. });
  568. createMarker(getMapIndex(actualMap, bankData), bankData);
  569. deleteEmptyPath(bankData);
  570. } else {
  571. removeArrow(getMapIndex(actualMap, bankData), bankData);
  572. deleteEmptyPath(bankData);
  573. }
  574. console.clear();
  575. for (let key in bankData) {
  576. console.log(key + ', map : ' + bankData[key].map + ', top : ' + bankData[key].top.path + ', bottom : ' + bankData[key].bottom.path + ', right : ' + bankData[key].right.path + ', left : ' + bankData[key].left.path + ', havenbag : ' + bankData[key].havenbag.path);
  577. }
  578. } else if ($('#phenix').is(":checked")) {
  579. if (!checkMaps(actualMap, phenixData)) {
  580. if ($('#pathHavenBag').is(":checked")) {
  581. if (checkMaps(actualMap, pathData)) {
  582. removeArrow(getMapIndex(actualMap, pathData), pathData);
  583. deleteEmptyPath(pathData);
  584. return;
  585. } else if (checkMaps(actualMap, bankData)) {
  586. removeArrow(getMapIndex(actualMap, bankData), bankData);
  587. deleteEmptyPath(bankData);
  588. return;
  589. }
  590. }
  591. phenixData.push({
  592. map: actualMap,
  593. top: {
  594. path: false,
  595. icon: undefined
  596. },
  597. bottom: {
  598. path: false,
  599. icon: undefined
  600. },
  601. right: {
  602. path: false,
  603. icon: undefined
  604. },
  605. left: {
  606. path: false,
  607. icon: undefined
  608. },
  609. havenbag: {
  610. path: false,
  611. icon: undefined
  612. },
  613. phenix: false
  614. });
  615. createMarker(getMapIndex(actualMap, phenixData), phenixData);
  616. deleteEmptyPath(phenixData);
  617. } else {
  618. removeArrow(getMapIndex(actualMap, phenixData), phenixData);
  619. deleteEmptyPath(phenixData);
  620. }
  621. console.clear();
  622. for (let key in phenixData) {
  623. console.log(key + ', map : ' + phenixData[key].map + ', top : ' + phenixData[key].top.path + ', bottom : ' + phenixData[key].bottom.path + ', right : ' + phenixData[key].right.path + ', left : ' + phenixData[key].left.path + ', havenbag : ' + phenixData[key].havenbag.path);
  624. }
  625. } else {
  626. if (!checkMaps(actualMap, pathData)) {
  627. if ($('#pathHavenBag').is(":checked")) {
  628. if (checkMaps(actualMap, bankData)) {
  629. removeArrow(getMapIndex(actualMap, bankData), bankData);
  630. deleteEmptyPath(bankData);
  631. return;
  632. } else if (checkMaps(actualMap, phenixData)) {
  633. removeArrow(getMapIndex(actualMap, phenixData), phenixData);
  634. deleteEmptyPath(phenixData);
  635. return;
  636. }
  637. }
  638. if ($('#linear').is(":checked")) {
  639. if (!checkMaps(actualMap, pathLinearData)) {
  640. pathLinearData.push({
  641. map: actualMap,
  642. top: {
  643. index: undefined,
  644. path: false,
  645. icon: undefined
  646. },
  647. bottom: {
  648. index: undefined,
  649. path: false,
  650. icon: undefined
  651. },
  652. right: {
  653. index: undefined,
  654. path: false,
  655. icon: undefined
  656. },
  657. left: {
  658. index: undefined,
  659. path: false,
  660. icon: undefined
  661. },
  662. havenbag: {
  663. index: undefined,
  664. path: false,
  665. icon: undefined
  666. },
  667. gather: false,
  668. fight: false,
  669. index: false
  670. });
  671. createMarker(getMapIndex(actualMap, pathLinearData), pathLinearData);
  672. deleteEmptyPath(pathLinearData);
  673. } else {
  674. removeArrow(getMapIndex(actualMap, pathLinearData), pathLinearData);
  675. deleteEmptyPath(pathLinearData);
  676. }
  677. } else {
  678. pathData.push({
  679. map: actualMap,
  680. top: {
  681. path: false,
  682. icon: undefined
  683. },
  684. bottom: {
  685. path: false,
  686. icon: undefined
  687. },
  688. right: {
  689. path: false,
  690. icon: undefined
  691. },
  692. left: {
  693. path: false,
  694. icon: undefined
  695. },
  696. havenbag: {
  697. path: false,
  698. icon: undefined
  699. },
  700. gather: false,
  701. fight: false,
  702. });
  703. createMarker(getMapIndex(actualMap, pathData), pathData);
  704. deleteEmptyPath(pathData);
  705. }
  706. } else {
  707. removeArrow(getMapIndex(actualMap, pathData), pathData);
  708. deleteEmptyPath(pathData);
  709. }
  710. console.clear();
  711. for (let key in pathData) {
  712. console.log(key + ', map : ' + pathData[key].map + ', top : ' + pathData[key].top.path + ', bottom : ' + pathData[key].bottom.path + ', right : ' + pathData[key].right.path + ', left : ' + pathData[key].left.path + ', havenbag : ' + pathData[key].havenbag.path + ', gather : ' + pathData[key].gather + ', fight : ' + pathData[key].fight);
  713. }
  714. }
  715. }
  716.  
  717. function deleteEmptyPath(array) {
  718. if (!array[getMapIndex(actualMap, array)].top.path && !array[getMapIndex(actualMap, array)].bottom.path && !array[getMapIndex(actualMap, array)].left.path && !array[getMapIndex(actualMap, array)].right.path && !array[getMapIndex(actualMap, array)].havenbag.path) {
  719. array.splice(getMapIndex(actualMap, array), 1);
  720. }
  721. }
  722.  
  723. function removeArrow(key, array) {
  724. removeArrowWay(key, array, "pathTop", "top");
  725. removeArrowWay(key, array, "pathLeft", "left");
  726. removeArrowWay(key, array, "pathBottom", "bottom");
  727. removeArrowWay(key, array, "pathRight", "right");
  728. removeArrowWay(key, array, "pathHavenBag", "havenbag");
  729. }
  730.  
  731. function removeArrowWay(key, array, className, iconType) {
  732. if ($('#' + className).is(":checked")) {
  733. if ($('#linear').is(":checked")) {
  734. if (array[key][iconType].icon !== undefined) {
  735. if (array[key].index == 4) {
  736. if (iconType == "top") {
  737. if (array[key].top.index == 1) {
  738. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  739. if (array[key].left.index > 1) array[key].left.index -= 1;
  740. if (array[key].right.index > 1) array[key].right.index -= 1;
  741. } else if (array[key].top.index == 2) {
  742. if (array[key].bottom.index > 2) array[key].bottom.index -= 1;
  743. if (array[key].left.index > 2) array[key].left.index -= 1;
  744. if (array[key].right.index > 2) array[key].right.index -= 1;
  745. } else if (array[key].top.index == 3) {
  746. if (array[key].bottom.index > 3) array[key].bottom.index -= 1;
  747. if (array[key].left.index > 3) array[key].left.index -= 1;
  748. if (array[key].right.index > 3) array[key].right.index -= 1;
  749. }
  750. } else if (iconType == "bottom") {
  751. if (array[key].bottom.index == 1) {
  752. if (array[key].top.index > 1) array[key].top.index -= 1;
  753. if (array[key].left.index > 1) array[key].left.index -= 1;
  754. if (array[key].right.index > 1) array[key].right.index -= 1;
  755. } else if (array[key].bottom.index == 2) {
  756. if (array[key].top.index > 2) array[key].top.index -= 1;
  757. if (array[key].left.index > 2) array[key].left.index -= 1;
  758. if (array[key].right.index > 2) array[key].right.index -= 1;
  759. } else if (array[key].bottom.index == 3) {
  760. if (array[key].top.index > 3) array[key].top.index -= 1;
  761. if (array[key].left.index > 3) array[key].left.index -= 1;
  762. if (array[key].right.index > 3) array[key].right.index -= 1;
  763. }
  764. } else if (iconType == "left") {
  765. if (array[key].left.index == 1) {
  766. if (array[key].top.index > 1) array[key].top.index -= 1;
  767. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  768. if (array[key].right.index > 1) array[key].right.index -= 1;
  769. } else if (array[key].left.index == 2) {
  770. if (array[key].top.index > 2) array[key].top.index -= 1;
  771. if (array[key].bottom.index > 2) array[key].bottom.index -= 1;
  772. if (array[key].right.index > 2) array[key].right.index -= 1;
  773. } else if (array[key].left.index == 3) {
  774. if (array[key].top.index > 3) array[key].top.index -= 1;
  775. if (array[key].bottom.index > 3) array[key].bottom.index -= 1;
  776. if (array[key].right.index > 3) array[key].right.index -= 1;
  777. }
  778. } else if (iconType == "right") {
  779. if (array[key].right.index == 1) {
  780. if (array[key].top.index > 1) array[key].top.index -= 1;
  781. if (array[key].left.index > 1) array[key].left.index -= 1;
  782. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  783. } else if (array[key].right.index == 2) {
  784. if (array[key].top.index > 2) array[key].top.index -= 1;
  785. if (array[key].left.index > 2) array[key].left.index -= 1;
  786. if (array[key].bottom.index > 2) array[key].bottom.index -= 1;
  787. } else if (array[key].right.index == 3) {
  788. if (array[key].top.index > 3) array[key].top.index -= 1;
  789. if (array[key].left.index > 3) array[key].left.index -= 1;
  790. if (array[key].bottom.index > 3) array[key].bottom.index -= 1;
  791. }
  792. }
  793. } else if (array[key].index == 3) {
  794. if (iconType == "top") {
  795. if (array[key].top.index == 1) {
  796. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  797. if (array[key].left.index > 1) array[key].left.index -= 1;
  798. if (array[key].right.index > 1) array[key].right.index -= 1;
  799. } else if (array[key].top.index == 2) {
  800. if (array[key].bottom.index > 2) array[key].bottom.index -= 1;
  801. if (array[key].left.index > 2) array[key].left.index -= 1;
  802. if (array[key].right.index > 2) array[key].right.index -= 1;
  803. }
  804. } else if (iconType == "bottom") {
  805. if (array[key].bottom.index == 1) {
  806. if (array[key].top.index > 1) array[key].top.index -= 1;
  807. if (array[key].left.index > 1) array[key].left.index -= 1;
  808. if (array[key].right.index > 1) array[key].right.index -= 1;
  809. } else if (array[key].bottom.index == 2) {
  810. if (array[key].top.index > 2) array[key].top.index -= 1;
  811. if (array[key].left.index > 2) array[key].left.index -= 1;
  812. if (array[key].right.index > 2) array[key].right.index -= 1;
  813. }
  814. } else if (iconType == "left") {
  815. if (array[key].left.index == 1) {
  816. if (array[key].top.index > 1) array[key].top.index -= 1;
  817. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  818. if (array[key].right.index > 1) array[key].right.index -= 1;
  819. } else if (array[key].left.index == 2) {
  820. if (array[key].top.index > 2) array[key].top.index -= 1;
  821. if (array[key].bottom.index > 2) array[key].bottom.index -= 1;
  822. if (array[key].right.index > 2) array[key].right.index -= 1;
  823. }
  824. } else if (iconType == "right") {
  825. if (array[key].right.index == 1) {
  826. if (array[key].top.index > 1) array[key].top.index -= 1;
  827. if (array[key].left.index > 1) array[key].left.index -= 1;
  828. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  829. } else if (array[key].right.index == 2) {
  830. if (array[key].top.index > 2) array[key].top.index -= 1;
  831. if (array[key].left.index > 2) array[key].left.index -= 1;
  832. if (array[key].bottom.index > 2) array[key].bottom.index -= 1;
  833. }
  834. }
  835. } else if (array[key].index == 2) {
  836. if (iconType == "top") {
  837. if (array[key].top.index == 1) {
  838. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  839. if (array[key].left.index > 1) array[key].left.index -= 1;
  840. if (array[key].right.index > 1) array[key].right.index -= 1;
  841.  
  842. }
  843. } else if (iconType == "bottom") {
  844. if (array[key].bottom.index == 1) {
  845. if (array[key].top.index > 1) array[key].top.index -= 1;
  846. if (array[key].left.index > 1) array[key].left.index -= 1;
  847. if (array[key].right.index > 1) array[key].right.index -= 1;
  848.  
  849. }
  850. } else if (iconType == "left") {
  851. if (array[key].left.index == 1) {
  852. if (array[key].top.index > 1) array[key].top.index -= 1;
  853. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  854. if (array[key].right.index > 1) array[key].right.index -= 1;
  855.  
  856. }
  857. } else if (iconType == "right") {
  858. if (array[key].right.index == 1) {
  859. if (array[key].top.index > 1) array[key].top.index -= 1;
  860. if (array[key].left.index > 1) array[key].left.index -= 1;
  861. if (array[key].bottom.index > 1) array[key].bottom.index -= 1;
  862.  
  863. }
  864. }
  865. }
  866. array[key].index -= 1;
  867. array[key][iconType].index = undefined;
  868. array[key][iconType].path = false;
  869. map.removeLayer(array[key][iconType].icon);
  870. array[key][iconType].icon = undefined;
  871. } else createMarkerWay(key, array, className, iconType);
  872. } else if (array[key][iconType].icon !== undefined) {
  873. array[key][iconType].path = false;
  874. map.removeLayer(array[key][iconType].icon);
  875. array[key][iconType].icon = undefined;
  876. } else createMarkerWay(key, array, className, iconType);
  877. }
  878. }
  879.  
  880. function createMarker(key, array) {
  881. createMarkerWay(key, array, "pathTop", "top");
  882. createMarkerWay(key, array, "pathLeft", "left");
  883. createMarkerWay(key, array, "pathBottom", "bottom");
  884. createMarkerWay(key, array, "pathRight", "right");
  885. createMarkerWay(key, array, "pathHavenBag", "havenbag");
  886. }
  887.  
  888. function createMarkerWay(key, array, className, iconType) {
  889. if ($('#' + className).is(":checked")) {
  890. if ($('#gather').is(":checked")) {
  891. if (iconType == "havenbag") {
  892. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  893. interactive: true,
  894. zIndexOffset: 5000,
  895. icon: icon[iconType].gather
  896. }).addTo(map).bindPopup('Téléportation au zaap map : ' + havenBagData[havenBagData.length - 1].mapTogo + ' | mapID : ' + havenBagData[havenBagData.length - 1].mapidTogo);
  897. } else {
  898. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  899. interactive: false,
  900. zIndexOffset: 5000,
  901. icon: icon[iconType].gather
  902. }).addTo(map);
  903. }
  904. array[key].gather = true;
  905. } else if ($('#fight').is(":checked")) {
  906. if (iconType == "havenbag") {
  907. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  908. interactive: true,
  909. zIndexOffset: 5000,
  910. icon: icon[iconType].fight
  911. }).addTo(map).bindPopup('Téléportation au zaap map : ' + havenBagData[havenBagData.length - 1].mapTogo + ' | mapID : ' + havenBagData[havenBagData.length - 1].mapidTogo);
  912. } else {
  913. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  914. interactive: false,
  915. zIndexOffset: 5000,
  916. icon: icon[iconType].fight
  917.  
  918. }).addTo(map);
  919. }
  920. array[key].fight = true;
  921. } else if ($('#bank').is(":checked")) {
  922. if (iconType == "right" || iconType == "left") {
  923. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1] * 1 + (0.2)), {
  924. interactive: false,
  925. zIndexOffset: 4500,
  926. icon: icon[iconType].bank
  927. }).addTo(map);
  928. } else if (iconType == "top" || iconType == "bottom") {
  929. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 + (0.1), actualMap.split(", ")[1]), {
  930. interactive: false,
  931. zIndexOffset: 4500,
  932. icon: icon[iconType].bank
  933. }).addTo(map);
  934. } else if (iconType == "havenbag") {
  935. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  936. interactive: true,
  937. zIndexOffset: 5000,
  938. icon: icon[iconType].bank
  939. }).addTo(map).bindPopup('Téléportation au zaap map : ' + havenBagData[havenBagData.length - 1].mapTogo + ' | mapID : ' + havenBagData[havenBagData.length - 1].mapidTogo);
  940. }
  941. array[key].bank = true;
  942. } else if ($('#phenix').is(":checked")) {
  943. if (iconType == "right" || iconType == "left") {
  944. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1] * 1 - (0.2)), {
  945. interactive: false,
  946. zIndexOffset: 4000,
  947. icon: icon[iconType].phoenix
  948. }).addTo(map);
  949. } else if (iconType == "top" || iconType == "bottom") {
  950. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 - (0.1), actualMap.split(", ")[1]), {
  951. interactive: false,
  952. zIndexOffset: 4000,
  953. icon: icon[iconType].phoenix
  954. }).addTo(map);
  955. } else if (iconType == "havenbag") {
  956. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  957. interactive: true,
  958. zIndexOffset: 5000,
  959. icon: icon[iconType].phoenix
  960. }).addTo(map).bindPopup('Téléportation au zaap map : ' + havenBagData[havenBagData.length - 1].mapTogo + ' | mapID : ' + havenBagData[havenBagData.length - 1].mapidTogo);
  961. }
  962. array[key].phenix = true;
  963. } else {
  964. if (iconType == "havenbag") {
  965. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  966. interactive: true,
  967. zIndexOffset: 5000,
  968. icon: icon[iconType].move
  969. }).addTo(map).bindPopup('Téléportation au zaap map : ' + havenBagData[havenBagData.length - 1].mapTogo + ' | mapID : ' + havenBagData[havenBagData.length - 1].mapidTogo);
  970. } else {
  971. array[key][iconType].icon = L.marker(dofusXYToMapXY(actualMap.split(", ")[0], actualMap.split(", ")[1]), {
  972. interactive: false,
  973. zIndexOffset: 5000,
  974. icon: icon[iconType].move
  975. }).addTo(map);
  976. }
  977. }
  978. if ($('#linear').is(":checked")) {
  979. array[key].index += 1;
  980. array[key][iconType].index = array[key].index;
  981. array[key][iconType].path = true;
  982. } else {
  983. array[key][iconType].path = true;
  984. }
  985. }
  986. }
  987.  
  988. function pathGenerator(index, array) {
  989. var path = "";
  990. if (index !== undefined) {
  991. if (array.length !== 0) {
  992. if (array[index].havenbag.path)
  993. path = "havenbag";
  994. else {
  995. if (array[index].top.path)
  996. path = "top";
  997. if (array[index].bottom.path)
  998. path += (path === "" ? "" : "|") + "bottom";
  999. if (array[index].left.path)
  1000. path += (path === "" ? "" : "|") + "left";
  1001. if (array[index].right.path)
  1002. path += (path === "" ? "" : "|") + "right";
  1003. }
  1004. return path;
  1005. }
  1006. }
  1007. }
  1008.  
  1009. function afterPhenix(map) {
  1010. for (let index = 0; index < pathData.length; index++) {
  1011. if (map == pathData[index].map) {
  1012. return index;
  1013. }
  1014. }
  1015. }
  1016.  
  1017. function gatherFigh(index, array) {
  1018. var path = "";
  1019. if (array[index].gather)
  1020. path = ", gather = true";
  1021. if (array[index].fight)
  1022. path += ", fight = true";
  1023. return path;
  1024. }
  1025.  
  1026. function addGather() {
  1027. let res = "";
  1028. for (let key in gatherData) {
  1029. let str = $('#' + gatherData[key]).attr("data-name");
  1030. for (let index in ressources) {
  1031. if (ressources[index] !== null) if (ressources[index][1] !== null) if (ressources[index][1] == str) res += '\t' + ressources[index][0] + ',' + ' -- ' + ressources[index][1] + '\r\n';
  1032. }
  1033. }
  1034. return res;
  1035. }
  1036.  
  1037. function havenbagCheck(option) {
  1038. for (let index = 0; index < havenBagData.length; index++) {
  1039. if (havenBagData[index][option]) {
  1040. return true;
  1041. }
  1042. }
  1043. return false;
  1044. }
  1045.  
  1046. function getLinearAction(params, key) {
  1047. if (pathLinearData[key].top.index == params) {
  1048. return "top";
  1049. } else if (pathLinearData[key].left.index == params) {
  1050. return "left";
  1051. } else if (pathLinearData[key].bottom.index == params) {
  1052. return "bottom";
  1053. } else if (pathLinearData[key].right.index == params) {
  1054. return "right";
  1055. } else if (pathLinearData[key].havenbag.index == params) {
  1056. return "havenbag";
  1057. }
  1058. }
  1059.  
  1060. $('#saveFile').on("click", function () {
  1061. var firstIf = false;
  1062. var txt = "-- Generated On Dofus-Map with Drigtime's SwiftPath Script Maker --\r\n";
  1063. txt += "GATHER = {\r\n";
  1064. txt += addGather();
  1065. txt += "} -- Les éléments à récolter\r\n" +
  1066. "OPEN_BAGS = true -- Ouvrir les sacs de ressources au fur et à mesure\r\n" +
  1067. "AUTO_DELETE = { } -- Les éléments à supprimer\r\n\r\n" +
  1068. "MAX_MONSTERS = 8 -- Le nombre maximum de monstres dans un groupe à combattre.\r\n" +
  1069. "MIN_MONSTERS = 1 -- Le nombre minimum de monstres dans un groupe à combattre.\r\n\r\n" +
  1070. "FORBIDDEN_MONSTERS = { } -- Monstres interdits\r\n" +
  1071. "FORCE_MONSTERS = { } -- Monstres obligatoires\r\n\r\n" +
  1072. "MAX_COMBAT = 800 -- Nombre de combats maximum\r\n";
  1073. if (pathLinearData.length !== 0) {
  1074. txt +=
  1075. '-- Drigtime Linear --\r\n' +
  1076. '-- Function Custom :\r\n' +
  1077. '\r\n' +
  1078. 'function GatherFight()\r\n' +
  1079. '\tfor index, actualMap in pairs(mapsWithChangeMap) do\r\n' +
  1080. '\t\tif (map:onMap(actualMap.map)) then\r\n' +
  1081. '\t\t\tif actualMap.gather and actualMap.fight then\r\n' +
  1082. '\t\t\t\treturn "both"\r\n' +
  1083. '\t\t\telseif actualMap.gather then\r\n' +
  1084. '\t\t\t\treturn "gather"\r\n' +
  1085. '\t\t\telseif actualMap.forcegather then\r\n' +
  1086. '\t\t\t\treturn "forcegather"\r\n' +
  1087. '\t\t\telseif actualMap.fight then\r\n' +
  1088. '\t\t\t\treturn "fight"\r\n' +
  1089. '\t\t\telseif actualMap.forcefight then\r\n' +
  1090. '\t\t\t\treturn "forcefight"\r\n' +
  1091. '\t\t\tend\r\n' +
  1092. '\t\t\treturn "path"\r\n' +
  1093. '\t\tend\r\n' +
  1094. '\tend\r\n' +
  1095. '\treturn false\r\n' +
  1096. 'end\r\n' +
  1097. '\r\n' +
  1098. '------------------\r\n' +
  1099. '\r\n' +
  1100. 'function move()\r\n';
  1101. if (havenbagCheck('move')) {
  1102. txt += "\tif map:onMap(\"0,0\") then\r\n";
  1103. firstIf = false;
  1104. for (let index = 0; index < havenBagData.length; index++) {
  1105. if (havenBagData[index].move) {
  1106. if (!firstIf) {
  1107. txt += "\t\tif actualMap == \"" + havenBagData[index].actualMap + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index].mapidToGo + ")\")\r\n";
  1108. firstIf = true;
  1109. } else
  1110. txt += "\t\telseif actualMap == \"" + havenBagData[index].actualMap + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index].mapidToGo + ")\")\r\n";
  1111. }
  1112. }
  1113. txt += '\t\tend\r\n' +
  1114. '\telse\r\n' +
  1115. '\t\tactualMap = map:currentMap()\r\n' +
  1116. '\tend\r\n';
  1117. }
  1118. txt += '\tif GatherFight() == "both" then\r\n' +
  1119. '\t\treturn {\r\n' +
  1120. '\t\t\t{map = map:currentMap(), custom = processMap, gather = true, fight = true}\r\n' +
  1121. '\t\t}\r\n' +
  1122. '\telseif GatherFight() == "gather" then\r\n' +
  1123. '\t\treturn {\r\n' +
  1124. '\t\t\t{map = map:currentMap(), custom = processMap, gather = true}\r\n' +
  1125. '\t\t}\r\n' +
  1126. '\telseif GatherFight() == "forcegather" then\r\n' +
  1127. '\t\treturn {\r\n' +
  1128. '\t\t\t{map = map:currentMap(), custom = processMap, forcegather = true}\r\n' +
  1129. '\t\t}\r\n' +
  1130. '\telseif GatherFight() == "fight" then\r\n' +
  1131. '\t\treturn {\r\n' +
  1132. '\t\t\t{map = map:currentMap(), custom = processMap, fight = true}\r\n' +
  1133. '\t\t}\r\n' +
  1134. '\telseif GatherFight() == "forcefight" then\r\n' +
  1135. '\t\treturn {\r\n' +
  1136. '\t\t\t{map = map:currentMap(), custom = processMap, forcefight = true}\r\n' +
  1137. '\t\t}\r\n' +
  1138. '\telseif GatherFight() == "path" then\r\n' +
  1139. '\t\treturn {\r\n' +
  1140. '\t\t\t{map = map:currentMap(), custom = processMap}\r\n' +
  1141. '\t\t}\r\n' +
  1142. '\telse\r\n' +
  1143. '\t\tglobal:printError("Aucune action sur la map : " .. map:currentMap() .. " | mapID : " .. map:currentMapId())\r\n' +
  1144. '\t\tglobal:disconnect()\r\n' +
  1145. '\tend\r\n' +
  1146. 'end\r\n' +
  1147. '\r\n' +
  1148. 'mapsWithChangeMap = {\r\n';
  1149. for (let key in pathLinearData) {
  1150. if (pathLinearData[key].index == 4) {
  1151. txt += '\t{map = "' + pathLinearData[key].map.replace(' ', '') + '", changeMap = "' + getLinearAction(1, key) + '", nextMap = "' + getLinearAction(2, key) + '", doNextMap = "no", thirdMap = "' + getLinearAction(3, key) + '", doThirdMap = "no", fourthMap = "' + getLinearAction(4, key) + '", doFourthMap = "no"' + gatherFigh(key, pathLinearData) + '},\r\n';
  1152. } else if (pathLinearData[key].index == 3) {
  1153. txt += '\t{map = "' + pathLinearData[key].map.replace(' ', '') + '", changeMap = "' + getLinearAction(1, key) + '", nextMap = "' + getLinearAction(2, key) + '", doNextMap = "no", thirdMap = "' + getLinearAction(3, key) + '", doThirdMap = "no"' + gatherFigh(key, pathLinearData) + '},\r\n';
  1154. } else if (pathLinearData[key].index == 2) {
  1155. txt += '\t{map = "' + pathLinearData[key].map.replace(' ', '') + '", changeMap = "' + getLinearAction(1, key) + '", nextMap = "' + getLinearAction(2, key) + '", doNextMap = "no"' + gatherFigh(key, pathLinearData) + '},\r\n';
  1156. } else {
  1157. txt += '\t{map = "' + pathLinearData[key].map.replace(' ', '') + '", changeMap = "' + getLinearAction(1, key) + '"' + gatherFigh(key, pathLinearData) + '},\r\n';
  1158. }
  1159. }
  1160. txt += '}\r\n' +
  1161. '\r\n' +
  1162. 'function processMap()\r\n' +
  1163. '\tfor index, actualMap in pairs(mapsWithChangeMap) do\r\n' +
  1164. '\t\tif (map:onMap(actualMap.map)) then\r\n' +
  1165. '\t\t\tif (actualMap.doNextMap) and (actualMap.doThirdMap) and (actualMap.doFourthMap) then\r\n' +
  1166. '\t\t\t\tif (actualMap.doFourthMap) == "yes" then\r\n' +
  1167. '\t\t\t\t\tactualMap.doFourthMap = "no"\r\n' +
  1168. '\t\t\t\t\tif (actualMap.fourthMapDoor) then\r\n' +
  1169. '\t\t\t\t\t\tactualMap.fourthMapDoor = tonumber(actualMap.fourthMapDoor)\r\n' +
  1170. '\t\t\t\t\t\tmap:door(actualMap.fourthMapDoor)\r\n' +
  1171. '\t\t\t\t\telseif (actualMap.fourthMapCustom) then\r\n' +
  1172. '\t\t\t\t\t\treturn (actualMap.fourthMapCustom)()\r\n' +
  1173. '\t\t\t\t\telse\r\n' +
  1174. '\t\t\t\t\t\tmap:changeMap(actualMap.fourthMap)\r\n' +
  1175. '\t\t\t\t\tend\r\n' +
  1176. '\t\t\t\telseif (actualMap.doThirdMap) == "yes" then\r\n' +
  1177. '\t\t\t\t\tactualMap.doThirdMap = "no"\r\n' +
  1178. '\t\t\t\t\tactualMap.doFourthMap = "yes"\r\n' +
  1179. '\t\t\t\t\tif (actualMap.thirdMapDoor) then\r\n' +
  1180. '\t\t\t\t\t\tactualMap.thirdMapDoor = tonumber(actualMap.thirdMapDoor)\r\n' +
  1181. '\t\t\t\t\t\tmap:door(actualMap.thirdMapDoor)\r\n' +
  1182. '\t\t\t\t\telseif (actualMap.thirdMapCustom) then\r\n' +
  1183. '\t\t\t\t\t\treturn (actualMap.thirdMapCustom)()\r\n' +
  1184. '\t\t\t\t\telse\r\n' +
  1185. '\t\t\t\t\t\tmap:changeMap(actualMap.thirdMap)\r\n' +
  1186. '\t\t\t\t\tend\r\n' +
  1187. '\t\t\t\telseif (actualMap.doNextMap == "yes") then\r\n' +
  1188. '\t\t\t\t\tactualMap.doNextMap = "no"\r\n' +
  1189. '\t\t\t\t\tactualMap.doThirdMap = "yes"\r\n' +
  1190. '\t\t\t\t\tif (actualMap.nextMapDoor) then\r\n' +
  1191. '\t\t\t\t\t\tactualMap.nextMapDoor = tonumber(actualMap.nextMapDoor)\r\n' +
  1192. '\t\t\t\t\t\tmap:door(actualMap.nextMapDoor)\r\n' +
  1193. '\t\t\t\t\telseif (actualMap.nextMapCustom) then\r\n' +
  1194. '\t\t\t\t\t\treturn (actualMap.nextMapCustom)()\r\n' +
  1195. '\t\t\t\t\telse\r\n' +
  1196. '\t\t\t\t\t\tmap:changeMap(actualMap.nextMap)\r\n' +
  1197. '\t\t\t\t\tend\r\n' +
  1198. '\t\t\t\telseif (actualMap.changeMapDoor) then\r\n' +
  1199. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1200. '\t\t\t\t\tactualMap.changeMapDoor = tonumber(actualMap.changeMapDoor)\r\n' +
  1201. '\t\t\t\t\tmap:door(actualMap.changeMapDoor)\r\n' +
  1202. '\t\t\t\telseif (actualMap.changeMapCustom) then\r\n' +
  1203. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1204. '\t\t\t\t\treturn (actualMap.changeMapCustom)()\r\n' +
  1205. '\t\t\t\telseif (actualMap.changeMap) then\r\n' +
  1206. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1207. '\t\t\t\t\tmap:changeMap(actualMap.changeMap)\r\n' +
  1208. '\t\t\t\tend\r\n' +
  1209. '\t\t\telseif (actualMap.doNextMap) and (actualMap.doThirdMap) then\r\n' +
  1210. '\t\t\t\tif (actualMap.doThirdMap) == "yes" then\r\n' +
  1211. '\t\t\t\t\tactualMap.doThirdMap = "no"\r\n' +
  1212. '\t\t\t\t\tif (actualMap.thirdMapDoor) then\r\n' +
  1213. '\t\t\t\t\t\tactualMap.thirdMapDoor = tonumber(actualMap.thirdMapDoor)\r\n' +
  1214. '\t\t\t\t\t\tmap:door(actualMap.thirdMapDoor)\r\n' +
  1215. '\t\t\t\t\telseif (actualMap.thirdMapCustom) then\r\n' +
  1216. '\t\t\t\t\t\treturn (actualMap.thirdMapCustom)()\r\n' +
  1217. '\t\t\t\t\telse\r\n' +
  1218. '\t\t\t\t\t\tmap:changeMap(actualMap.thirdMap)\r\n' +
  1219. '\t\t\t\t\tend\r\n' +
  1220. '\t\t\t\telseif (actualMap.doNextMap == "yes") then\r\n' +
  1221. '\t\t\t\t\tactualMap.doNextMap = "no"\r\n' +
  1222. '\t\t\t\t\tactualMap.doThirdMap = "yes"\r\n' +
  1223. '\t\t\t\t\tif (actualMap.nextMapDoor) then\r\n' +
  1224. '\t\t\t\t\t\tactualMap.nextMapDoor = tonumber(actualMap.nextMapDoor)\r\n' +
  1225. '\t\t\t\t\t\tmap:door(actualMap.nextMapDoor)\r\n' +
  1226. '\t\t\t\t\telseif (actualMap.nextMapCustom) then\r\n' +
  1227. '\t\t\t\t\t\treturn (actualMap.nextMapCustom)()\r\n' +
  1228. '\t\t\t\t\telse\r\n' +
  1229. '\t\t\t\t\t\tmap:changeMap(actualMap.nextMap)\r\n' +
  1230. '\t\t\t\t\tend\r\n' +
  1231. '\t\t\t\telseif (actualMap.changeMapDoor) then\r\n' +
  1232. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1233. '\t\t\t\t\tactualMap.changeMapDoor = tonumber(actualMap.changeMapDoor)\r\n' +
  1234. '\t\t\t\t\tmap:door(actualMap.changeMapDoor)\r\n' +
  1235. '\t\t\t\telseif (actualMap.changeMapCustom) then\r\n' +
  1236. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1237. '\t\t\t\t\treturn (actualMap.changeMapCustom)()\r\n' +
  1238. '\t\t\t\telseif (actualMap.changeMap) then\r\n' +
  1239. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1240. '\t\t\t\t\tmap:changeMap(actualMap.changeMap)\r\n' +
  1241. '\t\t\t\tend\r\n' +
  1242. '\t\t\telseif (actualMap.doNextMap) then\r\n' +
  1243. '\t\t\t\tif (actualMap.doNextMap == "yes") then\r\n' +
  1244. '\t\t\t\t\tactualMap.doNextMap = "no"\r\n' +
  1245. '\t\t\t\t\tif (actualMap.nextMapDoor) then\r\n' +
  1246. '\t\t\t\t\t\tactualMap.nextMapDoor = tonumber(actualMap.nextMapDoor)\r\n' +
  1247. '\t\t\t\t\t\tmap:door(actualMap.nextMapDoor)\r\n' +
  1248. '\t\t\t\t\telseif (actualMap.nextMapCustom) then\r\n' +
  1249. '\t\t\t\t\t\treturn (actualMap.nextMapCustom)()\r\n' +
  1250. '\t\t\t\t\telse\r\n' +
  1251. '\t\t\t\t\t\tmap:changeMap(actualMap.nextMap)\r\n' +
  1252. '\t\t\t\t\tend\r\n' +
  1253. '\t\t\t\telseif (actualMap.changeMapDoor) then\r\n' +
  1254. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1255. '\t\t\t\t\tactualMap.changeMapDoor = tonumber(actualMap.changeMapDoor)\r\n' +
  1256. '\t\t\t\t\tmap:door(actualMap.changeMapDoor)\r\n' +
  1257. '\t\t\t\telseif (actualMap.changeMapCustom) then\r\n' +
  1258. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1259. '\t\t\t\t\treturn (actualMap.changeMapCustom)()\r\n' +
  1260. '\t\t\t\telseif (actualMap.changeMap) then\r\n' +
  1261. '\t\t\t\t\tactualMap.doNextMap = "yes"\r\n' +
  1262. '\t\t\t\t\tmap:changeMap(actualMap.changeMap)\r\n' +
  1263. '\t\t\t\tend\r\n' +
  1264. '\t\t\telseif (actualMap.changeMapDoor) then\r\n' +
  1265. '\t\t\t\tactualMap.changeMapDoor = tonumber(actualMap.changeMapDoor)\r\n' +
  1266. '\t\t\t\tmap:door(actualMap.changeMapDoor)\r\n' +
  1267. '\t\t\telseif (actualMap.changeMapCustom) then\r\n' +
  1268. '\t\t\t\treturn (actualMap.changeMapCustom)()\r\n' +
  1269. '\t\t\telseif (actualMap.changeMap) then\r\n' +
  1270. '\t\t\t\tmap:changeMap(actualMap.changeMap)\r\n' +
  1271. '\t\t\telseif (actualMap.forcegather) then\r\n' +
  1272. '\t\t\tend\r\n' +
  1273. '\t\tend\r\n' +
  1274. '\tend\r\n' +
  1275. 'end\r\n';
  1276. } else {
  1277. txt += "\r\nfunction move()\r\n";
  1278. if (havenbagCheck('move')) {
  1279. txt += "\tif map:onMap(\"0,0\") then\r\n";
  1280. firstIf = false;
  1281. for (let index = 0; index < havenBagData.length; index++) {
  1282. if (havenBagData[index].move) {
  1283. if (!firstIf) {
  1284. txt += "\t\tif actualMap == \"" + havenBagData[index].actualMap + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index].mapidToGo + ")\")\r\n";
  1285. firstIf = true;
  1286. } else
  1287. txt += "\t\telseif actualMap == \"" + havenBagData[index].actualMap + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index].mapidToGo + ")\")\r\n";
  1288. }
  1289. }
  1290. txt += '\t\tend\r\n' +
  1291. '\telse\r\n' +
  1292. '\t\tactualMap = map:currentMap()\r\n' +
  1293. '\tend\r\n';
  1294. }
  1295. txt += '\treturn {\r\n' +
  1296. '\t\t{map = "83887104", path = "396"}, --Interieur banque Astrub vers Sortie--\r\n' +
  1297. '\t\t{map = "54534165", path = "424"}, --Interieur banque Frigost vers Sortie--\r\n' +
  1298. '\t\t{map = "2885641", path = "424"}, --Interieur banque Bonta vers Sortie--\r\n' +
  1299. '\t\t{map = "99095051", path = "410"}, --Interieur banque Amakna vers Sortie--\r\n' +
  1300. '\t\t{map = "8912911", path = "424"}, --Interieur banque Brakmar vers Sortie--\r\n' +
  1301. '\t\t{map = "91753985", path = "396"}, --Interieur banque Sufokia vers Sortie--\r\n' +
  1302. '\t\t{map = "86511105", door = "452"}, --Interieur banque Ottomaï vers Sortie--\r\n' +
  1303. '\t\t{map = "8129542", path = "409"}, --Interieur banque Pandala vers Sortie--\r\n' +
  1304. '\t\t{map = "84935175", path = "425"}, --Interieur banque Montagne Koalak vers Sortie--\r\n';
  1305. for (let key in pathData) {
  1306. txt += '\t\t{map = "' + pathData[key].map.replace(" ", "") + '", path = "' + pathGenerator(key, pathData) + '"' + gatherFigh(key, pathData) + '},\r\n';
  1307. }
  1308. txt += '\t}\r\nend\r\n\r\n';
  1309. }
  1310. txt += "function bank()\r\n";
  1311. if (havenbagCheck('bank')) {
  1312. txt += "\tif map:onMap(\"0,0\") then\r\n";
  1313. firstIf = false;
  1314. for (let index = 0; index < havenBagData.length; index++) {
  1315. if (havenBagData[index].bank) {
  1316. if (!firstIf) {
  1317. txt += "\t\tif actualMap == \"" + havenBagData[index].actualMap + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index].mapidToGo + ")\")\r\n";
  1318. firstIf = true;
  1319. } else
  1320. txt += "\t\telseif actualMap == \"" + havenBagData[index].actualMap + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index].mapidToGo + ")\")\r\n";
  1321. }
  1322. }
  1323. txt += "\t\tend\r\n" +
  1324. "\telse\r\n" +
  1325. "\t\tactualMap = map:currentMap()\r\n" +
  1326. "\tend\r\n";
  1327. }
  1328. txt += "\treturn {\r\n";
  1329. for (let key in bankData) {
  1330. txt += '\t\t{map = "' + bankData[key].map.replace(" ", "") + '", path = "' + pathGenerator(key, bankData) + '"},\r\n';
  1331. }
  1332. txt += '\t\t{map = "84674566", door = "303"}, --Devant banque Astrub--\r\n' +
  1333. '\t\t{map = "83887104", path = "396", npcBank = true}, --Banque Astrub--\r\n' +
  1334. '\t\t{map = "54172457", door = "358"}, --Devant banque Frigost--\r\n' +
  1335. '\t\t{map = "54534165", path = "424", npcBank = true}, --Banque Frigost--\r\n' +
  1336. '\t\t{map = "147254", door = "383"}, --Devant banque Bonta--\r\n' +
  1337. '\t\t{map = "2885641", path = "424", npcBank = true}, --Banque Bonta--\r\n' +
  1338. '\t\t{map = "88081177", door = "216"}, --Devant banque Amakna--\r\n' +
  1339. '\t\t{map = "99095051", path = "410", npcBank = true}, --Banque Amakna--\r\n' +
  1340. '\t\t{map = "144931", door = "248"}, --Devant banque Brakmar--\r\n' +
  1341. '\t\t{map = "8912911", path = "424", npcBank = true}, --Banque Brakmar--\r\n' +
  1342. '\t\t{map = "90703872", door = "302"}, --Devant banque Sufokia --\r\n' +
  1343. '\t\t{map = "91753985", path = "494", npcBank = true}, --Banque Sufokia--\r\n' +
  1344. '\t\t{map = "155157", door = "355"}, --Devant banque Ottomaï--\r\n' +
  1345. '\t\t{map = "86511105", door = "452", npcBank = true}, --Banque Ottomaï--\r\n' +
  1346. '\t\t{map = "12580", door = "284"}, --Devant banque Pandala--\r\n' +
  1347. '\t\t{map = "8129542", path = "409", npcBank = true}, --Banque Pandala--\r\n' +
  1348. '\t\t{map = "73400323", door = "330"}, --Devant banque Montagne Koalak--\r\n' +
  1349. '\t\t{map = "84935175", path = "425", npcBank = true}, --Banque Montagne Koalak--\r\n\t}\r\nend\r\n' +
  1350. '\r\n\r\nfunction phenix()\r\n';
  1351. if (havenbagCheck('phenix')) {
  1352. txt += "\tif map:onMap(\"0,0\") then\r\n";
  1353. firstIf = false;
  1354. for (let index = 0; index < havenBagData.length; index++) {
  1355. if (havenBagData[index].phenix) {
  1356. if (!firstIf) {
  1357. txt += '\t\tif actualMap == \"' + havenBagData[index].actualMap + '\" then\r\n\t\t\tmap:changeMap(\"zaap(' + havenBagData[index].mapidToGo + ')\")\r\n';
  1358. firstIf = true;
  1359. } else
  1360. txt += '\t\telseif actualMap == \"' + havenBagData[index].actualMap + '\" then\r\n\t\t\tmap:changeMap(\"zaap(' + havenBagData[index].mapidToGo + ')\")\r\n';
  1361. }
  1362. }
  1363. txt += 't\tend\r\n' +
  1364. 'telse\r\n' +
  1365. 't\tactualMap = map:currentMap()\r\n' +
  1366. 'tend\r\n';
  1367. } else if (havenbagCheck('move')) txt += '\tactualMap = map:currentMap()\r\n';
  1368. txt += "\treturn {\r\n";
  1369. for (let key in phenixData) {
  1370. txt += '\t\t{map = "' + phenixData[key].map.replace(" ", "") + '", path = "' + pathGenerator(key, phenixData) + '"},\r\n';
  1371. }
  1372. txt += '\t\t{map = "12,12", phenix = "184", path = "' + pathGenerator(afterPhenix("12, 12"), pathData) + '"},\r\n' +
  1373. '\t\t{map = "7,36", phenix = "0", path = "' + pathGenerator(afterPhenix("7, 36"), pathData) + '"},\r\n' +
  1374. '\t\t{map = "22,22", phenix = "272", path = "' + pathGenerator(afterPhenix("22, 22"), pathData) + '"},\r\n' +
  1375. '\t\t{map = "10,19", phenix = "192", path = "' + pathGenerator(afterPhenix("10, 19"), pathData) + '"},\r\n' +
  1376. '\t\t{map = "5,1", phenix = "0", path = "' + pathGenerator(afterPhenix("5, 1"), pathData) + '"},\r\n' +
  1377. '\t\t{map = "2,-1", phenix = "0", path = "' + pathGenerator(afterPhenix("2, -1"), pathData) + '"},\r\n' +
  1378. '\t\t{map = "13,-7", phenix = "0", path = "' + pathGenerator(afterPhenix("13, -7"), pathData) + '"},\r\n' +
  1379. '\t\t{map = "5,-9", phenix = "116", path = "' + pathGenerator(afterPhenix("5, -9"), pathData) + '"},\r\n' +
  1380. '\t\t{map = "2,-12", phenix = "272", path = "' + pathGenerator(afterPhenix("2, -12"), pathData) + '"},\r\n' +
  1381. '\t\t{map = "-6,-12", phenix = "0", path = "' + pathGenerator(afterPhenix("-6, -12"), pathData) + '"},\r\n' +
  1382. '\t\t{map = "36,10", phenix = "330", path = "' + pathGenerator(afterPhenix("36, 10"), pathData) + '"},\r\n' +
  1383. '\t\t{map = "25,-4", phenix = "450", path = "' + pathGenerator(afterPhenix("25, -4"), pathData) + '"},\r\n' +
  1384. '\t\t{map = "27,-33", phenix = "0", path = "' + pathGenerator(afterPhenix("27, -33"), pathData) + '"},\r\n' +
  1385. '\t\t{map = "24,-43", phenix = "245", path = "' + pathGenerator(afterPhenix("24, -43"), pathData) + '"},\r\n' +
  1386. '\t\t{map = "17,-36", phenix = "0", path = "' + pathGenerator(afterPhenix("17, -36"), pathData) + '"},\r\n' +
  1387. '\t\t{map = "-13,-29", phenix = "0", path = "' + pathGenerator(afterPhenix("-13, -29"), pathData) + '"},\r\n' +
  1388. '\t\t{map = "-10,-54", phenix = "342", path = "' + pathGenerator(afterPhenix("-10, -54"), pathData) + '"},\r\n' +
  1389. '\t\t{map = "-33,-56", phenix = "0", path = "' + pathGenerator(afterPhenix("-33, -56"), pathData) + '"},\r\n' +
  1390. '\t\t{map = "-10,13", phenix = "354", path = "' + pathGenerator(afterPhenix("-10, 13"), pathData) + '"},\r\n' +
  1391. '\t\t{map = "-14,31", phenix = "243", path = "' + pathGenerator(afterPhenix("-14, 31"), pathData) + '"},\r\n' +
  1392. '\t\t{map = "-26,34", phenix = "0", path = "' + pathGenerator(afterPhenix("-26, 34"), pathData) + '"},\r\n' +
  1393. '\t\t{map = "-26,36", phenix = "0", path = "' + pathGenerator(afterPhenix("-26, 36"), pathData) + '"},\r\n' +
  1394. '\t\t{map = "-55,40", phenix = "240", path = "' + pathGenerator(afterPhenix("-55, 40"), pathData) + '"},\r\n' +
  1395. '\t\t{map = "-58,18", phenix = "354", path = "' + pathGenerator(afterPhenix("-58, 18"), pathData) + '"},\r\n' +
  1396. '\t\t{map = "-60,-3", phenix = "0", path = "' + pathGenerator(afterPhenix("-60, -3"), pathData) + '"},\r\n' +
  1397. '\t\t{map = "-43,0", phenix = "259", path = "' + pathGenerator(afterPhenix("-43, 0"), pathData) + '"},\r\n' +
  1398. '\t\t{map = "-41,-17", phenix = "0", path = "' + pathGenerator(afterPhenix("-41, -17"), pathData) + '"},\r\n' +
  1399. '\t\t{map = "-43,-19", phenix = "0", path = "' + pathGenerator(afterPhenix("-43, -19"), pathData) + '"},\r\n' +
  1400. '\t\t{map = "-53,-40", phenix = "0", path = "' + pathGenerator(afterPhenix("-53, -40"), pathData) + '"},\r\n' +
  1401. '\t\t{map = "-67,-44", phenix = "219", path = "' + pathGenerator(afterPhenix("-67 ,-44"), pathData) + '"},\r\n' +
  1402. '\t\t{map = "-60,-79", phenix = "0", path = "' + pathGenerator(afterPhenix("-60, -79"), pathData) + '"}\r\n\t}\r\nend\r\n';
  1403.  
  1404. saveTextAsFile(txt);
  1405. });
  1406.  
  1407.  
  1408. function saveTextAsFile(txt) {
  1409. var textToSaveAsBlob = new Blob([txt], {
  1410. type: "text/plain"
  1411. });
  1412. var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
  1413. var fileNameToSaveAs;
  1414. if ($('#fileName').val() == "") fileNameToSaveAs = "Trajet.lua";
  1415. else fileNameToSaveAs = $('#fileName').val() + ".lua";
  1416. var downloadLink = document.createElement("a");
  1417. downloadLink.download = fileNameToSaveAs;
  1418. downloadLink.innerHTML = "Download File";
  1419. downloadLink.href = textToSaveAsURL;
  1420. downloadLink.style.display = "none";
  1421. document.body.appendChild(downloadLink);
  1422. downloadLink.click();
  1423. }
  1424.  
  1425. function languageSelector(params) {
  1426. switch (params) {
  1427. case "fr":
  1428. $('#top').empty().append('Haut');
  1429. $('#bottom').empty().append('Bas');
  1430. $('#left').empty().append('Gauche');
  1431. $('#right').empty().append('Droite');
  1432. $('#havenBag').empty().append('Havre-sac');
  1433. $('#tdgather').empty().append('Récolte');
  1434. $('#tdfight').empty().append('Combat');
  1435. $('#tdbank').empty().append('Banque');
  1436. $('#tdphoenix').empty().append('Phenix');
  1437. $('#tdMove').empty().append('Deplacement');
  1438. $('#restogather').empty().append('Ressources à récolter :');
  1439. $('#saveFile').empty().append('Sauvegarder');
  1440. $('#fileName').attr('placeholder', 'Nom du fichier');
  1441. $('#deletePath').empty().append('Supprimer');
  1442. $('#loadAFile').empty().append('Charger');
  1443. $('#moveOption').empty().append('Plus');
  1444. $('#linearButtonText').empty().append('Linéaire');
  1445. $('#infoLinear').empty().append('L\'option linéaire permet de créer des trajet avec plusieur actions différente dans un ordre précis sur une même map.');
  1446. $('#languageDisplayer').addClass('flag-icon-fr');
  1447. $('#languageDisplayer').removeClass('flag-icon-es');
  1448. $('#languageDisplayer').removeClass('flag-icon-gb');
  1449. GM_setValue("language", "fr");
  1450. break;
  1451. case "en":
  1452. $('#top').empty().append('Top');
  1453. $('#bottom').empty().append('Bottom');
  1454. $('#left').empty().append('Left');
  1455. $('#right').empty().append('Right');
  1456. $('#havenBag').empty().append('Haven bag');
  1457. $('#tdgather').empty().append('Gather');
  1458. $('#tdfight').empty().append('Fight');
  1459. $('#tdbank').empty().append('Bank');
  1460. $('#tdphoenix').empty().append('Phoenix');
  1461. $('#tdMove').empty().append('Move');
  1462. $('#restogather').empty().append('Resources to gather :');
  1463. $('#saveFile').empty().append('Save');
  1464. $('#fileName').attr('placeholder', 'Name of the file');
  1465. $('#deletePath').empty().append('Delete');
  1466. $('#loadAFile').empty().append('Load');
  1467. $('#moveOption').empty().append('More');
  1468. $('#linearButtonText').empty().append('Linear');
  1469. $('#infoLinear').empty().append('The linear option gives the possibility to put multiple action in a specific order on the same map.');
  1470. $('#languageDisplayer').removeClass('flag-icon-fr');
  1471. $('#languageDisplayer').removeClass('flag-icon-es');
  1472. $('#languageDisplayer').addClass('flag-icon-gb');
  1473. GM_setValue("language", "en");
  1474. break;
  1475. case "es":
  1476. $('#top').empty().append('Arriba');
  1477. $('#bottom').empty().append('Bajo');
  1478. $('#left').empty().append('Izquierda');
  1479. $('#right').empty().append('Derecha');
  1480. $('#havenBag').empty().append('Merkasako');
  1481. $('#tdgather').empty().append('Cosecha');
  1482. $('#tdfight').empty().append('Lucha');
  1483. $('#tdbank').empty().append('Banco');
  1484. $('#tdphoenix').empty().append('Fénix');
  1485. $('#tdMove').empty().append('Desplazamiento');
  1486. $('#restogather').empty().append('Recursos para cosechar :');
  1487. $('#saveFile').empty().append('Salvar');
  1488. $('#fileName').attr('placeholder', 'Nombre del archivo');
  1489. $('#deletePath').empty().append('Borrar');
  1490. $('#loadAFile').empty().append('Carga');
  1491. $('#moveOption').empty().append('Más');
  1492. $('#linearButtonText').empty().append('Lineal');
  1493. $('#infoLinear').empty().append('La opción lineal ofrece la posibilidad de poner varias acciones en un orden específico en el mismo mapa.');
  1494. $('#languageDisplayer').removeClass('flag-icon-fr');
  1495. $('#languageDisplayer').addClass('flag-icon-es');
  1496. $('#languageDisplayer').removeClass('flag-icon-gb');
  1497. GM_setValue("language", "es");
  1498. break;
  1499. default:
  1500. $('#top').empty().append('Haut');
  1501. $('#bottom').empty().append('Bas');
  1502. $('#left').empty().append('Gauche');
  1503. $('#right').empty().append('Droite');
  1504. $('#tdgather').empty().append('Récolte');
  1505. $('#tdfight').empty().append('Combat');
  1506. $('#tdbank').empty().append('Banque');
  1507. $('#tdphoenix').empty().append('Phenix');
  1508. $('#tdMove').empty().append('Deplacement');
  1509. $('#restogather').empty().append('Ressources à récolter :');
  1510. $('#saveFile').empty().append('Sauvegarder');
  1511. $('#fileName').attr('placeholder', 'Nom du fichier');
  1512. $('#deletePath').empty().append('Supprimer');
  1513. $('#loadAFile').empty().append('Charger');
  1514. $('#moveOption').empty().append('Plus');
  1515. $('#linearButtonText').empty().append('Linéaire');
  1516. $('#infoLinear').empty().append('L\'option linéaire permet de créer des trajet avec plusieur actions différente dans un ordre précis sur une même map.');
  1517. $('#languageDisplayer').addClass('flag-icon-fr');
  1518. $('#languageDisplayer').removeClass('flag-icon-es');
  1519. $('#languageDisplayer').removeClass('flag-icon-gb');
  1520. GM_setValue("language", "fr");
  1521. break;
  1522. }
  1523. }
  1524. languageSelector(GM_getValue("language"));
  1525.  
  1526. $('#file').change(function () {
  1527. var file = this.files[0];
  1528. var content;
  1529. var reader = new FileReader();
  1530. reader.onload = function (progressEvent) {
  1531. // Entire file
  1532. content = this.result;
  1533. let regexPath = /function move\(\)[\s\S]+?return.*?{\r\n([\s\S]+?)}\r\n.*end/g;
  1534. let regexPathLinear = /mapsWithChangeMap.?=.?{\r\n([\s\S]+?)}\r\n/g;
  1535. let regexBank = /function bank\(\)[\s\S]+?return.*?{\r\n([\s\S]+?)}\r\n.*end/g;
  1536. let regexPhenix = /function phenix\(\)[\s\S]+?return.*?{\r\n([\s\S]+?)}\r\n.*end/g;
  1537. let result;
  1538. let matche = regexBank.exec(content);
  1539. loadingFile = true;
  1540. $('#pathTop').prop('checked', false);
  1541. $('#pathLeft').prop('checked', false);
  1542. $('#pathBottom').prop('checked', false);
  1543. $('#pathRight').prop('checked', false);
  1544. $('#pathHavenBag').prop('checked', false);
  1545. if (matche !== null) {
  1546. result = matche[1];
  1547. result = result.split('\r\n');
  1548. for (let index = 0; index < result.length; index++) {
  1549. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  1550. if (matche !== null) actualMap = matche[1];
  1551. actualMap = actualMap.replace(/,/g, ", ");
  1552. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  1553. matche = /top/g.exec(result[index]);
  1554. if (matche !== null) $('#pathTop').prop('checked', true);
  1555. matche = /left/g.exec(result[index]);
  1556. if (matche !== null) $('#pathLeft').prop('checked', true);
  1557. matche = /bottom/g.exec(result[index]);
  1558. if (matche !== null) $('#pathBottom').prop('checked', true);
  1559. matche = /right/g.exec(result[index]);
  1560. if (matche !== null) $('#pathRight').prop('checked', true);
  1561. $('#bank').prop('checked', true);
  1562. onMapClick();
  1563. $('#pathTop').prop('checked', false);
  1564. $('#pathLeft').prop('checked', false);
  1565. $('#pathBottom').prop('checked', false);
  1566. $('#pathRight').prop('checked', false);
  1567. }
  1568. }
  1569. }
  1570.  
  1571. matche = regexPathLinear.exec(content);
  1572. if (matche !== null) {
  1573. result = matche[1];
  1574. result = result.split('\r\n');
  1575. $('#linear').prop('checked', true);
  1576. for (let index = 0; index < result.length; index++) {
  1577. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  1578. if (matche !== null) actualMap = matche[1];
  1579. actualMap = actualMap.replace(/,/g, ", ");
  1580. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  1581. let loadAddLinearAction = function (param) {
  1582. matche = param.exec(result[index]);
  1583. if (matche !== null) {
  1584. if (matche[1] == "top") $('#pathTop').prop('checked', true);
  1585. if (matche[1] == "left") $('#pathLeft').prop('checked', true);
  1586. if (matche[1] == "bottom") $('#pathBottom').prop('checked', true);
  1587. if (matche[1] == "right") $('#pathRight').prop('checked', true);
  1588. }
  1589. $('#move').prop('checked', true);
  1590. matche = /gather/g.exec(result[index]);
  1591. if (matche !== null) $('#gather').prop('checked', true);
  1592. matche = /fight/g.exec(result[index]);
  1593. if (matche !== null) $('#fight').prop('checked', true);
  1594. onMapClick();
  1595. $('#pathTop').prop('checked', false);
  1596. $('#pathLeft').prop('checked', false);
  1597. $('#pathBottom').prop('checked', false);
  1598. $('#pathRight').prop('checked', false);
  1599. $('#gather').prop('checked', false);
  1600. $('#fight').prop('checked', false);
  1601. };
  1602. loadAddLinearAction(/changeMap.?=.?"(.+?)"/g);
  1603. loadAddLinearAction(/nextMap.?=.?"(.+?)"/g);
  1604. loadAddLinearAction(/thirdMap.?=.?"(.+?)"/g);
  1605. loadAddLinearAction(/fourthMap.?=.?"(.+?)"/g);
  1606. }
  1607. }
  1608. $('#linear').prop('checked', false);
  1609. } else if ((matche = regexPath.exec(content)) !== null) {
  1610. result = matche[1];
  1611. result = result.split('\r\n');
  1612. for (let index = 0; index < result.length; index++) {
  1613. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  1614. if (matche !== null) actualMap = matche[1];
  1615. actualMap = actualMap.replace(/,/g, ", ");
  1616. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  1617. matche = /top/g.exec(result[index]);
  1618. if (matche !== null) $('#pathTop').prop('checked', true);
  1619. matche = /left/g.exec(result[index]);
  1620. if (matche !== null) $('#pathLeft').prop('checked', true);
  1621. matche = /bottom/g.exec(result[index]);
  1622. if (matche !== null) $('#pathBottom').prop('checked', true);
  1623. matche = /right/g.exec(result[index]);
  1624. if (matche !== null) $('#pathRight').prop('checked', true);
  1625. matche = /gather/g.exec(result[index]);
  1626. $('#move').prop('checked', true);
  1627. if (matche !== null) $('#gather').prop('checked', true);
  1628. matche = /fight/g.exec(result[index]);
  1629. if (matche !== null) $('#fight').prop('checked', true);
  1630. onMapClick();
  1631. $('#pathTop').prop('checked', false);
  1632. $('#pathLeft').prop('checked', false);
  1633. $('#pathBottom').prop('checked', false);
  1634. $('#pathRight').prop('checked', false);
  1635. $('#gather').prop('checked', false);
  1636. $('#fight').prop('checked', false);
  1637. }
  1638. }
  1639. }
  1640. matche = regexPhenix.exec(content);
  1641. if (matche !== null) {
  1642. result = matche[1];
  1643. result = result.split('\r\n');
  1644. for (let index = 0; index < result.length; index++) {
  1645. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  1646. if (matche !== null) actualMap = matche[1];
  1647. actualMap = actualMap.replace(/,/g, ", ");
  1648. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  1649. matche = /top/g.exec(result[index]);
  1650. if (matche !== null) $('#pathTop').prop('checked', true);
  1651. matche = /left/g.exec(result[index]);
  1652. if (matche !== null) $('#pathLeft').prop('checked', true);
  1653. matche = /bottom/g.exec(result[index]);
  1654. if (matche !== null) $('#pathBottom').prop('checked', true);
  1655. matche = /right/g.exec(result[index]);
  1656. if (matche !== null) $('#pathRight').prop('checked', true);
  1657. $('#phenix').prop('checked', true);
  1658. onMapClick();
  1659. $('#pathTop').prop('checked', false);
  1660. $('#pathLeft').prop('checked', false);
  1661. $('#pathBottom').prop('checked', false);
  1662. $('#pathRight').prop('checked', false);
  1663. }
  1664. }
  1665. }
  1666. $('#move').prop('checked', true);
  1667. loadingFile = false;
  1668. };
  1669. reader.readAsText(file);
  1670. });
  1671.  
  1672. $(document).keypress(function (evt) {
  1673. var keyCode = evt.key;
  1674. if (GM_getValue("keyboardLayout", "azerty") == "azerty") {
  1675. switch (keyCode) {
  1676. case "z":
  1677. if (!$('#pathTop').is(":checked"))
  1678. $('#pathTop').prop('checked', true);
  1679. else
  1680. $('#pathTop').prop('checked', false);
  1681. break;
  1682. case "q":
  1683. if (!$('#pathLeft').is(":checked"))
  1684. $('#pathLeft').prop('checked', true);
  1685. else
  1686. $('#pathLeft').prop('checked', false);
  1687. break;
  1688. case "s":
  1689. if (!$('#pathBottom').is(":checked"))
  1690. $('#pathBottom').prop('checked', true);
  1691. else
  1692. $('#pathBottom').prop('checked', false);
  1693. break;
  1694. case "d":
  1695. if (!$('#pathRight').is(":checked"))
  1696. $('#pathRight').prop('checked', true);
  1697. else
  1698. $('#pathRight').prop('checked', false);
  1699. break;
  1700. case "a":
  1701. if (!$('#pathHavenBag').is(":checked"))
  1702. $('#pathHavenBag').prop('checked', true);
  1703. else
  1704. $('#pathHavenBag').prop('checked', false);
  1705. break;
  1706. default:
  1707. break;
  1708. }
  1709. } else if (GM_getValue("keyboardLayout", "azerty") == "qwerty") {
  1710. switch (keyCode) {
  1711. case "w":
  1712. if (!$('#pathTop').is(":checked"))
  1713. $('#pathTop').prop('checked', true);
  1714. else
  1715. $('#pathTop').prop('checked', false);
  1716. break;
  1717. case "a":
  1718. if (!$('#pathLeft').is(":checked"))
  1719. $('#pathLeft').prop('checked', true);
  1720. else
  1721. $('#pathLeft').prop('checked', false);
  1722. break;
  1723. case "s":
  1724. if (!$('#pathBottom').is(":checked"))
  1725. $('#pathBottom').prop('checked', true);
  1726. else
  1727. $('#pathBottom').prop('checked', false);
  1728. break;
  1729. case "d":
  1730. if (!$('#pathRight').is(":checked"))
  1731. $('#pathRight').prop('checked', true);
  1732. else
  1733. $('#pathRight').prop('checked', false);
  1734. break;
  1735. case "q":
  1736. if (!$('#pathHavenBag').is(":checked"))
  1737. $('#pathHavenBag').prop('checked', true);
  1738. else
  1739. $('#pathHavenBag').prop('checked', false);
  1740. break;
  1741. default:
  1742. break;
  1743. }
  1744. }
  1745. });
  1746.  
  1747. $('#exampleModal').on('click', '.btn-primary', function () {
  1748. let e = $('#sel1 option:selected');
  1749. var objMap = JSON.parse(e.val());
  1750. if ($('#move').is(":checked") || $('#gather').is(":checked") || $('#fight').is(":checked"))
  1751. havenBagData.push({
  1752. actualMap: actualMap.split(", ")[0] + "," + actualMap.split(", ")[1],
  1753. mapToGo: objMap.map,
  1754. mapidToGo: objMap.mapid,
  1755. move: true,
  1756. });
  1757. else if ($('#bank').is(":checked"))
  1758. havenBagData.push({
  1759. actualMap: actualMap.split(", ")[0] + "," + actualMap.split(", ")[1],
  1760. mapToGo: objMap.map,
  1761. mapidToGo: objMap.mapid,
  1762. bank: true,
  1763. });
  1764. else if ($('#phenix').is(":checked"))
  1765. havenBagData.push({
  1766. actualMap: actualMap.split(", ")[0] + "," + actualMap.split(", ")[1],
  1767. mapToGo: objMap.map,
  1768. mapidToGo: objMap.mapid,
  1769. phenix: true
  1770. });
  1771. $('#exampleModal').modal('hide');
  1772. onMapClick();
  1773. });
  1774. $('#exampleModal').on('click', '.btn-secondary', function () {
  1775. havenToggle = false;
  1776. $('#exampleModal').modal('hide');
  1777. });
  1778. $('#exampleModal').on('click', '.close', function () {
  1779. havenToggle = false;
  1780. $('#exampleModal').modal('hide');
  1781. });
  1782.  
  1783. function linearActualItem(index, time) {
  1784. if (GM_getValue('language') == 'fr') {
  1785. if (pathLinearData[index].top.index == time) return 'Haut';
  1786. else if (pathLinearData[index].left.index == time) return 'Gauche';
  1787. else if (pathLinearData[index].bottom.index == time) return 'Bas';
  1788. else if (pathLinearData[index].right.index == time) return 'Droite';
  1789. else if (pathLinearData[index].havenbag.index == time) return 'Havre-sac';
  1790. } else if (GM_getValue('language') == 'en') {
  1791. if (pathLinearData[index].top.index == time) return 'Top';
  1792. else if (pathLinearData[index].left.index == time) return 'Left';
  1793. else if (pathLinearData[index].bottom.index == time) return 'Bottom';
  1794. else if (pathLinearData[index].right.index == time) return 'Right';
  1795. else if (pathLinearData[index].havenbag.index == time) return 'Havenbag';
  1796. } else if (GM_getValue('language') == 'es') {
  1797. if (pathLinearData[index].top.index == time) return 'Arriba';
  1798. else if (pathLinearData[index].left.index == time) return 'Bajo';
  1799. else if (pathLinearData[index].bottom.index == time) return 'Izquierda';
  1800. else if (pathLinearData[index].right.index == time) return 'Derecha';
  1801. else if (pathLinearData[index].havenbag.index == time) return 'Merkasako';
  1802. }
  1803.  
  1804. }
  1805.  
  1806. function LMap() {
  1807. if (map) {
  1808. map.on('click', onMapClick);
  1809. map.on('mousemove', function () {
  1810. for (let index = 0; index < pathLinearData.length; index++) {
  1811. if (pathLinearData[index].map == $('#mapCoordinates').text()) {
  1812. if (pathLinearData[index].index == 4) {
  1813. if (GM_getValue('language') == 'fr') {
  1814. $('#mapCoordinates').append(
  1815. '<span><br />Premiére action sur la map : ' + linearActualItem(index, 1) +
  1816. '<br />Deuxiéme action sur la map : ' + linearActualItem(index, 2) +
  1817. '<br />Troisiéme action sur la map : ' + linearActualItem(index, 3) +
  1818. '<br />Quatrième action sur la map : ' + linearActualItem(index, 4) + '</span>'
  1819. );
  1820. } else if (GM_getValue('language') == 'en') {
  1821. $('#mapCoordinates').append(
  1822. '<span><br />First action on the map : ' + linearActualItem(index, 1) +
  1823. '<br />Second action on the map : ' + linearActualItem(index, 2) +
  1824. '<br />Third action on the map : ' + linearActualItem(index, 3) +
  1825. '<br />Fourth action on the map : ' + linearActualItem(index, 4) + '</span>'
  1826. );
  1827. } else if (GM_getValue('language') == 'es') {
  1828. $('#mapCoordinates').append(
  1829. '<span><br />Primera acción en el mapa: ' + linearActualItem(index, 1) +
  1830. '<br />Segunda acción en el mapa : ' + linearActualItem(index, 2) +
  1831. '<br />Tercera acción en el mapa : ' + linearActualItem(index, 3) +
  1832. '<br />Cuarta acción en el mapa : ' + linearActualItem(index, 4) + '</span>'
  1833. );
  1834. }
  1835. } else if (pathLinearData[index].index == 3) {
  1836. if (GM_getValue('language') == 'fr') {
  1837. $('#mapCoordinates').append(
  1838. '<span><br />Premiére action sur la map : ' + linearActualItem(index, 1) +
  1839. '<br />Deuxiéme action sur la map : ' + linearActualItem(index, 2) +
  1840. '<br />Troisiéme action sur la map : ' + linearActualItem(index, 3) + '</span>'
  1841. );
  1842. } else if (GM_getValue('language') == 'en') {
  1843. $('#mapCoordinates').append(
  1844. '<span><br />First action on the map : ' + linearActualItem(index, 1) +
  1845. '<br />Second action on the map : ' + linearActualItem(index, 2) +
  1846. '<br />Third action on the map : ' + linearActualItem(index, 3) + '</span>'
  1847. );
  1848. } else if (GM_getValue('language') == 'es') {
  1849. $('#mapCoordinates').append(
  1850. '<span><br />Primera acción en el mapa: ' + linearActualItem(index, 1) +
  1851. '<br />Segunda acción en el mapa : ' + linearActualItem(index, 2) +
  1852. '<br />Tercera acción en el mapa : ' + linearActualItem(index, 3) + '</span>'
  1853. );
  1854. }
  1855. } else if (pathLinearData[index].index == 2) {
  1856. if (GM_getValue('language') == 'fr') {
  1857. $('#mapCoordinates').append(
  1858. '<span><br />Premiére action sur la map : ' + linearActualItem(index, 1) +
  1859. '<br />Deuxiéme action sur la map : ' + linearActualItem(index, 2) + '</span>'
  1860. );
  1861. } else if (GM_getValue('language') == 'en') {
  1862. $('#mapCoordinates').append(
  1863. '<span><br />First action on the map : ' + linearActualItem(index, 1) +
  1864. '<br />Second action on the map : ' + linearActualItem(index, 2) + '</span>'
  1865. );
  1866. } else if (GM_getValue('language') == 'es') {
  1867. $('#mapCoordinates').append(
  1868. '<span><br />Primera acción en el mapa: ' + linearActualItem(index, 1) +
  1869. '<br />Segunda acción en el mapa : ' + linearActualItem(index, 2) + '</span>'
  1870. );
  1871. }
  1872. } else if (pathLinearData[index].index == 1) {
  1873. if (GM_getValue('language') == 'fr') {
  1874. $('#mapCoordinates').append(
  1875. '<span><br />Premiére action sur la map : ' + linearActualItem(index, 1) + '</span>'
  1876. );
  1877. } else if (GM_getValue('language') == 'en') {
  1878. $('#mapCoordinates').append(
  1879. '<span><br />PFirst action on the map : ' + linearActualItem(index, 1) + '</span>'
  1880. );
  1881. } else if (GM_getValue('language') == 'es') {
  1882. $('#mapCoordinates').append(
  1883. '<span><br />Primera acción en el mapa: ' + linearActualItem(index, 1) + '</span>'
  1884. );
  1885. }
  1886. }
  1887. }
  1888. }
  1889. });
  1890. } else {
  1891. setTimeout(function () {
  1892. LMap();
  1893. }, 50);
  1894. }
  1895. }
  1896. LMap();
  1897.  
  1898. $('#linear').change(function () {
  1899. if (this.checked) {
  1900. $('#move').prop('checked', true);
  1901. $('#phenix').prop("disabled", true);
  1902. $('#bank').prop("disabled", true);
  1903. } else {
  1904. $('#phenix').prop("disabled", false);
  1905. $('#bank').prop("disabled", false);
  1906. }
  1907. });
  1908.  
  1909. $('#ressourcePickerCreator').on("click", function () {
  1910. $('#ressourcePickerBot').prepend('<span id="pickRessource' + picker + '" class="pickRessource ressourceColor1" onclick="clickOnTypePicker(\'' + picker + '\');" data-name="" data-ressourceid=""' +
  1911. 'style="background-position: -260px 0px; line-height: 49px !important; width: 49px !important; margin: 2px !important; height: 49px !important;">?</span>');
  1912. gatherData.push('pickRessource' + picker);
  1913. picker += 1;
  1914. });
  1915. $('#deletePath').on("click", function () {
  1916. let deleteAll = function (array) {
  1917. for (let index = 0; index < array.length; index) {
  1918. if (array[index].top)
  1919. if (array[index].top.icon) map.removeLayer(array[index].top.icon);
  1920. if (array[index].bottom)
  1921. if (array[index].bottom.icon) map.removeLayer(array[index].bottom.icon);
  1922. if (array[index].left)
  1923. if (array[index].left.icon) map.removeLayer(array[index].left.icon);
  1924. if (array[index].right)
  1925. if (array[index].right.icon) map.removeLayer(array[index].right.icon);
  1926. if (array[index].havenbag)
  1927. if (array[index].havenbag.icon) map.removeLayer(array[index].havenbag.icon);
  1928. array.splice(index, 1);
  1929. }
  1930. };
  1931. deleteAll(pathData);
  1932. deleteAll(pathLinearData);
  1933. deleteAll(bankData);
  1934. deleteAll(phenixData);
  1935. deleteAll(havenBagData);
  1936. console.clear();
  1937. });
  1938. $('#fr').on("click", function () {
  1939. languageSelector("fr");
  1940. });
  1941. $('#en').on("click", function () {
  1942. languageSelector("en");
  1943. });
  1944. $('#es').on("click", function () {
  1945. languageSelector("es");
  1946. });
  1947. $('#azerty').on("click", function () {
  1948. GM_setValue("keyboardLayout", "azerty");
  1949. });
  1950. $('#qwerty').on("click", function () {
  1951. GM_setValue("keyboardLayout", "qwerty");
  1952. });
  1953. })();