Trap Vaults


If you are interested in helping with tiles, vaults, patches or documentation, this is the place for that.

7hm

Snake Sneak

Posts: 109

Joined: Wednesday, 2nd February 2011, 03:20

Post Sunday, 6th March 2011, 01:31

Trap Vaults

I wanted somewhere to put this stuff - I'm going to describe the things and post the code. If anyone has suggestions for them, I'd appreciate. After they're up for a bit if they seem ok I'll post em to mantis.

The first trap (that I haven't put on the mantis) is a Xom altar.

The Xom altar is a small room with a mini hallway leading into an altar to the god. There is a wand in the hallway

When you approach the altar one of two things will happen.

1) if there is a monster in the room with you, Xom will laugh at you and remove the item.

2) If there is not a monster in the room, Xom will guffaw and allow you to approach. When you do pick up the item, the corridor will extend (walls are added) and a monster will appear at the other end

There is an exception: if you apport the item or the item is otherwise not where it's expected to be when you pick it up, Xom laughs at your impertinence and nothing happens to you

The wand is either teleportation, digging, or a small chance of random effects. This isn't intended to kill you, though that's a happy side effect in Xom's opinion.

This is the code used:

  Code:
function callback.xom_item_pickup(data, triggerable, triggerer, marker, ev)
  local x,y = marker:pos()
  local b = dgn.find_marker_positions_by_prop("monster", 1) [1]

  -- we check to ensure you didn't apport the item. if you did, Xom laughs at your impertinence
  -- and we remove the altar
  local c = dgn.find_marker_positions_by_prop("item", 1) [1]
  local u_x,u_y = you.pos()
  if (u_x ~= c.x) or (u_y ~= c.y) then
     crawl.god_speaks("Xom", "Xom laughs at your impertinence as space shifts around you.")
     return
  end

  -- When you pick up the item, Xom reacts visibly
  crawl.god_speaks("Xom","The space around you changes and a monster appears!")
  crawl.god_speaks("Xom","You hear laughter all around you.")

  -- This enacts the terrain changes; adding the walls and removing the altar
  for slave in iter.slave_iterator("wall_phase", 1) do
     dgn.terrain_changed(slave.x, slave.y, "rock_wall", false, false, false)
  end
 
  -- This creates the monsters
  if you.absdepth() <= 7 then
     dgn.create_monster(b.x, b.y, 'generate_awake ogre')
  elseif you.absdepth() <= 13 then
     dgn.create_monster(b.x, b.y, 'generate_awake troll')
  elseif you.absdepth() <= 17 then
     dgn.create_monster(b.x, b.y, 'generate_awake rock troll')
  elseif you.absdepth() <= 22 then
     dgn.create_monster(b.x, b.y, 'generate_awake iron troll')
  elseif you.absdepth() <= 27 then
     dgn.create_monster(b.x, b.y, 'generate_awake stone giant ; robe')
  end

end

function callback.xom_trap_step(data, triggerable, triggerer, marker, ev)
  local x,y = marker:pos()
  local a = dgn.find_marker_positions_by_prop("close_door", 1)[1]
  local c = dgn.find_marker_positions_by_prop("item", 1) [1]
  local see_mons = false
  local monster_step = false

-- If a monster steps on the trap, we don't want it to activate.  I'm not sure if
-- we should just change the trap back into a floor tile, or leave it active.  In
-- this case I left the trap active.
  if dgn.mons_at(x, y) ~= nil then
    monster_step = true
  end

  if monster_step == false then

    -- if you already apported (or otherwise got rid of the item) we need to get rid
    -- of the item
    local item_exist = true
    local stack = dgn.items_at(c.x,c.y)
    if #stack == 0 then
      item_exist = false
    else
      item_exist = true
    end

    if item_exist == false then
       dgn.grid(x, y, "floor")
       crawl.god_speaks("Xom","You sense Xom watching you.")
       return
    else
      dgn.grid(x, y, "floor")
      -- this checks to see if the spaces we'll change into walls are clear
      for slave in iter.slave_iterator("wall_phase", 1) do
         if dgn.mons_at(slave.x , slave.y) ~= nil then
     see_mons = true
   else
     if see_mons == true then
     else
     see_mons = false
     end
   end
      end   

      -- this checks to see if the spaces inside the vault are clear if see_mons
      -- didn't already change to true
      if see_mons == false then
        for slave in iter.slave_iterator("empty_space", 1) do
          if dgn.mons_at(slave.x , slave.y) ~= nil then
       see_mons = true
     else
       if see_mons == true then
       else
       see_mons = false
       end
     end
        end   
      end

      -- this determines whether or not the item will remain and warns the player
      if see_mons == false then
        crawl.god_speaks("Xom", "Xom guffaws as you eye the treasure near his altar.")
        x,y = marker:pos()
      else
        -- this eliminates the the altar, the item on the altar, the door behind the altar
        x,y = marker:pos()
        crawl.god_speaks("Xom", "Xom laughs he destroys an item near you.")
        iter.stack_destroy(c.x,c.y)
        dgn.grid(a.x,a.y, "floor")
      end
    end
  else
    return 
  end
end


And here is the map:

  Code:

###################################################################
# Xom Altar Trap
# In front of Xom's altar is a useful (preset) item.  He warns you that you shouldn't pick it up.
# If you approach the altar followed by a monster, Xom dissapears when you hit the pressure plate,
# as does the item.
# If you approach the altar alone, Xom's altar dissapears and a he turns the empty spaces into a
# closed corridor.  He then spawns a monster (+5 depth) at the other end of a corridor.
# The item you pick up is a wand geared towards escape / saving you options but with a small chance
# of random effects

NAME:    trap_god_xom
TAGS:    no_monster_gen no_item_gen
KITEM:    d = wand of teleportation / wand of digging / w:1 wand of random effects
SUBST:    X = x..
KFEAT:    ^ = pressure plate trap
KFEAT:    B = altar_xom
KPROP:    ^X.Bd| = no_rtele_into

{{
local cf = TriggerableFunction:new{func="callback.xom_item_pickup"}
local tm = TriggerableFunction:new{func="callback.xom_trap_step"}
tm:add_triggerer(DgnTriggerer:new{type="pressure_plate"})
cf:add_triggerer(DgnTriggerer:new{type="item_pickup", target="auto"})
lua_marker('d', cf)
lua_marker('^', tm)
lua_marker('d', props_marker { item = 1 })
lua_marker("m", props_marker { monster = 1})
lua_marker("|", props_marker { wall_phase = 1})
lua_marker(".", props_marker { empty_space = 1})
lua_marker("m", props_marker { empty_space = 2})
lua_marker("d", props_marker { empty_space = 3})
lua_marker("X", props_marker { empty_space = 4})
}}

SUBST:    |m : .

MAP
    xxxxxxxxx
   xxxxxxxxxxx
  xxxxX.....Xx
 xxxxxxx|||..x
