Advertisement
intangibles

Untitled

Sep 1st, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.72 KB | None | 0 0
  1. ## Duskruin Cleric Run
  2. ## Libraries Removed for Common Use
  3. ## By Kalros
  4.  
  5. ## CHANGE USER COMMANDS ON LINE 99
  6. ## CHANGE USER SPELLS ON LINE 120s
  7.  
  8.   $containerJar = 'backpack' if Char.name == 'Januk'
  9.   $containerJar = 'shawl' if Char.name == 'Iloru'
  10.   $containerJar = 'backpack' if Char.name == 'Lumino'
  11.  
  12. def run_wait_script(script, var1)
  13.   start_script "#{script}", ["#{var1}"] if var1 !~ /xx/
  14.   start_script "#{script}" if var1 =~ /xx/
  15.   sleep 1
  16.   wait_while { running?("#{script}")}
  17.   waitrt?
  18.   sleep 1
  19. end
  20.  
  21. def bput(message, *matches)
  22.     waitrt?
  23.     timer = Time.now
  24.     log = []
  25.     matches.flatten!
  26.     matches.map! { |item| item.is_a?(Regexp) ? item : /#{item}/i }
  27.       clear
  28.       put message
  29.       while Time.now - timer < 5
  30.         response = get?
  31.  
  32.         if response.nil?
  33.           pause 0.1
  34.           next
  35.         end
  36.  
  37.         log += [response]
  38.  
  39.         case response
  40.         when /((?:\.\.\.wait |Wait |\.\.\. wait )([0-9]+)|^You are still stunned)/
  41.         pause Regexp.last_match(1).to_i
  42.         put message
  43.         timer = Time.now
  44.         next
  45.       when /Sorry, you may only type ahead/
  46.           pause 1
  47.           put message
  48.           timer = Time.now
  49.           next      
  50.       end
  51.  
  52.           matches.each do |match|
  53.             if (result = response.match(match))
  54.               waitrt?
  55.               return result.to_a.first
  56.             end
  57.           end
  58.         end
  59.         echo '*** No match was found after 15 seconds, dumping info'
  60.         echo "messages seen length: #{log.length}"
  61.         log.each { |message| echo "message: #{message}" }
  62.         echo "checked against #{matches}"
  63.         $FAILED_COMMAND
  64. end
  65.  
  66. def startDR(room, tokenType)
  67.     if tokenType == 'booklet'
  68.       token = 'slip'
  69.       entrance = 'entrance'
  70.     else
  71.       token = 'jar'
  72.       entrance = 'grate'
  73.     end
  74.     containerJar = $containerJar
  75.     run_wait_script("go2", room)
  76.  
  77.     bput "get my #{tokenType}", '^You reach|^Get what|^You remove'
  78.  
  79.   if lefthand != tokenType and righthand != tokenType
  80.     echo 'No token in hand, exiting.'
  81.     exit
  82.   end
  83.  
  84.   bput 'stand', '^You stand|^You are' if !standing?
  85.   bput "go #{entrance}", "^Obvious"
  86.  
  87.   bput "put my #{tokenType} in my #{containerJar}", '^You put|^You toss|^I could not'
  88. end
  89.  
  90. def checkCol()
  91.   Spell[9903].cast if Spell[9903].timeleft < 0.01 and mana > 12 ## SIGN WARDING
  92. ##  Spell[9904].cast if Spell[9904].timeleft < 0.01 and mana > 12 ## SIGN STRIKING
  93.   Spell[9907].cast if Spell[9907].timeleft < 0.01 and mana > 12 ## SIGN DEFENDING
  94. ##  Spell[9908].cast if Spell[9908].timeleft < 0.01 and mana > 12 ## SIGN SMITING
  95.   Spell[9910].cast if Spell[9910].timeleft < 0.01 and mana > 12 ## SIGN DEFLECTION
  96. ##  Spell[9912].cast if Spell[9912].timeleft < 0.01 ## SIGN SWORD
  97.   Spell[9913].cast if Spell[9913].timeleft < 0.01 ## SIGN SHIELD
  98. ##  Spell[9914].cast if Spell[9914].timeleft < 0.01 ## SIGN DISSIPATION
  99. end
  100.  
  101. ## Watch for traps
  102. ## Also uses Exec Script from duskRuinArena
  103. def arenaWatch()
  104.   res = "You glance around"
  105.   while res == "You glance around"
  106.     res = bput "watch", "You appraise|^You've already|^You glance around|^You survey"
  107.   end
  108.   matchtimeout(1, "You set yourself|^You've already spotted")
  109.   $watchAgain = false
  110. end
  111.  
  112. ## Main combat loop
  113. def duskruinArena()
  114.   $breakDuskruin = false
  115.   ## Exec script to monitor lines. it also cancels duskruin loop
  116.   ## based on line triggers. Also watchs for traps.
  117.   check_lines = <<-eos
  118.     while line = get
  119.       $breakDuskRuin = true if line =~ /^You've been defeated.  You'll/
  120.       if line =~ /^An announcer boasts, "Combatant \\w+ is triumphant|^An announcer shouts, "You've run out of time|^You've been defeated|^You surrender/
  121.         ## CHANGE THE BELOW
  122.         ## ON EXIT
  123.         if Char.name == 'Iloru'
  124.           dothistimeout "wear shield", 3, /You/
  125.           dothistimeout "stow all", 3, /You/
  126.         end
  127.         if Char.name == 'Lumino'
  128.           dothistimeout "stow all", 3, /You/
  129.         end
  130.         if Char.name == 'Januk'
  131.           dothistimeout "sheath", 3, /You/
  132. ##          dothistimeout "stow all", 3, /You/
  133.         end
  134.         $breakDuskRuin = true
  135.         exit
  136.       elsif line =~ /You appraise.+/
  137.         echo line
  138.         put $trapCommand = /\\b(roll|bob|lean|pedal|jump|duck)\\b/.match(line)
  139.       elsif line =~ /fall victim/
  140.         $watchAgain = true
  141.       end
  142.     end
  143.   eos
  144.  
  145. start_exec_script(check_lines, :quiet => true)
  146.  
  147. checkCol ## check for COL spells
  148.  
  149.  
  150.   while $breakDuskRuin == false  
  151.     while checknpcs == false # Attack Loop
  152.       if stunned?
  153.         sleep 1 until !stunned?
  154.         $watchAgain = true
  155.       end
  156.       arenaWatch() if $watchAgain
  157.       fput "stand" unless standing?
  158.       bput "sign of wracking", "You shudder" if spirit > 6 and mana < 2 if Spell[9918].known?
  159.       if mana > 1
  160.         bput "incant 302", "You"
  161.       else
  162.         bput "incant 1700", "You"
  163.       end
  164.    
  165.       ## CHECK FOR MYSTIC FOCUS
  166.       if !Spell[1711].active?
  167.         bput "get my quartz orb", "You remove a heavy quartz orb"
  168.         bput "rub my orb", "You rub"
  169.         bput "stow my orb", "You put a heavy quartz orb in your forest green backpack|What were you trying"
  170.       end
  171.     end
  172.     $watchagain = false
  173.   end
  174. end
  175.  
  176. ## Driver Loop
  177. @container = $containerJar
  178. while true
  179.   startDR(23780, 'booklet')
  180.   duskruinArena
  181.  
  182.  
  183.   waitfor "closes an arena"
  184. ##  bput "open my package", "You"
  185. ##  bput "get my blood", "You"
  186. ##  bput "redeem my blood", "You"
  187. ##  bput "remove my #{@container}", "You"
  188. ##  bput "empty package in #{@container}", "You"
  189. ##  res = bput "drop package", "You toss"
  190. ##
  191. ##  if res != "You toss"
  192. ##    echo "script error"
  193. ##    exit
  194. # end
  195. ##  bput "wear my #{@container}", "You"
  196.   exit
  197. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement