Ability

From Dragon Age Toolset Wiki
Jump to: navigation, search
Scripting

The Ability System is used to handle Spells, Talents, Skills, and Item Abilities in Dragon Age.

Detailed Description

Spells, Talents, Skills and item abilities all use the same backend in the game, a mostly script implemented system relying heavily on two dimensional data arrays.

The most important 2da file for abilities is ABI_base.xls, as it defines each ability and all aspects of execution and handling in both scripting and engine code.


Ability Design Notes

When creating an ability in Dragon Age: Origins, we generally stick to the following guidelines

  • Keep it useful.

Some constant benefits (such as an increase in Attack or Defense) stay useful for the duration of the game as the progression of the related properties are slow. For other effects, such as damage, a constant value would mean that the ability will become progressively worse through the game as damage needed to drop enemies increases from level to level. In such cases, the ability should be tied in some fashion to a Spellpower (for spells) or another relevant trait (such as cunning for rogues) to ensure they stay useful throughout the game.

  • No repetition.

Each ability in Dragon Age: Origins is unique. No incremental abilities such as 'fireball I, fireball II, etc.'. Skills are exempt from this rule. Remember that the Damage Types dramatically alter the actual effect of an ability (such as lightning always draining stamina alongside doing damage), so having similar damaging abilities in different trees is usually fine.

  • Thematic matching.

Abilities within the same chain should follow a common theme.

  • Avoid binary abilities. Design hit heavy.

Avoid abilities that are hit-or-miss. Generally, abilities should hit whenever possible and use target side mitigation of effects (resistance checks, damage mitigation) instead of 'hit or miss' mechanics. Melee abilities may use the normal attack resolution routines but should always perform their attacks at a bonus. Use rank based mitigation and resistances to allow for very powerful effects that do not trivialize boss battles.

  • Use meaningful effects

Abilities should always be worth it. Don't do minor effects (+1 attack). The player should always be able to see the effect of the ability in game (not necessarily visually, but at least through increased damage, etc.). The first ability in a chain should, whenever possible, be active. The fourth ability in a chain should always have the biggest 'bang-for-the-buck' factor. Abilities lower in the chain should have shorter cooldowns. Do not allow instant death on bosses and elite bosses.

  • Avoid 'zero-sum' abilities

When possible, avoid 'zero-sum' abilities that trade a penalty for a benefit (e.g. increase defense but decrease attack). There are a number of these abilities that are valid (such as aim), but balancing them and keeping them useful is hard and requires a lot of work. This obviously does not apply to drastic abilities such as blood magic.

  • No emulation of defining class capabilities

Never ever grant a basic class capability from one class to another class via abilities. This means no invisibility or magical unlock spells for mages, as these are defining capabilities of the rogue class. No weapon talents for mages. No magic spells or large, targeted area of effects for warriors or rogues. Items might blur this line if the cost is balanced properly (e.g. grenades).


Basic Ability Types

Abilities are divided into 4 subtypes, as defined in the 'abilitytype' column in ABI_base.xls:

  • Talents - Abilities used by warriors and rogues, usually non magical in nature. (abilitytype=1)
  • Spells - Abilities used by mages, either spell or passive abilities. (abilitytype=2)
  • Skills - Abilities usable by all classes, such as Survival and Combat training (abilitytype=3).
  • Items - Abilities present on an item that are triggered when the item is used on the quickbar. (ability_type=4)

Note: Talents do not show up on mages and spells do not show up on rogue or warrior characters, so to create abilities that can be used by all classes, abilitytype 3 (Skill) must be used. To define under which heading an ability shows up on the character's talent/spell page, the field 'guitype' is used. It resolves against guitype.xls which lists all known headings.


There are 3 basic ability types in the game, defined by the field 'use_type' in ABI_base.xls.

Passive Abilities

Passive abilities (use_type = 3) grant persistent or conditionally persistent bonuses or penalties to the creature that has the ability.

A passive ability may grant up to 3 modifications to creature properties (properties.xls). Those modifications are defined in the passive_abilities worksheet of ABI_base.xls and linked to the ability through the passive_id column in ABI_base.xls.

Additionally, the bonuses of an ability can be made conditional on the character's current 'wield mode' (2-handed, dual, weapon & shield, or universal) through the conditional integer field on the passive_abilities worksheet.

Finally, a number of passive abilities do not define any property modifications in passive_abilites but instead have checks coded against their Ids directly in the combat resolution scripts (e.g. HasAbility( oCreature, ABILITY_TALENT_LETHALITY )). The mere presence of the ability on a creature causes a different code path to be taken in the scripts in those cases.

