Modifying "Abilities"

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
Varthonai
Posts: 8
Joined: April 14th, 2007, 9:08 pm

Modifying "Abilities"

Post by Varthonai »

I'm teaching myself WML (although I'm still very new) and I'm having some trouble modifying abilities.

The particular ability I want to make is a Weapon Special ability that will do damage to the player and all adjacent units (similar to the Explosive Bag in DotG, except it can be used indefinitely and the unit doesn't have to go to a shop to get it)

I tried downloading DotG and working off of that, but the scenario file is a little complicated for me and nothing looks at all like the code in the "abilities.cfg" file.

Help would be very much appreciated!
"Don't you worry about cancer?"
"I AM cancer. I do not frighten myself."
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Post by Mist »

You can't modify weapon specials or add new one like those in abilities.cfg for one simple reason - all are hardoced in sources as a C++ functions. If you want to do a custom "weapon special" you have to 'hack' your way around the problem by setting a global event that will fire every time a unit of given type uses a given attack option to strike.

So it would be something in a line of
[event]
name=attack
first_time_only=no
[filter]
type=<type>
[/filter]
[if]
[variable]
name=unit.attack[<attack nr>].name
equals=<area_attack_name>
[/variable]
[then]
[store_locations]
x=$x1
y=$y1
radius=1
[filter]
[not]
x=$x2
y=$y2
[/not]
[/filter]
variable=area
[/store_locations]
{FOREACH area i}
[store_unit]
x,y=$area[$i].x,$area[$i].y
variable=temp
kill=no
[/store_unit]
{VARIABLE_OP temp.hitpoints add -<attack_damage>}
{MODIFY_UNIT x,y=$area[$i].x,$area[$i].y hitpoints $temp.hitpoints}
{NEXT i}
{CLEAR_VARIABLE area}
{CLEAR_VARIABLE temp}
[/then]
[/if]
[/event]

Above event was written on the fly so might be buggy, replace <> with apropriate values/strings, keeping area attack as first declared will spare you the need of expanding if condition checking block, and remember to set twin event with [filter_second] instead of [filter] to serve using the weapon in defence.
Somewhere, between the sacred silence and sleep.
Disorder.
unit12
Posts: 66
Joined: April 11th, 2007, 11:49 pm

Post by unit12 »

removed
Last edited by unit12 on May 10th, 2007, 11:37 am, edited 1 time in total.
User avatar
governor
Posts: 267
Joined: December 8th, 2006, 12:32 am

Post by governor »

Use an attacker_hits event. Then store the unit on $x2,$y2 to get the attacked units side. Finally remove 1 gold from the hit side ([store_gold] and add [gold] (-1)) and add it to the side that attacks (add [gold] (1)).

The implementation isn't complicated: http://www.wesnoth.org/wiki/EventWML is your friend.

Also, you are likely to get more help if this is in its own thread. Maybe a mod could split it for you.
Post Reply