Page 203 of 400

Re: Ask a simple question, get a simple answer

Posted: Mon May 29, 2017 5:44 pm
by Isaac
minmay wrote:Pretty sure by "monster group" they meant a MonsterGroupComponent, not several different manually placed monsters.
That's a good point. I almost never use monster groups, so that never occurred to me.

It's kind of tricky to do... unless there is some undocumented feature for it; (which I don't know, but that you might ;) ).

Here is one method; based on the earlier script: (It works with single and grouped monsters; or both at once.)
Image

Code: Select all

--Script_entity

--List the monsters in the set here
groups = {}
set = {	
		"zarchton_1",
		"zarchton_2",	
		"ratling_group1",
		"ratling_group2",
		"medusa_group1",
		"medusa_group2",
		"zarchton_3",
		"zarchton_4",	
	}
	

for k,entry in pairs(set) do
	if entry:match("group%d+") then
		local monstergroup = findEntity(entry)
		if monstergroup and monstergroup.monstergroup then 
			groups[#groups+1] = {["entry"] = k, ["id"] = monstergroup.id, ["mType"] = (monstergroup.monstergroup:getMonsterType()),
								 ["count"] = monstergroup.monstergroup:getCount(), ["map"] = monstergroup.level,
								 ["x"] = monstergroup.x, ["y"] = monstergroup.y, ["f"] = monstergroup.facing, ["e"] = monstergroup.elevation}						
		end
	end	
end

for x = #set, 1, -1 do
	if set[x]:match("group%d+") then
		table.remove(set, x)
	end
end	



--Adds onDie hooks
function _addHooks()	
	for x = 1, #set do
		local monster = findEntity(set[x])
		if monster and monster.monster then
		   monster.monster:addConnector("onDie", self.go.id, "deadCheck")
		end
	end
end	


--Gets called by each monster as they die
function deadCheck(caller)
	--No entries, means they are all dead
	if #set < 1 then
		dungeon_door_wooden_1.door:open()  --========<< Triggered command/ opened door
		set = {}
		groups = {}
		return
	end
	
	--removes the dying monster from the set
	for k,v in pairs(set) do
		if v == caller.go.id then
			table.remove(set, k)
			break
		end
	end	
end


function _isInGroup(object)
	local answer = false
	for k, grp in pairs(groups) do				
			if	object.level == grp.map and
				object.x == grp.x and 
				object.y == grp.y and
				object.elevation == grp.e then
				answer = true
				break
			end
	end
	return answer
end


delayedCall(self.go.id, .1, "searchGroupMembers")

--Second Pass function:-----[called by delayedCall]------------
	
function searchGroupMembers()
	for _,each in pairs(groups) do
		for object in Dungeon.getMap(each['map']):allEntities() do
			if object.monster then
				if _isInGroup(object) then			
					set[#set+1] = object.id
					_addHooks()
				end 
			end
		end
	end
end


This method requires defining a uniquely named monster for each group. Also... whatever you put in the list (set=) must actually exist on the map when the game starts.

Code: Select all

--monsters.lua

-Groups MUST have "group" followed by a number in their name
--As in the examples group1, group2, group3

defineObject{
	name = "medusa_group1",
	baseObject = "medusa",
	components = {
	},
}

defineObject{
	name = "medusa_group2",
	baseObject = "medusa",
	components = {
	},
}

defineObject{
	name = "ratling_group1",
	baseObject = "ratling1",
	components = {
	},
}

defineObject{
	name = "ratling_group2",
	baseObject = "ratling1",
	components = {
	},
}


Demo Editor Project: https://www.dropbox.com/s/jlo17fxwmula5 ... d.zip?dl=0

Re: Ask a simple question, get a simple answer

Posted: Wed May 31, 2017 12:36 am
by Torquemada
How do you unlit a torch in a torchholder, I remember I did this is log 1 with the following script

function killTorch()
scripted_torch_2:destroy()
spawn("torch_holder",l,x,y,f):addItem(spawn("torch"):setFuel(0))
end")

This does not work in log 2

Re: Ask a simple question, get a simple answer

Posted: Wed May 31, 2017 1:15 am
by Isaac
Torquemada wrote:How do you unlit a torch in a torchholder, I remember I did this is log 1 with the following script

function killTorch()
scripted_torch_2:destroy()
spawn("torch_holder",l,x,y,f):addItem(spawn("torch"):setFuel(0))
end")

This does not work in log 2

Code: Select all

torch_holder_1.light:disable()
torch_holder_1.particle:disable()
torch_holder_1.sound:disable()

Re: Ask a simple question, get a simple answer

Posted: Wed May 31, 2017 3:25 am
by minmay

Code: Select all

function killTorch()
  scripted_torch_2:destroy()
  local torch = spawn("torch")
  torch.torchitem:setFuel(0)
  spawn("torch_holder",l,x,y,f,elevation).socket:addItem(torch.item)
end

Re: Ask a simple question, get a simple answer

Posted: Wed May 31, 2017 5:20 am
by Isaac
What happens if you have a custom torch item, and you use that?

Re: Ask a simple question, get a simple answer

Posted: Wed May 31, 2017 3:19 pm
by zimberzimber
Can a conditions description be modified to display data similar to how Rage does it?

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 01, 2017 3:56 am
by minmay
Isaac wrote:What happens if you have a custom torch item, and you use that?
You replace spawn("torch") with spawn([name of your custom torch item]).

Torquemada wanted a torch holder that contains a burnt-out torch with no fuel. The code you gave does prevent the torch holder from emitting light until the next time a torch is added to it, but the torch will still have full fuel.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 01, 2017 4:27 am
by Isaac
minmay wrote:Torquemada wanted a torch holder that contains a burnt-out torch with no fuel. The code you gave does prevent the torch holder from emitting light until the next time a torch is added to it, but the torch will still have full fuel.
I missed the part about the fuel.

Do you know anything about zimber's question? I assume it's about the change in status the text when the mouse hovers over the big portrait in the inventory menu. When rage is in effect, it lists the strength bonus instead of the usual health message.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 01, 2017 6:04 am
by minmay
zimberzimber wrote:Can a conditions description be modified to display data similar to how Rage does it?
No.

Re: Ask a simple question, get a simple answer

Posted: Sat Jun 03, 2017 9:27 am
by bongobeat
Hello there,

my question may be stupid but : what is the difference between the resistance of a monster, "absorb" or "immune"?