Page 1 of 2

HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 10:24 am
by Daght
I need a script were if Tentacles1 or 2 or 3 or 4 kills a party member then open the IronDoor.
Some one can help me?

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 10:42 am
by zapibranigan
I don't think it's possible to know the entity which causes a death of a champion.

This said, I think you can do your script with the following technic :

entity_1 is an instance of your monster

onDie : use a hook which does this : if a party member died, look for the four adjacents tiles (party.x and party.y), and look for the location of entity_1 (entity_1.x, entity.y) : if the entity is present, ironDoor:open()

Will it be good for your need? I can try to write you the needed scripts if you want (but I'm at work now so I won't be able to test it at the moment! :) )

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 11:23 am
by Daght
zapibranigan wrote:I don't think it's possible to know the entity which causes a death of a champion.

This said, I think you can do your script with the following technic :

entity_1 is an instance of your monster

onDie : use a hook which does this : if a party member died, look for the four adjacents tiles (party.x and party.y), and look for the location of entity_1 (entity_1.x, entity.y) : if the entity is present, ironDoor:open()

Will it be good for your need? I can try to write you the needed scripts if you want (but I'm at work now so I won't be able to test it at the moment! :) )
I will be glad if you can write it. Do it when you can, i'm ending the dungeon on this week end and i need to try it before publishing the beta of the full mod.

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 12:42 pm
by Neikun
That sounds mean D:

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 2:07 pm
by Montis
Neikun wrote:That sounds mean D:
it's could actually be the opposite.

like "you can do x to open the door, but if someone gets killed, the door opens as well"

I might try to whip up a script this afternoon when I have time.

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 2:40 pm
by Montis
Done. Can someone try the following?

in file init.lua
SpoilerShow

Code: Select all

cloneObject{
name = "party",
baseObject = "party",
onDie = function()
	murderMystery.checkWhoDidIt()
end,
}

script_entity murderMystery
SpoilerShow

Code: Select all

-- change the following line to suit your dungeon
suspectedMurderer = "tentacles"
doorToOpen = "mysteryDoor"

-- you shouldn't need to change any of the following lines
function checkWhoDidIt()
	local x = ""
	local y = ""
	for i=1,4 do
		if i==1 then
			x = party.x+1
		elseif i == 3 then
			x = party.x-1
		else
			x = party.x
		end

		if i==2 then
			y = party.y+1
		elseif i == 4 then
			y = party.y-1
		else
			y = party.y
		end

		for j in entitiesAt(party.level, x, y) do
			if j.name == suspectedMurderer then
				findEntity(doorToOpen):open()
				return
			end
		end
	end
end

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 3:09 pm
by Emciel
i like the script name Montis ^_^

in fact... it gave me an idea... a murder mystery mod!
one of your party members killed an innocent snail, following clues you must figure out which room the murder took place in and with which weapon!

Re: HELP: i need a script for a monster/party interaction.

Posted: Fri Sep 21, 2012 3:55 pm
by Komag
a Grimrock "Clue" game? Interesting!

Re: HELP: i need a script for a monster/party interaction.

Posted: Sat Sep 22, 2012 10:12 am
by Daght
The cript crashed as a party member died and the editor was shut down.

Re: HELP: i need a script for a monster/party interaction.

Posted: Sat Sep 22, 2012 11:13 am
by Montis
The function was incorrect, but not to the part that it crashed for me. I fiddled around a bit and reproduced the crash: the script_entity name must(!) be the same name as you refer to it in the onDie function. So when you have ondie... murderMystery.checkWhoDidIt(), you must name the script_entity "murderMystery" or the game will crash when trying to call the function.

I corrected the script of the function above, that will work now.