Zoable doors?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Zoable doors?

Post by Gambit37 »

I'm trying to understand this code, from the function zo_explode_square in damage.lua

Code: Select all

	-- Zo only works on a door with a control on it
	for i in pairs(c_objs) do
	    local v = c_objs[i]
	    local v_arch = dsb_find_arch(v)	
	    
	    if (exvar[v] and exvar[v].zoable) then
	    	local zo_value = exvar[v].zoable
	    	if (zo_value == true) then
	    		got_button = true
	    	else
	    		local z_power = calc_fireball_damage(range, dmg)
				if (z_power >= zo_value) then
					got_button = true
				end	
	    	end
	    	break
	    end
		if (v_arch.door_actuator) then
			got_button = true
			break
		end           
	end
I don't understand that first check for "zoable"? I've searched the entire base code for "zoable" and it's not used anywhere. So I tried using it in ESB and setting a door to zoable = false, which doesn't work -- I can still zo that door open/closed.

Please could you clarify what this is doing, and the correct way to make a door inst NOT zoable?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Zoable doors?

Post by Sophia »

The zoable exvar isn't used anywhere else in the base code because it's just something you'd set on the door, and only the zo spell's code would care about it.

Right now, a door can be opened with a zo spell if it is set zoable or if it has a button. So if neither of these two conditions are met, the door cannot be opened with a zo spell.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Zoable doors?

Post by Gambit37 »

Ah right! I have a cloned "fake" doorbutton that has had its function removed so that it doesn't do anything.

Clearly though that fake doorbutton is still telling DSB that the associated door is zoable.

So I should create my cloned doorbutton from a different object type, and the door will no longer be zoable?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Zoable doors?

Post by Sophia »

The thing that tells the code that a given button is a doorbutton is the door_actuator property being set on the arch. So if you set this property to false it will no longer be considered a doorbutton.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Zoable doors?

Post by Gambit37 »

OK, that works, but now I have some further problems with this:

I'm trying to make a clickable door.

It has a fake doorbutton that SHOULD NOT open the door, but that can be clicked to perform a custom function (display some text to the player.):

Code: Select all

obj.doorbutton_broken = {    
    type="FLOORUPRIGHT",
    renderer_hack="DOORBUTTON",
    class="DOORBUTTON",
    front=gfx.doorbutton,
    side=gfx.doorbutton_side,
    door_actuator=false,
    clickable = true,
    default_msg = nil,
    on_click = mhdo_doorbutton_broken
} 
I've created an invisible FLOORUPRIGHT on the same tile as the door, which is clickable and performs some custom functions:

Code: Select all

obj.door_clickzone = {
	type = "FLOORUPRIGHT",
	class = "DOORCLICKZONE",
	same_square = gfx.blank,
	front = gfx.door_clickzone,
	front_med = gfx.blank,
	front_far = gfx.blank,
	side = gfx.blank,
	side_med = gfx.blank,
	side_far = gfx.blank,
	door_actuator = false,
	clickable = true,
	default_msg = nil,
	on_click = mhdo_door_onclick
}
With my fake doorbutton set to door_actuator=false, the door is no longer zoable. Great! However, I get weird other behaviour:

Clicking the "door" (the invisible floorupright) also triggers the functions attached the fake doorbutton!

This seems like a bug to me, unless I'm doing something wrong?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Zoable doors?

Post by Sophia »

As you have already seen, the DSB port of the FTL DM dungeon has a flag set that only draws wallitem per wall. Clicks on that one wallitem are propagated to all other wallitems at the same location on the same tile. This is not how DSB ordinarily works, but it was easier to just pop in this hack rather than try to restructure all of DM's actuators. However, you're running afoul of it here-- clicking on the invisible "door" is propagating its click to the fake doorbutton in the same way.

FTL DM doesn't actually use clickable flooritems (except for doorbuttons, but they're kind of a weird hack anyway) so I think the simplest solution is to just disable this behavior for them. So that's what I'll do!
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Zoable doors?

Post by Gambit37 »

Ah OK, thanks for explaining and for looking at the fix.
Post Reply