Note that passive_ability benefits are not limited to abilities with use_type 3. Some active abilities also grant additional property modifying benefits to the owner.


Sustained Abilities

Sustained abilities (use_type = 2) are turned on and off per character and, while turned on, grant effects or property modifications to the user. Most 'buffs' are implemented this way.

Only members of the player's party are using sustained ability as the code overhead required to track them is too expensive to be used on monsters that only exist to die in an encounter with the player's party. (These creatures use duration based effects to emulate similar abilities instead).

Most sustained abilities follow the same pattern:

  • They do not have any activation cost, encouraging tactical use of buffs.
  • They increase the users Fatigue property, therefore increasing the activation cost of all other abilities.
  • They reduce the users maximum available mana or stamina by a constant value.
  • They use cooldown to prevent the user from being too opportunistic with their use.
  • Some abilities shut down when the user reaches 0 mana/stamina. Very powerful abilities (such as Momentum) have an associated stamina/mana drain effect to limit their use to a short or medium period of time. Creative item / buff use can be used to increase the length such an ability can be sustained.

The benefits from sustained abilities are calculated when the ability is activated. So if a character levels up or otherwise changes stats that influence the magnitude of a sustained ability, they will not update until the ability is reactivated the next time.

Some sustained abilities (such as Flaming Weapons) are active 'party-wide' - the caster not only sustains the ability on himself but on all his party members as well. This is controlled by the 'bPartyWide' flag in ABI_base.xls. Due to implementation limitations, party members who die or otherwise enter/exit the current party will not be affected by these abilities until they are recast. (we put low cooldown times on these abilities for that very reason).

Gameplay Design Note
  • Unlike in games like Baldur's Gate, the system in DA: Origins is designed to encourage tactical use of buffs over strategical. We wanted to put an emphasis on the player making smart choices during an encounter vs. the player guessing which buffs might be useful ahead of time or having to employ save-die-reload to find out.
  • It is generally wise to run only one or two buffs all around and activate additional buffs only when needed.


Activated Abilities

