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

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
J. Trudel
Posts: 117
Joined: Tue Aug 28, 2012 3:05 pm
Location: Montreal, Canada

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

Post by J. Trudel »

I want to execute a script only if some party members are not present. Anyone has a clue ?
The Lurker
User avatar
montagneyaya
Posts: 103
Joined: Tue May 01, 2012 11:08 pm

Re: [Help] Execute a script only if

Post by montagneyaya »

Use hook party:onDie
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: [Help] Execute a script only if

Post by cromcrom »

You can try
if party:getChampion(whomever):isAlive() == false then "whatever_script" end
A trip of a thousand leagues starts with a step.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: [Help] Execute a script only if

Post 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.
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
J. Trudel
Posts: 117
Joined: Tue Aug 28, 2012 3:05 pm
Location: Montreal, Canada

Re: [Help] Execute a script only if

Post 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.
The Lurker
Post Reply