Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.39 KB | None | 0 0
  1. -- Move ├───────────────────────────────────────────────────────────────────────
  2.  
  3. function move()
  4. return { { map = '-1,13', custom = main } }
  5. end
  6.  
  7. -- Main ├───────────────────────────────────────────────────────────────────────
  8.  
  9. function main()
  10.  
  11. if not onMap('-1,13') then
  12. return
  13. end
  14.  
  15. local change_map = lua.fn:chain(changeMap)
  16.  
  17. local function door(cell)
  18. use(cell, -1)
  19. return door
  20. end
  21.  
  22. local npc_reply = lua.fn:chain(npc.reply)
  23.  
  24. local npc_dopple = function(id, start)
  25. npc.npc(id, 1)
  26. if start then -- ugly
  27. npc_reply(-1)(-2)(-1)
  28. else
  29. npc_reply(-1)(-1)
  30. end
  31. -- Start fight
  32. leaveDialog()
  33. end
  34.  
  35. -- Sadida
  36. go({0,13})({0,9})({-1,9})
  37. door(342)(274)
  38. npc_dopple(442, ({ start = true }).start)
  39. change_map(408)(397)
  40.  
  41. -- Cra
  42. go({0,9})({0,3})
  43. door(401)(311)
  44. npc_dopple(439)
  45. change_map(472)(({451,465})[1])
  46.  
  47. -- Iop
  48. go({1,3})
  49. door(356)
  50. change_map(({415,429})[1])
  51. npc_dopple(434)
  52. door(269)
  53. change_map(({410,425})[1])
  54.  
  55. -- Rogue
  56. go({3,3})
  57. door(191)
  58. npc.npc(1422, 1)
  59. npc_reply(-1)
  60. door(159)(338)(311)(323)
  61. npc_dopple(1414)
  62. door(({495,509})[1])
  63. change_map(347)
  64. door(({439,453})[1])(({329,343})[1])
  65. npc.npc(1422, 1)
  66. npc_reply(-2)
  67. door(241)
  68.  
  69. -- Xelor
  70. go({3,1})
  71. door(373)(346)
  72. npc_dopple(437)
  73. change_map(410)(({397,411})[1])
  74.  
  75. -- Eliotrope
  76. go({4,0})
  77. door(274)
  78. change_map('right')('left')
  79. npc_dopple(2834)
  80. change_map('right')('bottom')
  81. use(498, ({ sufokia = 166742, amakna = 166741 }).amakna)
  82.  
  83. -- Eniripsa
  84. go({7,1})
  85. door(412)(290)(426)(346)
  86. npc_dopple(435)
  87. door(({348,362})[1])(({337,350})[1])(({319,333})[1])
  88. change_map('bottom')
  89.  
  90. -- Osamodas
  91. go({8,2})
  92. door(261)(242)
  93. npc_dopple(436)
  94. change_map(458)(424)
  95.  
  96. -- Feca
  97. go({8,5})({12,5})
  98. door(400)(290)
  99. npc_dopple(433)
  100. door(451)(424)
  101.  
  102. -- Foggernaut
  103. go({9,5})({9,1})
  104. door(217)(344)(398)
  105. change_map(499)
  106. npc_dopple(1594)
  107. door(311)
  108. change_map(494)(({452,466})[1])
  109. use(438, ({ sufokia = 146232, amakna = 146308 }).amakna)
  110.  
  111. -- Pandawa
  112. go({4,1})({4,-2})
  113. door(381)(317)
  114. npc_dopple(672)
  115. change_map(452)(452)
  116.  
  117. -- Huppermage
  118. go({-4,-2})
  119. door(272)
  120. change_map('top')('right')('top')
  121. door(474)
  122. npc_dopple(3053)
  123. change_map('left|bottom')('bottom')('left')('left|bottom')
  124. door(177)
  125.  
  126. -- Sram
  127. go({-3,-2})({-3,0})({-4,0})
  128. door(({317,384})[1])(275)
  129. npc_dopple(441)
  130. door(416)
  131. change_map(({388,442})[1])
  132.  
  133. -- Enutrof
  134. go({-3,0})({-1,-4})
  135. door(415)(311)
  136. npc_dopple(440)
  137. door(325)
  138. change_map(({456,469})[1])
  139.  
  140. -- Ecaflip
  141. go({1,-4})({1,-5})
  142. door(314)(245)(305)
  143. npc_dopple(438)
  144. door(233)(214)
  145. change_map(({382,397})[1])
  146.  
  147. -- Masqueraider
  148. go({1,-8})
  149. door(144)(107)(184)(184)(287)(290)
  150. npc_dopple(1425)
  151. door(284)
  152. change_map(511)
  153. door(402)(393)(394)(347)
  154.  
  155. -- Sacrier
  156. go({0,-8})({0,-7})({-2,-7})
  157. door(194)
  158. change_map(394)
  159. go({-2,-8})
  160. door(286)(285)(243)
  161. npc_dopple(443)
  162. change_map(({460,473})[1])(({401,414})[1])(({486,499})[1])
  163. go({-2,-5})
  164. door(367)
  165. change_map(({437,452})[1])
  166. go({0,-4})({0,13})
  167.  
  168. end
  169.  
  170. -- Utility ├────────────────────────────────────────────────────────────────────
  171.  
  172. function go(destination, fn)
  173.  
  174. local destination_str = lua.table:join(destination, ',')
  175.  
  176. local current_map = lua.table:map(lua.string:split(currentMap(), ','), tonumber)
  177.  
  178. local x_current, y_current = unpack(current_map)
  179. local x_destination, y_destination = unpack(destination)
  180.  
  181. local direction = function(start, stop) return (start == stop) and 0 or (start < stop) and 1 or -1 end
  182.  
  183. local x_direction = { [-1] = 'left', [0] = nil, [1] = 'right' }
  184. local y_direction = { [-1] = 'top', [0] = nil, [1] = 'bottom' }
  185.  
  186. local map = { map = current_map,
  187. direction = lua.table:join(lua.table:compact({ x_direction[direction(x_current, x_destination)],
  188. y_direction[direction(y_current, y_destination)] }), '|') }
  189.  
  190. local saved_current_map_str = currentMap()
  191.  
  192. if fn then fn(map) end
  193.  
  194. if (currentMap() == saved_current_map_str) then
  195. changeMap(map.direction)
  196. end
  197.  
  198. return (currentMap() == destination_str) and go or go(destination, fn)
  199. end
  200.  
  201. -- Library ├────────────────────────────────────────────────────────────────────
  202.  
  203. lua = {
  204. fn = {
  205. chain = function(self, fn)
  206. local function helper(...)
  207. fn(...)
  208. return helper
  209. end
  210. return helper
  211. end,
  212.  
  213. curry = function(self, fn, nargs)
  214. nargs = nargs or debug.getinfo(fn, 'u').nparamsend
  215. local helper = function(args, n)
  216. return n < 1 and fn(unpack(args)) or (function(...) return helper(lua.table:concat(args, {...}), n - #{...}) end)
  217. end
  218. return helper({}, nargs)
  219. end,
  220. },
  221.  
  222. math = {
  223. infinite = (1/0),
  224. },
  225.  
  226. object = {
  227. compare = function(self, a, b)
  228. if type(a) ~= type(b) then
  229. return false
  230. end
  231. if type(a) ~= 'table' or type(b) ~= 'table' then
  232. return a == b
  233. end
  234. for key, value_a in pairs(a) do local value_b = b[key]
  235. if not value_b or not self:compare(value_a, value_b) then
  236. return false
  237. end
  238. end
  239. for key, value_b in pairs(b) do local value_a = a[key]
  240. if not value_a then
  241. return false
  242. end
  243. end
  244. return true
  245. end,
  246.  
  247. copy = function(self, object)
  248. if type(object) ~= 'table' then
  249. return object
  250. end
  251. local res = {}
  252. for key, value in pairs(object) do
  253. res[self:copy(key)] = self:copy(value)
  254. end
  255. return res
  256. end,
  257.  
  258. range = function(self, start, stop, step)
  259. local step = (step ~= nil) and step or (start < stop) and 1 or -1
  260. local res = {}
  261. for value = start, stop, step do
  262. res[#res + 1] = value
  263. end
  264. return res
  265. end,
  266.  
  267. tap = function(self, object, fn)
  268. return fn(object)
  269. end,
  270. },
  271.  
  272. string = {
  273. split = function(self, str, sep)
  274. res = {}
  275. pattern = string.format("([^%s]+)", sep)
  276. str:gsub(pattern, (function(match) res[#res + 1] = match end))
  277. return res
  278. end,
  279. },
  280.  
  281. table = {
  282. compact = function(self, _table)
  283. return self:filter(_table, (function(value) return (value ~= nil) end))
  284. end,
  285.  
  286. concat = function(self, head, ...)
  287. local head = lua.object:copy(head)
  288. for key, tail in pairs({...}) do
  289. for key, value in pairs(tail) do
  290. head[#head + 1] = value
  291. end
  292. end
  293. return head
  294. end,
  295.  
  296. filter = function(self, _table, fn)
  297. local filtered = {}
  298. for key, value in pairs(lua.object:copy(_table)) do
  299. if fn(value) then
  300. filtered[#filtered + 1] = value
  301. end
  302. end
  303. return filtered
  304. end,
  305.  
  306. flatten = function(self, _table, level)
  307. level = level or lua.math.infinite
  308. return self:inject((function(memo, value)
  309. return (level < 1) or (type(value) ~= 'table') and self:push(memo, value) or self:concat(memo, self:flatten(value, (level - 1)))
  310. end), {}, _table)
  311. end,
  312.  
  313. head = function(self, _table)
  314. return _table[1]
  315. end,
  316.  
  317. inject = function(self, fn, initial, _table)
  318. local memo = lua.object:copy(initial)
  319. for key, value in pairs(_table) do
  320. memo = fn(memo, value)
  321. end
  322. return memo
  323. end,
  324.  
  325. insert = function(self, index, _table, object)
  326. local smart_index = (function(index, length) return (index > 0) and index or ((length + 2) + index) end)
  327. local res = lua.object:copy(_table)
  328. local index = smart_index(index, #res)
  329. local entry = res[index]
  330. res[index] = object
  331. return not entry and res or self:insert((index + 1), res, entry)
  332. end,
  333.  
  334. join = function(self, _table, separator)
  335. return self:inject((function(memo, value) return memo .. (separator or '') .. value end), self:head(_table), self:tail(_table))
  336. end,
  337.  
  338. map = function(self, objects, fn)
  339. local collection = {}
  340. for key, object in pairs(objects) do
  341. collection[key] = fn(object)
  342. end
  343. return collection
  344. end,
  345.  
  346. merge = function(self, a, b, fn)
  347. local a_copy, b_copy = lua.object:copy(a), lua.object:copy(b)
  348. local merged = a_copy
  349. for key, value in pairs(b_copy) do
  350. merged[key] = (merged[key] == nil) and value or (fn == nil) and value or fn(key, a_copy[key], b_copy[key])
  351. end
  352. return merged
  353. end,
  354.  
  355. push = function(self, _table, object)
  356. return self:insert(-1, _table, object)
  357. end,
  358.  
  359. reverse = function(self, _table)
  360. local reversed = {}
  361. for key, value in pairs(_table) do
  362. reversed[#_table + 1 - key] = value
  363. end
  364. return reversed
  365. end,
  366.  
  367. select = function(self, _table, fn)
  368. return self:head(self:filter(_table, fn))
  369. end,
  370.  
  371. tail = function(self, _table)
  372. return { select(2, unpack(_table)) }
  373. end,
  374. },
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement