"Random" titlemaps?
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.
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.
"Random" titlemaps?
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?
Re: "Random" titlemaps?
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.
Re: "Random" titlemaps?
Hmmm, this brings up a question: Can you use scripts to change maps in a titlemap, or will they simply be ignored?
e.g.:
e.g.:
Code: Select all
script 1 OPEN { // Select a random map
Teleport_NewMap(random(70, 75), 0, 0);
}- Remmirath
- Posts: 2562
- Joined: Sun Dec 23, 2007 3:53 am
- Graphics Processor: nVidia with Vulkan support
- Location: My house
- Contact:
Re: "Random" titlemaps?
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.
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
- 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?
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
}
}Re: "Random" titlemaps?
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:Tormentor667 wrote:I'd suggest something like this:
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;
}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;
}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.§-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...
For example, if you have an arry defined like this:
Code: Select all
int A[3] = { "Hello", 7, 3.1415 };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)];
Last edited by HotWax on Thu Oct 23, 2008 1:58 pm, edited 1 time in total.
- 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?
*makes a note of the switch command...*
- 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?
You never learned out 
- Cutmanmike
- Posts: 11354
- Joined: Mon Oct 06, 2003 3:41 pm
- Operating System Version (Optional): Windows 10
- Location: United Kingdom
- Contact:
Re: "Random" titlemaps?
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!Project Dark Fox wrote:*makes a note of the switch command...*