Make units hide by adding ambush ability

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
Anagkai
Posts: 36
Joined: February 12th, 2012, 10:05 am

Make units hide by adding ambush ability

Post by Anagkai » April 8th, 2018, 1:48 pm

I was trying to make hidden units in a scenario by giving them the ambush ability. I did not succeed, however. Either there is an error in the code, or the units remain visible, because they gain the ability after being placed.

This is the code:

Code: Select all

		[modify_unit]
			[filter]
				race=elf
				[not]
					type=Elvish Lady
				[/not]
			[/filter]
			{ABILITY_AMBUSH}
		[/modify_unit]
Obviously the respective units are standing on forest hexes.

Can anyone see a problem in this code?
My campaigns: Princess Nilwyn (available) & Relocate (in dev)

Caladbolg
Posts: 137
Joined: January 1st, 2016, 4:40 pm
Location: Hopelessly trapped within the Submachine

Re: Make units hide by adding ambush ability

Post by Caladbolg » April 8th, 2018, 4:12 pm

You should wrap {ABILITY_AMBUSH} inside the [abilities] tag and it should work.

Code: Select all

[modify_unit]
	[filter]
		race=elf
		[not]
			type=Elvish Lady
		[/not]
	[/filter]
	[abilities]
		{ABILITY_AMBUSH}
	[/abilities]	
[/modify_unit]
This all needs to be placed inside the prestart event to get what you want (if I understood you correctly).
Last edited by Ravana on April 8th, 2018, 4:45 pm, edited 1 time in total.
Reason: [code] should not be in [spoiler]

User avatar
Celtic_Minstrel
Developer
Posts: 1184
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Make units hide by adding ambush ability

Post by Celtic_Minstrel » April 9th, 2018, 1:33 am

You can also place {ABILITY_AMBUSH} directly in the [unit] tag. Do note however that this would result in the ability being lost when they level up (which is also the case with the modify_unit method); if you want them to keep it when they level up, you can also use an [object] placed in [modifications] in [unit].
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply