-
-
Notifications
You must be signed in to change notification settings - Fork 4
Critical Hits
The feature Critical Hits (GFA_CRITICALHITS
) implements critical hits for ranged weapons. The customization allows to define which body parts are weak spots and what happens when a critical hit occurs (event like screen print, sound jingle, additional XP, ...).
On projectile collision and positive hit registration with an NPC, a "config function" is called (GFA_GetCriticalHitDefinitions). In this function, based on the hit NPC, the weapon used, the damage, etc., you define a weak spot. This weak spot is defined by the name of the bone of the NPC model (e.g. "Bip01 Head") and a new base damage value (the damage of the weapon, not the final, applied damage).
After this function returns the weak spot definition (this can be different every time), the collision with the NPC is checked for the bone ("Was the NPC hit in Bip01 Head?"). If so, the damage will be overwritten with the newly defined damage value and another config function is called (GFA_StartCriticalHitEvent). This second function allows to start an event. By default a sound jingle is played and a hit marker is shown briefly to signal the critical hit. If the projectile did not hit the defined bone, the damage will of course not be adjusted and the event function will not be called.
The first part of this implementation differs, if free aiming for ranged weapons is not activated (e.g. disabled in the game menu, or when playing with keyboard controls only) or if the setting constant GFA_TRUE_HITCHANCE
is set to false. If that is the case, the shot cannot be checked for a specific bone of the model and a different config function is called instead (GFA_GetCriticalHitAutoAim). In this function you can return a critical hit probability, which will be used instead. The event function will be called on positive critical hit.
Keep in mind, that you should always adjust both of these alternatives, because there are players that prefer to play the game keyboard-only or others who might not like free aiming (boring!).
Contents 1. Variables |
This variable stores the number of critical hits for a game. It is internally increased and should not be modified. Its use should be purely read-only and may aid in features like critical hit counters.
This variable is primarily used to view the shooting statistics in a running game via the console command GFA STATS
.
The configuration of this feature is found in the file config/criticalHit.d.
This function is called every time (any kind of) NPC is hit by a projectile (arrows and bolts) to determine, whether a critical hit occurred. It defines the critical hit zone (weak spot) based on the NPC that it hit or the weapon used. A weak spot is defined by the name of a bone of the model and modified damage. This function is dynamic: It is called on every hit and the weak spot and damage can be calculated individually differently every time.
Note: This function is specific to active free aiming with scattering (GFA_TRUE_HITCHANCE
is true). For critical hits without free aiming see GFA_GetCriticalHitAutoAim below.
Note: This function only defines the critical hits. It is called every time an NPC is hit, regardless of whether it is a critical hit. To start an event when a critical hit actually occurs, see GFA_StartCriticalHitEvent below.
Ideas: incorporate weapon-specific stats, head shot talent, dependency on target, ...
Examples are given inside the function, but commented out to serve as inspiration of what is possible.
By default, weak spots for all Gothic 1 and Gothic 2 monsters are defined as head shots.
func void GFA_GetCriticalHitDefinitions(C_Npc target, C_Item weapon, int talent, int damage, int damageType, int returnPtr)
target |
The NPC that is hit by the projectile. |
weapon |
The ranged weapon that the shooter used (might be empty if unequipped immediately!). |
talent |
The talent value of the shooter depending on the ranged weapon. |
damage |
Base damage (damage of the ranged weapon), not the final damage! This value is an integer float. |
damageType |
Damage type of the projectile. |
returnPtr |
Instance pointer to the weak spot definition. |
This function is called every time (any kind of) NPC is hit by a projectile (arrows and bolts) to determine, whether a critical hit occurred. It allows to define a critical hit chance even for the standard auto aiming. Although not existing in the original Gothic 2, this is important here to balance the damage output between free aiming and auto aiming, as the player may switch between them anytime during a running game in the game menu.
Note: This is not necessary for Gothic 1, as it already has critical hits for auto aiming by default. Nevertheless, the original critical hit calculation of Gothic 1 is disabled and replaced by this function. This way, the critical hit chance can be manipulated if desired. The lines of code in the function for Gothic 1 lead to the default behavior of Gothic 1.
Note: This function is only called if free aiming is disabled, not active (game settings) or GFA_TRUE_HITCHANCE
is false. For critical hits with free aiming see GFA_GetCriticalHitDefinitions above.
Ideas: scale critical hit chance with player skill and distance, ...
Examples are given inside the function (section of Gothic 2), but commented out to serve as inspiration of what is possible.
func int GFA_GetCriticalHitAutoAim(C_Npc target, C_Item weapon, int talent)
target |
The NPC that is hit by the projectile. |
weapon |
The ranged weapon that the shooter used (might be empty if unequipped immediately!). |
talent |
The talent value of the shooter depending on the ranged weapon. |
returns | Percentage (chance level or hit chance), where 0 is no critical hit ever and and 100 always causes a critical hit. Everything in between is dependent on a respective probability. To disable this feature, simply have the function always return 0. |
This function is called when a critical hit occurs and can be used to print something to the screen, play a sound jingle or, as done here by default, show a hit marker. Leave this function blank for no event.
This function is called regardless of whether free aiming is active.
Idea: The critical hits could be counted here to give an XP reward after 25 head shots, print to screen, ...
Examples are given inside the function, but commented out to serve as inspiration of what is possible.
func void GFA_StartCriticalHitEvent(C_Npc target, C_Item weapon, int freeAimingIsEnabled)
target |
The NPC that is hit by the projectile. |
weapon |
The ranged weapon that the shooter used (might be empty if unequipped immediately!). |
freeAimingIsEnabled |
Indicator whether free aiming is currently active. |
Table of Contents
Features
Youtube Trailer
Demo Modifications
Installation & Requirements
Gothic 1
Gothic 2
Features & Configuration
Free Aiming
Ranged Combat
Spells
Re-usable Projectiles
Custom Collisions
Critical Hits
Hit Probability NEW
Creating a Mod File
Project Architecture
Debugging & Console Commands
Download
Free Aiming Patch
Settings for Players
Changelog
FAQ
Support this project
Acknowledgements
Contact & Discussion