Advertisement
Guest User

Automatic Safe Tile Marking - Inverse Version

a guest
Jun 22nd, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. # Automatic exclusion marking - Inverse version by PantsMacKenzie and Ultraviolent4
  2.  
  3. {
  4. function c_answer_prompt(prompt)
  5. if prompt == "Really walk into a travel-excluded area?" then
  6. return true
  7. end
  8. if prompt == "Really fly into a travel-excluded area?" then
  9. return true
  10. end
  11. if prompt == "Really swim into a travel-excluded area?" then
  12. return true
  13. end
  14. end
  15. }
  16.  
  17. # the macro to exclude tiles in LoS is set to "-" (the minus key) by default
  18. macros += M - ===mark_los
  19.  
  20. # if you play trunk on cbro or cpo you can use this to load an additional macro file (this won't override your regular macros)
  21. # additional_macro_file = marklos.macro
  22.  
  23. {
  24. function mark_los()
  25. los = you.los()
  26. for i = -los,los do
  27. for j = -los,los do
  28. if you.see_cell(i,j) then
  29. local feat = view.feature_at(i,j)
  30. if not should_unexclude(feat) then
  31. travel.set_exclude(i,j,0)
  32. end
  33. end
  34. end
  35. end
  36. end
  37. }
  38.  
  39. {
  40. function unmark_monsters()
  41. los = you.los()
  42. for i = -los,los do
  43. for j = -los,los do
  44. m = monster.get_monster_at(i,j)
  45. if m and (not should_ignore_monster(m)) then
  46. local feat = view.feature_at(i,j)
  47. if not feat_is_stair(feat) then
  48. travel.del_exclude(i,j,0)
  49. end
  50. end
  51. end
  52. end
  53. end
  54. }
  55.  
  56. {
  57. function unmark_feet()
  58. local feat = view.feature_at(0,0)
  59. los = you.los()
  60. if not feat_is_stair(feat) then
  61. travel.del_exclude(0,0,0)
  62. end
  63. end
  64. }
  65.  
  66. {
  67. function mark_all()
  68. los = you.los()
  69. for i = -los-1,los+1 do
  70. for j = -los-1,los+1 do
  71. local feat = view.feature_at(i,j)
  72. if should_exclude(feat) then
  73. travel.set_exclude(i,j,0)
  74. end
  75. if should_unexclude(feat) then
  76. travel.del_exclude(i,j,0)
  77. end
  78. end
  79. end
  80. end
  81. }
  82.  
  83. {
  84. function ready()
  85. mark_all()
  86. unmark_monsters()
  87. unmark_feet()
  88. end
  89. }
  90.  
  91. {
  92. function should_exclude(feat)
  93. return (not feat_is_floor(feat))
  94. end
  95. }
  96.  
  97. {
  98. function should_unexclude(feat)
  99. return feat_is_stair(feat)
  100. or feat_is_door(feat)
  101. or feat:find("water")
  102. or feat:find("lava")
  103. or feat:find("altar")
  104. or feat:find("shop")
  105. or feat:find("portal")
  106. or feat:find("arch")
  107. or feat:find("leading out of this place")
  108. or feat:find("gate")
  109. or feat:find("web")
  110. end
  111. }
  112.  
  113. {
  114. function should_ignore_monster(m)
  115. local name = m:name()
  116. return name:find("spire")
  117. or name:find("fulminant")
  118. or name:find("battlesphere")
  119. end
  120. }
  121.  
  122. {
  123. function feat_is_floor(feat)
  124. return feat:find("floor")
  125. end
  126. }
  127.  
  128. {
  129. function feat_is_door(feat)
  130. return feat:find("door")
  131. end
  132. }
  133.  
  134. {
  135. function feat_is_stair(feat)
  136. return (feat:find("stone_stairs_up") or
  137. (feat:find("exit_") and (feat == "exit_hell" or feat == "exit_vaults"
  138. or feat == "exit_zot" or feat == "exit_slime_pits"
  139. or feat == "exit_orcish_mines" or feat == "exit_lair"
  140. or feat == "exit_crypt" or feat == "exit_snake_pit"
  141. or feat == "exit_elven_halls" or feat == "exit_tomb"
  142. or feat == "exit_swamp" or feat == "exit_shoals"
  143. or feat == "exit_spider_nest" or feat == "exit_depths"
  144. or feat == "exit_temple" or feat == "exit_dungeon"))
  145. or feat == "escape_hatch_up"
  146. or feat:find("stone_stairs_down")
  147. or feat:find("enter_")
  148. or feat == "escape_hatch_down")
  149. end
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement