Advertisement
jslocomb

RandomMountContinued.lua

Dec 12th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 46.71 KB | None | 0 0
  1. version = "1.06.13"
  2. --RandomMount
  3. --Original Author: Mike Hendricks(AttilaTheFun)
  4. --Continuing Author: t4t3rt0t
  5. --Description:
  6. --              This add-on makes it simple to summon a random mount it takes into account ridding level, cold weather flying,
  7. --              flying areas, Modifiers available, and summons an appropriate mount.
  8. --              It has a simple interface /mnt: /rmount: Will summon riding/flying mounts in the appropriate areas. mnt and rmount are interchangeable
  9. --                                        /mnt riding: Summons riding mounts in flying areas
  10. --                                        /mnt flying: Attempt to summon a flying mount
  11. --                                        /mnt help: Display help
  12. --                                        /mnt r or f (search Term): Summons a mount based on specified search term
  13. --                                                example: to summon a skeletal warhorse type: /mnt skeletal
  14. --                                        /mnt config: Prints the current configuration
  15. --                                        /mnt rfilter: Toggle mount filtering
  16. --                                        /mnt safefly: Toggle double click to dismount while flying
  17. --                                        /mnt rfilters: List current filters
  18. --                                        /mnt locfilter: Toggle filter to summon only specific mounts in specific locations
  19. --                                        /mnt addloc % (zone:mount name1, mount name2, ...): Add locations and mounts to location checking. Separate mounts with commas. Use * as a wildcard to specify all mounts.
  20. --                                        /mnt removeloc % (zone:mount name1, mount name2, ...): Removes locations and mounts from location checking. Separate mounts with commas.
  21. --                                        /mnt loctable: Print the current location filtering table.
  22. --                                        /mnt clearloc: Clears location filters
  23. --                                        /mnt remove %: Remove all mounts matching % if rfilter is enabled
  24. --                                        /mnt clear: Clears all filters
  25. --                                        /mnt clearrem: Clears the mount removal table
  26. --                                        /mnt whereami: Prints your zone and mini-map zone.
  27. --                                        /mnt title: Enable or disable random title change.
  28. --                                        /mnt icon: Enable or disable changing random mount macro icons to the last summoned mount.
  29. --                                        /mnt PrintHelp("druid: Create a macro for druids that will cancel your form before trying to summon a mount.
  30. --                                        /mnt debug: Toggle debug printing for posting error messages
  31. --                                        /mnt No Flag: Summon a appropriate mount for the area
  32.  
  33. -- Get the Frame that is housing the UIErrorsFrame
  34. local originalOnEvent = UIErrorsFrame:GetScript("OnEvent")
  35. -- Listen for SYSTEM Errors from the UIErrorsFrame
  36. UIErrorsFrame:SetScript("OnEvent", function(self, event, message, r, g, b, ...)
  37.     -- Check the Error Message 
  38.     if message == SPELL_FAILED_NOT_HERE or message == SPELL_FAILED_ONLY_UNDERWATER then
  39.         -- Set mountError to true
  40.         mountError = true
  41.         mountErrorMsg = message
  42.     else
  43.         -- Set mountError to false
  44.         mountError = false
  45.         mountErrorMsg = nil
  46.         -- If error is not what we are looking for then return it to the original Frame
  47.         return originalOnEvent(self, event, message, r, g, b, ...)
  48.     end
  49. end)
  50.  
  51. -- mount dictionary to compensate for wow's terrible GetCompanionInfo("MOUNT", i) command.
  52. --One would assume info would imply useful things like can it fly and what skill is required etc.
  53. --1  = riding mount
  54. --2  = flying mount
  55. --3  = riding / flying mount
  56.  
  57. -- Mount Database
  58. local mountDict = {
  59. [75207]={1, "Abyssal Seahorse"},
  60. [48778]={1, "Acherus Deathcharger"},
  61. [60025]={2, "Albino Drake"},
  62. [127180]={1, "Albino Riding Crane"},
  63. [98204]={1, "Amani Battle Bear"},
  64. [96503]={2, "Amani Dragonhawk"},
  65. [43688]={1, "Amani War Bear"},
  66. [123886]={1, "Amber Scorpion"},
  67. [16056]={1, "Ancient Frostsaber"},
  68. [66906]={1, "Argent Charger"},
  69. [63844]={3, "Argent Hippogryph"},
  70. [67466]={1, "Argent Warhorse"},
  71. [61230]={3, "Armored Blue Wind Rider"},
  72. [60114]={1, "Armored Brown Bear"},
  73. [60116]={1, "Armored Brown Bear"},
  74. [96491]={1, "Armored Razzashi Raptor"},
  75. [61229]={3, "Armored Snowy Gryphon"},
  76. [132117]={2, "Ashen Pandaren Phoenix"},
  77. [40192]={2, "Ashes of Al'ar"},
  78. [127170]={2, "Astral Cloud Serpent"},
  79. [123992]={2, "Azure Cloud Serpent"},
  80. [59567]={2, "Azure Drake"},
  81. [41514]={2, "Azure Netherwing Drake"},
  82. [127174]={1, "Azure Riding Crane"},
  83. [118089]={1, "Azure Water Strider"},
  84. [97501]={2, "Beryl Fire Hawk"},
  85. [51412]={1, "Big Battle Bear"},
  86. [64987]={1, "Big Blizzard Bear [PH]"},
  87. [58983]={1, "Big Blizzard Bear"},
  88. [71342]={3, "Big Love Rocket"},
  89. [22719]={1, "Black Battlestrider"},
  90. [127286]={1, "Black Dragon Turtle"},
  91. [62048]={2, "Black Dragonhawk Mount"},
  92. [59650]={2, "Black Drake"},
  93. [35022]={1, "Black Hawkstrider"},
  94. [16055]={1, "Black Nightsaber"},
  95. [59572]={1, "Black Polar Bear"},
  96. [59976]={2, "Black Proto-Drake"},
  97. [26656]={1, "Black Qiraji Battle Tank"},
  98. [17461]={1, "Black Ram"},
  99. [6896]={1, "Black Ram"},
  100. [130138]={1, "Black Riding Goat"},
  101. [127209]={1, "Black Riding Yak"},
  102. [64977]={1, "Black Skeletal Horse"},
  103. [470]={1, "Black Stallion"},
  104. [60118]={1, "Black War Bear"},
  105. [60119]={1, "Black War Bear"},
  106. [48027]={1, "Black War Elekk"},
  107. [22718]={1, "Black War Kodo"},
  108. [59785]={1, "Black War Mammoth"},
  109. [59788]={1, "Black War Mammoth"},
  110. [22720]={1, "Black War Ram"},
  111. [22721]={1, "Black War Raptor"},
  112. [22717]={1, "Black War Steed"},
  113. [22723]={1, "Black War Tiger"},
  114. [22724]={1, "Black War Wolf"},
  115. [578]={1, "Black Wolf"},
  116. [64658]={1, "Black Wolf"},
  117. [107842]={2, "Blazing Drake"},
  118. [74856]={3, "Blazing Hippogryph"},
  119. [127220]={1, "Blonde Riding Yak"},
  120. [72808]={2, "Bloodbathed Frostbrood Vanquisher"},
  121. [127287]={1, "Blue Dragon Turtle"},
  122. [61996]={2, "Blue Dragonhawk"},
  123. [59568]={2, "Blue Drake"},
  124. [35020]={1, "Blue Hawkstrider"},
  125. [10969]={1, "Blue Mechanostrider"},
  126. [33630]={1, "Blue Mechanostrider"},
  127. [59996]={2, "Blue Proto-Drake"},
  128. [25953]={1, "Blue Qiraji Battle Tank"},
  129. [6897]={1, "Blue Ram"},
  130. [39803]={2, "Blue Riding Nether Ray"},
  131. [129934]={1, "Blue Shado-Pan Riding Tiger"},
  132. [17463]={1, "Blue Skeletal Horse"},
  133. [64656]={1, "Blue Skeletal Warhorse"},
  134. [32244]={3, "Blue Wind Rider"},
  135. [50869]={1, "Brewfest Kodo"},
  136. [43899]={1, "Brewfest Ram"},
  137. [50870]={1, "Brewfest Ram"},
  138. [49378]={1, "Brewfest Riding Kodo"},
  139. [59569]={2, "Bronze Drake"},
  140. [127288]={1, "Brown Dragon Turtle"},
  141. [34406]={1, "Brown Elekk"},
  142. [458]={1, "Brown Horse"},
  143. [18990]={1, "Brown Kodo"},
  144. [59573]={1, "Brown Polar Bear"},
  145. [6899]={1, "Brown Ram"},
  146. [88748]={1, "Brown Riding Camel"},
  147. [130086]={1, "Brown Riding Goat"},
  148. [127213]={1, "Brown Riding Yak"},
  149. [17464]={1, "Brown Skeletal Horse"},
  150. [6654]={1, "Brown Wolf"},
  151. [58615]={2, "Brutal Nether Drake"},
  152. [124550]={2, "Cataclysmic Gladiator's Twilight Drake"},
  153. [75614]={3, "Celestial Steed"},
  154. [43927]={3, "Cenarion War Hippogryph"},
  155. [23214]={1, "Charger"},
  156. [6648]={1, "Chestnut Mare"},
  157. [41515]={2, "Cobalt Netherwing Drake"},
  158. [39315]={1, "Cobalt Riding Talbuk"},
  159. [34896]={1, "Cobalt War Talbuk"},
  160. [97560]={2, "Corrupted Fire Hawk"},
  161. [102514]={2, "Corrupted Hippogryph"},
  162. [127156]={2, "Crimson Cloud Serpent"},
  163. [73313]={1, "Crimson Deathcharger"},
  164. [129552]={2, "Crimson Pandaren Phoenix"},
  165. [123160]={1, "Crimson Riding Crane"},
  166. [127271]={1, "Crimson Water Strider"},
  167. [68188]={1, "Crusader's Black Warhorse"},
  168. [68187]={1, "Crusader's White Warhorse"},
  169. [88990]={2, "Dark Phoenix"},
  170. [39316]={1, "Dark Riding Talbuk"},
  171. [34790]={1, "Dark War Talbuk"},
  172. [103081]={1, "Darkmoon Dancing Bear"},
  173. [63635]={1, "Darkspear Raptor"},
  174. [63637]={1, "Darnassian Nightsaber"},
  175. [121839]={2, "Dawnstone Panther"},
  176. [64927]={2, "Deadly Gladiator's Frostwyrm"},
  177. [126507]={2, "Depleted-Kyparium Rocket"},
  178. [6653]={1, "Dire Wolf"},
  179. [88335]={2, "Drake of the East Wind"},
  180. [88742]={2, "Drake of the North Wind"},
  181. [88744]={2, "Drake of the South Wind"},
  182. [88741]={2, "Drake of the West Wind"},
  183. [23161]={1, "Dreadsteed"},
  184. [32239]={3, "Ebon Gryphon"},
  185. [132118]={2, "Emerald Pandaren Phoenix"},
  186. [121837]={2, "Emerald Panther"},
  187. [8395]={1, "Emerald Raptor"},
  188. [63639]={1, "Exodar Elekk"},
  189. [110039]={2, "Experiment 12-B"},
  190. [5784]={1, "Felsteed"},
  191. [36702]={1, "Fiery Warhorse"},
  192. [101542]={1, "Flametalon of Alysrazor"},
  193. [97359]={3, "Flameward Hippogryph"},
  194. [17458]={1, "Fluorescent Green Mechanostrider"},
  195. [61451]={3, "Flying Carpet"},
  196. [44153]={3, "Flying Machine"},
  197. [63643]={1, "Forsaken Warhorse"},
  198. [84751]={1, "Fossilized Raptor"},
  199. [17460]={1, "Frost Ram"},
  200. [51960]={2, "Frost Wyrm Mount"},
  201. [43810]={2, "Frost Wyrm"},
  202. [23509]={1, "Frostwolf Howler"},
  203. [75596]={3, "Frosty Flying Carpet"},
  204. [65439]={2, "Furious Gladiator's Frost Wyrm"},
  205. [126508]={2, "Geosynchronous World Spinner"},
  206. [63638]={1, "Gnomeregan Mechanostrider"},
  207. [87090]={1, "Goblin Trike"},
  208. [87091]={1, "Goblin Turbo-Trike"},
  209. [123993]={2, "Golden Cloud Serpent"},
  210. [32235]={3, "Golden Gryphon"},
  211. [90621]={1, "Golden King"},
  212. [127176]={1, "Golden Riding Crane"},
  213. [16060]={1, "Golden Sabercat"},
  214. [127278]={1, "Golden Water Strider"},
  215. [135416]={3, "Grand Armored Gryphon"},
  216. [59810]={1, "Grand Black War Mammoth"},
  217. [59811]={1, "Grand Black War Mammoth"},
  218. [61465]={1, "Grand Black War Mammoth"},
  219. [61467]={1, "Grand Black War Mammoth"},
  220. [60136]={1, "Grand Caravan Mammoth"},
  221. [60140]={1, "Grand Caravan Mammoth"},
  222. [122708]={1, "Grand Expedition Yak"},
  223. [136163]={3, "Grand Gryphon"},
  224. [59802]={1, "Grand Ice Mammoth"},
  225. [59804]={1, "Grand Ice Mammoth"},
  226. [61469]={1, "Grand Ice Mammoth"},
  227. [61470]={1, "Grand Ice Mammoth"},
  228. [35710]={1, "Gray Elekk"},
  229. [18989]={1, "Gray Kodo"},
  230. [6777]={1, "Gray Ram"},
  231. [459]={1, "Gray Wolf"},
  232. [63639]={1, "Great Azuremyst Elekk"},
  233. [127295]={1, "Great Black Dragon Turtle"},
  234. [127302]={1, "Great Blue Dragon Turtle"},
  235. [35713]={1, "Great Blue Elekk"},
  236. [49379]={1, "Great Brewfest Kodo"},
  237. [127308]={1, "Great Brown Dragon Turtle"},
  238. [23249]={1, "Great Brown Kodo"},
  239. [34407]={1, "Great Elite Elekk"},
  240. [65641]={1, "Great Golden Kodo"},
  241. [23248]={1, "Great Gray Kodo"},
  242. [127293]={1, "Great Green Dragon Turtle"},
  243. [35712]={1, "Great Green Elekk"},
  244. [127310]={1, "Great Purple Dragon Turtle"},
  245. [35714]={1, "Great Purple Elekk"},
  246. [120822]={1, "Great Red Dragon Turtle"},
  247. [65637]={1, "Great Red Elekk"},
  248. [23247]={1, "Great White Kodo"},
  249. [120395]={1, "Green Dragon Turtle"},
  250. [18991]={1, "Green Kodo"},
  251. [15780]={1, "Green Mechanostrider"},
  252. [17453]={1, "Green Mechanostrider"},
  253. [61294]={2, "Green Proto-Drake"},
  254. [26056]={1, "Green Qiraji Battle Tank"},
  255. [39798]={2, "Green Riding Nether Ray"},
  256. [129932]={1, "Green Shado-Pan Riding Tiger"},
  257. [17465]={1, "Green Skeletal Warhorse"},
  258. [32245]={3, "Green Wind Rider"},
  259. [88750]={1, "Grey Riding Camel"},
  260. [127216]={1, "Grey Riding Yak"},
  261. [48025]={3, "Headless Horseman's Mount"},
  262. [110051]={3, "Heart of the Aspects"},
  263. [127169]={2, "Heavenly Azure Cloud Serpent"},
  264. [127161]={2, "Heavenly Crimson Cloud Serpent"},
  265. [127164]={2, "Heavenly Golden Cloud Serpent"},
  266. [127165]={2, "Heavenly Jade Cloud Serpent"},
  267. [127158]={2, "Heavenly Onyx Cloud Serpent"},
  268. [59797]={1, "Ice Mammoth"},
  269. [59799]={1, "Ice Mammoth"},
  270. [72807]={2, "Icebound Frostbrood Vanquisher"},
  271. [17459]={1, "Icy Blue Mechanostrider Mod A"},
  272. [124659]={2, "Imperial Quilen"},
  273. [72286]={3, "Invincible"},
  274. [63956]={2, "Ironbound Proto-Drake"},
  275. [63636]={1, "Ironforge Ram"},
  276. [10795]={1, "Ivory Raptor"},
  277. [17450]={1, "Ivory Raptor"},
  278. [113199]={2, "Jade Cloud Serpent"},
  279. [133023]={2, "Jade Pandaren Kite"},
  280. [127274]={1, "Jade Water Strider"},
  281. [120043]={2, "Jeweled Onyx Panther"},
  282. [127178]={1, "Jungle Riding Crane"},
  283. [93644]={1, "Kor'kron Annihilator"},
  284. [107845]={2, "Life-Binder's Handmaiden"},
  285. [65917]={1, "Magic Rooster"},
  286. [66122]={1, "Magic Rooster"},
  287. [66123]={1, "Magic Rooster"},
  288. [66124]={1, "Magic Rooster"},
  289. [61309]={3, "Magnificent Flying Carpet"},
  290. [55531]={1, "Mechano-hog"},
  291. [60424]={1, "Mekgineer's Chopper"},
  292. [44317]={2, "Merciless Nether Drake"},
  293. [44744]={2, "Merciless Nether Drake"},
  294. [63796]={2, "Mimiron's Head"},
  295. [93623]={2, "Mottled Drake"},
  296. [16084]={1, "Mottled Red Raptor"},
  297. [103195]={1, "Mountain Horse"},
  298. [29059]={1, "Naxxramas Deathcharger"},
  299. [28828]={2, "Nether Drake"},
  300. [3363]={2, "Nether Drake"},
  301. [121820]={2, "Obsidian Nightwing"},
  302. [10798]={1, "Obsidian Raptor"},
  303. [66846]={1, "Ochre Skeletal Warhorse"},
  304. [127154]={2, "Onyx Cloud Serpent"},
  305. [41513]={2, "Onyx Netherwing Drake"},
  306. [69395]={2, "Onyxian Drake"},
  307. [127272]={1, "Orange Water Strider"},
  308. [63640]={1, "Orgrimmar Wolf"},
  309. [471]={1, "Palamino"},
  310. [16082]={1, "Palomino"},
  311. [118737]={2, "Pandaren Kite"},
  312. [130985]={2, "Pandaren Kite"},
  313. [32345]={2, "Peep the Phoenix Mount"},
  314. [88718]={2, "Phosphorescent Stone Drake"},
  315. [472]={1, "Pinto"},
  316. [60021]={2, "Plagued Proto-Drake"},
  317. [16058]={1, "Primal Leopard"},
  318. [97493]={2, "Pureblood Fire Hawk"},
  319. [127289]={1, "Purple Dragon Turtle"},
  320. [35711]={1, "Purple Elekk"},
  321. [35018]={1, "Purple Hawkstrider"},
  322. [17455]={1, "Purple Mechanostrider"},
  323. [41516]={2, "Purple Netherwing Drake"},
  324. [39801]={2, "Purple Riding Nether Ray"},
  325. [23246]={1, "Purple Skeletal Warhorse"},
  326. [66090]={1, "Quel'dorei Steed"},
  327. [41252]={1, "Raven Lord"},
  328. [17456]={1, "Red and Blue Mechanostrider"},
  329. [127290]={1, "Red Dragon Turtle"},
  330. [61997]={2, "Red Dragonhawk"},
  331. [59570]={2, "Red Drake"},
  332. [130092]={3, "Red Flying Cloud"},
  333. [34795]={1, "Red Hawkstrider"},
  334. [10873]={1, "Red Mechanostrider"},
  335. [59961]={2, "Red Proto-Drake"},
  336. [26054]={1, "Red Qiraji Battle Tank"},
  337. [39800]={2, "Red Riding Nether Ray"},
  338. [129935]={1, "Red Shado-Pan Riding Tiger"},
  339. [17462]={1, "Red Skeletal Horse"},
  340. [22722]={1, "Red Skeletal Warhorse"},
  341. [16080]={1, "Red Wolf"},
  342. [579]={1, "Red Wolf"},
  343. [127177]={1, "Regal Riding Crane"},
  344. [18363]={1, "Riding Kodo"},
  345. [30174]={1, "Riding Turtle"},
  346. [17481]={1, "Rivendare's Deathcharger"},
  347. [121838]={2, "Ruby Panther"},
  348. [63963]={2, "Rusted Proto-Drake"},
  349. [101821]={2, "Ruthless Gladiator's Twilight Drake"},
  350. [93326]={2, "Sandstone Drake"},
  351. [121836]={2, "Sapphire Panther"},
  352. [97581]={1, "Savage Raptor"},
  353. [64731]={1, "Sea Turtle"},
  354. [66087]={3, "Silver Covenant Hippogryph"},
  355. [39802]={2, "Silver Riding Nether Ray"},
  356. [39317]={1, "Silver Riding Talbuk"},
  357. [34898]={1, "Silver War Talbuk"},
  358. [63642]={1, "Silvermoon Hawkstrider"},
  359. [8980]={1, "Skeletal Horse"},
  360. [32240]={3, "Snowy Gryphon"},
  361. [130965]={1, "Son of Galleon"},
  362. [107516]={2, "Spectral Gryphon"},
  363. [92231]={1, "Spectral Steed"},
  364. [42776]={1, "Spectral Tiger"},
  365. [107517]={2, "Spectral Wind Rider"},
  366. [92232]={1, "Spectral Wolf"},
  367. [10789]={1, "Spotted Frostsaber"},
  368. [15781]={1, "Steel Mechanostrider"},
  369. [23510]={1, "Stormpike Battle Charger"},
  370. [63232]={1, "Stormwind Steed"},
  371. [66847]={1, "Striped Dawnsaber"},
  372. [8394]={1, "Striped Frostsaber"},
  373. [10793]={1, "Striped Nightsaber"},
  374. [98718]={1, "Subdued Seahorse"},
  375. [34767]={1, "Summon Charger"},
  376. [73629]={1, "Summon Exarch's Elekk"},
  377. [73630]={1, "Summon Great Exarch's Elekk"},
  378. [69826]={1, "Summon Great Sunwalker Kodo"},
  379. [69820]={1, "Summon Sunwalker Kodo"},
  380. [34769]={1, "Summon Warhorse"},
  381. [66088]={2, "Sunreaver Dragonhawk"},
  382. [66091]={1, "Sunreaver Hawkstrider"},
  383. [68057]={1, "Swift Alliance Steed"},
  384. [32242]={3, "Swift Blue Gryphon"},
  385. [23241]={1, "Swift Blue Raptor"},
  386. [43900]={1, "Swift Brewfest Ram"},
  387. [23238]={1, "Swift Brown Ram"},
  388. [23229]={1, "Swift Brown Steed"},
  389. [23250]={1, "Swift Brown Wolf"},
  390. [65646]={1, "Swift Burgundy Wolf"},
  391. [23220]={1, "Swift Dawnsaber"},
  392. [102346]={1, "Swift Forest Strider"},
  393. [23221]={1, "Swift Frostsaber"},
  394. [23239]={1, "Swift Gray Ram"},
  395. [65640]={1, "Swift Gray Steed"},
  396. [23252]={1, "Swift Gray Wolf"},
  397. [32290]={3, "Swift Green Gryphon"},
  398. [35025]={1, "Swift Green Hawkstrider"},
  399. [23225]={1, "Swift Green Mechanostrider"},
  400. [32295]={3, "Swift Green Wind Rider"},
  401. [68056]={1, "Swift Horde Wolf"},
  402. [102350]={1, "Swift Lovebird"},
  403. [23219]={1, "Swift Mistsaber"},
  404. [61442]={2, "Swift Mooncloth Carpet"},
  405. [65636]={1, "Swift Moonsaber"},
  406. [65638]={1, "Swift Moonsaber"},
  407. [103196]={1, "Swift Mountain Horse"},
  408. [37015]={2, "Swift Nether Drake"},
  409. [23242]={1, "Swift Olive Raptor"},
  410. [23243]={1, "Swift Orange Raptor"},
  411. [23227]={1, "Swift Palomino"},
  412. [33660]={1, "Swift Pink Hawkstrider"},
  413. [32292]={3, "Swift Purple Gryphon"},
  414. [35027]={1, "Swift Purple Hawkstrider"},
  415. [65644]={1, "Swift Purple Raptor"},
  416. [32297]={3, "Swift Purple Wind Rider"},
  417. [24242]={1, "Swift Razzashi Raptor"},
  418. [32289]={3, "Swift Red Gryphon"},
  419. [65639]={1, "Swift Red Hawkstrider"},
  420. [32246]={3, "Swift Red Wind Rider"},
  421. [61444]={2, "Swift Shadoweave Carpet"},
  422. [101573]={1, "Swift Shorestrider"},
  423. [42777]={1, "Swift Spectral Tiger"},
  424. [61446]={2, "Swift Spellfire Carpet"},
  425. [102349]={1, "Swift Springstrider"},
  426. [23338]={1, "Swift Stormsaber"},
  427. [23251]={1, "Swift Timber Wolf"},
  428. [65643]={1, "Swift Violet Ram"},
  429. [47037]={1, "Swift War Elekk"},
  430. [35028]={1, "Swift Warstrider"},
  431. [46628]={1, "Swift White Hawkstrider"},
  432. [23223]={1, "Swift White Mechanostrider"},
  433. [23240]={1, "Swift White Ram"},
  434. [23228]={1, "Swift White Steed"},
  435. [23222]={1, "Swift Yellow Mechanostrider"},
  436. [32296]={3, "Swift Yellow Wind Rider"},
  437. [48954]={1, "Swift Zhevra"},
  438. [49322]={1, "Swift Zhevra"},
  439. [96499]={1, "Swift Zulian Panther"},
  440. [24252]={1, "Swift Zulian Tiger"},
  441. [88749]={1, "Tan Riding Camel"},
  442. [39318]={1, "Tan Riding Talbuk"},
  443. [34899]={1, "Tan War Talbuk"},
  444. [16059]={1, "Tawny Sabercat"},
  445. [32243]={3, "Tawny Wind Rider"},
  446. [18992]={1, "Teal Kodo"},
  447. [63641]={1, "Thunder Bluff Kodo"},
  448. [129918]={2, "Thundering August Cloud Serpent"},
  449. [124408]={2, "Thundering Jade Cloud Serpent"},
  450. [132036]={2, "Thundering Ruby Cloud Serpent"},
  451. [580]={1, "Timber Wolf"},
  452. [60002]={2, "Time-Lost Proto-Drake"},
  453. [61425]={1, "Traveler's Tundra Mammoth"},
  454. [61447]={1, "Traveler's Tundra Mammoth"},
  455. [44151]={3, "Turbo-Charged Flying Machine"},
  456. [65642]={1, "Turbostrider"},
  457. [10796]={1, "Turquoise Raptor"},
  458. [59571]={2, "Twilight Drake"},
  459. [107844]={2, "Twilight Harbinger"},
  460. [107203]={3, "Tyrael's Charger"},
  461. [92155]={1, "Ultramarine Qiraji Battle Tank"},
  462. [17454]={1, "Unpainted Mechanostrider"},
  463. [42781]={1, "Upper Deck - Spectral Tiger Mount"},
  464. [49193]={2, "Vengeful Nether Drake"},
  465. [46102]={1, "Venomhide Ravasaur"},
  466. [64659]={1, "Venomhide Ravasaur"},
  467. [41517]={2, "Veridian Netherwing Drake"},
  468. [101282]={2, "Vicious Gladiator's Twilight Drake"},
  469. [100332]={1, "Vicious War Steed"},
  470. [100333]={1, "Vicious War Wolf"},
  471. [41518]={2, "Violet Netherwing Drake"},
  472. [132119]={2, "Violet Pandaren Phoenix"},
  473. [60024]={2, "Violet Proto-Drake"},
  474. [10799]={1, "Violet Raptor"},
  475. [88746]={2, "Vitreous Stone Drake"},
  476. [88331]={2, "Volcanic Stone Drake"},
  477. [13819]={1, "Warhorse"},
  478. [64657]={1, "White Kodo"},
  479. [15779]={1, "White Mechanostrider Mod B"},
  480. [54753]={1, "White Polar Bear Mount"},
  481. [6898]={1, "White Ram"},
  482. [102488]={1, "White Riding Camel"},
  483. [130137]={1, "White Riding Goat"},
  484. [39319]={1, "White Riding Talbuk"},
  485. [123182]={1, "White Riding Yak"},
  486. [65645]={1, "White Skeletal Warhorse"},
  487. [16083]={1, "White Stallion"},
  488. [468]={1, "White Stallion"},
  489. [34897]={1, "White War Talbuk"},
  490. [98727]={3, "Winged Guardian"},
  491. [54729]={2, "Winged Steed of the Ebon Blade"},
  492. [16081]={1, "Winter Wolf"},
  493. [581]={1, "Winter Wolf"},
  494. [17229]={1, "Winterspring Frostsaber"},
  495. [59791]={1, "Wooly Mammoth"},
  496. [59793]={1, "Wooly Mammoth"},
  497. [74918]={1, "Wooly White Rhino"},
  498. [46199]={3, "X-51 Nether-Rocket X-TREME"},
  499. [46197]={3, "X-51 Nether-Rocket"},
  500. [75973]={3, "X-53 Touring Rocket"},
  501. [26055]={1, "Yellow Qiraji Battle Tank"}}
  502.  
  503. --Saved Variables
  504. debug = false                                                           --display debug info if enabled
  505. debug2 = false                                                          --Display debug info on all mounts
  506. notWanted = {}                                                          --Mounts that are not wanted to be summoned
  507. removeMount = false                                                     --Enable or disable notWanted mounts
  508. locationChk = true                                                      --enable or disable specific mounts in special locations
  509. locations = {}                                                          --locations to summon specific mounts(specialMounts)
  510. specialMounts = {}                                                      --special mounts to summon if in a specific location
  511. rndTitle = false                                                        --Randomly change the title when summoning a mount
  512. safeFly = false                                                         --Safe flying dismount if flying
  513. macroIcon = false                                                       --Update the macro icon with last summoned mount
  514. zones = {}                                                              --Contains the list of location filters
  515. mountError = false
  516. mountErrorMsg = nil
  517.  
  518. local nosummonlist = {}                                                 --Stores the last few mounts summoned so it won't summon it again
  519. local lastTime = GetTime()                                             --Safe flying last time that dismount was called
  520.  
  521. --bindings
  522. BINDING_HEADER_RANDOMMOUNT = "Random Mount"
  523. BINDING_NAME_RANDOMMOUNT_REG = "Auto Summon"
  524. BINDING_NAME_RANDOMMOUNT_RIDING = "Summon Riding"
  525. BINDING_NAME_RANDOMMOUNT_FLYING = "Summon Flying"
  526.  
  527. -- Run at Load
  528. function RandomMount_OnLoad()
  529.     SlashCmdList["RandomMount"] = FindMount;
  530.     SLASH_RandomMount1 = "/mnt";
  531.     SLASH_RandomMount2 = "/rmount";
  532. end
  533.  
  534. -- Check if you can Fly
  535. function CanFlyHere()
  536.     local zoneID = GetCurrentMapAreaID()
  537.     local zoneNum = GetCurrentMapZone()
  538.     local ridingSkill, classicLicense, coldLicense, pandaLicense = GetRidingSkill()
  539.  
  540.     -- Check for flyable area
  541.     if not IsFlyableArea() then
  542.         return(false)
  543.     elseif IsFlyableArea() then
  544.         if zoneID == 773 or zoneID == 756 then
  545.             return(false)
  546.         else
  547.             for j=1,6 do
  548.                 Index = {GetMapZones(j)}
  549.                 -- Zone Check
  550.                 for i, zone in ipairs(Index) do
  551.                     if zoneNum == i then
  552.                         if classicLicense == 1 and (j == 1 or j == 2 or j == 5) then
  553.                             return(true)
  554.                         elseif ridingSkill >= 225 and j == 3 then
  555.                             return(true)
  556.                         elseif coldLicense == 1 and j == 4 then
  557.                             return(true)
  558.                         elseif pandaLicense == 1 and j == 6 then
  559.                             return(true)
  560.                         end
  561.                     end
  562.                 end
  563.             end
  564.             return(false)
  565.         end
  566.     end
  567. end
  568.  
  569. -- Get your Riding Skill Level
  570. function GetRidingSkill()
  571.     local ridingSkill = 0
  572.     local classicLicense = 0
  573.     local coldLicense = 0
  574.     local pandaLicense = 0
  575.     local serpentLicense = 0
  576.     local _,_,_,numSpells = GetSpellTabInfo(1)
  577.     for i=1,numSpells do
  578.         local spellName = GetSpellBookItemName(i, BOOKTYPE_SPELL)
  579.         local _, spellID = GetSpellBookItemInfo(spellName)
  580.         if spellID == 90265 then
  581.             ridingSkill = 375
  582.         elseif spellID == 34091 then
  583.             ridingSkill = 300
  584.         elseif spellID == 34090 then
  585.             ridingSkill = 225
  586.         elseif spellID == 33391 then
  587.             ridingSkill = 150
  588.         elseif spellID == 33388 then
  589.             ridingSkill = 75
  590.         elseif spellID == 90267 then
  591.             classicLicense = 1
  592.         elseif spellID == 54197 then
  593.             coldLicense = 1
  594.         elseif spellID == 115913 then
  595.             pandaLicense = 1
  596.         elseif spellID == 130487 then
  597.             serpentLicense = 1
  598.         end
  599.     end
  600.     return ridingSkill, classicLicense, coldLicense, pandaLicense, serpentLicense
  601. end
  602.  
  603. -- Get your Profession Skill Level  (Thanks to phuzi0n for the cleaned up code)
  604. function GetProfessionSkill()
  605.     local taylorSkill = 0
  606.     local engineerSkill = 0
  607.     local prof1, prof2 = GetProfessions()
  608.     prof1 = prof1 or 0
  609.     prof2 = prof2 or 0
  610.     local _, _, skill1, _, _, _, skillLine1 = GetProfessionInfo(prof1)
  611.     local _, _, skill2, _, _, _, skillLine2 = GetProfessionInfo(prof2)
  612.     skillLine1 = skillLine1 or 0
  613.     skillLine2 = skillLine2 or 0
  614.     if skillLine1 == 197 then
  615.         taylorSkill = skill1 or 0
  616.     elseif skillLine2 == 197 then
  617.         taylorSkill = skill2 or 0
  618.     end
  619.     if skillLine1 == 202 then
  620.         engineerSkill = skill1 or 0
  621.     elseif skillLine2 == 202 then
  622.         engineerSkill = skill2 or 0
  623.     end
  624.     return taylorSkill, engineerSkill
  625. end
  626.  
  627. -- Check if you have a Sea Mount
  628. function seaMount()
  629.     zone = GetCurrentMapAreaID()
  630.     for i=1,GetNumCompanions("MOUNT"),1 do
  631.         local _, _, creatureSpellID = GetCompanionInfo("MOUNT", i)
  632.         if creatureSpellID == 75207 and (zone == 614 or zone == 615 or zone == 610) then
  633.             return(i)
  634.         elseif creatureSpellID == 64731 or creatureSpellID == 98718 then
  635.             return(i)
  636.         end
  637.     end
  638.     return(0)
  639. end
  640.  
  641. function HasZoneMounts(flying, riding, qiraji, searchMount, search)
  642.     --check to see if special zone mounts are learned and process search
  643.     for i=1,GetNumCompanions("MOUNT"),1 do
  644.         local _, creatureName, creatureSpellID = GetCompanionInfo("MOUNT", i)
  645.         if search ~= '' then
  646.             if strfind(strlower(creatureName), strlower(search)) then
  647.                 if creatureSpellID ~= 75207 then
  648.                     tinsert(searchMount, i)
  649.                 end
  650.             end
  651.         end
  652.         local chk = true
  653.         -- Check if you have Qiraji Battle Tank        
  654.         if creatureSpellID == 25953 or creatureSpellID == 26054 or creatureSpellID == 26055 or creatureSpellID == 26056 or creatureSpellID == 26656 then
  655.             chk = true
  656.             -- Check if Mount in notWanted List
  657.             for n, notW in ipairs(notWanted) do
  658.                 if strfind(strlower(creatureName), strlower(notW)) then
  659.                     chk = false
  660.                     break
  661.                 end
  662.             end
  663.             if chk then
  664.                 tinsert(qiraji, i)
  665.             end
  666.         else
  667.             -- Check if Mount is Flying add to List
  668.             if mountDict[creatureSpellID] then
  669.                 if mountDict[creatureSpellID][1] >= 2 then
  670.                     tinsert(flying, i)
  671.                 end
  672.                 if mountDict[creatureSpellID][1] == 1 or mountDict[creatureSpellID][1] == 3 then
  673.                     tinsert(riding, i)
  674.                 end
  675.             else
  676.                 PrintHelp(creatureName .. " " .. creatureSpellID .. " not in table, please report Name and ID on http://www.curse.com/addons/wow/random-mount.", "FF00ff00")
  677.             end
  678.         end
  679.     end
  680.     return flying, riding, qiraji, searchMount
  681. end
  682.  
  683. -- Check Locations List for Mount
  684. function LookForLocation(loc)
  685.     local zone = GetRealZoneText()
  686.     local miniMap = GetMinimapZoneText()
  687.     -- Search Locations List
  688.     for i, v in ipairs(locations) do
  689.         if strfind(strlower(zone), strlower(v)) or strfind(strlower(miniMap), strlower(v)) then
  690.             for j, k in ipairs(specialMounts) do
  691.                 for i=1,GetNumCompanions("MOUNT"),1 do
  692.                     local _, creatureName = GetCompanionInfo("MOUNT", i)
  693.                     if strfind(strlower(creatureName), strlower(k)) then
  694.                         return(true)
  695.                     end
  696.                 end
  697.             end
  698.         end
  699.     end
  700.     return(false)
  701. end
  702.  
  703. -- Check Special Mounts
  704. function lfmChk(creatureName)
  705.     if locationChk then
  706.         for j, k in ipairs(specialMounts) do
  707.             if strfind(strlower(creatureName), strlower(k)) then
  708.                 return(true)
  709.             end
  710.         end
  711.     end
  712.     return(false)
  713. end
  714.  
  715. -- from http://lua-users.org/wiki/SplitJoin  by PeterPrade
  716. function splitString(delimiter, text)
  717.     local list = {}
  718.     local pos = 1
  719.     if strfind("", delimiter, 1) then -- this would result in endless loops
  720.         error("delimiter matches empty string!")
  721.     end
  722.     while 1 do
  723.         local first, last = strfind(text, delimiter, pos)
  724.         if first then -- found?
  725.             tinsert(list, strsub(text, pos, first-1))
  726.             pos = last+1
  727.         else
  728.             tinsert(list, strsub(text, pos))
  729.             break
  730.         end
  731.     end
  732.     return list
  733. end
  734.  
  735. -- Add Mount to Locations List
  736. function AddLocF(info)
  737.     if string.len(info) > 0 then
  738.         local i = strfind(info, ":");
  739.         local locVar = strsub(info, 0, i - 1)
  740.         local mntVar = splitString(",", strsub(info, i + 1));
  741.         if not zones[strlower(locVar)] then
  742.             zones[strlower(locVar)] = {}
  743.         end
  744.         for i, v in ipairs(mntVar) do
  745.             local found = false
  746.             for n, item in ipairs(zones[strlower(locVar)]) do
  747.                 if v == item then
  748.                     PrintHelp(v .. " already added.", "FF00ff00")
  749.                     found = true
  750.                     break
  751.                 end
  752.             end
  753.             if not found then
  754.                 tinsert(zones[strlower(locVar)], v)
  755.             end
  756.         end
  757.         PrintHelp("When in " .. strlower(locVar) .. " mounts with " .. table.concat(zones[strlower(locVar)], ",") .. " will be summoned.", "FF00ff00")
  758.     end
  759. end
  760.  
  761. -- Print the Location List
  762. function printLocF()
  763.     PrintHelp("Location Mount database", "FFff00ff")
  764.     for i, v in pairs(zones) do
  765.         PrintHelp(i .. ":", "FF00ff00")
  766.         for j, w in ipairs(zones[i]) do
  767.             PrintHelp("       " .. w, "FF00ff99")
  768.         end
  769.     end
  770. end
  771.  
  772. -- Remove a Filtered Location
  773. function removeLocF(info)
  774.     if string.len(info) > 0 then
  775.         local i = strfind(info, ":");
  776.         --if : not found then remove zone table
  777.         if not i then
  778.             PrintHelp("Zone " .. info .. " is no longer filtered.", "FF00ff00")
  779.             zones[info] = nil
  780.         else
  781.             local locVar = strsub(info, 0, i - 1)
  782.             local mntVar = splitString(",", strsub(info, i + 1))
  783.             for i, v in ipairs(mntVar) do
  784.                 local found = false
  785.                 for n, item in ipairs(zones[locVar]) do
  786.                     if v == item then
  787.                         PrintHelp(v .. " removed from " .. locVar .. ".", "FF00ff99")
  788.                         tremove(zones[locVar], n)
  789.                         found = true
  790.                         break
  791.                     end
  792.                 end
  793.                 if not found then
  794.                     PrintHelp(v .. " not found in " .. locVar .. ".", "FF00ff99")
  795.                 end
  796.             end
  797.             if #zones[locVar] == 0 then
  798.                 PrintHelp(locVar .. " removed because it has no mounts.", "FF00ff00")
  799.                 zones[locVar] = nil
  800.             end
  801.         end
  802.     end
  803.     -- if : found then remove zone table elements, not entire table, if table is empty place * to signify empty
  804. end
  805.  
  806. -- Change the Character Title
  807. function Title()
  808.     if rndTitle then
  809.         local titles = {};
  810.         for i=1,GetNumTitles(),1 do
  811.             if IsTitleKnown(i) == 1 then
  812.                 tinsert(titles, i)
  813.             end
  814.         end
  815.         SetCurrentTitle(titles[random(# titles)])
  816.     end
  817. end
  818.  
  819. -- Check to see if we are Swimming or in Vashj'ir
  820. function checkSwimming()
  821.     local zone = GetCurrentMapAreaID()
  822.     if IsSwimming() then
  823.         return(true)
  824.     elseif not IsSwimming() and (zone == 614 or zone == 615 or zone == 610) then
  825.         return(true)
  826.     else
  827.         return(false)
  828.     end
  829. end
  830.  
  831. -- Add mount to the No Summon List
  832. function dontSummon(r, numCompanions, searchMount)
  833.     if numCompanions > 10 and GetCurrentMapAreaID() ~= 766 and not checkSwimming() and #(searchMount) == 0 and not removeMount then
  834.         tinsert(nosummonlist, r)
  835.     end
  836.     if #(nosummonlist) > numCompanions/5 then
  837.         tremove(nosummonlist, 1)
  838.     end
  839. end
  840.  
  841. -- Change the Macro Icon
  842. function Icon(r)
  843.     if macroIcon then    
  844.         local _, _, _, icon = GetCompanionInfo("MOUNT", r)  
  845.         -- loop to change the icons of macros that are calling /rmount
  846.         local numglobal,_ = GetNumMacros()
  847.         for j=1,numglobal do
  848.             local mbody = GetMacroBody(j)
  849.             if strfind(mbody,"/rmount") or strfind(mbody,"/mnt") then
  850.                 EditMacro(j,nil,strsub(icon,17),nil)
  851.             end
  852.         end
  853.     end
  854. end
  855.  
  856. -- Main Mount Call
  857. function FindMount(arg1)
  858.     local s = 0
  859.     local r
  860.     local qiraji = {}                   -- Clear qiraji list
  861.     local flying = {}                   -- Clear flying list
  862.     local riding = {}                   -- Clear riding list
  863.     local search = ""
  864.     local searchMount = {}              -- Clear search list
  865.     local zoneText = GetRealZoneText()  -- Get Zone Text
  866.     local canFly = CanFlyHere()         -- Check if can fly
  867.     local outdoors = IsOutdoors()       -- Check if outdoors
  868.     local ridingSK = GetRidingSkill()   -- Set Riding Skill
  869.     local taylorSkill, engineerSkill = GetProfessionSkill()   -- Get Profession Skills
  870.     local inLocation = false            --Used to check for location
  871.     local zoneChk = true
  872.     local removeMountPrev = removeMount
  873.  
  874.     -- Check for Modifiers
  875.     argv, _ = SecureCmdOptionParse(arg1)
  876.     -- Check argument after /mnt or /rmount
  877.     if argv == "help" then
  878.         PrintHelp("Random Mount " .. version .. " optional flags:", "FFFFFF00")
  879.         PrintHelp("mnt: rmount: Will summon riding/flying mounts in the appropriate areas. mnt and rmount are interchangeable", "FFFFFF00")
  880.         PrintHelp("riding: Summons riding mounts in flying areas", "FFFFFF00")
  881.         PrintHelp("flying: Attempt to summon a flying mount", "FFFFFF00")
  882.         PrintHelp("help: Display help", "FFFFFF00")
  883.         PrintHelp("[mod:Modifier Name]: Use any Modifier Blizzard Supports", "FFFFFF00")
  884.         PrintHelp("r or f (search Term): Summons a mount based on specified search term \rexample: to summon a skeletal warhorse type: /mnt r skeletal \rto summon a proto-drake type: /mnt f proto", "FFFFFF00")
  885.         PrintHelp("config: Prints the current configuration", "FFFFFF00")
  886.         PrintHelp("rfilter: Toggle mount filtering", "FFFFFF00")
  887.         PrintHelp("safefly: Toggle double click to dismount while flying", "FFFFFF00")
  888.         PrintHelp("rfilters: List current filters", "FFFFFF00")
  889.         PrintHelp("locfilter: Toggle filter to summon only specific mounts in specific locations", "FFFFFF00")
  890.         PrintHelp("addloc % (zone:mount name1, mount name2, ...): Add locations and mounts to location checking. Separate mounts with commas. Use * as a wildcard to specify all mounts.", "FFFFFF00")
  891.         PrintHelp("removeloc % (zone:mount name1, mount name2, ...): Removes locations and mounts from location checking. Separate mounts with commas.", "FFFFFF00")
  892.         PrintHelp("loctable: Print the current location filtering table.", "FFFFFF00")
  893.         PrintHelp("clearloc: Clears location filters", "FFFFFF00")
  894.         PrintHelp("remove %: Remove all mounts matching % if rfilter is enabled", "FFFFFF00")
  895.         PrintHelp("clear: Clears all filters", "FFFFFF00")
  896.         PrintHelp("clearrem: Clears the mount removal table", "FFFFFF00")
  897.         PrintHelp("whereami: Prints your zone and mini-map zone, and map coordinates.", "FFFFFF00")
  898.         PrintHelp("title: Enable or disable random title change.", "FFFFFF00")
  899.         PrintHelp("icon: Enable or disable changing random mount macro icons to the last summoned mount.", "FFFFFF00")
  900.         PrintHelp("debug: Toggle debug printing for posting error messages", "FFFFFF00")
  901.         PrintHelp("No Flag: Summon an appropriate mount for the area", "FFFFFF00")
  902.         return
  903.     elseif argv == "config" then
  904.         if debug then
  905.             PrintHelp("Debug: Enabled", "FF00ff00")
  906.         else
  907.             PrintHelp("Debug: Disabled", "FFff0000")
  908.         end
  909.         if removeMount then
  910.             PrintHelp("Mounts filtered: " .. table.concat(notWanted, ", "), "FF00ff00")
  911.         else
  912.             PrintHelp("Mount Removal Disabled.", "FFff0000")
  913.         end
  914.         if safeFly then
  915.             PrintHelp("Safe flying enabled. Double click to dismount while flying", "FF00ff00")
  916.         else
  917.             PrintHelp("Safe flying disabled.", "FFff0000")
  918.         end
  919.         if rndTitle then
  920.             PrintHelp("Random title enabled.", "FF00ff00")
  921.         else
  922.             PrintHelp("Random title disabled.", "FFff0000")
  923.         end
  924.         if macroIcon then
  925.             PrintHelp("Icon changing enabled.", "FF00ff00")
  926.         else
  927.             PrintHelp("Icon changing disabled.", "FFff0000")
  928.         end
  929.         return
  930.     elseif argv == "whereami" then
  931.         local posX, posY = GetPlayerMapPosition("player")
  932.         PrintHelp("You are in " .. GetRealZoneText() .. ", " .. GetMinimapZoneText() .. ", " .. posX .. ", " .. posY, "FF00ff00")
  933.         return
  934.     elseif argv == "debug" then
  935.         if debug == false then
  936.             debug = true
  937.             PrintHelp("Debug information enabled.", "FF00ff00")
  938.         elseif debug == true then
  939.             debug = false
  940.             PrintHelp("Debug information disabled.", "FFff0000")
  941.         end
  942.         return
  943.     elseif argv == "debug2" then
  944.         if debug2 == false then
  945.             debug2 = true
  946.             debug = true
  947.             PrintHelp("Debug2 information enabled. Your chat window will be spamed.", "FF00ff00")
  948.         elseif debug2 == true then
  949.             debug2 = false
  950.             PrintHelp("Debug2 information disabled.", "FFff0000")
  951.         end
  952.         return
  953.     elseif argv == "locfilter" then
  954.         if locationChk == false then
  955.             locationChk = true
  956.             PrintHelp("Location mount filtering enabled.", "FF00ff00")
  957.         elseif locationChk == true then
  958.             locationChk = false
  959.             PrintHelp("Location mount filtering disabled.", "FFff0000")
  960.         end
  961.         return
  962.     elseif argv == "rfilter" then
  963.         if removeMount == false then
  964.             removeMount = true
  965.             removeMountPrev = removeMount
  966.             PrintHelp("Mount removal enabled.", "FF00ff00")
  967.         elseif removeMount == true then
  968.             removeMount = false
  969.             removeMountPrev = removeMount
  970.             PrintHelp("Mount removal disabled.", "FFff0000")
  971.         end
  972.         return
  973.     elseif argv == "safefly" then
  974.         if safeFly == false then
  975.             safeFly = true
  976.             PrintHelp("Safe flying enabled. Double click to dismount while flying", "FF00ff00")
  977.         elseif safeFly == true then
  978.             safeFly = false
  979.             PrintHelp("Safe flying disabled.", "FFff0000")
  980.         end
  981.         return
  982.     elseif argv == "rfilters" then
  983.         if removeMount then
  984.             PrintHelp("Mounts filtered: " .. table.concat(notWanted, ", "), "FF00ffff")
  985.         else
  986.             PrintHelp("Mount removal disabled.", "FFff0000")
  987.         end
  988.         return
  989.     elseif argv == "title" then
  990.         if rndTitle == false then
  991.             rndTitle = true
  992.             PrintHelp("Random title enabled.", "FF00ff00")
  993.         elseif rndTitle == true then
  994.             rndTitle = false
  995.             PrintHelp("Random title disabled.", "FFff0000")
  996.         end
  997.         return
  998.     elseif argv == "icon" then
  999.         if macroIcon == false then
  1000.             macroIcon = true
  1001.             PrintHelp("Icon changing enabled.", "FF00ff00")
  1002.         elseif macroIcon == true then
  1003.             macroIcon = false
  1004.             PrintHelp("Icon changing disabled.", "FFff0000")
  1005.         end
  1006.         return
  1007.     elseif argv == "clear" then
  1008.         notWanted = {}
  1009.         zones = {}
  1010.         PrintHelp("All tables cleared.", "FF00ffff")
  1011.         return
  1012.     elseif argv == "clearrem" then
  1013.         notWanted = {}
  1014.         PrintHelp("Remove mount table cleared.", "FF00ffff")
  1015.         return
  1016.     elseif argv == "clearloc" then
  1017.         zones = {}
  1018.         PrintHelp("Special location table cleared.", "FF00ffff")
  1019.         return
  1020.     elseif argv == "loctable" then
  1021.         printLocF()
  1022.         return
  1023.     elseif argv:find("removeloc") then
  1024.         PrintHelp(strsub(argv, 11), "FF00ff99")
  1025.         if string.len(strsub(argv, 11)) > 0 then
  1026.             removeLocF(strsub(argv, 11))
  1027.         end
  1028.         return
  1029.     elseif argv == "riding" then
  1030.         canFly = false
  1031.     elseif argv == "flying" then
  1032.         if ridingSK < 225 then
  1033.             canFly = false
  1034.         else
  1035.             canFly = true
  1036.         end
  1037.     elseif argv:find("addloc") then
  1038.         if string.len(strsub(argv, 8)) > 0 then
  1039.             AddLocF(strsub(argv, 8))
  1040.         end
  1041.         return
  1042.     elseif argv:find("remove") then
  1043.         local found = false
  1044.         if strlen(strsub(argv, 8)) > 0 then
  1045.             for n, notW in ipairs(notWanted) do
  1046.                 if strsub(argv, 8) == notW then
  1047.                     PrintHelp(strsub(argv, 8) .. " already added.", "FF00ffff")
  1048.                     found = true
  1049.                     break
  1050.                 end
  1051.             end
  1052.             --PrintHelp(table.concat(notWanted, ", "), "FF00ffff")
  1053.             if not found then
  1054.                 PrintHelp("Mounts matching " .. strsub(argv, 8) .. " will no longer be summoned.", "FF00ff00")
  1055.                 tinsert(notWanted, strsub(argv, 8))
  1056.             end
  1057.         end
  1058.         return
  1059.     elseif argv == "rnd" then
  1060.         r = random(GetNumCompanions("MOUNT"))
  1061.         PrintHelp(r, "FF00ffff")
  1062.     elseif strfind(argv, "r%s", 1) then
  1063.         canFly = false
  1064.         search = strlower(strsub(argv, 3))
  1065.     elseif strfind(argv, "f%s", 1) then
  1066.         canFly = CanFlyHere()
  1067.         if canFly then
  1068.             search = strlower(strsub(argv, 3))
  1069.         end
  1070.     elseif argv == '' then
  1071.         search = argv
  1072.     else
  1073.         PrintHelp("No matching mount found.", "FF00ffff")
  1074.         return
  1075.     end
  1076.     -- Check if we are Mounted
  1077.     if IsMounted() then
  1078.         if safeFly and IsFlying() then
  1079.             local curTime = GetTime()
  1080.             if curTime < (lastTime + 0.5) then
  1081.                 Dismount()
  1082.                 return
  1083.             else
  1084.                 lastTime = curTime
  1085.                 return
  1086.             end
  1087.         else
  1088.             Dismount()
  1089.             return
  1090.         end
  1091.     elseif UnitInVehicle(UnitName("player")) then
  1092.         VehicleExit()
  1093.         return
  1094.     end
  1095.     -- Run Random Title
  1096.     Title()
  1097.     -- Get Number of Mounts
  1098.     numCompanions = GetNumCompanions("MOUNT")
  1099.     -- Check if you have the Appropriate Riding Skill
  1100.     if ridingSK >= 75 then
  1101.         -- Check for Zone Mounts
  1102.         local flying, riding, qiraji, searchMount = HasZoneMounts(flying, riding, qiraji, searchMount, search)
  1103.         -- Process Search Mount
  1104.         if search ~= '' and #searchMount == 0 then
  1105.             PrintHelp("No matching mount found.", "FF00ffff")
  1106.             return
  1107.         end
  1108.         if #(flying) == 0 then
  1109.             canFly = false
  1110.         end
  1111.         -- Check if you Can Fly, IsUsableSpell used for swimming on surface check
  1112.         if canFly and IsUsableSpell(88744) then
  1113.             -- Repeat picking a Mount until one is found that is appropriate
  1114.             for i=0, 1000, 1 do
  1115.                 r = random(numCompanions)
  1116.                 -- Test Mount
  1117.                 s = TestMount(r, ridingSK, zoneText, canFly, flying, qiraji, searchMount, debug, inLocation, zoneChk, taylorSkill, engineerSkill)
  1118.                 if s then
  1119.                     break
  1120.                 end
  1121.             end
  1122.             -- Summon Mount
  1123.             CallCompanion("MOUNT", r)
  1124.             -- Check if Summon Failed
  1125.             if mountError then
  1126.                 canFly = false
  1127.                 -- Check if you are Swimming
  1128.                 if checkSwimming() then
  1129.                     -- Get Sea Mount
  1130.                     r = seaMount()
  1131.                     -- Check if you have a Sea Mount
  1132.                     if r ~= 0 then
  1133.                         CallCompanion("MOUNT", r)
  1134.                         -- Check if Summon Failed
  1135.                         if mountErrorMsg ~= SPELL_FAILED_ONLY_UNDERWATER then
  1136.                             -- Set the Icon of the Sea Mount
  1137.                             Icon(r)
  1138.                             return
  1139.                         end
  1140.                     end
  1141.                 end
  1142.                 -- Reset mountError
  1143.                 mountError = false
  1144.                 -- Repeat picking a Mount until one is found that is appropriate
  1145.                 for i=0, 1000, 1 do
  1146.                     r = random(numCompanions)
  1147.                     -- Test Mount
  1148.                     s = TestMount(r, ridingSK, zoneText, canFly, flying, qiraji, searchMount, debug, inLocation, zoneChk, taylorSkill, engineerSkill)
  1149.                     if s then
  1150.                         break
  1151.                     end
  1152.                 end
  1153.                 -- Summon Mount
  1154.                 CallCompanion("MOUNT", r)
  1155.                 -- Check if Summon Failed
  1156.                 if mountError then
  1157.                     PrintHelp("Cannot Summon Mount", "FFff0000")
  1158.                 end
  1159.             end
  1160.         else
  1161.             -- Check if you are Swimming
  1162.             if checkSwimming() then
  1163.                 -- Get Sea Mount
  1164.                 r = seaMount()
  1165.                 -- Check if you have a Sea Mount
  1166.                 if r ~= 0 then
  1167.                     CallCompanion("MOUNT", r)
  1168.                     -- Check if Summon Failed
  1169.                     if mountErrorMsg ~= SPELL_FAILED_ONLY_UNDERWATER then
  1170.                         -- Set the Icon of the Sea Mount
  1171.                         Icon(r)
  1172.                         return
  1173.                     end
  1174.                 end
  1175.             end
  1176.             mountError = false
  1177.             if #(riding) ~= 0  and outdoors and not InCombatLockdown() then
  1178.                 -- Repeat picking a Mount until one is found that is appropriate
  1179.                 for i=0, 1000, 1 do
  1180.                     r = random(numCompanions)
  1181.                     -- Test Mount
  1182.                     s = TestMount(r, ridingSK, zoneText, canFly, flying, qiraji, searchMount, debug, inLocation, zoneChk, taylorSkill, engineerSkill)
  1183.                     if s then
  1184.                         break
  1185.                     end
  1186.                 end
  1187.                 -- Summon Mount
  1188.                 CallCompanion("MOUNT", r)
  1189.                 -- Check if Summon Failed
  1190.                 if mountError then
  1191.                     PrintHelp("Cannot Summon Mount", "FFff0000")
  1192.                 end
  1193.             end
  1194.         end
  1195.         -- Set Icon of the Mount
  1196.         Icon(r)
  1197.         return
  1198.     end
  1199. end
  1200.  
  1201. -- Test the Mount
  1202. function TestMount(r, ridingSK, zoneText, canFly, flying, qiraji, searchMount, debug, inLocation, zoneChk, taylorSkill, engineerSkill)
  1203.     local _, creatureName, creatureSpellID = GetCompanionInfo("MOUNT", r)
  1204.     local mv
  1205.     -- Check if Mount is in Database
  1206.     if mountDict[creatureSpellID] then
  1207.         -- Get the Mount type
  1208.         mv = mountDict[creatureSpellID][1]
  1209.         -- Check if Mount exists in Database
  1210.         if mv then
  1211.             -- Check if unusable (does not ensure it's usable)
  1212.             usable = IsUsableSpell(creatureSpellID)
  1213.             if not usable then
  1214.                 return false
  1215.             end
  1216.             -- Check Search List
  1217.             if #(searchMount) > 0 then
  1218.                 if tContains(searchMount, r) then
  1219.                     if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 12) end
  1220.                     return(true)
  1221.                 else
  1222.                     return(false)
  1223.                 end
  1224.             end
  1225.             --Remove Mount processing
  1226.             if removeMount then
  1227.                 for n, notW in ipairs(notWanted) do
  1228.                     if strfind(strlower(creatureName), strlower(notW)) or creatureSpellID == tonumber(notW) then
  1229.                         return(false)
  1230.                     end
  1231.                 end
  1232.             end
  1233.             --Zone Checking
  1234.             if locationChk and zoneChk then
  1235.                 realZone = GetCurrentMapAreaID()
  1236.                 miniMapZone = GetMinimapZoneText()
  1237.                 local found = false
  1238.                 if zones[strlower(miniMapZone)] then
  1239.                     zoneChk = false
  1240.                     for i, type in ipairs(zones[strlower(miniMapZone)]) do
  1241.                         if strfind(strlower(creatureName), strlower(type)) or type == "*" then
  1242.                             zoneChk = true
  1243.                             found = true
  1244.                             if debug then PrintHelp(type .. " : " .. creatureName .. " is found", "FFffff00") end
  1245.                             break
  1246.                         end
  1247.                     end
  1248.                 end
  1249.                 -- Check your Zone
  1250.                 if zones[strlower(realZone)] then
  1251.                     if not found then
  1252.                         zoneChk = false
  1253.                         for i, type in ipairs(zones[strlower(realZone)]) do
  1254.                             if strfind(strlower(creatureName), strlower(type)) or type == "*" then
  1255.                                 zoneChk = true
  1256.                                 if debug then PrintHelp(type .. " : " .. creatureName .. " is found", "FFffff00") end
  1257.                                 break
  1258.                             end
  1259.                         end
  1260.                     end
  1261.                 end
  1262.                 if not zoneChk then
  1263.                     return(false)
  1264.                 end
  1265.             end
  1266.             --profession mounts
  1267.             if (creatureSpellID == 44153 and engineerSkill < 300) or
  1268.                 (creatureSpellID == 44151 and engineerSkill < 375) or
  1269.                 (creatureSpellID == 61451 and taylorSkill < 300) or
  1270.                 (creatureSpellID == 75596 and taylorSkill < 425) or
  1271.                 (creatureSpellID == 61309 and taylorSkill < 425) then
  1272.                 return(false)
  1273.             end
  1274.             --flying mounts
  1275.             if canFly and #flying > 0 and ridingSK >= 225 then
  1276.                 if mv >= 2 then
  1277.                     if inLocation then
  1278.                         if lfmChk(creatureName) then
  1279.                             if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 11) end
  1280.                             return(true)
  1281.                         end
  1282.                     else
  1283.                         if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 10) end
  1284.                         return(true)
  1285.                     end
  1286.                 end
  1287.             --zone specific mounts
  1288.             elseif realZone == 766 and #qiraji > 0 then
  1289.                 if ridingSK >= 150 and mv == 1 then
  1290.                     if inLocation then
  1291.                         if lfmChk(creatureName) then
  1292.                             if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 36) end
  1293.                             return(true)
  1294.                         end
  1295.                     elseif creatureSpellID == 25953 or creatureSpellID == 26054 or creatureSpellID == 26055 or creatureSpellID == 26056 or creatureSpellID == 26656 then
  1296.                         if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 35) end
  1297.                         return(true)
  1298.                     end
  1299.                 end
  1300.             --Regular Mounts
  1301.             elseif not canFly and ridingSK >= 75 and creatureSpellID ~= 64731 and creatureSpellID ~= 75207 and creatureSpellID ~= 98718 and creatureSpellID ~= 25953 and creatureSpellID ~= 26054 and creatureSpellID ~= 26055 and creatureSpellID ~= 26056 and creatureSpellID ~= 26656 then
  1302.                 if mv ~= 2 then
  1303.                     if inLocation then
  1304.                         if lfmChk(creatureName) then
  1305.                             if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 51) end
  1306.                             return(true)
  1307.                         end
  1308.                     else
  1309.                         if debug then PrintSummon("FF00ffff", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 50) end
  1310.                         return(true)
  1311.                     end
  1312.                 end
  1313.             end
  1314.             if debug2 then
  1315.                 PrintSummon("FFffff99", creatureName, r, ridingSK, mountDict[creatureSpellID][1], zoneText, canFly, creatureSpellID, 00)
  1316.             end
  1317.         end
  1318.     end
  1319. end
  1320.  
  1321. -- Print Help
  1322. function PrintHelp(cmd, color)
  1323.     print(format('|c%s%s|r', color, cmd))
  1324. end
  1325.  
  1326. -- Print in Summon Color
  1327. function PrintSummon(color, creatureName, r, ridingSK, creatureDict, zoneText, canFly, creatureSpellID, mountNum)
  1328.     canFly = tostring(canFly)
  1329.     print(format("|c%s%s - Mnt#:%s - Skill: %s - type:%s - %s - %s - flyZone:%s - cID:%s - cond:%s|r", color, creatureName, r, ridingSK, creatureDict, zoneText, GetMinimapZoneText(), canFly, creatureSpellID, mountNum))
  1330. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement