Exp carryover for units of different sides.

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
Vilebeggar
Posts: 153
Joined: September 5th, 2018, 5:21 pm
Location: Albania

Exp carryover for units of different sides.

Post by Vilebeggar »

So the deal is i want to make it so that the units of side 1 and 2 after scenario 1 ends, to carryover to the next scenario while retaining their exp and being part of side 1 in the next level. But how to do that?
Competitive Wesnoth. For the fans by the fans.
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: Exp carryover for units of different sides.

Post by lhybrideur »

I would say the easiest way is to add a event at the end of your scenario changing the side of the units of side 2 to side 1
something like

Code: Select all

[event]
        name=victory #maybe something a bit earlier
        [store_unit]
            [filter]
                side=2
            [/filter]
            variable=fixing
        [/store_unit]
        {FOREACH fixing i}
            [modify_unit]
                [filter]
                         id=i.id
                [/filter]
                side=1
            [/modify_unit]
            [unstore_unit]
                variable=fixing[$i]
                find_vacant=no
            [/unstore_unit]
        {NEXT i}
        {CLEAR_VARIABLE fixing}
[/event]
I didn't check if this work though.
Shiki
Developer
Posts: 348
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Exp carryover for units of different sides.

Post by Shiki »

In general, using [store_unit] to change unit values is mostly not anymore necessary nowadays.
In this particular situation, there's a neat trick with it though.

When units change their side, they change also their team color.
But, as we know that side 2 will not persist past this scenario, we can store a copy of side 2 units on side 1's recall list, and leave the units on the field unchanged. The recall list itself cannot be viewed in linger mode (after winning the scenario), so this trick is invisible to the player.

Code: Select all

	[store_unit]
		[filter]
			side=2
		[/filter]
		variable=fixing
	[/store_unit]
	[foreach]
		array=fixing
		[do]
			[set_variable]
				name=this_item.side
				value=1
			[/set_variable]
			[unstore_unit]
				variable=this_item
				x,y=recall,recall
			[/unstore_unit]
		[/do]
	[/foreach]
Try out the dark board theme.
Vilebeggar
Posts: 153
Joined: September 5th, 2018, 5:21 pm
Location: Albania

Re: Exp carryover for units of different sides.

Post by Vilebeggar »

Yeah, also the units im talking about are going to be spawned right off the start. So i don't want them to be in the recall list.
Competitive Wesnoth. For the fans by the fans.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Exp carryover for units of different sides.

Post by Ravana »

Then just store them, and in next scenario unstore.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Exp carryover for units of different sides.

Post by vghetto »

Check out the code for Wild Frontiers it stores the map, gold, villages and units for all sides and restores them all on the next scenario.
look for STORE_MAP_AND_UNITS and RESTORE_MAP_AND_UNITS

https://github.com/virtualghetto/Wild_F ... macros.cfg
Post Reply