Changing difficulty

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
white_haired_uncle
Posts: 1202
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Changing difficulty

Post by white_haired_uncle »

Can I change the difficulty from within a scenario?

I'm playing with a new difficulty level, but I want it to only apply to the first chapter for now (that's the only place it's implemented). I was hoping to put a victory event at the end of the scenario, with something like

Code: Select all

#ifdef HARDER
#undef HARDER
#define HARD
#enddef
#endif
Doesn't seem to work. When I go to load the next scenario it still shows as Harder. Do I just have to throw a message and have the player reload the next scenario with the change difficulty option?

And just out of curiousity, what's actually happening when I do the above? Anything? Could one make a real mess of things this way?
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3011
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Changing difficulty

Post by Ravana »

This lets you define HARD for rest of the file (and preprocessor context). It has nothing to do with what you see on screen. And events do not affect it.
white_haired_uncle
Posts: 1202
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Changing difficulty

Post by white_haired_uncle »

Hmm, I take that back. The scenario load still shows Harder, but in the next scenario HARD is set and things like the GOLD macro work as if the difficulty has been reset to Hard.
Speak softly, and carry Doombringer.
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: Changing difficulty

Post by gnombat »

You can put preprocessor directives inside an event, but that doesn't mean the preprocessor will actually run when the event occurs. The preprocessor runs (as it name suggests) before the WML code is even processed.

So it might sort of appear to work, because it will undefine the HARDER symbol and define the HARD symbol for all lines of code processed after that, including lines in other scenarios. The preprocessor directives would actually make more sense if you put them at the end of your scenario .cfg file (or the beginning of the next scenario .cfg file) rather than inside an event.

But I wouldn't expect that to actually change the program's own notion of what the selected difficulty is. (The selected difficulty affects which preprocessor symbols are defined, not the other way around.) So presumably if you save the game it stores the originally selected difficulty?
white_haired_uncle
Posts: 1202
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Changing difficulty

Post by white_haired_uncle »

gnombat wrote: March 24th, 2024, 8:49 pm You can put preprocessor directives inside an event, but that doesn't mean the preprocessor will actually run when the event occurs. The preprocessor runs (as it name suggests) before the WML code is even processed.
Oh. Good point.
gnombat wrote: March 24th, 2024, 8:49 pm So it might sort of appear to work, because it will undefine the HARDER symbol and define the HARD symbol for all lines of code processed after that, including lines in other scenarios. The preprocessor directives would actually make more sense if you put them at the end of your scenario .cfg file (or the beginning of the next scenario .cfg file) rather than inside an event.
Just so happens that's where they were. In an event, but also more or less at the end of the file.
gnombat wrote: March 24th, 2024, 8:49 pm But I wouldn't expect that to actually change the program's own notion of what the selected difficulty is. (The selected difficulty affects which preprocessor symbols are defined, not the other way around.) So presumably if you save the game it stores the originally selected difficulty?
I don't know. Probably. I didn't bother to look. Even though some things seem to work, I don't trust it will cover everything. I'm not looking to do it that way, I'm looking to see if there is a way to do it.
Speak softly, and carry Doombringer.
User avatar
Pentarctagon
Project Manager
Posts: 5566
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Changing difficulty

Post by Pentarctagon »

This probably would be easier to implement with a plain WML variable and then adding handling to further adjust the relevant values/settings based on the variable's value.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply