##############################################################################
# Collapsing statue, by ldierk.
#
# Flavour vault, the statue crumbles into stones and rocks as soon as the
# player touches it.
# Rare, to keep the surprise. (Only one in hundred instances have an old,
# crumbling statue.)

# TODO:
# 1. Currently, you have to use * direction for melee attacks. This is not
#    good, an ordinary melee attack (bumping) should suffice. We don't want
#    pressure plates around the statue, the player should touch the thing.
# 2. The message ("You notice a very old statue...") should interrupt
#    travel/explore.

{{
function callback.ldierk_statue_collapse (data, triggerable, triggerer, marker, ev)
        if triggerer.type == "player_los" and not data.seen then
                crawl.mpr("You notice a very old statue. Maybe it will break if you hit it?")
                data.seen = true
        elseif triggerer.type == "wall_hit" then
                crawl.mpr("As you hit the statue it collapses.")
                local mp = dgn.point(marker:pos())
                dgn.terrain_changed( mp.x, mp.y, "floor", false, false, false)
                local stone = "stone"
                if (crawl.one_chance_in(4) ) then
                        stone = "large rock"
                end
                dgn.create_item(mp.x, mp.y, stone )
                triggerable:remove(marker)
        end
end
}}

NAME:   ldierk_statue_collapse
ORIENT: float
DEPTH:  D:3-9
SUBST: # = G:99 #:1

{{
local collapsemarker = TriggerableFunction:new {
  func="callback.ldierk_statue_collapse",
  repeated=true,
  data={seen=false}
  }

collapsemarker:add_triggerer(DgnTriggerer:new {
  type="wall_hit"
   })

collapsemarker:add_triggerer(DgnTriggerer:new {
  type="player_los"
  })

lua_marker("#", collapsemarker)

}}
KFEAT: # = granite_statue
: lua_marker("#", portal_desc {
:        desc="a very old granite statue"})

: if crawl.one_chance_in(2) then
SUBST: abc = x, de = xx.
: elseif crawl.one_chance_in(3) then
SUBST: acfh = T
: elseif crawl.one_chance_in(3) then
SUBST: abcdefgh = W
: end
SUBST: abcdefgh = .
SUBST: W : WWWw'm, ' = WWw
SUBST: T : TTTTUx

MAP
abc
d#e
fgh
ENDMAP
