9
3

SeniorInitiateDelvin.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. --[[
  2. Script Name : SpawnScripts/qeynos_combined02/SeniorInitiateDelvin.lua
  3. Script Author : Rylec
  4. Script Date : 2021.02.01 05:02:19
  5. Script Purpose :
  6. :
  7. This script is quite complex and allows for all the behaviours of Delvin on Live: He can move left or right
  8. around the building and at each of the four corners he will either make a short or long pause, or he will step
  9. around a bit (initiated by one of several emotes). He can also make between 1 and 3 rounds before going back
  10. inside, and when returning he may bow.
  11. Not implemented yet: proximity for his conversation (it is using hail for now) and he also sometimes runs back
  12. which is not included at it looks a bit odd.
  13. --]]
  14. -- Flags used for checking how many rounds he is making and for which of the 14 different special choices he can make along his way
  15. local NumberOfTrips = 0
  16. local SpecialEventTrigger = 0
  17. function spawn(NPC)
  18. AddTimer(NPC, 3000, "move_start")
  19. end
  20. function hailed(NPC, Spawn)
  21. FaceTarget(NPC, Spawn)
  22. math.randomseed(os.time())
  23. local Conversation = math.random(1,2)
  24. if Conversation == 1 then
  25. PlayFlavor(NPC, "", "Oh, my aching back! As good a time to stop and chat as any, I say.", "yawn", 0, 0, Spawn)
  26. else
  27. PlayFlavor(NPC, "", "Almost time to stop and have an ale, isn't it?", "wink", 0, 0, Spawn)
  28. end
  29. end
  30. function respawn(NPC)
  31. spawn(NPC)
  32. end
  33. function move_start(NPC)
  34. -- walks to a location in mid room and calls the function that triggers the door widget
  35. MoveToLocation(NPC, 767.33, -19.36, -378.62, 2, "open_door")
  36. go_outside(NPC)
  37. end
  38. function go_outside(NPC)
  39. -- Live has several location outside the door before Delvin starts to walk around the building
  40. math.randomseed(os.time())
  41. local MoveOutside = math.random(1,3)
  42. if MoveOutside == 1 then
  43. MoveToLocation(NPC, 756.65, -19.65, -378.86, 2, "pick_special_event")
  44. elseif MoveOutside == 2 then
  45. MoveToLocation(NPC, 757.38, -19.64, -377.92, 2, "pick_special_event")
  46. else
  47. MoveToLocation(NPC, 758.01, -19.64, -378.51, 2, "pick_special_event")
  48. end
  49. end
  50. function pick_special_event(NPC)
  51. -- First trip is initiated. Most of the times Delvin does something special on first round (sometimes nothing)
  52. NumberOfTrips = 1
  53. math.randomseed(os.time())
  54. local SpecialEvent = math.random(1,14)
  55. if SpecialEvent == 1 then
  56. left_no_pause(NPC)
  57. elseif SpecialEvent == 2 then
  58. -- left_short_pause_first_corner
  59. SpecialEventTrigger = 2
  60. MoveToLocation(NPC, 757.84, -19.63, -363.12, 2, "special_event")
  61. elseif SpecialEvent == 3 then
  62. -- left_short_pause_second_corner
  63. SpecialEventTrigger = 3
  64. MoveToLocation(NPC, 758.68, -19.63, -364.16, 2)
  65. MoveToLocation(NPC, 783.59, -19.63, -364.16, 2, "special_event")
  66. elseif SpecialEvent == 4 then
  67. -- left_long_pause_first_corner
  68. SpecialEventTrigger = 4
  69. MoveToLocation(NPC, 757.84, -19.63, -363.12, 2, "special_event")
  70. elseif SpecialEvent == 5 then
  71. -- left_long_pause_second_corner
  72. SpecialEventTrigger = 5
  73. MoveToLocation(NPC, 758.68, -19.63, -364.16, 2)
  74. MoveToLocation(NPC, 783.59, -19.63, -364.16, 2, "special_event")
  75. elseif SpecialEvent == 6 then
  76. left_restless_first_corner(NPC)
  77. elseif SpecialEvent == 7 then
  78. MoveToLocation(NPC, 758.05, -19.63, -363.92, 2, "left_restless_second_corner")
  79. elseif SpecialEvent == 8 then
  80. right_no_pause(NPC)
  81. elseif SpecialEvent == 9 then
  82. -- right_short_pause_first_corner
  83. SpecialEventTrigger = 9
  84. MoveToLocation(NPC, 758.29, -19.63, -394.06, 2, "special_event")
  85. elseif SpecialEvent == 10 then
  86. -- right_short_pause_second_corner
  87. SpecialEventTrigger = 10
  88. MoveToLocation(NPC, 758.29, -19.63, -393.24, 2)
  89. MoveToLocation(NPC, 783.44, -19.63, -394.01, 2, "special_event")
  90. elseif SpecialEvent == 11 then
  91. -- right_long_pause_first_corner
  92. SpecialEventTrigger = 11
  93. MoveToLocation(NPC, 758.29, -19.63, -394.06, 2, "special_event")
  94. elseif SpecialEvent == 12 then
  95. -- right_long_pause_second_corner
  96. SpecialEventTrigger = 12
  97. MoveToLocation(NPC, 758.29, -19.63, -393.24, 2)
  98. MoveToLocation(NPC, 783.44, -19.63, -394.01, 2, "special_event")
  99. elseif SpecialEvent == 13 then
  100. right_restless_first_corner(NPC)
  101. else
  102. MoveToLocation(NPC, 758.29, -19.63, -394.06, 2, "right_restless_second_corner")
  103. end
  104. end
  105. function left_no_pause(NPC)
  106. -- Delvin does nothing on his first round
  107. MoveToLocation(NPC, 758.68, -19.63, -363.33, 2)
  108. MoveToLocation(NPC, 783.59, -19.63, -364.16, 2)
  109. MoveToLocation(NPC, 783.42, -19.63, -394.05, 2)
  110. MoveToLocation(NPC, 757.29, -19.63, -394.07, 2, "return_to_start_left")
  111. end
  112. function left_restless_first_corner(NPC)
  113. -- Delvis makes some shuffling around on first corner going left
  114. SpecialEventTrigger = 6
  115. MoveToLocation(NPC, 757.84, -19.63, -363.12, 2, "left_restless_first_corner_first_pause")
  116. end
  117. function left_restless_first_corner_first_pause(NPC)
  118. -- This timer is added else the emote will not execute (probably triggered before he reaches location)
  119. AddTimer(NPC, math.random(1000,1500), "left_restless_first_corner_animation")
  120. end
  121. function left_restless_first_corner_animation(NPC)
  122. -- Emote pick
  123. math.randomseed(os.time())
  124. local PauseAnimation = math.random(1,4)
  125. if PauseAnimation == 1 then
  126. PlayAnimation(NPC, 12030)
  127. elseif PauseAnimation == 2 then
  128. PlayAnimation(NPC, 12246)
  129. elseif PauseAnimation == 3 then
  130. PlayAnimation(NPC, 12329)
  131. else
  132. PlayAnimation(NPC, 323)
  133. end
  134. AddTimer(NPC, math.random(15000,60000), "left_restless_first_corner_second_pause")
  135. end
  136. function left_restless_first_corner_second_pause(NPC)
  137. -- These following functions are added since there is no delay in the current MoveToLocation function
  138. MoveToLocation(NPC, 756.50, -19.63, -364.08, 2)
  139. AddTimer(NPC, math.random(15000,60000), "left_restless_first_corner_third_pause")
  140. end
  141. function left_restless_first_corner_third_pause(NPC)
  142. MoveToLocation(NPC, 758.87, -19.63, -364.19, 2)
  143. AddTimer(NPC, math.random(15000,60000), "left_restless_first_corner_fourth_pause")
  144. end
  145. function left_restless_first_corner_fourth_pause(NPC)
  146. -- Continues his first round after a brief final pause
  147. MoveToLocation(NPC, 756.50, -19.63, -364.08, 2)
  148. AddTimer(NPC, math.random(7000,10000), "left_first_corner_continue")
  149. end
  150. function left_restless_second_corner(NPC)
  151. -- Delvis makes some shuffling around on second corner going left
  152. SpecialEventTrigger = 7
  153. MoveToLocation(NPC, 784.36, -19.63, -362.99, 2, "left_restless_second_corner_second_pause")
  154. end
  155. function left_restless_second_corner_second_pause(NPC)
  156. -- This timer is added else the emote will not execute (probably triggered before he reaches location)
  157. AddTimer(NPC, math.random(1000,1500), "left_restless_second_corner_animation")
  158. end
  159. function left_restless_second_corner_animation(NPC)
  160. -- Emote pick
  161. math.randomseed(os.time())
  162. local PauseAnimation = math.random(1,4)
  163. if PauseAnimation == 1 then
  164. PlayAnimation(NPC, 12030)
  165. elseif PauseAnimation == 2 then
  166. PlayAnimation(NPC, 12246)
  167. elseif PauseAnimation == 3 then
  168. PlayAnimation(NPC, 12329)
  169. else
  170. PlayAnimation(NPC, 323)
  171. end
  172. AddTimer(NPC, math.random(15000,60000), "left_restless_second_corner_second_pause")
  173. end
  174. function left_restless_second_corner_second_pause(NPC)
  175. -- These following functions are added since there is no delay in the current MoveToLocation function
  176. MoveToLocation(NPC, 783.53, -19.63, -362.90, 2)
  177. AddTimer(NPC, math.random(15000,60000), "left_restless_second_corner_third_pause")
  178. end
  179. function left_restless_second_corner_third_pause(NPC)
  180. MoveToLocation(NPC, 784.43, -19.63, -363.03, 2)
  181. AddTimer(NPC, math.random(15000,60000), "left_restless_second_corner_fourth_pause")
  182. end
  183. function left_restless_second_corner_fourth_pause(NPC)
  184. -- Continues his first round after a brief final pause
  185. MoveToLocation(NPC, 783.35, -19.63, -394.01, 2)
  186. AddTimer(NPC, math.random(7000,10000), "left_second_corner_continue")
  187. end
  188. function right_no_pause(NPC)
  189. MoveToLocation(NPC, 756.64, -19.65, -393.05, 2)
  190. MoveToLocation(NPC, 783.47, -19.63, -393.09, 2)
  191. MoveToLocation(NPC, 783.93, -19.63, -363.73, 2)
  192. MoveToLocation(NPC, 757.48, -19.63, -364.03, 2, "return_to_start_right")
  193. end
  194. function right_restless_first_corner(NPC)
  195. -- Delvis makes some shuffling around on first corner going right
  196. SpecialEventTrigger = 13
  197. MoveToLocation(NPC, 758.12, -19.63, -394.04, 2, "right_restless_first_corner_first_pause")
  198. end
  199. function right_restless_first_corner_first_pause(NPC)
  200. -- This timer is added else the emote will not execute (probably triggered before he reaches location)
  201. AddTimer(NPC, math.random(1000,1500), "right_restless_first_corner_animation")
  202. end
  203. function right_restless_first_corner_animation(NPC)
  204. math.randomseed(os.time())
  205. local PauseAnimation = math.random(1,4)
  206. if PauseAnimation == 1 then
  207. PlayAnimation(NPC, 12030)
  208. elseif PauseAnimation == 2 then
  209. PlayAnimation(NPC, 12246)
  210. elseif PauseAnimation == 3 then
  211. PlayAnimation(NPC, 12329)
  212. else
  213. PlayAnimation(NPC, 323)
  214. end
  215. AddTimer(NPC, math.random(15000,60000), "right_restless_first_corner_second_pause")
  216. end
  217. function right_restless_first_corner_second_pause(NPC)
  218. -- These following functions are added since there is no delay in the current MoveToLocation function
  219. MoveToLocation(NPC, 758.38, -19.63, -393.02, 2)
  220. AddTimer(NPC, math.random(15000,60000), "right_restless_first_corner_third_pause")
  221. end
  222. function right_restless_first_corner_third_pause(NPC)
  223. MoveToLocation(NPC, 756.02, -19.64, -394.27, 2)
  224. AddTimer(NPC, math.random(15000,60000), "right_restless_first_corner_fourth_pause")
  225. end
  226. function right_restless_first_corner_fourth_pause(NPC)
  227. -- Continues his first round after a brief final pause
  228. MoveToLocation(NPC, 758.74, -19.63, -393.89, 2)
  229. AddTimer(NPC, math.random(7000,10000), "right_first_corner_continue")
  230. end
  231. function right_restless_second_corner(NPC)
  232. -- Delvis makes some shuffling around on second corner going right
  233. SpecialEventTrigger = 14
  234. MoveToLocation(NPC, 783.46, -19.63, -393.08, 2, "right_restless_second_corner_first_pause")
  235. end
  236. function right_restless_second_corner_first_pause(NPC)
  237. -- This timer is added else the emote will not execute (probably triggered before he reaches location)
  238. AddTimer(NPC, math.random(1000,1500), "right_restless_second_corner_animation")
  239. end
  240. function right_restless_second_corner_animation(NPC)
  241. math.randomseed(os.time())
  242. local PauseAnimation = math.random(1,4)
  243. if PauseAnimation == 1 then
  244. PlayAnimation(NPC, 12030)
  245. elseif PauseAnimation == 2 then
  246. PlayAnimation(NPC, 12246)
  247. elseif PauseAnimation == 3 then
  248. PlayAnimation(NPC, 12329)
  249. else
  250. PlayAnimation(NPC, 323)
  251. end
  252. AddTimer(NPC, math.random(15000,60000), "right_restless_second_corner_second_pause")
  253. end
  254. function right_restless_second_corner_second_pause(NPC)
  255. -- These following functions are added since there is no delay in the current MoveToLocation function
  256. MoveToLocation(NPC, 783.37, -19.63, -394.12, 2)
  257. AddTimer(NPC, math.random(15000,60000), "right_restless_second_corner_third_pause")
  258. end
  259. function right_restless_second_corner_third_pause(NPC)
  260. MoveToLocation(NPC, 783.37, -19.63, -393.01, 2)
  261. AddTimer(NPC, math.random(15000,60000), "right_restless_second_corner_fourth_pause")
  262. end
  263. function right_restless_second_corner_fourth_pause(NPC)
  264. -- Continues his first round after a brief final pause
  265. MoveToLocation(NPC, 783.39, -19.63, -394.08, 2)
  266. AddTimer(NPC, math.random(7000,10000), "right_second_corner_continue")
  267. end
  268. function special_event(NPC)
  269. -- Picks lenght of pause if that is the special event depending on which corner (using SpecialEventTrigger flag)
  270. if SpecialEventTrigger == 2 then
  271. AddTimer(NPC, math.random(2500,5000), "left_first_corner_continue")
  272. elseif SpecialEventTrigger == 3 then
  273. AddTimer(NPC, math.random(2500,5000), "left_second_corner_continue")
  274. elseif SpecialEventTrigger == 4 then
  275. AddTimer(NPC, math.random(95000,120000), "left_first_corner_continue")
  276. elseif SpecialEventTrigger == 5 then
  277. AddTimer(NPC, math.random(95000,120000), "left_second_corner_continue")
  278. elseif SpecialEventTrigger == 9 then
  279. AddTimer(NPC, math.random(2500,5000), "right_first_corner_continue")
  280. elseif SpecialEventTrigger == 10 then
  281. AddTimer(NPC, math.random(2500,5000), "right_second_corner_continue")
  282. elseif SpecialEventTrigger == 11 then
  283. AddTimer(NPC, math.random(95000,120000), "right_first_corner_continue")
  284. elseif SpecialEventTrigger == 12 then
  285. AddTimer(NPC, math.random(95000,120000), "right_second_corner_continue")
  286. end
  287. end
  288. -- These functions continues the first round after a special event
  289. function left_first_corner_continue(NPC)
  290. MoveToLocation(NPC, 783.46, -19.63, -363.05, 2)
  291. MoveToLocation(NPC, 783.31, -19.63, -393.26, 2)
  292. MoveToLocation(NPC, 758.15, -19.63, -394.00, 2, "return_to_start_left")
  293. end
  294. function left_second_corner_continue(NPC)
  295. MoveToLocation(NPC, 783.31, -19.63, -393.26, 2)
  296. MoveToLocation(NPC, 758.15, -19.63, -394.00, 2, "return_to_start_left")
  297. end
  298. function right_first_corner_continue(NPC)
  299. MoveToLocation(NPC, 783.31, -19.63, -393.26, 2)
  300. MoveToLocation(NPC, 783.46, -19.63, -363.05, 2)
  301. MoveToLocation(NPC, 757.48, -19.63, -364.03, 2, "return_to_start_right")
  302. end
  303. function right_second_corner_continue(NPC)
  304. MoveToLocation(NPC, 783.46, -19.63, -363.05, 2)
  305. MoveToLocation(NPC, 757.48, -19.63, -364.03, 2, "return_to_start_right")
  306. end
  307. function return_to_start_left(NPC)
  308. -- Returns Delvin to one of three locations outside the door after completing a round going left
  309. math.randomseed(os.time())
  310. local ReturnStart = math.random(1,3)
  311. if ReturnStart == 1 then
  312. MoveToLocation(NPC, 756.65, -19.65, -378.86, 2, "extra_trip_left")
  313. elseif ReturnStart == 2 then
  314. MoveToLocation(NPC, 757.38, -19.64, -377.92, 2, "extra_trip_left")
  315. else
  316. MoveToLocation(NPC, 758.01, -19.64, -378.51, 2, "extra_trip_left")
  317. end
  318. end
  319. function extra_trip_left(NPC)
  320. -- Delving makes either 0, 1 or 2 extra rounds (most often 1 extra round), without any special events going left
  321. if NumberOfTrips == 1 then
  322. math.randomseed(os.time())
  323. local SecondTripRandom = math.random(1,100)
  324. if SecondTripRandom <= 10 then
  325. open_door(NPC)
  326. and_back_again(NPC)
  327. else
  328. NumberOfTrips = 2
  329. math.randomseed(os.time())
  330. local PickTrip = math.random(1,3)
  331. if PickTrip == 1 then
  332. left_01(NPC)
  333. elseif PickTrip == 2 then
  334. left_02(NPC)
  335. else
  336. left_03(NPC)
  337. end
  338. end
  339. elseif NumberOfTrips == 2 then
  340. math.randomseed(os.time())
  341. local ThirdTripRandom = math.random(1,100)
  342. if ThirdTripRandom <= 10 then
  343. NumberOfTrips = 3
  344. math.randomseed(os.time())
  345. local PickLastTrip = math.random(1,3)
  346. if PickLastTrip == 1 then
  347. left_01(NPC)
  348. elseif PickLastTrip == 2 then
  349. left_02(NPC)
  350. else
  351. left_03(NPC)
  352. end
  353. else
  354. return_to_base(NPC)
  355. -- open_door(NPC)
  356. -- and_back_again(NPC)
  357. end
  358. else
  359. return_to_base(NPC)
  360. -- open_door(NPC)
  361. -- and_back_again(NPC)
  362. end
  363. end
  364. -- These functions make a tiny variation in the way Delvin walks around the hut going left
  365. function left_01(NPC)
  366. MoveToLocation(NPC, 758.82, -19.63, -363.06, 2)
  367. MoveToLocation(NPC, 783.61, -19.63, -362.95, 2)
  368. MoveToLocation(NPC, 783.36, -19.63, -393.23, 2)
  369. MoveToLocation(NPC, 757.61, -19.64, -394.02, 2, "extra_trip_left")
  370. end
  371. function left_02(NPC)
  372. MoveToLocation(NPC, 758.04, -19.63, -363.98, 2)
  373. MoveToLocation(NPC, 783.89, -19.63, -363.04, 2)
  374. MoveToLocation(NPC, 783.35, -19.63, -394.04, 2)
  375. MoveToLocation(NPC, 756.70, -19.65, -392.53, 2, "extra_trip_left")
  376. end
  377. function left_03(NPC)
  378. MoveToLocation(NPC, 756.82, -19.63, -363.92, 2)
  379. MoveToLocation(NPC, 784.13, -19.63, -363.03, 2)
  380. MoveToLocation(NPC, 783.29, -19.63, -393.11, 2)
  381. MoveToLocation(NPC, 758.33, -19.63, -393.04, 2, "extra_trip_left")
  382. end
  383. function return_to_start_right(NPC)
  384. -- Returns Delvin to one of three locations outside the door after completing a round going left
  385. math.randomseed(os.time())
  386. local ReturnStart = math.random(1,3)
  387. if ReturnStart == 1 then
  388. MoveToLocation(NPC, 756.65, -19.65, -378.86, 2, "extra_trip_right")
  389. elseif ReturnStart == 2 then
  390. MoveToLocation(NPC, 757.38, -19.64, -377.92, 2, "extra_trip_right")
  391. else
  392. MoveToLocation(NPC, 758.01, -19.64, -378.51, 2, "extra_trip_right")
  393. end
  394. end
  395. function extra_trip_right(NPC)
  396. -- Delving makes either 0, 1 or 2 extra rounds (most often 1 extra round), without any special events going right
  397. if NumberOfTrips == 1 then
  398. math.randomseed(os.time())
  399. local SecondTripRandom = math.random(1,100)
  400. if SecondTripRandom <= 10 then
  401. return_to_base(NPC)
  402. -- open_door(NPC)
  403. -- and_back_again(NPC)
  404. else
  405. NumberOfTrips = 2
  406. math.randomseed(os.time())
  407. local PickTrip = math.random(1,3)
  408. if PickTrip == 1 then
  409. right_01(NPC)
  410. elseif PickTrip == 2 then
  411. right_02(NPC)
  412. else
  413. right_03(NPC)
  414. end
  415. end
  416. elseif NumberOfTrips == 2 then
  417. math.randomseed(os.time())
  418. local ThirdTripRandom = math.random(1,100)
  419. if ThirdTripRandom <= 10 then
  420. NumberOfTrips = 3
  421. math.randomseed(os.time())
  422. local PickLastTrip = math.random(1,3)
  423. if PickLastTrip == 1 then
  424. right_01(NPC)
  425. elseif PickLastTrip == 2 then
  426. right_02(NPC)
  427. else
  428. right_03(NPC)
  429. end
  430. else
  431. return_to_base(NPC)
  432. -- open_door(NPC)
  433. -- and_back_again(NPC)
  434. end
  435. else
  436. return_to_base(NPC)
  437. -- open_door(NPC)
  438. -- and_back_again(NPC)
  439. end
  440. end
  441. -- These functions make a tiny variation in the way Delvin walks around the hut going left
  442. function right_01(NPC)
  443. MoveToLocation(NPC, 757.61, -19.64, -394.02, 2)
  444. MoveToLocation(NPC, 783.36, -19.63, -393.23, 2)
  445. MoveToLocation(NPC, 783.61, -19.63, -362.95, 2)
  446. MoveToLocation(NPC, 758.82, -19.63, -363.06, 2, "extra_trip_right")
  447. end
  448. function right_02(NPC)
  449. MoveToLocation(NPC, 756.70, -19.65, -392.53, 2)
  450. MoveToLocation(NPC, 783.35, -19.63, -394.04, 2)
  451. MoveToLocation(NPC, 783.89, -19.63, -363.04, 2)
  452. MoveToLocation(NPC, 758.04, -19.63, -363.98, 2, "extra_trip_right")
  453. end
  454. function right_03(NPC)
  455. MoveToLocation(NPC, 758.33, -19.63, -393.04, 2)
  456. MoveToLocation(NPC, 783.29, -19.63, -393.11, 2)
  457. MoveToLocation(NPC, 784.13, -19.63, -363.03, 2)
  458. MoveToLocation(NPC, 756.82, -19.63, -363.92, 2, "extra_trip_right")
  459. end
  460. function return_to_base(NPC)
  461. -- Delvin can return to 3 different locations outside the door when he is done with his rounds
  462. math.randomseed(os.time())
  463. local ReturnBase = math.random(1,3)
  464. if ReturnBase == 1 then
  465. MoveToLocation(NPC, 756.65, -19.65, -378.86, 2, "open_door")
  466. elseif ReturnBase == 2 then
  467. MoveToLocation(NPC, 757.38, -19.64, -377.92, 2, "open_door")
  468. else
  469. MoveToLocation(NPC, 758.01, -19.64, -378.51, 2, "open_door")
  470. end
  471. and_back_again(NPC)
  472. end
  473. function and_back_again(NPC)
  474. MoveToLocation(NPC, 774.207, -19.0057, -378.641, 2, "end_of_trip")
  475. end
  476. function end_of_trip(NPC)
  477. -- This function is needed to give enough delay for the emote to trigger
  478. AddTimer(NPC, math.random(1000,1500), "extra_delay_for_bow")
  479. end
  480. function extra_delay_for_bow(NPC)
  481. -- On Live Delvin only bows sometimes when he returns from his rounds
  482. math.randomseed(os.time())
  483. local EndTrip = math.random(1,3)
  484. if EndTrip == 1 then
  485. PlayAnimation(NPC, 121)
  486. AddTimer(NPC, math.random(90000,120000), "move_start")
  487. else
  488. AddTimer(NPC, math.random(90000,120000), "move_start")
  489. end
  490. end
  491. function open_door(NPC)
  492. -- Triggers the door widget to open it for Delvin
  493. zone = GetZone(NPC)
  494. local widget = SpawnByLocationID(zone, 571400)
  495. OpenDoor(widget)
  496. end