Creating a new Leadership type 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
K-BAR
Posts: 1
Joined: November 9th, 2009, 3:18 pm

Creating a new Leadership type ability

Post by K-BAR »

I am trying to give one of my units a new leadership ability which allows it to give all adjacent, friendly unit's attacks the Magical ability. I copied the "Leadership" WML, but I don't know how to apply the Magical ability to adjacent units. I am new to writing WML so I may just be missing something obvious. Thanks for the help. Here is what I have so far:

#define ABILITY_LEADERSHIP_ARYWEN
# Canned definition of the Leadership (level 5) ability to be included in an
# [abilities] clause.
[leadership]
id=leadership
apply_to=
[attack]
[specials]
{WEAPON_SPECIAL_MAGICAL}
[/specials]
[/attack]
name= _ "Guiding Light"
female_name= _ "female^Guiding Light"
description= _ "Guiding Light:
Arywen gives each of our adjacent units a Magical power to their attacks."
affect_self=no
[affect_adjacent]
adjacent=n,ne,se,s,sw,nw
[/affect_adjacent]
[/leadership]
#enddef
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2176
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: Creating a new Leadership type ability

Post by Ken_Oh »

Yeah, you're just making stuff up. Don't do that.

Look at http://wiki.wesnoth.org/AbilitiesWML . Does it say that "apply_to=" is allowed in abilities? No, it doesn't (except for resistance). Then you make up other stuff after that.

What you actually need to do have a unique dummy ability and then insert a conditional weapon special into every unit that you want to make use of this ability.

This is going to be quite a bit more complicated than I think you were hoping it would be, but here is the initial code you need. The difficult part will be inserting the weapon special into the units. If you're using an era with all of your own units, it will be simpler, but otherwise you're going to need a recruit event to assign the specials plus some way to handle it when units level up or gain new attacks.

Code: Select all

#define ABILITY_LEADERSHIP_ARYWEN
	[dummy]
		id=guiding_light
		name= _ "Guiding Light"
		female_name= _ "female^Guiding Light"
		description= _ "Guiding Light:
		Arywen gives each of our adjacent units a Magical power to their attacks."
	[/dummy]
#enddef

Code: Select all

[chance_to_hit]
	id=magical
	name= _ "magical"
	description= _ "Magical:
This attack always has a 70% chance to hit regardless of the defensive ability of the unit being attacked."
	value=70
	cumulative=no
	[filter_adjacent]
		is_enemy=no
		ability=guiding_light
	[/filter_adjacent]
[/chance_to_hit]
Post Reply