"Random" titlemaps?

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.
Locked
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

"Random" titlemaps?

Post by Ceeb »

I want to have several different titlemaps in my mod, or at least a way to have different views in the same map. How would I achieve that effect with an ACS script?
User avatar
Medricel
Posts: 1138
Joined: Sat Nov 20, 2004 9:47 am

Re: "Random" titlemaps?

Post by Medricel »

Set up cameras in the areas you want to show, then use [wiki]ChangeCamera[/wiki] in a script to cycle through views of the map.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: "Random" titlemaps?

Post by HotWax »

Hmmm, this brings up a question: Can you use scripts to change maps in a titlemap, or will they simply be ignored?

e.g.:

Code: Select all

script 1 OPEN { // Select a random map
     Teleport_NewMap(random(70, 75), 0, 0);
}
User avatar
Remmirath
Posts: 2562
Joined: Sun Dec 23, 2007 3:53 am
Graphics Processor: nVidia with Vulkan support
Location: My house
Contact:

Re: "Random" titlemaps?

Post by Remmirath »

I'll make a test wad and see if it works...

EDIT: i've tried something similar to what Hotwax suggested, and the script is parsed and executed, but for an unknown reason, it doesn't teleport to the last array number... :?

I'll post the example wad; i hope someone can explain this.
Attachments
random teleporter.wad
Random map teleporter
(1022 Bytes) Downloaded 26 times
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: "Random" titlemaps?

Post by Tormentor667 »

I'd suggest something like this:

Code: Select all

script 100 OPEN
{
	int titlecase;
	titlcase=random(1,5)

	if(titlecase==1)
	{
		//scripts for case 1 here, for example camera viewpoints,
		//hudmessages or whatelse you need
	}
	if(titlecase==2)
	{
		//scripts for case 2
	}
	[..]
	if(titlecase==5)
	{
		//scripts for case 5
	}
}
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: "Random" titlemaps?

Post by HotWax »

Tormentor667 wrote:I'd suggest something like this:
That works, but I'd recommend using the switch command instead. It's a powerful command that does the job of several if X = blah lines and thus reduces redundancy and makes the code look cleaner. Here's your example using a switch statement:

Code: Select all

switch(random(1, 5)) {
     case 1:
          // scripts for case 1 here
          break;
     case 2:
          // scripts for case 2
          break;
     [..]
     case 5:
          // scripts for case 5
          break;
}
In addition, you can also make a default block which is executed if none of the other cases catch the result. And to further reduce redundancy, you can make multiple cases execute the same code. Thus:

Code: Select all

switch (random(1, 7)) {
     case 1:
          // Only executed for result of 1
     case 2:
          // Executed for a result of 1 OR 2 (note the lack of a break statement in case 1)
          break;
     case 3:
     case 5:
          // Executed for a result of 3 or 5.
          break;
     default:
          // Executed for any other value (4, 6 or 7 in this example)
          break;
}
§-Morpheus-§ wrote:EDIT: i've tried something similar to what Hotwax suggested, and the script is parsed and executed, but for an unknown reason, it doesn't teleport to the last array number... :?
I can't check the map right now, but that sounds like you might be using an array incorrectly. Arrays are 0-index, which means they start counting at 0 and end at one less than the declared array size.

For example, if you have an arry defined like this:

Code: Select all

int A[3] = { "Hello", 7, 3.1415 };
"Hello" is actually A[0], not A[1] (which is 7). A[2] is 3.1415 and A[3] doesn't exist.

If you were to create code to pick one of these 3 values at random, it should look like this:

Code: Select all

int B = A[random(0, 2)];
Just a shot in the dark.
Last edited by HotWax on Thu Oct 23, 2008 1:58 pm, edited 1 time in total.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Re: "Random" titlemaps?

Post by Project Shadowcat »

*makes a note of the switch command...*
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: "Random" titlemaps?

Post by Tormentor667 »

You never learned out ;)
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: "Random" titlemaps?

Post by Cutmanmike »

Project Dark Fox wrote:*makes a note of the switch command...*
I did that but I always end up doing it that way out of bad habits. I really should start using it because in theory it will make my wad smaller! :o
Locked

Return to “Editing (Archive)”