There are many ranges used for different engine calculations. These may be of interest to know how the game works.

Distance Basics

All the distances in the game are in meters, stored as float values, eg: 12.53 is 12.53 meters. Each tile of the game is 10 meters on a side.

Distances in the game use point-to-point. Each creature is considered to be 1.0M "high" for any line of sight checks but this may not be used for other ranges.

PERSPACE and CREPERSPACE

These are two columns in appearance.2da which are defined as:

PERSPACEPersonal Space. For more information see Creature Size. Used to pathfind around objects and walkmesh. Stops a creature from passing through another creature (by comparing each of their PERSPACE values).
CREPERSPACECreature Personal Space. For more information see Creature Size. Usually larger than PERSPACE. It determines pathfinding (and melee range) for moving around/past creatures in combat.

They also have some additional uses in determining how far something has to be to you to do actions (such as spellcasting) see below. Both are important.

Spell Distances

Spells at their core rely on the ranges in ranges.2da; usually these distances are used (note "Personal" is changed to "Touch" range when it's used on an object - usually only when casting a personal spell like Spell Mantle, on a spell scroll to craft it):

Label              PrimaryRange
SpellRngPers       0           
SpellRngTouch      2.25        
SpellRngShrt       8           
SpellRngMed        20          
SpellRngLng        40          

You can target an object target or a target location on the ground. They obviously differ.

Spell Target Object

The game does not use the Z distance for this calculation, instead it just compares the caster and targets X/Y location, so if the caster is at (1.0, 1.0, 2.0) and the target is (1.0, 4.0, 6.0) it will compare (1.0, 1.0, 0.0) and (1.0, 4.0, 0.0) meaning a 3.0 point to point distance.

For targeting an object you need 3 components:

  • Spell Range
  • Casters CREPERSPACE value - 0.1
  • Target object CREPERSPACE value - 0.1

For instance in an example we're casting Aid (a Touch 2.25 range spell) with the caster being a Adult Dragon casting against a Stirge. These are our relevant information:

  • Spell range: 2.25
  • Casters CREPERSPACE: 2.0 - 0.1 = 1.9
  • Target CREPERSPACE: 0.3 - 0.1 = 0.2
  • Total: 4.35

This means when the game moves you to range to start casting (once casting has started it will complete - even if the target moves further away) it will in this case use the distance of 4.35M, much higher since you are going from "combat edge to edge" (minus 0.2 in this case) so you don't need to hit the middle of their body. Else we'd potentially have to walk into dragons to cast short range spells!

Spell Target Location

Targeting a location has some interesting aspects. Again the Z is ignored (interestingly the target location chosen is Z + 0.3 - presumably to help spell visuals - so usually 0.3 Z if the ground is at 0.0).

For targeting a location you need 2 components:

  • Spell Range
  • Casters CREPERSPACE value - 0.1

So a Adult Dragon casting a Touch range ground target spell like Mass Heal would have:

  • Spell Range: 2.25
  • Caster CREPERSPACE: 2.0 - 0.1 = 1.9
  • Total: 4.15

This means you get a slight penalty to your CREPERSPACE value only, but it's still for shorter ranged spells potentially quite a bit longer than you'd think.

Melee Combat Distances

Melee combat involves a few different additional items to consider, actually not using CREPERSPACE at all (except for pathfinding to the enemy). Some of this is a complete mess depending on the situation whether or not you're "in range to attack" or to make an attack of opportunity (or hit someone with cleave or whirlwind attack or circle kick etc.).

The difference to CREPERSPACE helps weapons "hit" the target so they "overlap" a bit. Noting there are some times you can be quite far away from an target and still hit due to tolerances to the attack ranges. The below would be the maximum ranges if you could not move as it were (say you were under an Entangle effect). Of course if a creature is closer it's possible to attack.

These seem to be the relevant 2da entries for melee:

appearance.2da:

WEAPONSCALE

Amount to scale weapons so that they are appropriately sized for use by this model. Size scaling factor to apply to weapon models equipped by creatures having this appearance. Only meaningful if MODELTYPE is not S

This also appears to affect melee attack distance if your model type is P (player) or F (full), but not L (large) for some reason (so Balors don't get increased attack range but do get a bigger weapon for whatever reason)

HITDIST

When this creature is attacking another creature, subtract the HITDIST from the actual distance between attacker and target before comparing the distance to the PREFATCKDIST.

PREFATCKDIST

Preferred distance from which to attack a target. Creature will use short-range, normal-range, or long-range versions of its melee animations depending on distance of the target.

If no weapons are equipped (ie unarmed/creature weapons) this is the attack distance used.

baseitems.2da:

PrefAttackDist

**** if not a weapon.

Otherwise the preferred distance for attacking with this weapon. The distance is selected so that attack animations look their best in the most commonly anticipated situations. Interacts with creature size values in appearance.2da for each creature, and their WeaponScale value (eg; Half Orcs are bigger so can stand slightly further away and swing).

Ranged weapons tend to just use the value "30".

This needs some more investigation on what is required for the attacker and attackee, especially if one has a longer ranged weapon (and WEAPONSCALE is a thing for their appearance!) can you get a case where one creature can attack another, but they can't attack back?

Main testing seems to using the distance depending on if a weapon is equipped on the attacker.

Attacker Weapon Equipped

This uses the weapons PrefAttackDist, combined with the WEAPONSCALE and HITDIST properties, as below:

  • Attacker weapon PrefAttackDist
    • If attacker is "P" or "F" model multiply this amount by WEAPONSCALE
  • Target HITDIST

Therefore a Half-Orc with a Double-Axe attacking a Dwarf:

  • Attacker Double-Axe PrefAttackDist: 1.5
    • Attacker is "P" appearance so multiply 1.5 by WEAPONSCALE of 1.3. 1.5 * 1.3 = 1.95
  • Target HITDIST is 0.3
  • Total: 2.25

Attacker No Weapon Equipped (Unarmed)

This uses PREFATCKDIST, combined with HITDIST, so a lot simpler.

  • Attacker PREFATCKDIST
  • Target HITDIST

Example of a Dragon attacking a Balor:

  • Attacker PREFATCKDIST: 3.3
  • Target HITDIST: 1.5
  • Total: 4.8

Melee Animation Choice

The choice of close, medium or long reach animations is based on this calculation:

Distance between targets - HITDIST of target:

  • < Preferred Attack Distance - 0.25 = close reach
  • <= Preferred Attack Distance + 0.25 = medium reach
  • Anything else = long reach

Melee Combat Steps

There is a number of things that happen in combat - things move around, changing targets, and combat steps.

As noted above there is a good amount of movement forwards or backwards if we are "close" to the ranges suggested above. Try running into a creature and you start moving back. If you make your WEAPONSCALE number stupidly high (like 10.0) you can get some real walking back!

Cleave, Circle Kick and New Target Selections

This appears to simply be the desired usual attack range above, but with no target so HITDIST is 0.0, and instead a 1.5M range is put in to simulate finding someone else to go ham on.

Therefore the Dragon example would have a new target / cleave range of 3.3 + 1.5 = 4.8M range.

Whirlwind Attack Range

Base ranges seem to be hardcoded to be set precisely in ruleset.2da for each version:

WHIRLWIND_ATTACK_RANGE2.0fThe range of DoWhirlwindAttack(TRUE, FALSE) (normal non-improved version)
IMPROVED_WHIRLWIND_ATTACK_RANGE4.0fThe range of DoWhirlwindAttack(TRUE, TRUE) (normal improved version)

The game then makes sure the checked distance isn't simply point-to-point but is each creatures personal space - PERSPACE - subtracted.

For instance if we are a Human 3.0M from a Dragon are we in range of a normal Whirlwind attack?

  • Distance point to point: 3.0
  • Human PERSPACE: 0.3
  • Dragon PERSPACE: 1.1
  • Total: 3.0 - 0.3 - 1.1 = 1.6

This 1.6 is compared with the 2.0 range limit and we are in range! However if we had another Human it'd be 3.0 - 0.3 - 0.3 = 2.4 so be out of range.

  • No labels