Sophia has put up with me long enough and I'll post this question publically: I am a noob, so bear with.
Q: How do I make a Grappling hook using DSB?
Hey, before I post, I just found where all the methods are kept... [reads]
ok:
this is what I have: [don't cringe, this is a brute-force method of stealing other people's code, sorry]
objects.lua:
Code: Select all
obj.grappling_hook = {
name="GRAPPLE",
type="THING",
class="MISC",
mass=8,
icon=gfx.icons[128],
dungeon=gfx.rope,
methods = {
{ "CLIMB UP", 0, CLASS_NINJA, method_climbup }
{ "CLIMB DOWN", 0, CLASS_NINJA, method_climbdown }
},
fit_pouch = true,
fit_sheath = true
}
methods.lua:
Code: Select all
function method_climbup(name, ppos, who, what)
local idle_set = false
local m = lookup_method_info(name, what)
if (not m) then return end
local lev, xc, yc, face = dsb_party_coords()
local dx, dy = dsb_forward(face)
--xc = xc + dx
--yc = yc + dy
lev = lev - 1
local got_pit = dsb_fetch(lev, xc, yc, CENTER)
if (got_pit) then
local blocked = false
for d=0,4 do
local got_monster = search_for_type(lev, (xc + dx), (yc + dy), d, "MONSTER")
if (got_monster) then
blocked = true
break
end
end
if (not blocked) then
for i in pairs(got_pit) do
local v = got_pit[i]
local arch = dsb_find_arch(v)
if (arch.class == "PIT") then
if (not dsb_get_gfxflag(v, GF_INACTIVE)) then
burn_stamina(who, m.stamina_used)
att_idle(ppos, m.idleness)
idle_set = true
-- Giving the experience here is my tweak. Original DM
-- gives xp even if there is no pit. I don't like that.
xp_up(who, m.xp_class, m.xp_sub, m.xp_get)
gt_rope_use = true
dsb_party_place(lev, (xc + dx), (yc + dy), face)
end
end
end
end
end
if (not idle_set) then
att_idle(ppos, m.idleness / 2)
end
end
but.
I need to add to the monster block a check for walls:
is it something to do with -
dsb_fetch(level, x, y, tile_location)
???
cheers for any pointers on this, thanks.