Skip to content

Free Aiming For Spells

szapp edited this page Dec 12, 2017 · 23 revisions

The feature Free Aiming for Spells (GFA_SPELLS) implements free aiming for spell combat. There is not much room for configuration.

For adjustments to the reticle for spells, see reticle adjustments.
 

Contents

1.   Requirements for Spells
    1.1.   Free Movement
    1.2.   Free Aiming
2.   Config Functions
    2.1.   GFA_ShiftAimVob
3.   Aim Vob Helper Functions
    3.1.   GFA_AimVobAttachFX
    3.2.   GFA_AimVobDetachFX


Requirements for Spells

Not all spells support free aiming or movement while investing/casting as explained here. Three properties of the C_Spell instance decide over the mechanic of each spell.

Class C_Spell {
    // ...
    var int targetCollectAlgo;
    var int canTurnDuringInvest;
    var int canChangeTargetDuringInvest;
};

All Gothic 1 and Gothic 2 spells meet the necessary requirements (or explicitly don't if they shouldn't) of these properties out of the box. The properties of any new spells, you might design or introduce to your mod, should be adjusted to the requirements below.

Here is an overview. For requirements of the spell properties see below.

Spell Type Example
Free aiming +
Movement while while investing/casting
Projectile spells Fireball
Movement while while investing/casting Area-of-effect spells
Summoning spells
Light spells
Firerain
Summon Golem
Light
Stationary (vanilla Gothic) Focus spells
Healing spells
Teleport spells
Transformation spells
Sleep/Control
Medium Heal
Teleport
Transf. to Sheep

Free Movement

For a spell to support movement while investing/casting, the properties need to meet the following requirements.

  • targetCollectAlgo must not be TARGET_COLLECT_FOCUS
  • canTurnDuringInvest must be true

If any of the requirements is not met, the spell behaves like in Gothic vanilla. This is, however, sometimes desired like for example for sleep or control (Gothic 1), where the player should remain stationary.

Free Aiming

For a spell to support movement while investing/cast and free aiming, the properties need to need the following requirements:

  • targetCollectAlgo must be TARGET_COLLECT_FOCUS_FALLBACK_NONE
  • canTurnDuringInvest must be true
  • canChangeTargetDuringInvest must be true

Config Functions

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

GFA_ShiftAimVob

This function is called continuously while aiming with spells to correct the aim vob position.
It should never be of use and should be adjusted for individual spells only. Usually, no spell requires the aim vob to be shifted. Exceptions are spells that utilize the aim vob as target to spawn VFX on it with the functions GFA_AimVobAttachFX and GFA_AimVobDetachFX.

func int GFA_ShiftAimVob(var int spellID, var int posPtr)
spellID Active spell ID (e.g. SPL_Firebolt)
posPtr Pointer to the position vector of the aim vob
return Distance in centimeters to shift the aim vob along the viewing angle of the camera.

Aim Vob Helper Functions

These functions are provided by GFA and aid in visualizing the aim vob. They may be used in the function documented above.

GFA_AimVobAttachFX

This is not a config function. It is a function provided by GFA and can be called from outside.
Attach a visual FX to the aim vob. This function is never used internally, but is useful for spells that visualize the aim vob.
This function should go hand in hand with detaching the visual FX (GFA_AimVobDetachFX): If you attach an FX, you should make sure to remove the FX, when it is no longer needed.

func void GFA_AimVobAttachFX(string effectInst)
effectInst VisualFX instance to attach (e.g. "spellFX_LIGHTSTAR_WHITE")

 

GFA_AimVobDetachFX

This is not a config function. It is a function provided by GFA and can be called from outside.
Detach the visual FX from the aim vob, that was previously spawned with GFA_AimVobAttachFX.

func void GFA_AimVobDetachFX()