Changing unit type mid-campaign?

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
borisblue
Posts: 91
Joined: March 4th, 2006, 1:38 am
Contact:

Changing unit type mid-campaign?

Post by borisblue »

Hey, is it possible to change a unit type mid-campaign?
As in, unit x was a frog in the first few campaigns, and then in the start of the next scenario gets kissed by a girl or sth and then changes into a prince.
I want him to keep the xp he had as a frog. Is that doable?
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Easily. Research [store_unit] - the most powerful tool at a campaign-writer's disposal.

Example:

Code: Select all

[store_unit]
[filter]
description=Frogman
[/filter]
variable=temp
kill=yes
[/store_unit]
[set_variable]
name=temp.type
value=Prince
[/set_variable]
[unstore_unit]
variable=temp
[/unstore_unit]
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
borisblue
Posts: 91
Joined: March 4th, 2006, 1:38 am
Contact:

Post by borisblue »

thanks turin!
Gee, it's a little complicated... can you recall a campaign scenario that uses this so i can check it out?
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Liberty

The guts are in a macro in the main .cfg.
Hope springs eternal.
Wesnoth acronym guide.
jg
Posts: 244
Joined: September 12th, 2005, 7:17 am

Post by jg »

So one could basically use the store_unit for knowing what level your hero is on?

Would it be something like this? Or is there a more elegant way of doing it?

Code: Select all


[store_unit]
[filter]
description=Hero
[/filter]
variable=temp
[/store_unit]

[if]
         [variable]
         name=temp.type
        value="lvl2 unit"
         [/variable]
         [then]
         ...
         [/then]
[/if]
I would use this for example to give my hero another name, like Lord "Something", instead of Master "Something", when he becomes level 2.
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

niceman wrote:So one could basically use the store_unit for knowing what level your hero is on?

Would it be something like this? Or is there a more elegant way of doing it?

Code: Select all


[store_unit]
[filter]
description=Hero
[/filter]
variable=temp
[/store_unit]

[if]
         [variable]
         name=temp.type
        value="lvl2 unit"
         [/variable]
         [then]
         ...
         [/then]
[/if]
I would use this for example to give my hero another name, like Lord "Something", instead of Master "Something", when he becomes level 2.
Yes, except in the [variable] tag replace "value" with "equals". You must consult the WML reference to learn the correct syntax. Another way to do it is to take advantage of the "advance" event, which triggers when the unit levels up. If you keep track of level-ups it would be easier to know when to change his name.
Hope springs eternal.
Wesnoth acronym guide.
jg
Posts: 244
Joined: September 12th, 2005, 7:17 am

Post by jg »

Ok, thanks for your help ...:lol: But in my/our campaign, we need it only in the beginning of a new scenario. So I wouldn't need the 'advance' event in this campaign. But in others, it might well come in handy....

P.S: Let us correct that, will come in handy
Post Reply