overriding advancement using [advancefrom]

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
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

overriding advancement using [advancefrom]

Post by The_Gnat »

Basically i want to change what a unit advances to using [advancefrom]. However currently [advancefrom] only appends advancements to the unit. Is there a way to override the previous units advancements and change them to exactly what the [advancefrom] contains?

The reason i want to use advancefrom is because events and [modify_unit] do not change the description files of units.

Thank you!
User avatar
Ravana
Forum Moderator
Posts: 3011
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: overriding advancement using [advancefrom]

Post by Ravana »

When you use advancefrom, then you are in singleplayer context, therefore you can just define exact unit types you want.
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: overriding advancement using [advancefrom]

Post by The_Gnat »

Ravana wrote:When you use advancefrom, then you are in singleplayer context, therefore you can just define exact unit types you want.
Thank you for replying. It would be easier if there was just a way to override the advancement. Or a way to override a description file.

My problem is that i want to have two standards. One for multiplayer and one for singleplayer. If i define extra units it will confuse the multiplayer version.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: overriding advancement using [advancefrom]

Post by beetlenaut »

You can use [store_unit] and put whatever value you want in the advances_to key. That will replace what was there before.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: overriding advancement using [advancefrom]

Post by The_Gnat »

beetlenaut wrote:You can use [store_unit] and put whatever value you want in the advances_to key. That will replace what was there before.
Will this modify the description information?

Thank you for responding! :D
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: overriding advancement using [advancefrom]

Post by beetlenaut »

The help files are not tied to units in any way, so no. The descriptions come from [unit_type], which is not modified by changing units in the game. You should be able to use preprocessor commands like #ifdef in [unit_type], but I don't know if that would help.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: overriding advancement using [advancefrom]

Post by The_Gnat »

beetlenaut wrote:The help files are not tied to units in any way, so no. The descriptions come from [unit_type], which is not modified by changing units in the game. You should be able to use preprocessor commands like #ifdef in [unit_type], but I don't know if that would help.
That is very helpful! Can i define and undefine definitions in game that will then effect units description files using ifdef? For Example:

In game event:

Code: Select all

[event]
   name=moveto
   first_time_only=no

   [filter]
        {XXXXX}
   [/filter]

   #define CHANGE_DESCRIPTION_FILE
   #enddef
[/event]

In unit file:
[unit_type]
 ...
   #ifdef CHANGE_DESCRIPTION_FILE
           [advance_from]
                   unit=Swordsman
           [/advance_from]
   #endif
 ...
[/unit_type]

Would something like that work? Thank you! :D
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: overriding advancement using [advancefrom]

Post by beetlenaut »

Using an event probably won't do anything. We are talking about preprocessor directives, not variables. They cause the engine to make a permanent decision when the file is loaded. There is no reason that changing one would cause the file to be reloaded though. I was thinking that you could use #ifdef to see if MULTIPLAYER was defined when the unit type was loaded. That might work.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: overriding advancement using [advancefrom]

Post by The_Gnat »

beetlenaut wrote:Using an event probably won't do anything. We are talking about preprocessor directives, not variables. They cause the engine to make a permanent decision when the file is loaded. There is no reason that changing one would cause the file to be reloaded though. I was thinking that you could use #ifdef to see if MULTIPLAYER was defined when the unit type was loaded. That might work.
Yes, i understand definitions are only defined on game loading. In that case can i search for a definition #ifdef CAMPAIGN (i believe i have asked this question before). Or can i re-load my description files mid game in order to edit them?
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: overriding advancement using [advancefrom]

Post by beetlenaut »

Searching for a definition is what #ifdef does. Or did I misunderstand the question?

There is no way to trigger the cache to reload with WML. Since the game forces you to go to the title screen to do it manually, I doubt it could safely be done from within the game anyway.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: overriding advancement using [advancefrom]

Post by The_Gnat »

beetlenaut wrote:Searching for a definition is what #ifdef does. Or did I misunderstand the question?
Sorry about being unclear what i am meaning is: is there a way to write an #ifdef CAMPAIGN like you can write #ifdef MULTIPLAYER.

I believe that this has not been created, but that is no problem. Thank you all for your feedback and help it has been very useful! :D
User avatar
James_The_Invisible
Posts: 536
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: overriding advancement using [advancefrom]

Post by James_The_Invisible »

No, there is not a define for singleplayer mode, every campaign has its own one. But you can use #ifndef MULTIPLAYER.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: overriding advancement using [advancefrom]

Post by beetlenaut »

The_Gnat wrote:is there a way to write an #ifdef CAMPAIGN
#ifndef MULTIPLAYER

Edit: Uh...yeah. What he said. Faster than me.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: overriding advancement using [advancefrom]

Post by The_Gnat »

Thank you for your help!! :D
Post Reply