Changing unit types

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
DeCoolest_Cat
Posts: 128
Joined: December 5th, 2015, 8:29 pm

Changing unit types

Post by DeCoolest_Cat »

In my campaign, there is a scenario similar to "Capturing the Ogres" in Eastern Invasion. You recruit dwarves to try and capture bears. So lets say I recruit two thunderers and a fighter. I have also created bear rider units (with fighter and thunderer variants). I want to know is there any way to change the fighter to the fighter version of the bear rider, and the thunderer to their version of the bear rider in the next scenario. I'm assuming it would have to be done in the recall list, but correct me if I'm wrong.
Author of beta campaign Kalbruk's Journey - My art thread - My collection of single player scenarios: The Archives
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Changing unit types

Post by Ravana »

Wouldnt {VARIABLE unit.type bear_thunderer} work for you? If those different variants have same type then you might need to use [object] to select which one.

Doesnt matter much if you want to do it in recall list of normally.
User avatar
DeCoolest_Cat
Posts: 128
Joined: December 5th, 2015, 8:29 pm

Re: Changing unit types

Post by DeCoolest_Cat »

Ravana wrote:Wouldnt {VARIABLE unit.type bear_thunderer} work for you?
I'm not entirely sound with variables, but most likely it would. However, would something like this here work as well?

Code: Select all

[if]
     [have_unit]
         type=Dwarvish Thunderer
     [/have_unit]
     [then]
          [modify_unit]
             type=Bear Thunderer
          [/modify_unit]
     [/then]
[/if]
Author of beta campaign Kalbruk's Journey - My art thread - My collection of single player scenarios: The Archives
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Changing unit types

Post by zookeeper »

DirectActionsWML#.5Btransform_unit.5D looks like what you want.
User avatar
DeCoolest_Cat
Posts: 128
Joined: December 5th, 2015, 8:29 pm

Re: Changing unit types

Post by DeCoolest_Cat »

Thanks, zookeeper. So if I read that correctly I would change "[modify_unit]" to "[transform_unit]" and "type=" to "transform_to="?
Author of beta campaign Kalbruk's Journey - My art thread - My collection of single player scenarios: The Archives
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Changing unit types

Post by Ravana »

Yes. Notice that unless you also include some filter, it will change all units.
User avatar
DeCoolest_Cat
Posts: 128
Joined: December 5th, 2015, 8:29 pm

Re: Changing unit types

Post by DeCoolest_Cat »

So this would be it? If so, thanks to both of you!

Code: Select all

[if]
     [have_unit]
          type=Dwarvish Thunderer
     [/have_unit]
     [then]
          [transform_unit]
               [filter]
                    type=Dwarvish Thunderer
               [/filter]
               transform_to=Bear Thunderer
          [/transform_unit]
     [/then]
[/if]
Author of beta campaign Kalbruk's Journey - My art thread - My collection of single player scenarios: The Archives
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Changing unit types

Post by zookeeper »

Except it said not to use a [filter] tag.
User avatar
DeCoolest_Cat
Posts: 128
Joined: December 5th, 2015, 8:29 pm

Re: Changing unit types

Post by DeCoolest_Cat »

Forgot about that. So should I put the [filter] tags outside of the [transform_unit] tags?
Author of beta campaign Kalbruk's Journey - My art thread - My collection of single player scenarios: The Archives
GbDorn
Posts: 60
Joined: March 26th, 2014, 5:07 pm

Re: Changing unit types

Post by GbDorn »

DeCoolest_Cat wrote:should I put the [filter] tags outside of the [transform_unit] tags?
No, just remove them. And you don't need the [if] [have_unit] [then] construct ([transform_unit] will just do nothing if no unit matches the filter)
Note that [transform_unit]:
- does not modify hit points and move points (just max hit points and max move points), so you may want to add some code to handle this,
- does not work on units in the recall list (as it is unclear to me when you want the change to happen).
Post Reply