Add new ability to a type of unit

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

Add new ability to a type of unit

Post by Enderlook » January 23rd, 2018, 10:43 pm

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: 439
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces

Re: Add new ability to a type of unit

Post by James_The_Invisible » January 23rd, 2018, 11:12 pm

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).
My content: For Power series
Ports: Danse Macabre Story of the Wose
Royal Guard/Silver Mage

Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Re: Add new ability to a type of unit

Post by Enderlook » January 24th, 2018, 1:35 am

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: 252
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: Add new ability to a type of unit

Post by Xara » January 24th, 2018, 3:31 am

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.

User avatar
James_The_Invisible
Posts: 439
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces

Re: Add new ability to a type of unit

Post by James_The_Invisible » January 24th, 2018, 12:03 pm

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].
My content: For Power series
Ports: Danse Macabre Story of the Wose
Royal Guard/Silver Mage

Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Re: Add new ability to a type of unit

Post by Enderlook » January 24th, 2018, 5:16 pm

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