Skip to content

Free Aiming

szapp edited this page Dec 9, 2018 · 12 revisions

The Feature Free Aiming (GFA_RANGED and/or GFA_SPELLS) offers some fundamental configuration options, as well as reticle adjustments. Detailed configuration, however, is separated into free aiming for ranged combat and free aiming for spells.
 

Contents

1.   Fundamental Settings
    1.1.   GFA_STRAFING
    1.2.   GFA_NO_AIM_NO_FOCUS
    1.3.   GFA_ROTATION_SCALE
    1.4.   GFA_CAMERA_X_SHIFT
    1.5.   GFA_DEBUG_CONSOLE
    1.6.   GFA_DEBUG_PRINT
2.   INI Settings
3.   Reticle Configuration
    3.1.   GFA_GetRangedReticle
    3.2.   GFA_GetSpellReticle
4.   Reticle Helper Functions
    4.1.   GFA_AnimateReticleByTime
    4.2.   GFA_AnimateReticleByPercent


Fundamental Settings

These settings are static (constants). They are and under no circumstances should be changed during the game. They are general free aiming settings and affect free aiming for both ranged combat and spells.

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

GFA_STRAFING

Enable/Disable the movement while aiming. This affects both ranged and spell combat, but is only applied to either if free aiming for them is initialized (GFA_RANGED and/or GFA_SPELLS).

GFA_NO_AIM_NO_FOCUS

This constant is no longer a configuration setting. Since v1.1.0 it has been outsourced into the INI settings for more freedom for the end user.

GFA_ROTATION_SCALE

Turn rate while aiming. This constant has by default a carefully chosen value and it is not recommended to change this constant. This has nothing to do with mouse sensitivity. Do not change if you don't know what you are doing. Affects Gothic 1 controls only.

GFA_CAMERA_X_SHIFT

Set to true, if the free aiming camera (CCamSys_Def script instance) is modified to shoulder view. This is not recommended! Shot origin and camera would be to different causing parallax effect and aiming becomes highly inaccurate.

GFA_DEBUG_CONSOLE

Enable console commands (debugging). It is recommended to disable in this in a final mod release.

GFA_DEBUG_PRINT

Disply output information to zSpy by default. This can also be enabled via console in a running game, if GFA_DEBUG_CONSOLE is enabled.


INI Settings

Some settings have been outsourced into the Gothic.ini-file to be made adjustable by the players. They are grouped under the section [GFA]. The INI-section and INI-entries are auto generated with their default values when GFA is first used (or if they are missing).

[GFA]
freeAimingEnabled=1            ; Equivalent to the menu setting (on/off)
focusUpdateIntervalMS=0        ; Changes the frequency of focus collection
                               ; Increase when performance is low (not recommended)
showFocusWhenNotAiming=0       ; Show focus name and focus bar when not aiming
                               ; When zero, this prevents using ranged weapons or
                               ; spells as "enemy detector" when running around
                               ; with them drawn. This setting affects both ranged
                               ; and spell combat, with the exception of spells in
                               ; Gothic 2 combat (player is continuously aiming).
reticleSizePx=64               ; Reticle size in pixels (at its largest)
                               ; Useful to increase with ultra high resolution
overwriteControlSchemeRanged=0 ; Override ranged combat controls *)
overwriteControlSchemeSpells=0 ; Override spell combat controls  *)

; *)
; 0 = Automatic/default: Follow the general control scheme setting from the menu
; 1 = Override with Gothic 1 controls
; 2 = Override with Gothic 2 controls

The entries about the control scheme overrides, only take effect in Gothic 2. The differences between the control schemes are explained on the wiki pages for ranged combat and spells.


Reticle

The reticle is very dynamic as it may change with aiming distance, target focus and may be animated by time or external criteria. A reticle has the following properties kept in the Reticle class. You do not have to create or maintain this class in the configuration, but only fill or change its properties in the config functions below.

class Reticle {
    var string texture; // Texture file name
    var int size;       // Size in percentage (100 is biggest size, 0 is smallest)
    var int color;      // zCOLOR
};

GFA already comes with a collection of reticle texture files. The reticle can be hidden by setting the texture to an empty string.
The color can be created with LeGo's RGBA function.

The configuration of the reticle is found in the file config/reticle.d.

GFA_GetRangedReticle

This function is called continuously while aiming with a ranged weapon (bows and crossbows). It allows defining the reticle texture, size and color at any point in time while aiming, based on a variety of properties.

Ideas: more sophisticated customization like e.g. change the texture by draw force, the size by accuracy, ...
Examples are given inside the function, but commented out to serve as inspiration of what is possible.

By default, for example, the size is scaled by aiming distance. As indicated by the in-line comments in the function, basing the size (or color) on the functions GFA_GetDrawForce and GFA_GetAccuracy is also possible.

func void GFA_GetRangedReticle(C_Npc target, C_Item weapon, int talent, int dist, int returnPtr)
target The NPC that is in focus (if any).
weapon The ranged weapon in use.
talent The talent value depending on the ranged weapon.
dist Aiming distance to the next obstacle.
returnPtr Instance pointer to the reticle definition.

 

GFA_GetSpellReticle

This function is called continuously while aiming with a spells. It allows defining the reticle texture, size and color at any point in time while aiming, based on a variety of spell properties.

To hide the reticle (might be of interest for certain spells), set the texture to an empty string.

Ideas: more sophisticated customization like e.g. change the texture by spellID, the size by spellLevel, ...
Examples are given inside the function, but commented out to serve as inspiration of what is possible.

By default, for example, the size is scaled by aiming distance. As indicated by the in-line comments in the function, basing the size (or color) on the any provided spell properties is easily possible.

func void GFA_GetSpellReticle(C_Npc target, int spellID, C_Spell spellInst, int spellLevel, int isScroll, int manaInvested, int dist, int returnPtr)
target The NPC that is in focus (if any).
spellID The current spell ID (e.g. SPL_Firebolt).
spellInst The C_Spell instance of the current spell.
spellLevel The spell level as defined by the Spell_Logic_* function.
isScroll Is the spell a scroll (true/false).
manaInvested How much many was invested up to this point.
dist Aiming distance to the next obstacle.
returnPtr Instance pointer to the reticle definition.

Reticle Helper Functions

These functions are provided by GFA an aid in visualizing the reticle. They may be used in the functions above documented.

GFA_AnimateReticleByTime

This is not a config function. It is a function provided by GFA and can be called from outside.
This function allows animated reticle textures dependent on time.

func string GFA_AnimateReticleByTime(string textureFileName, int framesPerSecond, int numberOfFrames)
textureFileName The base file name for which the several textures exist with the postfix textureFileName_00.tga, ..., textureFileName_numFrames-1.tga.
framesPerSecond FPS of the animation.
numFrames The number of texture files belonging to the animation.
returns The texture file name depending on the current frame time.

 

GFA_AnimateReticleByPercent

This is not a config function. It is a function provided by GFA and can be called from outside.
This function allows animated reticle textures dependent on a given percentage. This is useful to indicate progress of draw force or distance to target or any other gradual property.

func string GFA_AnimateReticleByPercent(string textureFileName, int percent, int numberOfFrames)
textureFileName The base file name for which the several textures exist with the postfix textureFileName_00.tga, ..., textureFileName_numFrames-1.tga.
percent Percentage along 0 and numFrames-1.
numFrames The number of texture files belonging to the animation.
returns The texture file name depending on percent.