Add new ability to a type of unit

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
Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Add new ability to a type of unit

Post by Enderlook »

I am trying to add a new ability to some type of units but it isn't working. I think I am using wrong [unit_type] but I am not sure what to do.

Code: Select all

#define MAKE_HEALERS
	[set_variables]
		name=special
		[value]
			id=NE Ancient Wose Shaman
		[/value]
		[value]
			id=Ne Saurian Holy
		[/value]
		[value]
			id=NE Saurian Prophet
		[/value]
		[value]
			id=NE_Saurian Healer
		[/value]
		[value]
			id=NE Saurian Devotee
		[/value]
		[value]
			id=NE Healer Mage
		[/value]
		[value]
			id=NE Nature Mage
		[/value]
		[value]
			id=NE Woods Mage
		[/value]
	[/set_variables]
	
	{FOREACH special index}
		[store_unit]
			[filter]
				id=$special[$index].id
			[/filter]
			variable=unit
		[/store_unit]
		[unit_type]
			[base_unit]
				id=$special[$index].id
			[/base_unit]
			[abilities]
				{ABILITY_HEALER $unit.abilities.heals.value}
			[/abilities]
		[/unit_type]
	{NEXT medic}
#enddef
User avatar
James_The_Invisible
Posts: 533
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: Add new ability to a type of unit

Post by James_The_Invisible »

As far as I know, you cannot define unit types during a scenario. If you want to give some units an ability in scenario, [object] is the way to go. But be aware that object is applied only to first unit matching filter so in order to give it to multiple units you should use it in a cycle (FOREACH).
Also you used macro NEXT incorrectly. It should be {NEXT index} (just like second argument of FOREACH macro).
Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Re: Add new ability to a type of unit

Post by Enderlook »

James_The_Invisible wrote:As far as I know, you cannot define unit types during a scenario. If you want to give some units an ability in scenario, [object] is the way to go. But be aware that object is applied only to first unit matching filter so in order to give it to multiple units you should use it in a cycle (FOREACH).
Also you used macro NEXT incorrectly. It should be {NEXT index} (just like second argument of FOREACH macro).
So, it won't affect all the unit who share the same id? Also I'm not doing an scenario. I just want to give this abilities in the normal play. Is it the same?
User avatar
Xara
Posts: 270
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: Add new ability to a type of unit

Post by Xara »

Normally, no two units should have the same ID. You can check this via :inspect, there should be some suffix to distinguish them. You should filter unit type instead, and iterate over each unit.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons
User avatar
James_The_Invisible
Posts: 533
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: Add new ability to a type of unit

Post by James_The_Invisible »

So you are making a multiplayer era/modification? Well, it does not really matter in the end, [unit_type] should do nothing in [scenario]/[multiplayer]/[era]/[modification].
Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Re: Add new ability to a type of unit

Post by Enderlook »

James_The_Invisible wrote:So you are making a multiplayer era/modification? Well, it does not really matter in the end, [unit_type] should do nothing in [scenario]/[multiplayer]/[era]/[modification].
Oh, I am doing a multiplayer era, which also has a modification. So I can't give a new ability to some types of units?
Post Reply