Changing difficulty
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.
-
- Posts: 1226
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Changing difficulty
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
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?
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
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.
Re: Changing difficulty
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.
-
- Posts: 1226
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Changing difficulty
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.
Re: Changing difficulty
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
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?
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?
-
- Posts: 1226
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Changing difficulty
Oh. Good point.
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 So it might sort of appear to work, because it will undefine theHARDER
symbol and define theHARD
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.
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.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?
Speak softly, and carry Doombringer.
- Pentarctagon
- Project Manager
- Posts: 5567
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Changing difficulty
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
take one down, patch it around
-2,147,483,648 little bugs in the code