Advertisement
Guest User

Automatic Safe Tile Marking - Inverse Version

a guest
Jun 17th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 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. end
  9. }
  10.  
  11. # the macro to exclude tiles in LoS is set to "-" (the minus key) by default
  12. macros += M - ===mark_los
  13.  
  14. {
  15. function mark_los()
  16. los = you.los()
  17. for i = -los,los do
  18. for j = -los,los do
  19. if you.see_cell(i,j) then
  20. local feat = view.feature_at(i,j)
  21. if not should_unexclude(feat) then
  22. travel.set_exclude(i,j,0)
  23. end
  24. end
  25. end
  26. end
  27. end
  28. }
  29.  
  30. {
  31. function unmark_monsters()
  32. los = you.los()
  33. for i = -los,los do
  34. for j = -los,los do
  35. m = monster.get_monster_at(i,j)
  36. if m and (not should_ignore_monster(m)) then
  37. local feat = view.feature_at(i,j)
  38. if not feat_is_stair(feat) then
  39. travel.del_exclude(i,j,0)
  40. end
  41. end
  42. end
  43. end
  44. end
  45. }
  46.  
  47. {
  48. function unmark_feet()
  49. local feat = view.feature_at(0,0)
  50. los = you.los()
  51. if not feat_is_stair(feat) then
  52. travel.del_exclude(0,0,0)
  53. end
  54. end
  55. }
  56.  
  57. {
  58. function mark_all()
  59. los = you.los()
  60. for i = -los-1,los+1 do
  61. for j = -los-1,los+1 do
  62. local feat = view.feature_at(i,j)
  63. if should_exclude(feat) then
  64. travel.set_exclude(i,j,0)
  65. end
  66. if should_unexclude(feat) then
  67. travel.del_exclude(i,j,0)
  68. end
  69. end
  70. end
  71. end
  72. }
  73.  
  74. {
  75. function ready()
  76. mark_all()
  77. unmark_monsters()
  78. unmark_feet()
  79. end
  80. }
  81.  
  82. {
  83. function should_exclude(feat)
  84. return (not feat_is_floor(feat))
  85. end
  86. }
  87.  
  88. {
  89. function should_unexclude(feat)
  90. return feat_is_stair(feat)
  91. or feat_is_door(feat)
  92. or feat:find("water")
  93. or feat:find("lava")
  94. or feat:find("altar")
  95. or feat:find("shop")
  96. or feat:find("portal")
  97. end
  98. }
  99.  
  100. {
  101. function should_ignore_monster(m)
  102. local name = m:name()
  103. return name:find("spire")
  104. or name:find("fulminant")
  105. or name:find("battlesphere")
  106. end
  107. }
  108.  
  109. {
  110. function feat_is_floor(feat)
  111. return feat:find("floor")
  112. end
  113. }
  114.  
  115. {
  116. function feat_is_door(feat)
  117. return feat:find("door")
  118. end
  119. }
  120.  
  121. {
  122. function feat_is_stair(feat)
  123. return (feat:find("stone_stairs_up") or
  124. (feat:find("exit_") and (feat == "exit_hell" or feat == "exit_vaults"
  125. or feat == "exit_zot" or feat == "exit_slime_pits"
  126. or feat == "exit_orcish_mines" or feat == "exit_lair"
  127. or feat == "exit_crypt" or feat == "exit_snake_pit"
  128. or feat == "exit_elven_halls" or feat == "exit_tomb"
  129. or feat == "exit_swamp" or feat == "exit_shoals"
  130. or feat == "exit_spider_nest" or feat == "exit_depths"
  131. or feat == "exit_temple" or feat == "exit_dungeon"))
  132. or feat == "escape_hatch_up"
  133. or feat:find("stone_stairs_down")
  134. or feat:find("enter_")
  135. or feat == "escape_hatch_down")
  136. end
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement