Change units side

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
Alopex95
Posts: 22
Joined: April 3rd, 2020, 12:14 pm

Change units side

Post by Alopex95 »

Hey everyone!

Is there a way to change the side of the units (including the leader)?
To be precise, I want a particular side (say side 1) to acquire all the units of another side (for example, side 2), including the leader. I also want that the death of the leader of the acquired side causes the defeat of the player. I already have a defeat condition for this: is this enough, or should something more be done since we are changing the side of the leader himself of that side?

Thanks in advance for all the suggestions.
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Change units side

Post by Lord-Knightmare »

You know, most of problems are solvable by reading the WML documentation.

For example this:
To be precise, I want a particular side (say side 1) to acquire all the units of another side (for example, side 2), including the lead
Is this:

Code: Select all

{MODIFY_UNIT (side=2) side 1}
. I already have a defeat condition for this: is this enough,
Yes. It is.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Change units side

Post by Celtic_Minstrel »

Alopex95 wrote: December 2nd, 2022, 1:31 pm I also want that the death of the leader of the acquired side causes the defeat of the player. I already have a defeat condition for this: is this enough, or should something more be done since we are changing the side of the leader himself of that side?
If by "defeat condition" you mean the defeat_condition key in [side], then no, that's not enough. That'll result in defeat when both leaders die, but not when only one leader dies.

If by "defeat condition" you mean a death event, then yes, that's enough.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Alopex95
Posts: 22
Joined: April 3rd, 2020, 12:14 pm

Re: Change units side

Post by Alopex95 »

Lord-Knightmare wrote: December 2nd, 2022, 2:00 pm You know, most of problems are solvable by reading the WML documentation.
You know, maybe did I already consult the WML documentation but didn't find what I was looking for?
For example this:
To be precise, I want a particular side (say side 1) to acquire all the units of another side (for example, side 2), including the lead
Is this:

Code: Select all

{MODIFY_UNIT (side=2) side 1}
Thanks for the snippet, I'll try it.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Change units side

Post by Helmet »

Alopex95 wrote: December 5th, 2022, 10:41 am To be precise, I want a particular side (say side 1) to acquire all the units of another side (for example, side 2), including the lead
This is how I would do it.
I included [not] to exclude a type of unit.
Change the name=turn 3 to whatever happened that triggered the event.

Code: Select all

	[event]
		name=turn 3
		[modify_unit]
			[filter]
				side=2
				[not]
					type=Giant Rat, Ogre
				[/not]
			[/filter]	
			side=1
		[/modify_unit]
	[/event]
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
Alopex95
Posts: 22
Joined: April 3rd, 2020, 12:14 pm

Re: Change units side

Post by Alopex95 »

Helmet wrote: December 5th, 2022, 3:33 pm
Alopex95 wrote: December 5th, 2022, 10:41 am To be precise, I want a particular side (say side 1) to acquire all the units of another side (for example, side 2), including the lead
This is how I would do it.
I included [not] to exclude a type of unit.
Change the name=turn 3 to whatever happened that triggered the event.

Code: Select all

	[event]
		name=turn 3
		[modify_unit]
			[filter]
				side=2
				[not]
					type=Giant Rat, Ogre
				[/not]
			[/filter]	
			side=1
		[/modify_unit]
	[/event]
That's a fine approach! I like it a lot, especially the way to personalize which units include or are not in the change process.
I will use this one!

Thanks a lot!
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Change units side

Post by Helmet »

Alopex95 wrote: December 6th, 2022, 1:50 pm That's a fine approach! I like it a lot, especially the way to personalize which units include or are not in the change process.
I will use this one!
I'm glad it was useful, and thanks for the update. When I'm reading old threads and the OP doesn't post again, I always wonder, "Did they ever solve their problem?" :)

If you get stuck again and the Wiki isn't helping, don't hesitate to post another question. I often find myself stuck, so I know firsthand how useful this forum is. I'm probably one of the Top 10 question-askers!

If you plan to upload your completed campaign to the add-on server and you're not sure what to do, my "DIY Campaign" has a pretty good explanation how to do it, conveyed using "story" text in the first scenario.

Good luck with the WML. :)
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
Alopex95
Posts: 22
Joined: April 3rd, 2020, 12:14 pm

Re: Change units side

Post by Alopex95 »

Helmet wrote: December 6th, 2022, 5:05 pm
Alopex95 wrote: December 6th, 2022, 1:50 pm That's a fine approach! I like it a lot, especially the way to personalize which units include or are not in the change process.
I will use this one!
I'm glad it was useful, and thanks for the update. When I'm reading old threads and the OP doesn't post again, I always wonder, "Did they ever solve their problem?" :)

If you get stuck again and the Wiki isn't helping, don't hesitate to post another question. I often find myself stuck, so I know firsthand how useful this forum is. I'm probably one of the Top 10 question-askers!

If you plan to upload your completed campaign to the add-on server and you're not sure what to do, my "DIY Campaign" has a pretty good explanation how to do it, conveyed using "story" text in the first scenario.

Good luck with the WML. :)
Thanks a lot for your kindness! Sorry, but sometimes I lag to reply (even to my questions!) due to real life. I confirm that your solution helped me a lot! :)
Thanks also for your availability and for your time answering my questions! I've always been a fan of Wesnoth, and now that I'm learning WML to create my levels, it's so funny and engaging. The WML documentation and especially this forum are great resources!

And, of course, when I'll complete my campaign, I'll download your tutorial campaign to upload it on the add-on server. What a neat idea you had to instruct those who need to upload finished works. :)
Post Reply