Activated abilities (use_type = 4) are abilities that instantly execute their effect (see Targeting Behavior below). Most melee talents or targeted spells fall in this category. There are several sub-types of activated abilies, such as

  • Targeted, single target spells and talents (such as Winter's Grasp or Flurry)
  • Ground targeted abilities (such as Blizzard or various Glyphs)
  • Self targeted activated abilities.

Targeting Behavior

An ability's targeting behavior is controlled by several settings in ABI_base.xls


AutoTarget is a boolean field that defines how the UI resolves targeting.

Value Effect
0 The UI will always bring up a targeting cursor.
1 The UI will only produce a targeting cursor if no suitable target is currently selected. e.g if the player currently has a hostile creature targeted and if the spells TargetType includes 0x4 (hostile), the ability will trigger immediately, not producing a targeting cursor. Most single target spells and talents use this setting.

Regardless of AutoTarget setting, the UI will never produce a targeting cursor if an ability is type 0x1 (self) -


TargetType is a bit mask derived from the following table and controls the behavior of the UI's targeting cursor.

Bitmask Effect
0x1 Self
0x2 Friendly Creature
0x4 Hostile Creature
0x8 Placeable Object
0x10 (deprecated) Area of Effect Object
0x20 Ground
0x40 (deprecated) Dead Body
0x80 Party Member


AutoDraw is an integer boolean field that defines how a character's weapons are handled when the ability is triggered.

Value Effect
0 The ability will not affect the player's weapon sheath status.
1 The engine will force the player to draw/unsheathe his weapon before executing the ability. This is used for most bow and melee weapon abilities.
2 The engine will force the player to stow away any non staff melee weapons before executing the ability. This is used to ensure that no inappropriate animations play with weapons drawn (e.g. the player conjuring with a sword clipping through his body) and to discourage switching between melee and spellcasting on the fly.

Balancing (Cost, Cooldown, etc)

Abilities in Dragon Age are balanced along several vectors, most of which boil down to simple 'use frequency'. As a general rule of thumb, the more specialized and limited the effect of an ability is, the more outrageously powerful an ability can be.

Use frequency of abilities can be adjusted by modifying the following field in ABI_base.xls

  • Cost: This is the simple mana (spells) or stamina (talents) activation cost of an ability. It is subtracted when the conjure phase of the spell has succesfully completed (e.g. no cost for spell interruptions). Without sufficient resources to cover activation cost, the UI will not allow the player to execute the ability. The value is a constant integer and is multiplied with 1+(Current Fatigue) of the caster.
  • Cooldown: Cooldown is a constant float in seconds that defines how long the player has to wait after the successful activation of an ability until he can use it again. For abilities that apply duration based debuffs or effects to a target, cooldown is usually set slightly higher than the duration of the effect to avoid stacking by the same caster.
  • Upkeep: Defines how much mana or stamina is removed from the casters overall pool while a sustained ability is active. This naturally limits the number of sustained abilities present on a creature and ensures that the more beneficial buffs are active on the caster, the less mana is available for immediate use.
  • Fatigue: Fatigue affects use frequency only indirectly, but it prevents characters from stacking too many buffs on each other, as each sustained ability active usually adds around 5-10% fatigue to the caster.
  • Mana/Stamina drain: By reducing the mana/stamina regeneration rate on a creature, the duration for which a sustained ability can be used can be restricted. This mechanic is used only for the most powerful sustained abilities in the game, which are flagged to turn off when the caster sustaining them reaches 0 mana/stamina.


Other balancing vectors:

  • AoESize and AoeShape: Area of effect spells that deal friendly fire are location and situation restricted on normal+ difficulty (hard+ on the consoles). Since dropping an Inferno on your own party members is hardly a good idea in most cases, the usefulness of the spell becomes restricted to careful positioning and the earlier stages of combat.
  • Threat Generation: Abilities apply threat not just by damage but often by activation. Higher activation threat of an ability can balance out outrageously powerful effects by making it harder for the player to use the spell. The prime example is the Walking Bomb kind of spells which deal excellent damage, but, on higher difficulties, also make the targets very very angry at the caster. Using these spells effectively often requires a tactical approach by the player, thus limiting their universal usefulness and offsetting their very powerful effects.
  • Threat Removal: Some abilities are designed to only provide a short term benefit (Such as 3s stun on Mindblast) but offset their weakness by removing threat from the caster, often by reinitializing the threat tables on the target, causing enemies to randomly seek new targets.
  • Conjure time: Spells with a conjure time of 1+ (Speed in ABI_base.xls) can be interrupted by damage, limiting their usefulness in melee situations or when only one party member remains on the battlefield. Many of the very powerful Area of Effect type spells use this feature. Most activated spells have a conjure time of 0, making them instant cast.
  • Range: Lower ranges force the ability user into potentially more dangerous situations, adding additional risk to the use of an ability.

Q&A

Q: Where do we find the exact formula for abilities ?

A: Due to most abilities being unique, the only place to find the exact details on each spell is in the scripts. While a lot of data can be glanced from ABI_base.xls, a lot of the detailed mechanics are very different between abilities and can only be found in the appropriate spellscript. The *_constant.nss files hold some basic values, but often get further modified in the scripts.

This is also one of the reasons why some elements of a talent are not displayed in the UI description in game. While we can calculate cost and cooldown based on the casting character and his fatigue and other properties (and consequently display it), we can usually not calculate damage or duration as they are mitigated on the target creature:

Displaying those values results in very misleading information (e.g. while damage seems to be higher on one ability, the mitigation mechanisms and unique side effects of another ability will make it just as good or better - in certain situations) and it turned out to be better to provide the player with general guidance than the misleading information.

Q: What is Spellpower and how does it interact with abilities

Spellpower is probably the most important stat for a mage character (and only exists on mage characters). It is calculated as max(Magic - 10,0) and therefore increases by one point for every point a mage spends on his Magic attribute.

Most mage spells benefit directly from higher spellpower by increased damage, effect magnitude and duration. It also plays a role in a mages ability to overcome mental or physical resistance on a target (where applicable). The actual impact of spellpower on an ability varies from spell to spell but the most common construct equates to something like 1% increase in spell potency per point of Spellpower. Thus, items and spells that increase spellpower are very powerful as they increase the potency of every spell the mage can cast.

Spellpower is the only factor that causes an increase of a spells potency over time, so a level 20 mage with neglected the Magic attribute would be much less powerful than a mage that didn't neglect Magic.

Some examples:

  • The damage potential for Winter's Grasp is calculated as (100.0f + GetCreatureSpellPower(stEvent.oCaster)) * 0.36f;
  • The healing potential for the heal spell is calculated as (100.0f + GetCreatureSpellPower(stEvent.oCaster)) * 0.40f;
  • The damage over time component of blizzard is executed as ApplyEffectDamageOverTime(a[i], oCreator, ABILITY_SPELL_BLIZZARD, (100.0f + GetCreatureSpellPower(oCreator)) * 0.1, (BLIZZARD_INTERVAL_DURATION - 0.5f), DAMAGE_TYPE_COLD);

Note that these formulas only list the raw damage potential and do not take into account the effects of damage types, difficulty, rank, resistances, magical shields and any other mitigating factors on the target or enhancing factors on the caster. This means that just comparing the numbers will not give you an idea which spell is better or worse.

For non-mage spells and abilities, spellpower is often substituted by an appropriate other construct (such as max(Cunning-10,0) for rogue abilities).

Q: Can we have the damage formula for abilities ?

A: There is no damage formula for abilities, as mentioned before, each ability follows their own rules.

In general, talent damage is based on the weapon being used (e.g. Assault does 3 melee attacks that deal weapon damage with some additional bonuses) and are modified by external cirumstances such as location, critical chance and ability to deliver a backstab and are mitigated by armor on the target.

Spells deal damage of different damage types following a rough rule of (Constant * (Spellpower / Variable)) / [Variables] ) + Modifiers but this only tells part of the story as actual damage is dependent on the target, it's resistances, rank and a number of other factors.

