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
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

New Ability

Post by Sir Iwein »

Actually, I'm trying to do something for Wesnoth by myself after playing it a long time.
Here is my Question: I want to make warmachines with incresed chance to hit and incresed damage if the opponent is in a castle or a village.
I copied the ability marksman and want to add a filter with the specific location of the opponent, but i dont know how to do that
#define WEAPON_SPECIAL_CATAPULT
[chance_to_hit]
id=catapult
name= _ "catapult"
description= _ "Catapult:
In castles or villages, this attack has at least 80% chance to hit."
value=80
cumulative=yes
active_on=offense
# [filter]
#if enemy on castle or village
# [/filter]
[/chance_to_hit]
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

[filter_opponent]? http://www.wesnoth.org/wiki/AbilitiesWML.

Code: Select all

[filter_opponent]
    [filter_location]
        terrain=*^V*,C*
    [/filter_location]
[/filter_opponent]
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

Post by Sir Iwein »

It still doesnt works :?
#define WEAPON_SPECIAL_CATAPULT
[chance_to_hit]
id=catapult
name= _ "catapult"
description= _ "Catapult:
In castles or villages, this attack has at least 80% chance to hit."
value=80
cumulative=yes
active_on=offense
[filter_opponent]
[filter_location]
terrain=*^V*,C*
[/filter_location]
[/filter_opponent]
[/chance_to_hit]
#enddef
its in a utils folder
it shoud be loaded by the campaign
#ifdef CAMPAIGN_ELVISH_WAR
[+units]
{~campaigns/Elvish_War/units}
[/units]
[binary_path]
path="data/campaigns/Elvish_War"
[/binary_path]
{@campaigns/Elvish_War/scenarios}
{@campaigns/Elvish_War/utils}
#endif
[attack]
name=ballista
description=_"ballista"
type=pierce
[specials]
{WEAPON_SPECIAL_CATAPULT}
[/specials]
range=ranged
damage=9
number=3
icon=attacks/javelin-orcish.png
[/attack]
So it should work, but there is no mark on the unit for the ability, there is no remark about an errror, I dont know whats the problem[/quote]
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Sir Iwein wrote:its in a utils folder
it shoud be loaded by the campaign
Always include macro definitions before the point at which they're used. Now you're including the units first, then the macros, which means that when the game preprocesses the units, it doesn't yet know that those macros exist, and therefore they are not substituted with anything.
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

Post by Sir Iwein »

Now the game gives an error, there would be a missing closing tag for the [filter_location] tag, but there is one, what can be wrong
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Sir Iwein wrote:Now the game gives an error, there would be a missing closing tag for the [filter_location] tag, but there is one, what can be wrong
A missing closing quote or the wrong number of arguments given in a macro call.
User avatar
Sir Iwein
Posts: 13
Joined: February 13th, 2008, 8:09 am

Post by Sir Iwein »

thank you, now it works :D
Post Reply