Help with making 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
Sarudak
Posts: 122
Joined: January 24th, 2008, 2:14 am

Help with making abilities

Post by Sarudak »

I've never made abilities before but I would like to try and make some for my Rise of Empires add-on. But the effects of the abilities seem to be mostly hard coded. For example I wanted to create an ability 'Legendary Aura'. Any unit attacking or being attacked by a unit with that ability that did not also have the ability would be immediately slowed however I see no way of doing this. No idea where to even begin.
User avatar
db0
Posts: 400
Joined: January 3rd, 2006, 8:39 pm
Location: Somewhere Far Beyond...
Contact:

Post by db0 »

Seems simple

Here's some pseudocode

Code: Select all

Event - attack
   if
      unit filter
          ability=legendary aura
   then
      if
        not
           unit filter
              second unit
              ability=legendary aura
        then
            store second unit
            modify stored unit variable
               status=slowed
             unstore unit 
        else
             if       
               unit filter
               second unit
               ability=legendary aura
            then
               store unit
               modify stored unit variable
                   status=slowed
               unstore unit 
 
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

A lot of abilities are hard-coded, but you can make new abilities with many effects by using [event]s.

What you want to do is make an attack event that filters for if the unit attacking or being attacked has the ability and then filters for if the second unit has the ability.

If you need wml spelled out for you and someone else doesn't just go ahead and do it for you, try looking at the Abilities Era for many event-driven abilities.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Ken Oh wrote:What you want to do is make an attack event that filters for if the unit attacking or being attacked has the ability and then filters for if the second unit has the ability.
Yeah, but the problem with that is that it won't show the correct damage calculations, because the damage calculations wouldn't know the unit will get slowed immediately when the fight starts.

Ideally, it'd work like this:

1. Invisible weapon specials on all the unit's attacks which halves opponent's damage. This makes damage calculations show the opponent's damage halved.

2. An attack event which slows the opponent, and deactivates the aforementioned weapon special (otherwise the opponent would only deal a quarter of its normal damage, instead of half).

3. An attack_end event which reactivates the weapon special.

4. A dummy ability tag which makes the whole feature look like an ability.
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

zookeeper wrote:Yeah, but the problem with that is that it won't show the correct damage calculations, because the damage calculations wouldn't know the unit will get slowed immediately when the fight starts.
Yeah, I totally wish there was a "consider attack" event (that would necessarily need a "un-consider attack" event) to handle stuff like that.
User avatar
TL
Posts: 511
Joined: March 3rd, 2007, 3:02 am

Post by TL »

zookeeper wrote:Ideally, it'd work like this:

1. Invisible weapon specials on all the unit's attacks which halves opponent's damage. This makes damage calculations show the opponent's damage halved.

2. An attack event which slows the opponent, and deactivates the aforementioned weapon special (otherwise the opponent would only deal a quarter of its normal damage, instead of half).

3. An attack_end event which reactivates the weapon special.
You can simplify this, I think. You should be able to have the invisible weapon special filter on the opponent to check for the slow status (via a wml_filter). Then you'd only need one event to slow the opponent (which should work as either an attack or attack_end event, since either way their damage is getting halved) and wouldn't have to activate and deactivate your weapon special manually.

Performancewise, I'm not sure which would work better, but I suspect in either case it's probably not going to be game-killing.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

TL wrote:
zookeeper wrote:Ideally, it'd work like this:

1. Invisible weapon specials on all the unit's attacks which halves opponent's damage. This makes damage calculations show the opponent's damage halved.

2. An attack event which slows the opponent, and deactivates the aforementioned weapon special (otherwise the opponent would only deal a quarter of its normal damage, instead of half).

3. An attack_end event which reactivates the weapon special.
You can simplify this, I think. You should be able to have the invisible weapon special filter on the opponent to check for the slow status (via a wml_filter). Then you'd only need one event to slow the opponent (which should work as either an attack or attack_end event, since either way their damage is getting halved) and wouldn't have to activate and deactivate your weapon special manually.
True, that should work and would simplify it a bit.
TL wrote:Performancewise, I'm not sure which would work better, but I suspect in either case it's probably not going to be game-killing.
Usually this kind of stuff doesn't really affect performance at all. Events are run pretty fast, and it's mostly the cases where you're regularly doing changes to a big number of units (like all units, or all units of your side, etc) which need some thinking.
Post Reply