Hubs?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Hubs?

Post by P1ayer27 »

I'm working on a co-op mod which will have many levels. In between each level, I want to warp to a shop level, where you can buy new items. How can I make it so I only have to define one map, and exiting the shop will always proceed to the next level? I was thinking about giving each player a dummy item named map01, map02, and so on, and exiting the shop would check their inventory, before proceeding to the next level, but I thought using a hub would be much simpler. I looked on the wiki, and I'm still a bit confused though.
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Hubs?

Post by XutaWoo »

You could simply use a global variable to track the player's progress, and alter which level they go to using if statements and [wiki]ChangeLevel[/wiki].
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Re: Hubs?

Post by P1ayer27 »

Ummm... what do you mean track their progress? Like, can you give an example? I don't quite follow you...
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Hubs?

Post by XutaWoo »

Code: Select all

global int 1:progress

script 8 (void)
{
	progress++;
	Exit_Normal(0);
}
Use this instead of Exit_Normal for normal levels, and...

Code: Select all

global int 1:progress

script 8 (void)
{
	switch(proggess)
	{
		case 1:
			ChangeLevel("MAP02", 0, 0, -1);
			break;
		case 2:
			ChangeLevel("MAP02", 0, 0, -1);
			break;
		case 3:
			ChangeLevel("MAP04", 0, 0, -1);
			break;
		//etc
		default:
			ChangeLevel("MAP01", 0, 0, -1);
			break;
	}


}
Use this for the shop's exit.
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Re: Hubs?

Post by P1ayer27 »

Yes, it works! ...But is there a reason why I can't just add the progress when I exit the shop? That way it can work with the original Doom levels, if it ever needed to. Unless I'm missing something...
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: Hubs?

Post by XutaWoo »

No, there isn't a reason. I just did it like that to keep the shop's exit script smaller.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Hubs?

Post by Gez »

Not much larger this way, is it?

Code: Select all

global int 1:progress

script 8 (void)
{
	progress++;
	switch(proggess)
	{
		case 1:
			ChangeLevel("MAP02", 0, 0, -1);
			break;
		case 2:
			ChangeLevel("MAP02", 0, 0, -1);
			break;
		case 3:
			ChangeLevel("MAP04", 0, 0, -1);
			break;
		//etc
		default:
			ChangeLevel("MAP01", 0, 0, -1);
			break;
	}
}
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Re: Hubs?

Post by P1ayer27 »

Thanks again for your solution, but I think I found an even easier way to do it.
Spoiler: GLOBAL Script
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Hubs?

Post by NeuralStunner »

Tip: Use Switch. It's much more clean and compact than a bunch of Ifs. Plus once the correct choice is found, it breaks out, which from a logical standpoint is more efficient.
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Re: Hubs?

Post by P1ayer27 »

Ummm... I still did use Switch. I just didn't use Progress++;. This way I can warp to a map and it won't break everything. It doesn't just add progress whenever I exit ANY level, it sets the progress based off of the information of the level you are in.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Hubs?

Post by NeuralStunner »

P1ayer27 wrote:Ummm... I still did use Switch.
Your example didn't, which is all I had to go on. Joy!
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Re: Hubs?

Post by P1ayer27 »

Notice my spoiler said "GLOBAL Script". I hadn't changed the other script, based on "all you had to go on". =\
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Hubs?

Post by NeuralStunner »

How does that... What does... Why...
Spoiler:
Seriously, I have no idea what you just tried to explain. You said you'd found "an easier way to do it", which to me says that was what you were going to use. And it certainly didn't have any Switch in there.

... Uh, I guess this is already solved, anyway. Good luck!
P1ayer27
Posts: 203
Joined: Fri Aug 14, 2009 10:05 pm

Re: Hubs?

Post by P1ayer27 »

It's not a smaller or simpler script, so I guess easier wasn't the right word. What I meant was that the other method wouldn't allow you to teleport to a level, without breaking the level flow, but the new script will allow you to do just that. Since the old method never actually set the value of the progress variable, it just added one to it, teleporting to MAP15 and then exiting would bring you to the shop, but when you exited you'd go straight to MAP01. The new way the variable is actually set, not just altered, so jumping around between maps will still keep everything intact. If you still can't understand me, just try not to worry about it too much since, like you already said, it's been solved. ;)
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Hubs?

Post by NeuralStunner »

There was no problem understanding what the script does. How it does it was, at last revision, to use a lot of Ifs.
Locked

Return to “Editing (Archive)”