Some additional factors affecting spell damage are:

  • damage resistance.
  • magical shields.
  • difficulty level.
  • elemental damage bonuses from spells or items
  • Environmental conditions (frozen targets take less damage from fire, etc.)

Q: What are the differences between damage types?

A: Creatures have variable damage resistances based on their type and rank. Dragons might get 60% less damage from fire (60% fire resistance), other creatures will have different immunities. Additional effects are:

  • Electricity: In addition to normal damage, these also reduce the targets stamina (but not mana) by the same amount, making them very effective boss killers.
  • Fire: Cancels Cold based damage over time effects and applies damage over time.
  • Cold: Cancel Fire based damage over time effects and often is accompanied by slow or slipping effects.
  • Spirit: There are very few ways of increasing spirit resistance in the game, so spells dealing spirit damage are universally useful...
  • Nature: Rarely found on spells. Many creatures are resistant to this.

(This should probably go on its own wiki page)

Q: Are sustained abilities mutually exclusive ?

A: There is a very limited number of sustained abilities that are mutually exclusive, usually because it makes sense. Mutually exclusive abilities cancel each other upon activation.

  • Shield stances (Shield Wall, Shield Cover, Shield Defense) are mutually exclusive.
  • Archery stances (Aim, Rapid Fire, Defensive Fire) are mutually exclusive.
  • Shapeshifting forms (Sorry, no Bear-Wolfspider) are mutually exclusive.
  • Weapon Enhancement spells are too, but only for the same caster (so two mages can run two different weapon enhancements if they want to).
  • Bard Songs are mutually exclusive.
  • The Death Syphon and Death Magic spells are mutually exclusive.

Technically, all abilities in ABI_base.xls that share the same 'condition_group' value are mutually exclusive.

Q: What are the rules for stacking effects and damage ?

A: The general rules of stacking for abilities are:

  • Identical effect from different abilities stack (e.g. getting +10 attack from one ability and +10 attack from another nets +20 attack).
  • The effects of identical abilities stack as long as they are from different caster. (Same caster usually does not apply as cooldown often exceeds duration).
  • Weapon enhancement spells of the same type (e.g. 2 mages with flame weapons) do not stack. The sword does not get more flaming, sorry :)
  • Animation based effects (knockdown, stun, etc.) stack, but only the one with the highest priority is played. This is defined in the priority column in effects.xls.
  • Glyphs do stack but there is a limit of 5 active glyphs per caster.
  • Fire and Cold DoT effects do not stack, the spell cast last will cancel any existing spell of the opposite type.
  • Fire and Cold AoEs cancel each other, other AoEs might interact rather violently, handle with care :)

For equipment and item based effects, the game usually stacks within the minumum and maximum clamp values of a property (properties.xls). This means that you can accumulate a lot of +damage or +critical critical chance effects, but for some stat types there is a point where you are no longer gaining any benefits (e.g. speed modification - animations can only be sped up to a certain point before breaking, so stacking momentum, haste and a weapon with a speed based effect will not result in a -3.0s attack time, sorry :p)


For almost all effects, the total result of all property modifications on a creature are visible on the main character UI by hovering over the individual stats.

