How to make a new 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
nitaybenshahar
Posts: 4
Joined: December 25th, 2011, 8:31 am

How to make a new ability

Post by nitaybenshahar »

Hello,

i want to make a new ability that interacts with a units xp.
I looked at the file abilities.cfg but i figured it is no help. i need to get to where the abilities are actually programmed, as far as i know.
could anyone please tell me where i could find the code or give another suggestion?

any help will be appreciated.
CherryDelight
Posts: 32
Joined: January 14th, 2012, 10:40 pm

Re: How to make a new ability

Post by CherryDelight »

AFAIK, this would have to be done with an [event] inside [unit_type]. You could then just make a dummy ability to display the name in the unit's information.
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: How to make a new ability

Post by SkyOne »

nitaybenshahar wrote:I looked at the file abilities.cfg but i figured it is no help.
Those abilities are defined in scenario, unit, and any other files. So those are exactly what abilities are.
nitaybenshahar wrote:i need to get to where the abilities are actually programmed
Anywhere on your CFG file in your campaign folder.


For example, on the default abilities.cfg, there is:

Code: Select all

#define ABILITY_HEALS
    # Canned definition of the heal+4 ability to be included in an [abilities] clause.
    [heals]
        value=4
        id=healing
        affect_allies=yes
        name= _ "heals +4"
        female_name= _ "female^heals +4"
        description=  _ "Heals +4:
Allows the unit to heal adjacent allied units at the beginning of our turn.

A unit cared for by this healer may heal up to 4 HP per turn, or stop poison from taking effect for that turn.
A poisoned unit cannot be cured of its poison by a healer, and must seek the care of a village or a unit that can cure."
        affect_self=no
        poison=slowed
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
#enddef
this ability is defined as {ABILITY_HEALS} either in scenario files and unit files usually.

As an example (the case of unit files)
Elvish Shaman:
Spoiler:
In the case of a scenario file (sorry, from mine):
Spoiler:
You can also add any abilities in any [event]s by using an [object] tag.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
nitaybenshahar
Posts: 4
Joined: December 25th, 2011, 8:31 am

Re: How to make a new ability

Post by nitaybenshahar »

I wanted to create an ability of my own: kind of like healing but instead it is 'teaching' units around (adding to their xp)

thanks for the help
CherryDelight
Posts: 32
Joined: January 14th, 2012, 10:40 pm

Re: How to make a new ability

Post by CherryDelight »

[heals] can only affect units' hit points. Like I said earlier, you'll probably need to script a side turn event for this, probably with a {FOREACH} to find each relevant healer and apply the experience bonus to its adjacent allies.

If you want this to display in unit descriptions, you'll also need to create a dummy ability in each relevant [unit_type] or [unit]:

Code: Select all

[unit_type]
  # Blah, blah, blah.
    [abilities]
        [custom]
            id=teacher
            name= _"teacher"
            description= _"Teacher: this unit increases its allies' experience points at the beginning of its turn."
        [/custom]
    [/abilities]
  # Etc. etc. ad nauseum
[/unit_type]
This will also make it easier for you to filter your event (ability=teacher) to find all the "teacher" units on a given side at the beginning of each side turn.

I don't have enough time to debug an event right now, so I'll see if I can write something functional for this tomorrow, if you still need help and nobody comes along with a better idea.
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: How to make a new ability

Post by Exasperation »

An ability that does this, named Battle Tutor, was implemented for the Free Saurian faction in the Era of Strife; you could start by looking to see how they did it.
Post Reply