Skip to content

Free Aiming

szapp edited this page Oct 30, 2017 · 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.
 

List of setting constants

GFA_STRAFING
GFA_NO_AIM_NO_FOCUS
GFA_ROTATION_SCALE
GFA_CAMERA_X_SHIFT
GFA_DEBUG_CONSOLE
GFA_DEBUG_PRINT

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

Reticle Adjustments

GFA_GetRangedReticle
GFA_GetSpellReticle
 
GFA_AnimateReticleByTime
GFA_AnimateReticleByPercent

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

Fundamental Settings

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

Remove focus when not aiming. The focus (focus name and focus bar) will only be visible in combat when aiming. This prevents using ranged weapons or spells as enemy detector when running around with them drawn. This setting 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_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.


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. Their names are defined as string constants in config/reticleTextures.d for easy usage along with some recommendations. The reticle can be hidden by setting the texture to an empty string.
The color can be created with LeGo's RGBA function.

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.

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.