Q: How does game difficulty affect abilities ?

A: Our approach to game difficulty dictates that the effect of your chosen setting are

  • non punishing - You do not get less XP for chosing a lower difficulty mode, etc.
  • challenge scaling - Higher difficulty will reward you with greater obstacles to overcome.
  • fair - Lower difficulties grant benefits that gradually get removed. (This does not mean the rules are symmetric and is not true on nightmare at all. Nightmare is evil. And unfair.)
  • non persistent - Difficulty changes are possible on the fly, at any time and take immediate effect.

The game is balanced so that Hard mode is challenging for a Baldur's gate veteran.

Based on these guidelines, you can expect the following ability behaviors in game:

  • The lower the difficulty, the longer your hostile effects such as stuns will last on enemies and the shorter they will last on you.
  • The lower the difficulty, the more damage your abilities will do.
  • The lower the difficulty, the less likely the enemy AI will use devastating special abilities (Note: less likely does not mean 'does not use').
  • Casual and Normal have reduced friendly or nullified fire damage damage from area effect spells. Hard and Nightmare require careful positioning and tactical use of spells.
  • The higher the difficulty, the more careful you need to manage threat when using spells and abilities (The AI becomes smarter about picking targets).

Q: What is spell affinity ?

A: Spell Affinity was a design we toyed with for a while during development but decided not to implement.

Q: How does Rank Based Mitigation Work ?

A: In line with Dragon Age: Origin's asymmetric approach to rules, the game uses creature ranks (instead of levels) in addition to stats and resistances to define how creatures get affected by abilities. In short: Boss monsters get affected differently by abilities and effects than Lieutenants or Critters.

The rank system is the primary balancing vector for the games difficulty levels and profoundly affects all aspects of combat. The gory details of this system are defined in creature_ranks.xls and difficulty.xls.

Rank mitigation affects not just damage in- and output of a creature, but also the duration that hostile effects persist on it and is different for each difficulty level of the game. Note that party members have their own rank in this system and are handled differently from other creatures in some cases.

Below is the formula used for rank based effect duration mitigation:

// sys_resistances_h
// @brief Returns an effect duration scaled by rank of oCreature and game difficulty
// @author Georg
float GetRankAdjustedEffectDuration(object oCreature, float fDur)
{
 
    // -------------------------------------------------------------------------
    // Georg: This deserves some explanation:
    //
    //        One of the core issues when designing the combat system was always
    //        the fact that the story called for sequences during the game in which
    //        your main character acts solo.
    //
    //        Characters reliant on special abilities, such as rogues, would require
    //        them to be very effective in order to beat enemies that a standard tank
    //        can plow through. However, if these abilities would maintain the same
    //        effectiveness in a full party, most encounters would turn into a stunfest.
    //
    //        The solution is to add 1 second flat to each detrimental effect duration
    //        lasting at least 1 second for each unoccupied slot in the party - before applying
    //        rank and difficulty modifiers. This also makes solo play a bit more viable.
    //
    //        This is in addition to the diminishing returns on quickly successive stuns.
    //
    // -------------------------------------------------------------------------
    if (!IsPartyMember(oCreature))
    {
        float fPartySizeModifier = IntToFloat(Max(0,4 - GetArraySize(GetPartyList())));
 
        if (fDur >= 1.0f)
        {
            fDur += fPartySizeModifier;
        }
    }
 
    float fRankDurMod = Diff_GetDurationModifier(oCreature);
    if (fRankDurMod >0.0f)
    {
        return (fDur * fRankDurMod);
    }
    else
    {
     return fDur;
    }
}

Q: What does 'asymmetric rules system' mean ?

The goal behind Dragon Age: Origin's rule system was to create a fun and challenging video game experience first and foremost.

We describe the rules as 'asymmetric' because a subset of the game rules treats player controlled characters and monsters differently, which is a deviation from pen and paper rule design that often require player and opponents to be treated exactly the same.

Notable Examples:

  • Party members never die permanently (get shattered, etc.)
  • Differently ranked creatures (including party members) get affected for different durations by effects
  • In limited situations in the game, we apply benefits to the player to overcome greater odds than they would usually be able to.
  • Some abilities will work diferently when deployed against the party (although the visual results might be identical).
  • Elimination of instant death situations (not fun!) against players but not against monsters (fun!).
  • Sustained abilities only work for players (the overhead is not justified for monsters that won't ever reappear after they die).


Language: English  • русский