Custom ability doesn't do anything

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

Custom ability doesn't do anything

Post by Anagkai »

...except being indicated on the unit.

So, the unit has said ability. Also I have a good number of other abilities, that do work, so it seems there is a problem with that specific one.

What it should do: Everytime a unit adjacent to and on the same side as a unit with this abilitiy dies, said side should get 1 gold.

Here's the ability code:

Code: Select all

#define ABILITY_RECYCLING
    [dummy]
        id=recycling
        name= _ "recycling"
        female_name= _ "female^recycling"
        description=_ "This unit will produce one gold whenever an adjacent allied unit dies."
    [/dummy]
	[event]
		id=recycling_produce_gold
		name=die
		first_time_only=no

		[filter_adjacent]
			ability=recycling
			adjacent=n,ne,se,s,sw,nw
		[/filter_adjacent]
	
		[gold]
			side=unit.side
			amount=1
		[/gold]

		text= _ "+1 Gold"	
	[/event]
#enddef
Hope, somebody can give me a clue...
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
User avatar
Ravana
Forum Moderator
Posts: 2997
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Custom ability doesn't do anything

Post by Ravana »

side=unit.side - no such side exists.
text= _ "+1 Gold" [event] does not use text key.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Custom ability doesn't do anything

Post by zookeeper »

Wherever it is you call that macro is not a place where [event] is recognized.

And [filter_adjacent] in an [event] has no meaning.
Anagkai
Posts: 58
Joined: February 12th, 2012, 10:05 am

Re: Custom ability doesn't do anything

Post by Anagkai »

-Why would that side not exist? Does a "die" event not have the associated (i.e. dying) unit as a variable?
-Can I use the [print]-tag?
-How would I go about implementing an ability that needs an event.
-Do I need to put the filter_adjacent inside the [filter]?
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
User avatar
Pentarctagon
Project Manager
Posts: 5562
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Custom ability doesn't do anything

Post by Pentarctagon »

Anagkai wrote: March 17th, 2018, 8:03 am -Why would that side not exist? Does a "die" event not have the associated (i.e. dying) unit as a variable?
He means it should be $unit.side, not unit.side as it is, since there is in fact no side that is literally the value "unit.side".
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
skeptical_troll
Posts: 500
Joined: August 31st, 2015, 11:06 pm

Re: Custom ability doesn't do anything

Post by skeptical_troll »

Anagkai wrote: March 17th, 2018, 8:03 am -How would I go about implementing an ability that needs an event.
-Do I need to put the filter_adjacent inside the [filter]?
-You can see some examples of unit abilities here. The [abilities] tag does not support [event], you can put it somewhere else, like inside the unit definition or in the relevant scenarios.
-yes
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: Custom ability doesn't do anything

Post by Bitron »

If you want to have the event inside your abilities tag, you can try this:

Code: Select all

#define YOUR MACRO
	[dummy]
		# your dummy
	[/dummy]

	[/abilities] # jump out of the abilities tag

	[event]
		# your event
	[/event] 

	[+abilities] # go back in
#enddef
Post Reply