Difference between revisions of "Combat Rules"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (Hit Resolution: indentation)
m (Hit Resolution)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
'''This page is work in progress'''
+
{{Infobox script}}
  
=== Overview ===
+
'''This page is work in progress'''
  
 
This page describes the technical implementation and flow of combat logic in the game scripts.
 
This page describes the technical implementation and flow of combat logic in the game scripts.
Line 8: Line 8:
 
Note: The term 'property' used on this page refers to [[Creature Properties]].
 
Note: The term 'property' used on this page refers to [[Creature Properties]].
  
=== Detailed Description ===
+
== Detailed Description ==
  
 
Combat in Dragon Age: Origin is handled mainly through scripts - the game engine itself has little knowledge of rule concepts such as 'Strength', 'Damage Modifier' or 'Armor Penetration'.
 
Combat in Dragon Age: Origin is handled mainly through scripts - the game engine itself has little knowledge of rule concepts such as 'Strength', 'Damage Modifier' or 'Armor Penetration'.
  
 +
=== Hit Resolution  ===
  
==== Hit Resolution  ====
+
Hit resolution is implemented in the function [[combat_h.nss#Combat_GetAttackResult|Combat_GetAttackResult]] in the script library [[combat_h.nss]], which is invoked from the [[creature_core.nss]] script whenever an attack event is received. The function returns one of several [[COMBAT_RESULT_*]] constants and handles messaging to the game engine which animation to play.
 
+
Hit resolution is implemented in the function [[combat_h.nss#Combat_GetAttackResult|Combat_GetAttackResult]] in the script library [[combat_h.nss]], which is invoked from the [[creature_core.nss]] script whenever an attack event is received. The function returns one of several [[COMBAT_RESULT|COMBAT_RESULT_*]] constants and handles messaging to the game engine which animation to play.
+
  
 
Overall, Dragon Age: Origin's combat system is 'hit heavy' as a target's armor does not modify its chance of getting hit.
 
Overall, Dragon Age: Origin's combat system is 'hit heavy' as a target's armor does not modify its chance of getting hit.
Line 37: Line 36:
  
 
if bHit
 
if bHit
 +
 
   if  HasEffect(attacker, EFFECT_TYPE_MISDIRECTION_HEX)
 
   if  HasEffect(attacker, EFFECT_TYPE_MISDIRECTION_HEX)
 
     if bCrit  
 
     if bCrit  
Line 45: Line 45:
 
   if bBackstab
 
   if bBackstab
 
     return COMBAT_RESULT_BACKSTAB
 
     return COMBAT_RESULT_BACKSTAB
 +
 +
  if bCrit
 +
    return COMBAT_RESULT_CRITICAL_HIT
 
   else
 
   else
     if bCrit
+
     return  COMBAT_RESULT_HIT
      return COMBAT_RESULT_CRITICAL_HIT
+
    else
+
      return  COMBAT_RESULT_HIT
+
  
 
else
 
else
Line 56: Line 56:
 
</dascript>
 
</dascript>
  
===== Attack Rating =====
+
==== Attack Rating ====
  
 
Attack rating includes:
 
Attack rating includes:
Line 68: Line 68:
 
* + Difficulty setting based modifications
 
* + Difficulty setting based modifications
  
===== Defense Rating =====
+
==== Defense Rating ====
  
 
Defense rating includes:
 
Defense rating includes:
  
* Defender defense value and (missile deflection if attack was ranged). This includes items, effects and magical bonus.
+
* Defender defense value (and missile deflection if attack was ranged). This includes items, effects and magical bonus.
 
* Difficulty setting based modifications
 
* Difficulty setting based modifications
  
===== Flanking Bonus Determination =====
+
==== Flanking Bonus Determination ====
  
 
* Flanking bonus is a floating point value that applies to both AttackRating and to the chance to score a critical hit.
 
* Flanking bonus is a floating point value that applies to both AttackRating and to the chance to score a critical hit.
* It is essentially a representation of close the character is to the best position when attacking the enemy (directly in the back)
+
* It is essentially a representation of how close the character is to the best position when attacking the enemy (directly in the back)
 
* Various shield abilities on the target reduce or prevent the attacker from getting the bonus.
 
* Various shield abilities on the target reduce or prevent the attacker from getting the bonus.
 
* The further away the character is from that position, the more the bonus is diluted.
 
* The further away the character is from that position, the more the bonus is diluted.
Line 86: Line 86:
 
* The full logic is implemented in the function [[combat_h.nss#Combat_GetFlankingBonus|Combat_GetFlankingBonus]] in [[combat_h.nss]].
 
* The full logic is implemented in the function [[combat_h.nss#Combat_GetFlankingBonus|Combat_GetFlankingBonus]] in [[combat_h.nss]].
  
===== Backstab Determination =====
+
==== Backstab Determination ====
  
 
* Backstab is determined for each melee attack only.
 
* Backstab is determined for each melee attack only.
Line 95: Line 95:
 
* The damage logic is implemented in [[combat_damage_h.nss#Combat_Damage_GetBackstabDamage|Combat_Damage_GetBackstabDamage]].
 
* The damage logic is implemented in [[combat_damage_h.nss#Combat_Damage_GetBackstabDamage|Combat_Damage_GetBackstabDamage]].
  
===== Critical Hit Determination =====
+
==== Critical Hit Determination ====
  
 
* Critical Hit Chance uses the attackers Melee or Ranged critical hit modifier based on attack type.
 
* Critical Hit Chance uses the attackers Melee or Ranged critical hit modifier based on attack type.
 
* + the attacking weapon's critical hit modifier stat.
 
* + the attacking weapon's critical hit modifier stat.
 
* + 1.20x (1.1x for non rogues) the attacker's [[#Flanking Bonus Determination|Flanking Bonus]] in the current situation.
 
* + 1.20x (1.1x for non rogues) the attacker's [[#Flanking Bonus Determination|Flanking Bonus]] in the current situation.
* + 3.5 for each enemy past the 2nd that is fighting a warriors with the bravery talent.
+
* + 3.5 for each enemy past the 2nd that is fighting a warrior with the bravery talent.
 
* A critical hit occurs when the resulting CriticalHitChance is smaller than RandomFloat()*100.0f.
 
* A critical hit occurs when the resulting CriticalHitChance is smaller than RandomFloat()*100.0f.
 
* Certain effects and spells (e.g. Death Hex) can always override the result, as will attacking from stealth (always hits critical).
 
* Certain effects and spells (e.g. Death Hex) can always override the result, as will attacking from stealth (always hits critical).
 
* The logic is  implemented in the function [[combat_h.nss#Combat_GetAttackResult|Combat_GetAttackResult]] in the script library [[combat_h.nss]]
 
* The logic is  implemented in the function [[combat_h.nss#Combat_GetAttackResult|Combat_GetAttackResult]] in the script library [[combat_h.nss]]
  
==== Damage Resolution ====
+
=== Damage Resolution ===
  
 
Damage resolution logic is implemented in the script [[combat_damage_h.nss]].
 
Damage resolution logic is implemented in the script [[combat_damage_h.nss]].
  
===== Critical Hit Damage Modification =====
+
==== Critical Hit Damage Modification ====
  
 
* Critical hits increase the amount of damage done by an attack by a fixed multiplier.
 
* Critical hits increase the amount of damage done by an attack by a fixed multiplier.
* The magnitude of the multiplier can be affected by items and effects, but is not affected by of the character's attributes.
+
* The magnitude of the multiplier can be affected by items and effects, but is not affected by any of the character's attributes.
 
* Historical Note: Critical damage used to be variable 'up to...', but was changed to constant to provide a more predictable flow of damage.
 
* Historical Note: Critical damage used to be variable 'up to...', but was changed to constant to provide a more predictable flow of damage.
 
* The logic for critical damage is implemented in [[combat_damage_h.nss#GetCriticalDamageModifier]].
 
* The logic for critical damage is implemented in [[combat_damage_h.nss#GetCriticalDamageModifier]].
  
===== Backstab Damage Modification =====
+
==== Backstab Damage Modification ====
  
 
* Backstab damage is essentially identical to critical damage, but modified by certain rogue talents.
 
* Backstab damage is essentially identical to critical damage, but modified by certain rogue talents.
Line 122: Line 122:
  
 
[[Category: Scripts]]
 
[[Category: Scripts]]
 +
{{Languages|Combat Rules}}

Latest revision as of 13:42, 4 April 2015

Scripting

This page is work in progress

This page describes the technical implementation and flow of combat logic in the game scripts. It deals mostly with weapon based combat, for spells and abilities, please see Abilities.

Note: The term 'property' used on this page refers to Creature Properties.

Detailed Description

Combat in Dragon Age: Origin is handled mainly through scripts - the game engine itself has little knowledge of rule concepts such as 'Strength', 'Damage Modifier' or 'Armor Penetration'.

Hit Resolution

Hit resolution is implemented in the function Combat_GetAttackResult in the script library combat_h.nss, which is invoked from the creature_core.nss script whenever an attack event is received. The function returns one of several COMBAT_RESULT_* constants and handles messaging to the game engine which animation to play.

Overall, Dragon Age: Origin's combat system is 'hit heavy' as a target's armor does not modify its chance of getting hit.

The simplified decision tree for to hit resolution is as follows:

if Target Is Placeable Object
  return COMBAT_RESULT_HIT
 
if Target Displacement/Dodge < RandomF(100.0)
  return COMBAT_RESULT_MISS  
 
if Attacker Is Using BASE_ITEM_TYPE_STAFF
  return COMBAT_RESULT_HIT
 
bHit = RandomF(100.0) < AttackRating - DefenseRating
bCrit = CheckCricital()
bBackstab = CheckBackstab()
 
if bHit
 
  if  HasEffect(attacker, EFFECT_TYPE_MISDIRECTION_HEX)
    if bCrit 
      return COMBAT_RESULT_HIT
    else
      return COMBAT_RESULT_MISS
 
  if bBackstab
    return COMBAT_RESULT_BACKSTAB
 
  if bCrit
    return COMBAT_RESULT_CRITICAL_HIT
  else
    return  COMBAT_RESULT_HIT
 
else
  return COMBAT_RESULT_MISS

Attack Rating

Attack rating includes:

  • Base attack value (54.0f)
  • + Flanking Bonus (position based, modified by attacker and enemy talents and effects as well as shields. Rogues have a bonus here).
  • + Distance based penalties (for ranged attacks)
  • + Attacker's attack property value (this includes modifiers from buffs, etc.)
  • + Any +attack item bonuses on the weapon that performs the attack.
  • + Any external bonuses or penalties passed into the function (from talent scripts, etc.)
  • + Difficulty setting based modifications

Defense Rating

Defense rating includes:

  • Defender defense value (and missile deflection if attack was ranged). This includes items, effects and magical bonus.
  • Difficulty setting based modifications

Flanking Bonus Determination

  • Flanking bonus is a floating point value that applies to both AttackRating and to the chance to score a critical hit.
  • It is essentially a representation of how close the character is to the best position when attacking the enemy (directly in the back)
  • Various shield abilities on the target reduce or prevent the attacker from getting the bonus.
  • The further away the character is from that position, the more the bonus is diluted.
  • The magnitude of the bonus ranges from +0 to +15 (+20 with combat_movement) and is applied to AttackRating and partially (1+(FlankingBonus/5)) to critical hit chance.
  • Most characters only flank 60 degrees in each direction, combat movement allows an increase to 90 degrees (the full back 180).
  • Only rogues get the full flanking bonus, everyone else still gets half.
  • The full logic is implemented in the function Combat_GetFlankingBonus in combat_h.nss.

Backstab Determination

  • Backstab is determined for each melee attack only.
  • Backstab requires the attacker to have a flanking bonus > 0 (some talents waive this restriction)
  • Only creatures with the Rogue Character Class may backstab. This is a class benefit.
  • Only humanoid attackers can backstab (this includes darkspawn)
  • The full logic is implemented in the function Combat_CheckBackstab in combat_h.nss.
  • The damage logic is implemented in Combat_Damage_GetBackstabDamage.

Critical Hit Determination

  • Critical Hit Chance uses the attackers Melee or Ranged critical hit modifier based on attack type.
  • + the attacking weapon's critical hit modifier stat.
  • + 1.20x (1.1x for non rogues) the attacker's Flanking Bonus in the current situation.
  • + 3.5 for each enemy past the 2nd that is fighting a warrior with the bravery talent.
  • A critical hit occurs when the resulting CriticalHitChance is smaller than RandomFloat()*100.0f.
  • Certain effects and spells (e.g. Death Hex) can always override the result, as will attacking from stealth (always hits critical).
  • The logic is implemented in the function Combat_GetAttackResult in the script library combat_h.nss

Damage Resolution

Damage resolution logic is implemented in the script combat_damage_h.nss.

Critical Hit Damage Modification

  • Critical hits increase the amount of damage done by an attack by a fixed multiplier.
  • The magnitude of the multiplier can be affected by items and effects, but is not affected by any of the character's attributes.
  • Historical Note: Critical damage used to be variable 'up to...', but was changed to constant to provide a more predictable flow of damage.
  • The logic for critical damage is implemented in combat_damage_h.nss#GetCriticalDamageModifier.

Backstab Damage Modification


Language: English  • русский