Advertisement
Guest User

illusion_tutor.lic

a guest
Nov 23rd, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.62 KB | None | 0 0
  1. =begin
  2. This script waits for someone to whisper "Illusion" to you, then helps them Teach or Learn a particular illusion.
  3. just to be clear, this script is mainly for people who are already mastered and want to help others during downtime without typing everything.
  4. thanks to everyone who helped me debug, especially Murkshev. And Tillmen, Sam, Pandin, Riall, and Casis for some code pointers.
  5. ~Moredin
  6.  
  7. 2/28/2011 - added option where pupil can ask for a promotion in the illusion skill ranks
  8. 10/06 - made it harder to 'break' the script by adding regex and timeouts while waiting for correct responses/successful reps. so if one person messes up or logs out, someone else can still start a session.
  9. 10/09 - takes into account the script-users's guild mastery status; people get 2x credit on reps from them. thanks to Malisai for help debugging
  10. 10/10 - pauses other scripts (visible ones) that are running, so at the time someone whispers so they don't interfere with tutoring.
  11. 02/02/2012 - increased timeout time before reteaching to 60 since Gristash sucks at making roses...(used to wait 45 seconds for success)
  12. Mar 2012 - made opening line more flexible to what it recognizes. can whisper anything with the words "promote", "promotion", "illusion", or any variation of the latter ("illusions", "illusioning", etc)
  13. - made it count the failures and re-teach those failures at end of lesson.
  14. Kaldonis takes over as maintainer
  15. 20 Oct 2016 - trying to make two tutors to stop Doing each other
  16. 17 Aug 2017 - promotion in all tasks, beta test on checkin requirement
  17.  
  18. REPORT ANY BUGS
  19. =end
  20.  
  21.  
  22. before_dying { $teaching_illusions = nil }
  23.  
  24. rank = dothistimeout 'gld', 20, /^You are (?:a member|Guild Master) of the Sorcerer Guild\.$/
  25. if rank =~ /^You are Guild Master of the Sorcerer Guild\.$/
  26. guildmaster = true
  27. echo ""
  28. echo "You are a Guild Master. People training with you earn 2 reps instead of 1."
  29. echo ""
  30. else
  31. end
  32. echo ""
  33. echo "Someone must WHISPER a sentence with 'illusion(s)', 'promote/promotion', or 'nominate' in it to start the sessions."
  34. echo ""
  35.  
  36. loop {
  37. line = get until line =~ /^([A-Z][a-z]+) whispers, \".*?illusion.*?\"|^([A-Z][a-z]+) whispers, \".*?promote.*?\"|^([A-Z][a-z]+) whispers, \".*?promotion.*?\"|^([A-Z][a-z]+) whispers, \".*?nominate.*?\"/i
  38. if line =~ /^([A-Z][a-z]+) whispers, \".*?illusion.*?\"/i
  39. person = $1
  40. $teaching_illusions = true
  41. for s in Script.running
  42. s.pause unless ( s == Script.self or s.to_s == "sigils" or s.to_s == "narost" or s.to_s == "rnum" )
  43. end
  44. elsif line =~ /^([A-Z][a-z]+) whispers, \".*?promot.*?\"/i
  45. person = $1
  46. skill = $2
  47. if skill =~ /illus|alch|trink|potion/i
  48. sleep 0.1
  49. else
  50. fput "whisper #{person} I am to promote you in which one: illus, alch, trink, or potion?"
  51. y = matchtimeout( 25, "#{person} whispers, \"(\\w+)")
  52. #y =~ /#{person} whispers, \"(\w+)/ # cannot handle: Beyrn whispers, "Promote illus."
  53. y =~ /#{person} whispers, \"(illus|alch|trink|potion)/i
  54. skill = $1
  55. end
  56. fput "gld promote #{person} in #{skill}"
  57. # another exception: Beyrn is behind in his dues! You'll have to check him in first.
  58. line = get until line =~ /^You offer to promote|needs to diversify (his|her) training by learning|^Promote whom/
  59. if line =~ /training by learning (.*) before/
  60. prerequisite = $1
  61. fput "whisper #{person} You need #{prerequisite} before I can promote you in illusions, sorry."
  62. sleep 1
  63. elsif line =~ /^You offer to promote/
  64. promote_result = dothistimeout 'nod approve #{person}', 10, /has mastered the skill!|ranks of this skill!/
  65. if promote_result =~ /has mastered the skill!/
  66. mastered = true
  67. else
  68. mastered = false
  69. end
  70. elsif line =~ /is behind in (his|her) dues/
  71. fput "whisper #{person} You are behind on your dues! Let's settle that first!"
  72. fput "gld checkin #{person}"
  73. fput "whisper occ #{person} This feature is still in beta testing, sorry!"
  74. sleep 1
  75. end
  76. elsif line =~ /^([A-Z][a-z]+) whispers, \".*?nominate.*?\"/i
  77. person = $1
  78. fput "gld nominate #{person}"
  79. fput "whisper #{person} You'll need 1 other Guild Master here and a nomination from him or her also. Congratulations on your achievement!"
  80. fput "nod"
  81. end
  82. sleep 1
  83. if $teaching_illusions == true
  84. failcount = 0
  85. fput "whisper #{person} Are you here to Teach or Learn?"
  86. y = matchtimeout( 25, "#{person} whispers, \"(\\w+)")
  87. y =~ /#{person} whispers, \"(\w+)/
  88. role = $1
  89. if role =~ /Learn/
  90. fput "nod #{person}"
  91. sleep 0.5
  92. fput "whisper #{person} How many reps?"
  93. y = matchtimeout( 25, "#{person} whispers, \"(\\d+)")
  94. y =~ /#{person} whispers, \"(\d+)/
  95. reps = $1.to_f
  96. if reps > 42
  97. fput "whisper #{person} that's too many reps!"
  98. next
  99. end
  100. reps = (reps/2).ceil if guildmaster == true
  101. unless reps == nil
  102. fput "whisper #{person} I am to show you which one: rose, vortex, maelstrom, void, shadow, or demon?"
  103. y = matchtimeout( 25, "#{person} whispers, \"(\\w+)")
  104. y =~ /#{person} whispers, \"(\w+)/
  105. skill = $1
  106. end
  107. sleep 0.5
  108. if guildmaster == true
  109. fput "whisper #{person} I'm going to teach you #{skill} #{reps} times since each of my lessons counts as two." if skill =~ /Rose|Vortex|Maelstrom|Void|Shadow|Demon/
  110. else
  111. fput "whisper #{person} OK, I'll teach you #{skill} #{reps} times" if skill =~ /Rose|Vortex|Maelstrom|Void|Shadow|Demon/
  112. end
  113. if skill =~ /Rose/
  114. waitrt?
  115. reps.to_i.times { fput "illusion teach #{person} rose"; result = matchtimeout( 60, "a perfectly-shaped black essence rose lies across #{person}\'s hand" ); if result == false; failcount = failcount + 1; end }
  116. if failcount > 0
  117. fput "whisper #{person} I think you failed a few reps...I'll give you another chance at those now."
  118. failcount.to_i.times { fput "illusion teach #{person} rose"; matchtimeout( 60, "a perfectly-shaped black essence rose lies across #{person}\'s hand" ) }
  119. else
  120. fput "whisper #{person} I've taught you the number of times you required."
  121. end
  122. elsif skill =~ /Vortex/
  123. waitrt?
  124. reps.to_i.times { fput "illusion teach #{person} vortex"; result = matchtimeout( 60, "#{person} holds out the palm\.*?takes the form of a swirling colorless vortex" ); if result == false; failcount = failcount + 1; end }
  125. if failcount > 0
  126. fput "whisper #{person} I think you failed a few reps...I'll give you another chance at those now."
  127. failcount.to_i.times { fput "illusion teach #{person} vortex"; matchtimeout( 60, "#{person} holds out the palm\.*?takes the form of a swirling colorless vortex" ) }
  128. else
  129. fput "whisper #{person} I've taught you the number of times you required."
  130. end
  131. elsif skill =~ /Maelstrom/
  132. waitrt?
  133. reps.to_i.times { fput "illusion teach #{person} maelstrom"; result = matchtimeout( 60, "#{person} holds\.*?swiftly reaches its full potential, raining tiny hailstones down into" ); if result == false; failcount = failcount + 1; end }
  134. if failcount > 0
  135. fput "whisper #{person} I think you failed a few reps...I'll give you another chance at those now."
  136. failcount.to_i.times { fput "illusion teach #{person} maelstrom"; matchtimeout( 60, "#{person} holds\.*?swiftly reaches its full potential, raining tiny hailstones down into" ) }
  137. else
  138. fput "whisper #{person} I've taught you the number of times you required."
  139. end
  140. elsif skill =~ /Void/
  141. waitrt?
  142. reps.to_i.times { fput "illusion teach #{person} void"; result = matchtimeout( 60, "#{person} holds up\.*?The miniature fissure begins to feed on the air around you" ); if result == false; failcount = failcount + 1; end }
  143. if failcount > 0
  144. fput "whisper #{person} I think you failed a few reps...I'll give you another chance at those now."
  145. failcount.to_i.times { fput "illusion teach #{person} void"; matchtimeout( 60, "#{person} holds up\.*?The miniature fissure begins to feed on the air around you" ) }
  146. else
  147. fput "whisper #{person} I've taught you the number of times you required."
  148. end
  149. elsif skill =~ /Shadow/
  150. waitrt?
  151. reps.to_i.times { fput "illusion teach #{person} shadow"; result = matchtimeout( 60, "#{person} gazes intently at \.*? the other isolated where \.*? used to be" ); if result == false; failcount = failcount + 1; end }
  152. if failcount > 0
  153. fput "whisper #{person} I think you failed a few reps...I'll give you another chance at those now."
  154. failcount.to_i.times { fput "illusion teach #{person} shadow"; matchtimeout( 60, "#{person} gazes intently at \.*? the other isolated where \.*? used to be" ) }
  155. else
  156. fput "whisper #{person} I've taught you the number of times you required."
  157. end
  158. elsif skill =~ /Demon/
  159. waitrt?
  160. reps.to_i.times { fput "illusion teach #{person} demon"; result = matchtimeout( 60, "stands in its place and #{person} withdraws" ); if result == false; failcount = failcount + 1; end }
  161. if failcount > 0
  162. fput "whisper #{person} I think you failed a few reps...I'll give you another chance at those now."
  163. failcount.to_i.times { fput "illusion teach #{person} demon"; matchtimeout( 60, "stands in its place and #{person} withdraws" ) }
  164. else
  165. fput "whisper #{person} I've taught you the number of times you required."
  166. end
  167. else
  168. fput "whisper #{person} I didn't catch what illusion you wanted."
  169. sleep 1
  170. end
  171. elsif role =~ /Teach/
  172. fput "nod #{person}"
  173. sleep 1
  174. fput "whisper #{person} How many reps?"
  175. y = matchtimeout( 25, "#{person} whispers, \"(\\d+)")
  176. y =~ /#{person} whispers, \"(\d+)/
  177. reps = $1.to_f
  178. if reps > 22
  179. fput "whisper #{person} that's too many reps!"
  180. next
  181. end
  182. reps = (reps/2).ceil if guildmaster == true
  183. unless reps == nil
  184. fput "whisper #{person} Are you teaching Rose or Vortex? There's no point in teaching the others."
  185. y = matchtimeout( 25, "#{person} whispers, \"(\\w+)")
  186. y =~ /#{person} whispers, \"(\w+)/
  187. skill = $1
  188. end
  189. sleep 1
  190. if skill =~ /Rose/
  191. waitrt?
  192. if guildmaster == true
  193. fput "whisper #{person} Alright, go ahead. You only need to tell me about making a rose #{reps} times, since I'm a Guildmaster."
  194. else
  195. fput "whisper #{person} Tell me about the forming of roses, then."
  196. end
  197. reps.to_i.times {
  198. matchtimeout( 30, "Making sure you are watching" )
  199. sleep 0.5
  200. waitrt?
  201. if !righthand and !lefthand
  202. fput "illusion rose"
  203. elsif righthand||lefthand == "rose"
  204. fput "eat my rose"
  205. fput "illusion rose"
  206. end
  207. }
  208. elsif skill =~ /Vortex/
  209. waitrt?
  210. if guildmaster == true
  211. fput "whisper #{person} Alright, go ahead. You only need to tell me about making a vortex #{reps} times, since I'm a Guild Master."
  212. else
  213. fput "whisper #{person} Tell me about the forming of vortices, then."
  214. end
  215. reps.to_i.times {
  216. matchtimeout( 30, "making sure to allow you to glimpse into its secrets" )
  217. sleep 0.5
  218. waitrt?
  219. if !righthand and !lefthand
  220. fput "illusion vortex"
  221. elsif righthand||lefthand == "vortex"
  222. fput "eat my vortex"
  223. fput "illusion vortex"
  224. end
  225. }
  226. else
  227. fput "whisper #{person} I'm not demonstrating anything except a Vortex or a Rose!"
  228. sleep 1
  229. end
  230. else
  231. fput "whisper #{person} sorry, start over by asking me about illusions or promotions. "
  232. sleep 1
  233. end
  234. end
  235. sleep 1
  236. fput "whisper #{person} You can start a new session now if you'd like."
  237. if mastered == true
  238. sleep 1
  239. fput "whisper #{person} Just kidding! But seriously, congratulations!"
  240. end
  241. for s in Script.running; s.unpause if s.paused; end
  242. fput "'::#{person} done" if $teaching_illusions == true
  243. $teaching_illusions = nil
  244. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement