Guest User

Untitled

a guest
Jan 18th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.54 KB | None | 0 0
  1. # TEAMCAPTAIN apparentbliss
  2.  
  3. # include all HDA except HDAtravel
  4. include += HilariousDeathArtist.rc
  5.  
  6. msg_condense_repeats=true
  7.  
  8. easy_eat_chunks=true
  9. auto_eat_chunks=true
  10.  
  11. rest_wait_both=true
  12. rest_wait_percent=100
  13.  
  14. # caster automagic settings
  15. # use a when autofighting, stop at 20% MP, don't melee automatically
  16. automagic_enable=true
  17. automagic_slot=a
  18. automagic_stop=20
  19. automagic_fight=false
  20.  
  21.  
  22. # personal version of HDA travel with bug fixes for trunk
  23.  
  24. ##################
  25. # solHDAtravel #
  26. ##################
  27.  
  28. -- Rests up to at least 75% hp (or missing at least 30hp) and 50% mp (or missing at least 20mp)
  29. -- Eats chunks automatically, handled by auto_eat_chunks interface option
  30. -- Travels to the nearest corpse if we have no chunks and are at Very Hungry or Hungry or using Gourmand and at Full
  31. -- Automatically chops valid corpses if we are standing on them and we have no chunks
  32. -- Will stop autotravel at Near Starving
  33. -- Channels MP if you have staff of energy or worship Sif when you have extra chunks
  34. -- Casts regen out of combat if you have spare chunks and are missing hp
  35. -- TODO: better detection of non-edible corpses before standing on them
  36. -- TODO: Fix up for Vampire, Ghoul, and possibly Spriggan/Mummy
  37. -- NOTE: If you don't have rP you will still chop poisonous corpses, but not pick up their chunks
  38.  
  39. : function solHDAtravel()
  40. : local mp, max_mp = you.mp()
  41. : local hp, max_hp = you.hp()
  42. : local first_monster = next(getMonsterList())
  43. : local already_checked = (no_results() or dont_know_how_to_get_there())
  44. : local you_are_barbed = (have_barbs() and not removed_barbs())
  45. : local is_safe = (first_monster == nil)
  46. : local missing_mp = (mp < max_mp)
  47. : local missing_hp = (hp < max_hp)
  48. : local you_are_mummy = string.find(you.race(), "Mummy")
  49. : local you_are_vampire = string.find(you.race(), "Vampire")
  50. : local you_are_bloodless = you.hunger_name() == "bloodless"
  51. : local you_are_ghoul = string.find(you.race(), "Ghoul")
  52. : local have_no_chunks = number_of_chunks() == 0
  53. : local have_no_blood = number_of_potions_of_blood() == 0
  54. : local you_do_not_eat = string.find(you.race(), "Spriggan") or you_are_mummy or you_are_vampire
  55. : local need_to_recover = should_rest(hp, mp, max_hp, max_mp)
  56. : local you_are_sif = string.find(you.god(), "Sif")
  57. : local you_are_yred = string.find(you.god(), "Yred")
  58. : local you_are_zin = string.find(you.god(), "Zin")
  59. : local you_are_fedhas = string.find(you.god(), "Fedhas")
  60. : local you_are_good = string.find(you.god(), "Shining") or string.find(you.god(), "Elyvilon") or you_are_zin
  61. : local sacrifice_god = you_worship_sacrifice_god()
  62. : local lichform = string.find(you.transform(), "lich")
  63. : local bladehands = string.find(you.transform(), "blade")
  64. : local dragonform = string.find(you.transform(), "dragon")
  65. : local melded_weapon = (bladehands or dragonform)
  66. : local you_are_regen = you.regenerating()
  67. : local you_know_sublimation = known_spells["Sublimation of Blood"] and (spells.fail("Sublimation of Blood") < 20) and (mp>3)
  68. : local you_know_animate_skeleton = known_spells["Animate Skeleton"] and (spells.fail("Animate Skeleton") < 20) and (mp>1)
  69. : local you_know_animate_dead = known_spells["Animate Dead"] and (spells.fail("Animate Dead") < 20) and (mp>4)
  70. : local chunks_are_equipped = is_weapon("chunk")
  71. : local distort_weapon = is_weapon("distort")
  72. : local vamp_weapon = is_weapon("vamp") and not chunks_are_equipped
  73. : local have_a_weapon = weapon_in_inventory()
  74. : local gourmand_and_hungry = you_are_gourmand() and not (you_are_very_full() or you_are_engorged() or you_are_ghoul)
  75. : local ghoul_missing_hp = you_are_ghoul and ((hp < (max_hp - 5)) or you.rot() > 0)
  76. : local want_to_eat = (you_are_hungry() or gourmand_and_hungry or ghoul_missing_hp) and not you_do_not_eat
  77. : local have_spare_chunks = not have_no_chunks and not you_are_hungry()
  78. : local you_have_staff_of_energy = is_in_inventory("staff of energy")
  79. : local have_potion_of_blood = is_in_inventory("potion of blood") or is_in_inventory("potions of blood")
  80. : local staff_of_energy_is_equipped = is_weapon("staff of energy")
  81. : local staff_of_power_is_equipped = is_weapon("staff of power")
  82. : local staff_of_energy_letter = find_item_letter("staff of energy")
  83. : local chunks_letter = find_item_letter("chunk")
  84. : local you_are_hungerless = you_are_mummy or lichform
  85. : local no_food_issues = (you_are_hungerless or have_spare_chunks)
  86. : local should_channel_mp = ((max_mp - mp) > 5) and no_food_issues
  87. : local can_cast_regen = known_spells["Regeneration"] and (mp>3) and (spells.fail("Regeneration") < 20)
  88. : local you_have_regen_ring = is_in_inventory("regeneration")
  89. : local regen_ring_letter = find_item_letter("regeneration")
  90. : local regen_ring_is_equipped = is_ring("regeneration")
  91. : local should_regen_hp = (not (you_are_good or you_are_regen or lichform)) and ((hp/max_hp) < 0.80) and (you_have_regen_ring or can_cast_regen) and not you_are_bloodless
  92. : local should_sublimate = (not (you_are_good or lichform)) and ((mp/max_mp) < 0.60) and you_know_sublimation and mp>2 and ((hp/max_hp) > 0.95)
  93. : local should_animate_skeleton = (not (you_are_good or you_are_fedhas)) and you_know_animate_skeleton and mp>1 and (not can_not_animate())
  94. : local should_animate_dead = (not (you_are_good or you_are_fedhas)) and you_know_animate_dead and mp>4 and (not can_not_animate())
  95. : local you_want_spare_chunks = (not (have_spare_chunks or you_do_not_eat)) and (can_cast_regen or you_have_staff_of_energy or you_are_sif)
  96. : local you_want_chunks = (not you_are_hungerless and have_no_chunks and (want_to_eat or you_want_spare_chunks)) or (you_are_vampire and number_of_potions_of_blood() < 5) or (you_are_ghoul and number_of_chunks() < 6)
  97. : --crawl.mpr(string.format("you_are_fedhas is: %s", you_are_fedhas and "True" or "False"))
  98. : --crawl.mpr(string.format("should_animate_skeleton is: %s", should_animate_skeleton and "True" or "False"))
  99. : --crawl.mpr(string.format("need_to_recover is: %s", need_to_recover and "True" or "False"))
  100. : --crawl.mpr(string.format("you_want_chunks is: %s", you_want_chunks and "True" or "False"))
  101. : --crawl.mpr(string.format("want_to_eat is: %s", want_to_eat and "True" or "False"))
  102. : --crawl.mpr(string.format("number_of_potions_of_blood is: %s", number_of_potions_of_blood()))
  103. : --crawl.mpr(string.format("number_of_chunks is: %s", number_of_chunks()))
  104. : --crawl.mpr(string.format("ghoul_missing_hp is: %s", ghoul_missing_hp and "True" or "False"))
  105. : --crawl.mpr(string.format("you.hunger_name() is: %s", you.hunger_name()))
  106. : --crawl.mpr(string.format("have_spare_chunks is: %s", have_spare_chunks and "True" or "False"))
  107. : --crawl.mpr(string.format("can_cast_regen is: %s", can_cast_regen and "True" or "False"))
  108. : --crawl.mpr(string.format("you_are_not_ghoul is: %s", you_are_not_ghoul and "True" or "False"))
  109. : --crawl.mpr(string.format("you_want_spare_chunks is: %s", you_want_spare_chunks and "True" or "False"))
  110. : --crawl.mpr(string.format("you_are_hungerless is: %s", you_are_hungerless and "True" or "False"))
  111. : --crawl.mpr(string.format("have_no_chunks is: %s", have_no_chunks and "True" or "False"))
  112. : if (is_safe) then
  113. : if you_are_barbed then
  114. : rest()
  115. : elseif should_sublimate and not (you_are_vampire or lichform) then
  116. : crawl.mpr("<lightcyan>Autocasting Sublimation of Blood.</lightcyan>")
  117. : sendkeys('zm')
  118. : elseif should_channel_mp and you_are_sif and (you.piety_rank() > 0) then
  119. : crawl.mpr("<lightcyan>Autochanneling using Sif.</lightcyan>")
  120. : sendkeys('aa')
  121. : elseif should_regen_hp and can_cast_regen then
  122. : crawl.mpr("<green>Autocasting Regen.</green>")
  123. : --This assumes casting regen is bound to zr
  124. : sendkeys('zr')
  125. : elseif (not melded_weapon) and (should_channel_mp and you_have_staff_of_energy and no_food_issues) and (not (distort_weapon or vamp_weapon)) and you_are_not_felid() then
  126. : if not staff_of_energy_is_equipped then
  127. : crawl.mpr("<cyan>Switching to staff of energy.</cyan>")
  128. : sendkeys('w1')
  129. : end
  130. : crawl.mpr("<lightcyan>Autochanneling using staff of energy.</lightcyan>")
  131. : sendkeys('v')
  132. : elseif (weapon_in_slot_a() or uses_unarmed()) and (no_weapon() and have_a_weapon) or (staff_of_energy_is_equipped and (not (staff_of_energy_letter == 'a')) or (chunks_are_equipped and (not (chunks_letter == 'a')))) then
  133. : if uses_unarmed() then
  134. : crawl.mpr("<cyan>Switching to unarmed.</cyan>")
  135. : sendkeys('w-')
  136. : else
  137. : crawl.mpr("<cyan>Switching to main weapon.</cyan>")
  138. : sendkeys('wa')
  139. : end
  140. : elseif want_to_eat and number_of_chunks() > 0 then
  141. : crawl.mpr("<cyan>Autoeating chunks.</cyan>")
  142. : sendkeys('e')
  143. : elseif you_want_chunks and on_corpses() and not on_chunks() and (not can_not_butcher()) then
  144. : if should_animate_skeleton then
  145. : crawl.mpr("<cyan>Autocasting Animate Skeleton for chunks.</cyan>")
  146. : sendkeys('zA')
  147. : else
  148. : crawl.mpr("<cyan>Autochopping corpse.</cyan>")
  149. : sendkeys('c')
  150. : end
  151. : elseif you_want_chunks and (not (you_are_zin or need_to_recover or on_chunks() or on_corpses() or already_checked)) then
  152. : crawl.mpr("<yellow>You may need something to eat soon, looking for food.</yellow>")
  153. : find_corpses()
  154. : elseif you_are_starving_or_near() and have_no_chunks and (not (on_chunks() or on_corpses())) then
  155. : local have_bread = is_in_inventory("bread ration")
  156. : local have_meat = is_in_inventory("meat ration")
  157. : if have_bread or have_meat then
  158. : local result = crawl.yesnoquit("<cyan>Eat a ration?</cyan>", true, 'e')
  159. : if result == 1 and have_bread then
  160. : sendkeys('e1')
  161. : elseif result == 1 then
  162. : sendkeys('e2')
  163. : elseif result == 0 then
  164. : autoexplore()
  165. : end
  166. : if not (is_in_inventory("bread ration") or is_in_inventory("meat ration")) then
  167. : crawl.mpr("<lightred>That was your last ration! You should go get more.</lightred>")
  168. : end
  169. : else
  170. : crawl.mpr("<red>No rations left! You should look for food.</red>")
  171. : end
  172. : elseif need_to_recover and not you_are_starving() then
  173. : if you_are_bloodless and have_potion_of_blood then
  174. : crawl.mpr("<cyan>Autoquaffing potion of blood.</cyan>")
  175. : sendkeys('q1')
  176. : else
  177. : rest()
  178. : end
  179. : elseif you_are_yred and (you.piety_rank() >= 3) and (item_in_view("corpse") or item_in_view("skeleton") or on_corpses()) and not recently_mass_animated() then
  180. : crawl.mpr("<cyan>Autocasting Mass Animate Remains.</cyan>")
  181. : sendkeys('aa')
  182. : elseif (not sacrifice_god) and (item_in_view("corpse") or item_in_view("skeleton") or on_corpses()) and should_animate_dead and not already_animated() then
  183. : crawl.mpr("<cyan>Autocasting Animate Dead.</cyan>")
  184. : sendkeys('zA')
  185. : elseif (not sacrifice_god) and on_corpses() and should_animate_skeleton then
  186. : crawl.mpr("<cyan>Autocasting Animate Skeleton.</cyan>")
  187. : sendkeys('zA')
  188. : elseif you_are_yred and (you.piety_rank() >= 1) and on_corpses() then
  189. : crawl.mpr("<cyan>Autocasting Animate Remains.</cyan>")
  190. : sendkeys('aa')
  191. : else
  192. : --This does the general travelling
  193. : autoexplore()
  194. : end
  195. : else
  196. : --This will provide the "foo is nearby" message
  197. : autoexplore()
  198. : end
  199. : end
  200.  
  201. <
  202.  
  203. function sendkeys(command)
  204. crawl.flush_input()
  205. crawl.sendkeys(command)
  206. coroutine.yield(true)
  207. crawl.flush_input()
  208. end
  209.  
  210. function should_rest(hp, mp, max_hp, max_mp)
  211. local you_are_mummy = string.find(you.race(), "Mummy")
  212. local you_are_deep_dwarf = string.find(you.race(), "Deep Dwarf")
  213. local bloodless_vampire = (number_of_potions_of_blood() == 0) and (you.hunger_name() == "bloodless")
  214. local can_not_regen = you_are_deep_dwarf or bloodless_vampire
  215. local missing_hp = (hp < (max_hp*0.80)) or ((max_hp-hp) > 30)
  216. local missing_mp = (mp < (max_mp*0.80)) or ((max_mp-mp) > 20)
  217. return missing_mp
  218. or (missing_hp and not can_not_regen)
  219. or you.slowed()
  220. or you.poisoned()
  221. or you.confused()
  222. or you.exhausted()
  223. or (((hp < max_hp) or (mp < max_mp)) and you_are_mummy)
  224. end
  225.  
  226. -- Hungry, Very Hungry, Near Starving, Starving
  227. function you_are_hungry()
  228. return not you_are_not_hungry() and ((string.find(you.hunger_name(), "hungry")) or you_are_starving_or_near())
  229. end
  230.  
  231. -- Normal Satiation
  232. function you_are_not_hungry()
  233. return (string.find(you.hunger_name(), "not hungry"))
  234. end
  235.  
  236. -- Engorged
  237. function you_are_engorged()
  238. return (string.find(you.hunger_name(), "completely stuffed"))
  239. end
  240.  
  241. -- Very full
  242. function you_are_very_full()
  243. return (string.find(you.hunger_name(), "very full"))
  244. end
  245.  
  246. -- Near Starving
  247. function you_are_near_starving()
  248. return (string.find(you.hunger_name(), "near starving"))
  249. end
  250.  
  251. -- Near Starving, Starving
  252. function you_are_starving_or_near()
  253. return (string.find(you.hunger_name(), "starving"))
  254. end
  255.  
  256. -- Starving
  257. function you_are_starving()
  258. return you_are_starving_or_near() and not you_are_near_starving()
  259. end
  260.  
  261. function autoexplore()
  262. sendkeys('o')
  263. end
  264.  
  265. function have_barbs()
  266. return string.find(crawl.messages(10), escape("The barbed spikes become lodged in your body"))
  267. or string.find(crawl.messages(10), escape("The barbed spikes dig painfully into your body as you move"))
  268. end
  269.  
  270. function already_animated()
  271. return string.find(crawl.messages(20), escape("Autocasting Animate Dead"))
  272. end
  273.  
  274. function removed_barbs()
  275. return string.find(crawl.messages(10), escape("You carefully extract the manticore spikes from your body"))
  276. or string.find(crawl.messages(10), escape("The manticore spikes snap loose"))
  277. end
  278.  
  279. function no_results()
  280. return string.find(crawl.messages(10), escape("Can't find anything matching that"))
  281. or string.find(crawl.messages(10), escape("You may need something to eat soon"))
  282. end
  283.  
  284. function dont_know_how_to_get_there()
  285. return string.find(crawl.messages(10), escape("know how to get there"))
  286. or string.find(crawl.messages(10), escape("Have to go through"))
  287. end
  288.  
  289. function can_not_animate()
  290. return string.find(crawl.messages(10), escape("There is nothing here that can be animated"))
  291. end
  292.  
  293. function can_not_bottle()
  294. return string.find(crawl.messages(10), escape("There isn't anything to bottle here"))
  295. end
  296.  
  297. function recently_mass_animated()
  298. return string.find(crawl.messages(10), escape("Autocasting Mass Animate Remains"))
  299. end
  300.  
  301. function can_not_butcher()
  302. return string.find(crawl.messages(10), escape("anything suitable to butcher here"))
  303. end
  304.  
  305. function can_not_eat_that()
  306. return string.find(crawl.messages(10), escape("You can't eat that"))
  307. --These strings don't seem to show up in messages
  308. --or string.find(crawl.messages(10), escape("Not only inedible but also greatly harmful"))
  309. --or string.find(crawl.messages(10), escape("It is caustic"))
  310. end
  311.  
  312. function rest()
  313. sendkeys('5')
  314. end
  315.  
  316. function you_are_gourmand()
  317. return you.gourmand() or (not you_are_not_ghoul()) or (not you_are_not_felid()) or (not you_are_not_troll()) or (string.find(you.race(), "Kobold"))
  318. end
  319.  
  320. function have_rotten_chunks()
  321. for it in inventory() do
  322. if string.find(it.name(), "chunk") and string.find(it.name(), "rott") then
  323. return false
  324. end
  325. end
  326. return true
  327. end
  328.  
  329. function number_of_chunks()
  330. for it in inventory() do
  331. if string.find(it.name(), "chunk") and string.find(it.name(), "flesh") and not food.dangerous(it) then
  332. return it.quantity
  333. end
  334. end
  335. return 0
  336. end
  337.  
  338. function number_of_potions_of_blood()
  339. for it in inventory() do
  340. if string.find(it.name(), "potion") and string.find(it.name(), "blood") then
  341. return it.quantity
  342. end
  343. end
  344. return 0
  345. end
  346.  
  347. function is_in_inventory(str)
  348. for it in inventory() do
  349. if string.find(it.name(), str) then
  350. return true
  351. end
  352. end
  353. return false
  354. end
  355.  
  356. function weapon_in_inventory()
  357. for it in inventory() do
  358. if string.find(it.class(true), "weapon") then
  359. return true
  360. end
  361. end
  362. return false
  363. end
  364.  
  365. function weapon_in_slot_a()
  366. local it = items.inslot(0)
  367. if it then
  368. return string.find(it.class(true), "weapon")
  369. else
  370. return false
  371. end
  372. end
  373.  
  374. function find_item_letter(str)
  375. for i = 0,51 do
  376. it = items.inslot(i)
  377. if it then
  378. if string.find(it.name(), str) then
  379. return items.index_to_letter(i)
  380. end
  381. end
  382. end
  383. return false
  384. end
  385.  
  386. function you_worship_sacrifice_god()
  387. return string.find(you.god(), "Trog")
  388. --or string.find(you.god(), "Oka")
  389. --or string.find(you.god(), "Makhleb")
  390. or string.find(you.god(), "Beogh")
  391. or string.find(you.god(), "Lugonu")
  392. --or string.find(you.god(), "Nemelex")
  393. end
  394.  
  395. function on_corpses()
  396. local fl = you.floor_items()
  397. for it in iter.invent_iterator:new(fl) do
  398. if string.find(it.name(), "corpse")
  399. and not string.find(it.name(), "rotting")
  400. and not string.find(it.name(), "plague")
  401. and not string.find(it.name(), "kobold") then
  402. return true
  403. end
  404. end
  405. return false
  406. end
  407.  
  408. function on_chunks()
  409. for it in floor_items() do
  410. if string.find(it.name(), "chunk") then
  411. return true
  412. else
  413. return false
  414. end
  415. end
  416. end
  417.  
  418. function you_are_carnivore()
  419. return you.saprovorous()
  420. end
  421.  
  422. function you_are_not_ghoul()
  423. return not (string.find(you.race(), "Ghoul"))
  424. end
  425.  
  426. function you_are_not_troll()
  427. return not (string.find(you.race(), "Troll"))
  428. end
  429.  
  430. function you_are_not_felid()
  431. return not (string.find(you.race(), "Felid"))
  432. end
  433.  
  434. function you_are_not_octopode()
  435. return not (string.find(you.race(), "Octopode"))
  436. end
  437.  
  438. function find_corpses()
  439. local race = you.race()
  440. local god = you.god()
  441. local exclude_this = ""
  442. if string.find(god, "Shining") then
  443. exlude_this = race
  444. end
  445. sendkeys(string.char(6) .. "@corpse&&!!rott&&!!kobold&&!!skel&&!!sky&&!!necrop&&!!ugly&&!!vampire&&!!corpse rot&&!!&&!!botono" .. exclude_this .. "\ra\r")
  446. end
  447.  
  448. function inventory()
  449. return iter.invent_iterator:new(items.inventory())
  450. end
  451.  
  452. function floor_items()
  453. return iter.invent_iterator:new(you.floor_items())
  454. end
  455.  
  456. function no_weapon()
  457. return (items.equipped_at("Weapon") == nil) and not uses_unarmed()
  458. end
  459.  
  460. function uses_unarmed()
  461. return not you_are_not_ghoul()
  462. or not you_are_not_troll()
  463. or not you_are_not_felid()
  464. or (you.skill("Unarmed Combat") >= 3)
  465. end
  466.  
  467. function is_weapon(str)
  468. local weapon = items.equipped_at("Weapon")
  469. if weapon then
  470. return string.find(weapon.name(), str)
  471. else
  472. return false
  473. end
  474. end
  475.  
  476. function is_ring(str)
  477. local ring1 = items.equipped_at("Left Ring")
  478. local ring2 = items.equipped_at("Right Ring")
  479. if ring1 and ring2 then
  480. return string.find(ring1.name(), str) or string.find(ring2.name(), str)
  481. elseif ring1 then
  482. return string.find(ring1.name(), str)
  483. elseif ring2 then
  484. return string.find(ring2.name(), str)
  485. else
  486. return false
  487. end
  488. end
  489.  
  490. function item_in_view(str)
  491. local x,y
  492. for x = -7,7 do
  493. for y = -7,7 do
  494. if not (x == 0 and y == 0) then
  495. local pile = items.get_items_at(x,y)
  496. if pile ~= nil then
  497. for it in iter.invent_iterator:new(pile) do
  498. if string.find(it.name(), str) and you.see_cell_no_trans(x,y) then
  499. return true
  500. end
  501. end
  502. end
  503. end
  504. end
  505. end
  506. return false
  507. end
  508.  
  509. -- Returns a table where the key is the monster description and value is the total number of that mob in your vision
  510. function getMonsterList()
  511. local monsters = {}
  512. for x = -7,7 do
  513. for y = -7,7 do
  514. m = monster.get_monster_at(x, y)
  515. local attitude_hostile = 0
  516. if m and (m:attitude() == attitude_hostile) and not (m:is_firewood()) then
  517. desc = m:desc()
  518. if (monsters[desc] == nil) then
  519. monsters[desc] = 1
  520. else
  521. monsters[desc] = monsters[desc] + 1
  522. end
  523. end
  524. end
  525. end
  526. return monsters
  527. end
  528.  
  529. --Escapes the special characters in a string for pattern matching
  530. function escape(str)
  531. --Escapes parens and dash "()-"
  532. local escaped = str:gsub('[%(%)%-]','%\%1')
  533. --Removes any coloration parts of the string
  534. return (escaped:gsub('<[^<]*>',''))
  535. end
  536.  
  537. local function init_spells()
  538. local spell_list = {}
  539.  
  540. for _, spell_name in ipairs(you.spells()) do
  541. spell_list[spell_name] = true
  542. end
  543.  
  544. return spell_list
  545. end
  546.  
  547. known_spells = init_spells()
  548. >
Add Comment
Please, Sign In to add comment