Skip to content

Free Aiming For Ranged Combat

szapp edited this page Oct 12, 2019 · 7 revisions

The feature Free Aiming for Ranged Combat (GFA_RANGED) offers quite some configurations regarding damage, recoil, projectile gravity and accuracy adjustments.

For adjustments to the reticle, see reticle adjustments.

At time of shooting a ranged weapon, the projectile trajectory is manipulated to fly into the direction of the reticle. Before this takes place, several "config functions" are called to aid in this manipulation.
The trajectory of the projectile may be influenced by gravity (GFA_GetDrawForce) and accuracy (GFA_GetAccuracy). These functions are provided with the used weapon and the associated skill value to return suitable values.
The damage of the projectile may also be altered (GFA_GetInitialBaseDamage). For that the previous two functions may be used to influence the damage.
Lastly, the shot may introduce a weapon recoil on the player (GFA_GetRecoil), which is a vertical rotation of the camera to increase difficulty for rapid aiming and shooting.
 

Contents

1.   Constants
    1.1.   GFA_TRUE_HITCHANCE
    1.2.   GFA_UPDATE_RET_SHOOT
    1.3.   GFA_TRAJECTORY_ARC_MAX
    1.4.   GFA_PROJECTILE_GRAVITY
    1.5.   GFA_MAX_RECOIL
2.   Config Functions
    2.1.   GFA_GetDrawForce
    2.2.   GFA_GetAccuracy
    2.3.   GFA_GetRecoil
    2.4.   GFA_GetInitialBaseDamage


Constants

These settings are static (constants). They are and under no circumstances should be changed during the game.

The constants can be found in the file config/settings.d.

GFA_TRUE_HITCHANCE

Enable hit chance by accuracy and physical scattering of shots (true), or disable to use Gothic's default hit chance calculated by hitchance and distance (Gothic 2) or dexterity and distance (Gothic 1).

GFA_UPDATE_RET_SHOOT

Also update the reticle while the shooting/reloading animation plays. If set to false, the reticle will remain the same in between shots.

GFA_TRAJECTORY_ARC_MAX

Maximum time (ms) after which a projectile trajectory drops off with gravity.

GFA_PROJECTILE_GRAVITY

Amount of gravity to apply to a projectile after GFA_TRAJECTORY_ARC_MAX ms.

GFA_MAX_RECOIL

Visual angle (in degrees) of maximum recoil (when is recoil = 100%).


Config Functions

The configuration of this feature is found in the file config/ranged.d.

The global variable GFA_ProjectilePtr that provides the current projectile, is set to zero for the functions below, because the projectile has not left the shooter. It's properties (like position or instance) are thus trivial to infer. The config function GFA_GetInitialBaseDamage is the only shooting related function where the projectile pointer is provided. The other config functions mentioned below can be called from this function. This offers - for example - to attach an effect to the projectile depending on the draw force.

GFA_GetDrawForce

This function is called at the point of shooting a bow or a crossbow. The return value scales the gravity of the projectile in percent, where 0 is fast gravity drop-off and 100 is the straightest shot possible. Regardless of the percentage, however, all shots are impacted by gravity at the latest after GFA_TRAJECTORY_ARC_MAX milliseconds.

This function is also well-suited to be called by the other functions below.

Ideas: incorporate factors like e.g. a quick-draw talent, weapon-specific stats, ...

By default, for example, bows are scaled with longer draw time (how long has the bow been drawn), whereas crossbows are scaled with shorter aiming time (how long was the aim held steady). This results in slower build up once per aiming for bows and faster build up for crossbows, but restarts every time the mouse moves. Additionally, crossbows have recoil, see GFA_GetRecoil below. All of this is a design choice and can be changed in these functions.

func int GFA_GetDrawForce(C_Item weapon, int talent)
weapon Ranged weapon in use.
talent Talent value depending on the ranged weapon.
returns Draw force in percent (0 = no drop, 100 = maximum drop in gravity).

 

GFA_GetAccuracy

This function is called at the point of shooting a bow or a crossbow. The return value scales the accuracy of the projectile in percent, where 0 is maximum scattering and 100 is precisely on target.

Note: This function is only used, if GFA_TRUE_HITCHANCE is set to true. Otherwise, Gothic's default hit chance calculation (based on skill and distance from target) is used and the accuracy defined here does not take effect!

Ideas: incorporate factors like e.g. weapon-specific accuracy stats, weapon spread, accuracy talent, ...

By default, for example, the accuracy is scaled by talent and by draw force (see function above).
Note: For Gothic 1, instead of the talent, the dexterity is used (as is default for Gothic 1).

func int GFA_GetAccuracy(C_Item weapon, int talent)
weapon Ranged weapon in use.
talent Talent value depending on the ranged weapon.
returns Accuracy in percent (0 = worst, 100 = best).

 

GFA_GetRecoil

This function is called at the point of shooting a bow or a crossbow. The return value scales the recoil of the weapon in percent, where 0 is no recoil and 100 is maximum recoil.

Ideas: incorporate factors like e.g. weapon-specific recoil stats, weapon draw force, strength attribute, ...

By default, for example, the recoil is scaled with strength and is only active for crossbows, to counterbalance the shorter aiming time (better draw force), see GFA_GetDrawForce above.

func int GFA_GetRecoil(C_Item weapon, int talent)
weapon Ranged weapon in use.
talent Talent value depending on the ranged weapon.
returns Recoil in percent (0 = no recoil, 100 = most recoil).

 

GFA_GetInitialBaseDamage

This function is called at the point of shooting a bow or crossbow. It may be used to alter the base damage at time of shooting (if weapon has one damage type only). This should never be necessary, as all damage specifications should be set in the item script of the weapon. However, here the initial damage may be scaled by draw force or accuracy (see functions above). The return value is the base damage (equivalent to the damage in the item script of the weapon).

This is the only shooting related function where the projectile pointer GFA_ProjectilePtr is provided. The other config functions mentioned above can be called from this function. This offers - for example - to attach an effect to the projectile depending on the draw force (see example in the scripts).

Ideas: incorporate factors like e.g. weapon-specific damage stats, draw force, ...

By default, for example, the damage is scaled by draw force to yield less damage when the bow is only briefly drawn, or the crossbow only briefly held steady.

func int GFA_GetInitialBaseDamage(int baseDamage, int damageType, C_Item weapon, int talent, int aimingDistance)
baseDamage Weapon damage as found in the weapon instance script.
damageType Damage type of the weapon (only one is allowed).
weapon Ranged weapon in use.
talent Talent value depending on the ranged weapon.
aimingDistance Aiming distance to the nearest obstacle. Note: This is not necessarily the distance to a target NPC!
returns New base damage for this shot.