1# Trog burns a book at his altar.
2#
3# He only does so if both the altar and the book are in sight of the player.
4# This should give sneaky players an opportunity to apport the book, but
5# only if they spot the vault in time.
6
7{{
8function callback.trog_book_convert_book(data, triggerable,
9                                          triggerer, marker, ev)
10  if data.turns ~= you.turns() then
11    data.tc = data.tc + 1
12    data.turns = you.turns()
13  end
14
15  if data.tc < 3 then
16    return
17  end
18
19  if data.triggered == true then
20    return
21  end
22
23  local m = dgn.find_marker_positions_by_prop("slave_name", "trog_book")[1]
24  if m ~= nil then
25    local _x, _y = m:xy()
26
27    if not you.see_cell(_x, _y) then
28      return
29    end
30
31    for book in iter.stash_iterator(_x, _y) do
32      if string.find(book.name(), 'Retrieval') then
33        book.destroy()
34        dgn.place_cloud(_x, _y, "flame", 15)
35        crawl.god_speaks("Trog", "The spellbook bursts into flames! "
36                              .. "Trog roars with delight!")
37      end
38    end
39    data.triggered = true
40  end
41end
42}}
43
44
45NAME:   trog_book
46TAGS:   temple_overflow_trog temple_overflow_1
47KFEAT:  _ = altar_trog
48{{
49local tm = TriggerableFunction:new{func="callback.trog_book_convert_book",
50  repeated=true, data={turns=you.turns(), tc=0, triggered=false} }
51tm:add_triggerer(DgnTriggerer:new{type="player_los"})
52lua_marker('_', tm)
53}}
54MARKER: b = lua:portal_desc {slave_name="trog_book"}
55KFEAT:  b = .
56KITEM:  b = randbook title:Retrieval spells:apportation numspells:1
57MAP
58xxxxxxx
59x.....xxx
60x._.b....@
61x.....xxx
62xxxxxxx
63ENDMAP
64