GZDF - Multiple 'IfItem' checks

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
hvgcore
Posts: 5
Joined: Thu Aug 22, 2024 6:03 pm
Preferred Pronouns: She/Her

GZDF - Multiple 'IfItem' checks

Post by hvgcore »

If I try to have more than one 'ifitem' checks on a page of dialogue, it only reads one of them, even if that one isn't true. Is there a specific way to do it I'm missing, or is it just not possible in GZDF? Zdoom wiki says 'up to 3' ifitems are possible in USDF, and from what I've read on the forums an indefinite number should be possible (if annoying to manage) in GZDF. Am I missing something?

Example code of how I'm doing it - basically it is a basic quest with two different endings, and each ending is a different inventory item as a dummy token. This code is for turning in the quest and getting a specific response based on which ending you have. If I have just one ifitem on the page it works fine with the required item, but if both of them are on the page and only one item is present, it won't pass that flag, if that makes sense?

Code: Select all

Page
{
                Link = "QuestDoneEnding1";
		IfItem
		{
			item = "TestQuestTokenDone1";
			amount = 1;
		}

                Link = "QuestDoneEnding2";
		IfItem
		{
			item = "TestQuestTokenDone2";
			amount = 1;
		}
		PageName = "Quest2";
		Name = "testnpc";
		Panel = "NPCC";
		Dialog = "How did you go?";
		Goodbye = "RANDOM_GOODBYE";
}
User avatar
Player701
 
 
Posts: 1693
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: GZDF - Multiple 'IfItem' checks

Post by Player701 »

hvgcore wrote: Wed Aug 28, 2024 1:06 am If I have just one ifitem on the page it works fine with the required item, but if both of them are on the page and only one item is present, it won't pass that flag, if that makes sense?
Well, the wiki clearly states that:
ZDoom Wiki wrote:If all conditions are satisfied then it will jump to the page pointed to by the link property in the page block.
So it's not like you can have each IfItem block have its own corresponding Link on the same page. Instead, there is only a single Link, and all IfItem conditions must be satisfied in order for the link to trigger.

To solve this, you need one of your tokens (let's call it Token A) to signify the completion of the quest regardless of the specific ending, and the other token (Token B) to be given only in case of the alternate ending. So that in case of the first ending, the player receives only Token A, and in case of the second (alternate) ending the player gets both Token A and Token B.

The structure of your dialogue pages should then be as follows: first, check for Token A and link to the normal ending page, but on that page also check for Token B and link to the alternate ending page. Now each ending gets its own page, exactly they way you wanted.
User avatar
hvgcore
Posts: 5
Joined: Thu Aug 22, 2024 6:03 pm
Preferred Pronouns: She/Her

Re: GZDF - Multiple 'IfItem' checks

Post by hvgcore »

Yep, I'd realised upon re-reading the wiki page that ifitem includes all of them. Your idea should work nicely though I think, so thank you for that!

Return to “Scripting”