[SOLVED] Problem with weapon special

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
Nyanyanyan
Posts: 10
Joined: May 11th, 2018, 10:40 pm

[SOLVED] Problem with weapon special

Post by Nyanyanyan » October 21st, 2018, 10:17 pm

I'm trying to make a pretty straightforward weapon special. It's basically supposed to be the bloodlust ability from https://wiki.wesnoth.org/WML_Abilities#Bloodlust as a weapon special. To implement this I tried

Code: Select all

#define WEAPON_SPECIAL_DOD
 [dummy]
  id=dod
  name= _ "dance of death"
  description=_"Dance of Death"
 [/dummy]
[/specials]
[/attack]
    [event]
        name=die
        first_time_only=no

        [filter_second]
			special=dod
        [/filter_second]

        {MODIFY_UNIT x,y=$x2,$y2 moves 1}
        {MODIFY_UNIT x,y=$x2,$y2 attacks_left 1}
    [/event]
[+attack]
[+specials]
#enddef
But upon launching the Era it tells me that this macro wasn't found. It's in the ability.cfg of that era which has a lot of working abilities and specials in it.
Any idea why this is happening or anything else that might be wrong with "my" code?
Thanks in advance.
Last edited by Nyanyanyan on October 22nd, 2018, 11:50 am, edited 1 time in total.

Kharn
Posts: 82
Joined: December 12th, 2005, 7:50 pm
Location: Dallas, Tx

Re: Problem with weapon special

Post by Kharn » October 21st, 2018, 11:45 pm

There may be a way to make that work given the setup you did, but I would do it a different way. Remove the weapon special, then add the following event to the unit:

Code: Select all

  [event]
        name=die
        first_time_only=no

        [filter_second]
			id=PUT_UNIT_ID_HERE
        [/filter_second]

        {MODIFY_UNIT x,y=$x2,$y2 moves 1}
        {MODIFY_UNIT x,y=$x2,$y2 attacks_left 1}
    [/event]
If this is not working try removing filters entirely and just allowing all units to have this ability to see if that even works. I have always just done events instead of using weapon specials. For example:

Code: Select all

[event]
	name=attacker_hits
	first_time_only=no
	
	[filter_attack]
		name=Theft
	[/filter_attack]
	
	[store_unit]
		[filter]
			x,y=$x1,$y1
		[/filter]
		variable=unit_att_with_charm
		mode=append
	[/store_unit]
	[set_variable]
		name=unit_att_with_charm.variables.charm_has_worked
		value=yes
	[/set_variable]
	[unstore_unit]
		variable=unit_att_with_charm
	[/unstore_unit]
	
	{CLEAR_VARIABLE unit_att_with_charm}
[/event]
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.

Nyanyanyan
Posts: 10
Joined: May 11th, 2018, 10:40 pm

Re: Problem with weapon special

Post by Nyanyanyan » October 22nd, 2018, 8:45 am

Kharn wrote:
October 21st, 2018, 11:45 pm
There may be a way to make that work given the setup you did, but I would do it a different way. Remove the weapon special, then add the following event to the unit:

Code: Select all

  [event]
        name=die
        first_time_only=no

        [filter_second]
			id=PUT_UNIT_ID_HERE
        [/filter_second]

        {MODIFY_UNIT x,y=$x2,$y2 moves 1}
        {MODIFY_UNIT x,y=$x2,$y2 attacks_left 1}
    [/event]
If this is not working try removing filters entirely and just allowing all units to have this ability to see if that even works. I have always just done events instead of using weapon specials. For example:

Code: Select all

[event]
	name=attacker_hits
	first_time_only=no
	
	[filter_attack]
		name=Theft
	[/filter_attack]
	
	[store_unit]
		[filter]
			x,y=$x1,$y1
		[/filter]
		variable=unit_att_with_charm
		mode=append
	[/store_unit]
	[set_variable]
		name=unit_att_with_charm.variables.charm_has_worked
		value=yes
	[/set_variable]
	[unstore_unit]
		variable=unit_att_with_charm
	[/unstore_unit]
	
	{CLEAR_VARIABLE unit_att_with_charm}
[/event]
The thing is that I want the special to be recognized as an actual weapon special since this is for an era not a campaign so it's important people know the abilities of units and I may apply it to more than one unit which would make everything pretty messy for those unit codes.
Anyway, my real concern for now isn't that my ability isn't running as intended, it really is that my special isn't even recognized.
Thanks for reply though.

Nyanyanyan
Posts: 10
Joined: May 11th, 2018, 10:40 pm

Re: Problem with weapon special

Post by Nyanyanyan » October 22nd, 2018, 11:49 am

Apparently the problem was that I somehow deleted the previous #enddef so yeah, it had nothing to do with the code.

Post Reply