Keeping side 2 leader's XP for next scenario

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
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Keeping side 2 leader's XP for next scenario

Post by Helmet »

I have a campaign I'm trying to make a little fancier.

The enemy leader of Scenario 1, called Vinkus, is probably not going to be killed before a victory condition is met. Therefore, I want him to pop-up on a random turn in Scenario 2 and cause more trouble. I got the random turn part figured out; I used a randomized variable. The problem is, I can't figure out how to recall Vinkus. This is my workaround: in Scenario 2, I created a unit of the same type as Vinkus and re-used his name. Unfortunately, the copy of Vinkus in Scenario 2 has none of Vinkus' experience.

I suspect I may need to store and unstore the experience somehow. Or save_id. I don't know. I read the wiki and tried to figure it out, to no avail. Thanks for any help you can provide.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Keeping side 2 leader's XP for next scenario

Post by Pilauli »

You can probably use [store_unit] at the end of scenario 1, and then use [unstore_unit] in scenario 2. I've never done this myself, but it seems like it should work. The wiki should have details on how to use them, and you can also refer to the scenario in HttT where Delfador goes away for a while.

Okay, it looks like they use custom macros defined as follows:

Code: Select all

#define STORE_DELFADOR
    [if]
        [have_unit]
            id=Delfador
            search_recall_list=yes
        [/have_unit]
        [then]
            [store_unit]
                [filter]
                    id=Delfador
                [/filter]
                kill=yes
                variable=delfador_store
            [/store_unit]
        [/then]
    [/if]
#enddef

#define RESTORE_DELFADOR
    [if]
        [variable]
            name=delfador_store.id
            equals="Delfador"
        [/variable]
        [then]
            [unstore_unit]
                variable=delfador_store
                x,y=recall,recall
            [/unstore_unit]
            {CLEAR_VARIABLE delfador_store}
        [/then]
    [/if]
#enddef
You could probably use a simpler version, something like this:

Code: Select all

    # End of scenario 1
    [store_unit]
        [filter]
            id=Vinkus
        [/filter]
        variable=variable_that_stores_vinkus
    [/store_unit]

    # Inside the event that creates Vinkus
    [unstore_unit]
        variable=variable_that_stores_vinkus
        x,y= # Whatever location you want him in
    [/unstore_unit]
    {CLEAR_VARIABLE variable_that_stores_vinkus}
You may need to manually heal him up either just before you store him or just after you unstore him.

If you want him to be a recurring villain who always escapes at the last minute, you could use a last_breath event to heal him up, store him, and "kill" him. Then unstore him next time he needs to appear. (You would probably also need to put a backup store_unit tag in the end-of-scenario thingy so that he gets properly stored if he doesn't die.) Hmm... I should make a campaign with a character like that. Maybe a ghost?
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Keeping side 2 leader's XP for next scenario

Post by Helmet »

Pilauli wrote: September 30th, 2020, 4:35 am You can probably use [store_unit] at the end of scenario 1...

Hmm... I should make a campaign with a character like that. Maybe a ghost?
Thank you, that worked. Wow, I think I finally understand [store_unit].

I did your suggestion and healed Vinkus before storing him. Everybody on side 1 gets healed before arriving in Scenario 2, why not Vinkus? I used [heal_unit].

Ooo, I like the ghost idea. If the player kills Vinkus in Scenario 2, maybe I'll have him return in a later scenario as some sort of undead. I like the idea of him being a persistent nuisance.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Keeping side 2 leader's XP for next scenario

Post by beetlenaut »

[store_unit] creates a variable. All units on the map are automatically healed, but it wouldn't make much sense for the game to "heal" variables, even if a unit did happen to be stored in one.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Keeping side 2 leader's XP for next scenario

Post by Helmet »

Ah, thanks. That makes sense.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply