GenericCraftingTrainer.lua 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. --[[
  2. Script Name : SpawnScripts/Generic/GenericCraftingTrainer.lua
  3. Script Purpose : <Crafting Trainer>
  4. Script Author : theFoof (SendSecondaryChoice() by Jabantiz)
  5. Script Date : 2013.10.20
  6. Script Notes : This script handles crafting trainers
  7. --]]
  8. local artisan_ess_1 = 31371
  9. local artisan_ess_2 = 31373
  10. local ARTISAN = 1
  11. local CRAFTSMAN = 2
  12. local PROVISIONER = 3
  13. local WOODWORKER = 4
  14. local CARPENTER = 5
  15. local OUTFITTER = 6
  16. local ARMORER = 7
  17. local WEAPONSMITH = 8
  18. local TAILOR = 9
  19. local SCHOLAR = 10
  20. local JEWELER = 11
  21. local SAGE = 12
  22. local ALCHEMIST = 13
  23. function spawn(NPC)
  24. end
  25. function respawn(NPC)
  26. spawn(NPC)
  27. end
  28. function hailed(NPC, Spawn)
  29. CraftingTrainerHail(NPC, Spawn)
  30. end
  31. function CraftingTrainerHail(NPC, Spawn)
  32. FaceTarget(NPC, Spawn)
  33. conversation = CreateConversation()
  34. if GetTradeskillLevel(Spawn) < 9 then
  35. if not HasBooks(Spawn) or GetTradeskillLevel(Spawn) < 2 then
  36. AddConversationOption(conversation, "Yes, please teach me.", "GiveBooks")
  37. AddConversationOption(conversation, "No, not at the moment.", "Chat1")
  38. StartConversation(conversation, NPC, Spawn, "You show interest in the crafting trade. Good. We can always use talented artisans. I can help you get started. Would you be interested?")
  39. else
  40. Chat2(NPC, Spawn)
  41. end
  42. elseif GetTradeskillLevel(Spawn) == 9 then
  43. Chat4(NPC, Spawn)
  44. elseif GetTradeskillLevel(Spawn) == 19 then
  45. Chat5(NPC, Spawn)
  46. elseif GetTradeskillLevel(Spawn) < 20 then
  47. Chat2(NPC, Spawn)
  48. else
  49. PlayFlavor(NPC, "", "You have learned everything I have to teach. You are free to use our crafting facilities to hone your skills and master your craft.", "hello", 0, 0, Spawn)
  50. end
  51. end
  52. function HasBooks(Spawn)
  53. local has_books = true
  54. --check if the player has certain recipe books
  55. if not HasRecipeBook(Spawn, artisan_ess_1) and not HasItem(Spawn, artisan_ess_1, 1) then
  56. has_books = false
  57. end
  58. if not HasRecipeBook(Spawn, artisan_ess_2) and not HasItem(Spawn, artisan_ess_2, 1) then
  59. has_books = false
  60. end
  61. return has_books
  62. end
  63. function GiveBooks(NPC, Spawn)
  64. --give recipe books if not scribed and does not have
  65. if not HasRecipeBook(Spawn, artisan_ess_1) and not HasItem(Spawn, artisan_ess_1, 1) then
  66. SummonItem(Spawn, artisan_ess_1, 1)
  67. end
  68. if not HasRecipeBook(Spawn, artisan_ess_2) and not HasItem(Spawn, artisan_ess_2, 1) then
  69. SummonItem(Spawn, artisan_ess_2, 1)
  70. end
  71. if GetTradeskillLevel(Spawn) < 2 then
  72. SetTradeskillClass(Spawn, ARTISAN)
  73. SetTradeskillLevel(Spawn, 2)
  74. end
  75. Chat3(NPC, Spawn)
  76. end
  77. function Chat1(NPC, Spawn)
  78. PlayFlavor(NPC, "", "Oh, well feel free to come back later whenever you'd like.", "", 1689589577, 4560189, Spawn)
  79. end
  80. function Chat2(NPC, Spawn)
  81. PlayFlavor(NPC, "", "I have nothing else to teach you for the moment. Please return to me when you have earned enough experience to choose your profession.", "", 1689589577, 4560189, Spawn)
  82. end
  83. function Chat3(NPC, Spawn)
  84. FaceTarget(NPC, Spawn)
  85. conversation = CreateConversation()
  86. AddConversationOption(conversation, "I will start on that now.")
  87. StartConversation(conversation, NPC, Spawn, "There, you now have knowledge required to begin crafting. Speak to the Tradeskill Tutor for more detailed guidance on learning to craft, if you are interested in more information. Return to me when you are ready to select a crafting specialty.")
  88. end
  89. function Chat4(NPC, Spawn)
  90. FaceTarget(NPC, Spawn)
  91. conversation = CreateConversation()
  92. AddConversationOption(conversation, "My name is " .. GetName(Spawn) ..".", "SendSecondaryChoice")
  93. AddConversationOption(conversation, "No thank you, I'll come back later.")
  94. StartConversation(conversation, NPC, Spawn, "I'm glad you have come back for more training, it looks like you've learned quite a bit in a very short time. I can certify you in your chosen trade class. Before I begin your paperwork, I'll need your name.")
  95. end
  96. function Chat5(NPC, Spawn)
  97. FaceTarget(NPC, Spawn)
  98. conversation = CreateConversation()
  99. AddConversationOption(conversation, "My name is " .. GetName(Spawn) .. ".", "Send" .. GetTradeskillClassName(Spawn) .. "Choice")
  100. StartConversation(conversation, NPC, Spawn, "I'm glad that you continued on as a " .. GetTradeskillClassName(Spawn) .. " and came back to advance your skills. I can certify you in your chosen trade specialty. I need your name before I can start your paperwork.")
  101. end
  102. function SendSecondaryChoice(NPC, Spawn)
  103. window = CreateOptionWindow()
  104. AddOptionWindowOption(window, "Craftsman", "Craftsmen become carpenters, provisioners, or woodworkers. They make furniture and strong boxes, food, drink, bows, arrows, totems, wooden weapons, and wooden shields.", 1, 420, "select_craftsman")
  105. AddOptionWindowOption(window, "Outfitter", "Outfitters become armorers, tailors, or weaponsmiths. They make plate and chainmail armor, heavy shields, cloth and leather armor, casual clothing, backpacks, hex dolls, and metal weapons.", 1, 411, "select_outfitter")
  106. AddOptionWindowOption(window, "Scholar", "Scholars become alchemists, jewelers, and sages. They make spell and combat art upgrades for adventurers, potions, poisons, and jewelry.", 1, 396, "select_scholar")
  107. SendOptionWindow(window, Spawn, "Select A Profession")
  108. end
  109. function select_craftsman(NPC, Spawn)
  110. SetTradeskillClass(Spawn, CRAFTSMAN)
  111. SetTradeskillLevel(Spawn, 10)
  112. end
  113. function select_outfitter(NPC, Spawn)
  114. SetTradeskillClass(Spawn, OUTFITTER)
  115. SetTradeskillLevel(Spawn, 10)
  116. end
  117. function select_scholar(NPC, Spawn)
  118. SetTradeskillClass(Spawn, SCHOLAR)
  119. SetTradeskillLevel(Spawn, 10)
  120. end
  121. function SendOutfitterChoice(NPC, Spawn)
  122. window = CreateOptionWindow()
  123. AddOptionWindowOption(window, "Armorer", "Armorers are skilled at creating plate and chainmail armor.", 2, 40, "select_armorer")
  124. AddOptionWindowOption(window, "Weaponsmith", "Weaponsmiths specialize in making metal weapons of all damage types.", 2, 41, "select_weaponsmith")
  125. AddOptionWindowOption(window, "Tailor", "Tailors make cloth and leather armor, casual clothing, backpacks, hex dolls, and ammo holders.", 2, 42, "select_tailor")
  126. SendOptionWindow(window, Spawn, "Select A Class")
  127. end
  128. function select_armorer(NPC, Spawn)
  129. SetTradeskillClass(Spawn, ARMORER)
  130. SetTradeskillLevel(Spawn, 20)
  131. end
  132. function select_weaponsmith(NPC, Spawn)
  133. SetTradeskillClass(Spawn, WEAPONSMITH)
  134. SetTradeskillLevel(Spawn, 20)
  135. end
  136. function select_tailor(NPC, Spawn)
  137. SetTradeskillClass(Spawn, TAILOR)
  138. SetTradeskillLevel(Spawn, 20)
  139. end
  140. function SendScholarChoice(NPC, Spawn)
  141. local window = CreateOptionWindow()
  142. AddOptionWindowOption(window, "Sage", "Sages specialize in making spell upgrade scrolls for mages and priests.", 2, 37, "select_sage")
  143. AddOptionWindowOption(window, "Alchemist", "Alchemists make fighter combat art upgrades, potions, and poisons.", 2, 38, "select_alchemist")
  144. AddOptionWindowOption(window, "Jeweler", "Jewelers make upgrades for scout combat arts, as well as jewelery such as rings, earrings, necklaces, bracelets, and belts.", 2, 39, "select_jeweler")
  145. SendOptionWindow(window, Spawn, "Select A Class")
  146. end
  147. function select_sage(NPC, Spawn)
  148. SetTradeskillClass(Spawn, SAGE)
  149. SetTradeskillLevel(Spawn, 20)
  150. end
  151. function select_alchemist(NPC, Spawn)
  152. SetTradeskillClass(Spawn, ALCHEMIST)
  153. SetTradeskillLevel(Spawn, 20)
  154. end
  155. function select_jeweler(NPC, Spawn)
  156. SetTradeskillClass(Spawn, JEWELER)
  157. SetTradeskillLevel(Spawn, 20)
  158. end
  159. function SendCraftsmanChoice(NPC, Spawn)
  160. local window = CreateOptionWindow()
  161. AddOptionWindowOption(window, "Carpenter", "Carpenters make furniture of all types, strong boxes, and a variety of sales crates.", 2, 44, "select_carpenter")
  162. AddOptionWindowOption(window, "Provisioner", "Provisioners make food and drink that will regenerate health and power faster between battles.", 2, 43, "select_provisioner")
  163. AddOptionWindowOption(window, "Woodworker", "Woodworkers make wooden weapons, totems, bows, arrows, and wooden shields.", 2, 45, "select_woodworker")
  164. SendOptionWindow(window, Spawn, "Select A Class")
  165. end
  166. function select_carpenter(NPC, Spawn)
  167. SetTradeskillClass(Spawn, CARPENTER)
  168. SetTradeskillLevel(Spawn, 20)
  169. end
  170. function select_provisioner(NPC, Spawn)
  171. SetTradeskillClass(Spawn, PROVISIONER)
  172. SetTradeskillLevel(Spawn, 20)
  173. end
  174. function select_woodworker(NPC, Spawn)
  175. SetTradeskillClass(Spawn, WOODWORKER)
  176. SetTradeskillLevel(Spawn, 20)
  177. end