Make units hide by adding ambush ability

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

Make units hide by adding ambush ability

Post by Anagkai »

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) & Home of the Undead (available)
Caladbolg
Posts: 198
Joined: January 1st, 2016, 4:40 pm
Location: Hopelessly trapped within the Submachine

Re: Make units hide by adding ambush ability

Post by Caladbolg »

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: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Make units hide by adding ambush ability

Post by Celtic_Minstrel »

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.
Former maintainer of Steelhive.
Post Reply