xxB.d..^..m.{@
 xxxxxxx|||..x
  xxxxX.....Xx
   xxxxxxxxxxx
    xxxxxxxxx
ENDMAP



*** I have a known issue with this. If anyone has an idea of how to fix it, please let me know

When you pick up the item, it only triggers the event if you don't already have the item identified. Not really sure if there's a different trigger I should be using, if there's a workaround or if this is an unintended bug or what.

7hm

Snake Sneak

Posts: 109

Joined: Wednesday, 2nd February 2011, 03:20

Post Sunday, 6th March 2011, 02:36

Re: Trap Vaults

This is the Beogh vault that has already been posted to the mantis.

It's pretty simple. There's a room with lava pools. Two of the pools have islands filled with ogres, trolls and orcs (who do not have ranged weapons). Between those two pools is an altar to beogh. There are some items on the ground near the altar. There is also a secret door behind the altar which contains more treasure. The treasure is ok but not great.

If you are a godless orc, or a priest of beogh in good standing, he allows you through.

If you do not meet that criteria, Beogh warns you when you get near. If you continue, he alters the lava terrain to floor tiles so that the monsters can leave the island and attack you.

You will still have time to run back the other way.

Here is the code
  Code:
function callback.beogh_warn_stepped(data, triggerable, triggerer, marker, ev)
  local x, y = marker:pos()

-- This checks to see if you worship Beogh and are in good standing or are a godless
-- orc . If you do/are then you get a positive message but if you don't, Beogh warns
-- you that you should not continue towards his altar. (Monsters stepping on this
-- trap will also activate it.
  if you.god() == "Beogh" and you.piety() > 50 then
     crawl.god_speaks("Beogh" , "Your god welcomes your presense at his shrine.")
     dgn.grid(x, y, "floor")
  elseif you.race() == "Hill Orc" and you.god() == "No God" then
     crawl.god_speaks("Beogh" , "Beogh will allow you to approach his shrine.")
     dgn.grid(x, y, "floor")
  else
     if you.race() == "Demigod" then
        crawl.god_speaks("Beogh" , "The orc god booms: STAY AWAY HOLY BEING!")
     elseif you.race() == "Demonspawn" then
        crawl.god_speaks("Beogh", "The orc god booms: STAY AWAY FOUL BEING!")
     else
        crawl.god_speaks("Beogh" , "The orc god booms: STAY AWAY MORTAL!")
     end
     dgn.grid(x, y, "floor")
  end
end

function callback.beogh_trap_stepped(data, triggerable, triggerer, marker, ev)
  local x, y = marker:pos()
  local monster_step = false
-- If a monster steps on the trap, we don't want it to activate.  I'm not sure if
-- we should just change the trap back into a floor tile, or leave it active.  In
-- this case I left the trap active.
  if dgn.mons_at(x, y) ~= nil then
    monster_step = true
  end

-- This actually enacts the changes.  First it ensures that the player is the one
-- activating the trap, then it checks to see if she's a Beogh worshipper in good
-- standing or a godless orc (a potential worshipper).  If it is the player and
-- one of these cases apply to her, nothing happens.  Otherwise the trap is sprung.
  if monster_step == true then
    return
  elseif (you.god() == "Beogh" and you.piety() > 50) or
      (you.race() == "Hill Orc" and you.god() == "No God") then
    dgn.grid(x, y, "floor")
  else
    crawl.god_speaks("Beogh", "Beogh calls his wrath down upon you! The monsters attack!")
    for slave in iter.slave_iterator("bridge", 1) do
      dgn.terrain_changed(slave.x, slave.y, "floor", false, false, false)
    end
    dgn.grid(x, y, "floor")
  end
end


Here is the map
  Code:
##############################################################################
# Beogh Altar Trap
# There are many monsters (Ogres / Trolls / etc) on the lava islands. There is
# a very good item sitting on the pressure plate trap.  When you stand on
# the trap, Beogh rages that you would steal the items that were left for him
# by worshippers, and creates lava bridges so that the monsters can leave the
# island and run towards you.
# If you are a worshipper of his, or if you are a godless Orc he asks you to
# approach the altar, and does not open the bridge
#
NAME:    trap_god_beogh
TAGS:    uniq_altar_beogh temple_overflow_beogh no_monster_gen
DEPTH:    Orc: 2-4
ORIENT:    float

# , gives you a warning not to come closer
# ^ actually triggers the trap
KFEAT:    ,^ = pressure plate trap
KFEAT:   Z = altar_beogh
KFEAT:    z = alarm trap
KPROP:    ^,z1* = no_rtele_into
{{
local tm = TriggerableFunction:new{func="callback.beogh_trap_stepped",
                                   repeated=true}
local tm2 = TriggerableFunction:new{func="callback.beogh_warn_stepped",
                                   repeated=true}
tm:add_triggerer(DgnTriggerer:new{type="pressure_plate"})
tm2:add_triggerer(DgnTriggerer:new{type="pressure_plate"})
lua_marker('^', tm)
lua_marker(',', tm2)
lua_marker('M', props_marker { bridge=1 })
}}
SUBST:    M : l , L : l , 1 = 1:30 2
MONS:    w:7 troll ; robe . nothing / w:5 ogre ;  giant club | robe / w:5 orc ; war axe | robe
MONS:    w: 10 rock troll ; robe . nothing / w: 10 two-headed ogre ; giant spiked club | robe / \
    w:5 orc warrior ; broad axe | robe

MAP   
     x@xx
     x.xx   
     x.xx       
   xxx..xxx     
  xxlll.llxx   
 xxllll.lllxxx
 x...........x
xx.llll,llll.xx
x..l11l*l11l..x
x..M11l^l11M..x
x..M11lzl11M..x
xx.MlllZlllM.xx
 x...xx=xx...x
 xxxxx***xxxxx
     xxxxx
ENDMAP

Return to Contributions

Who is online

Users browsing this forum: No registered users and 12 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.