Empty party not fragging monster

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
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Empty party not fragging monster

Post by Joramun »

Would it be possible to have a flag or several flags
setting the way collision with the empty party work ?
I like the way monsters are killed in csbwin.
What Is Your Quest ?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Empty party not fragging monster

Post by Sophia »

The engine already automatically kills monsters if they happen to occupy the same space as the party.
The only thing we need to do is change the collision detection for monsters to allow the party to move into their spaces.

Add this to your startup.lua (or whatever)

Code: Select all

function monster_frag_col(self, id, what)
	-- No colliding inst means it's the party
	if (not what) then
		local empty = true
		for ppos=0,3 do
		    if (dsb_ppos_char(ppos)) then
		        empty = false
			end
		end
		if (empty) then
			return false
		end
	end
	
	-- Otherwise, handle things normally
	if (self.nonmat) then
		return nonmat_col(self, id, what)
	end	
	return true
end
Then, place this at the bottom of your dungeon's objects.lua to make the monsters use the new collision function:

Code: Select all

for o in pairs(obj) do
	local arch = obj[o]
	if (arch.type == "MONSTER") then
		arch.col = monster_frag_col
	end
end
If you've written a fancier monster collision function already, you'll need to tweak the one I gave you, but you surely get the idea. :)
Post Reply