Snake Sneak
Posts: 109
Joined: Wednesday, 2nd February 2011, 03:20
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:
And here is the map:
*** 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.
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.