Page 1 of 1

[Help] Execute a script only if some party members not there

Posted: Tue Nov 13, 2012 10:42 am
by J. Trudel
I want to execute a script only if some party members are not present. Anyone has a clue ?

Re: [Help] Execute a script only if

Posted: Tue Nov 13, 2012 11:04 am
by montagneyaya
Use hook party:onDie

Re: [Help] Execute a script only if

Posted: Tue Nov 13, 2012 11:19 am
by cromcrom
You can try
if party:getChampion(whomever):isAlive() == false then "whatever_script" end

Re: [Help] Execute a script only if

Posted: Tue Nov 13, 2012 11:43 am
by Xanathar
By present, do you mean alive or enabled ?

Code: Select all

for c = 1, 4 do
	if (party:getChampion(c):getEnabled() and party:getChampion(c):isAlive()) then 
		party:getChampion(c):levelUp()
	end
end
This code levels up any alive and enabled character. The getEnabled part is required to support the Toorum mode or other scenarios in your mod where characters could get disabled (if any).

Instead this:

Code: Select all

local aliveCount = 0
local allCount = 0

for c = 1, 4 do
	if (party:getChampion(c):getEnabled() then 
		allCount = allCount + 1
		
		if (party:getChampion(c):isAlive()) then 
			aliveCount = aliveCount + 1
		end
	end
end

if (aliveCount < allCount) then
    -- here at least one character is dead 
end
This will detect dead party members and work also in Toorum mode and with disabled characters.

Re: [Help] Execute a script only if

Posted: Tue Nov 13, 2012 3:17 pm
by J. Trudel
Many thanks to all ! I didn't realize that party:getChampion(whoever):getEnabled() returned if a party member was enabled or not and I am using it elsewhere in my mod. I guess I will know this one now.