-
-
Notifications
You must be signed in to change notification settings - Fork 4
Hit Probability
To represent a learnable character skill for ranged combat with bow and crossbow, Gothic implements a probability at which shots register based on the character skill. The automatic aiming of Gothic calculates whether a shot hits or misses based on two criteria:
- Character skill (dexterity in Gothic 1 amd hit chance talent in Gothic 2)
- Distance to target
The figure above shows the percentage of shots that register a hit (vertical axis) depending on the distance to target (horizontal axis) for different character skill values (colored curves). The left axes show the implementation for Gothic 1 based for different dexterity values, the right axes show Gothic 2 based on hit chance talent, both at their default settings. For a specific distance, the probability of a hitting the target is indicated on the vertical axis where the curves intersect the distance value.
Example (Gothic 1, left graph)
At a distance of 20 meters the 10-dexterity curve indicates a hit probability of 10% on the vertical axis.
Based on the graphs, we can spot difference between Gothic 1 and Gothic 2:
In Gothic 1, the character skill is equal to the hit percentage at 20 meters, whereas in Gothic 2 that distance is 15 meters. The hit percentage is linearly falling with increased distance in Gothic 1. For Gothic 2, however, the implementation is nonlinear and the hit probability approaches zero toward the maximum distance for all character skill values.
Tip
If the default hit probability of Gothic's auto aiming is preferred for free aiming, refer to the configuration around GFA_TRUE_HITCHANCE.
Tip
A discussion of whether free aiming should even implement a hit probability is attached at the bottom of this article.
To implement hit probability, the precision of shots is manipulated based on character skill.
Imperfect shots will deviate from the aiming target with varying angles (colored areas; colors carry no meaning) forming a scattering cone (colored lines) around the perfect flight trajectory (gray line) expanding from the shooter (left).
The implementation of hit probability is based on the circle area of the scattering cone (light gray circle).
The radius of the cone is proportional to the character skill, such that uniform random sampling from the area of the circle results in the desired ratio of hits and misses.
The illustration below shows a human model as target superimposed with the cone circle from the perspective of the shooter.
Consider the player character has a 40% skill. The area of the smaller circle then makes up 40% of the area of the larger circle. Points sampled uniformly from inside the outer circle at random will result in 40% of the points inside the inner circle (red area) and 60% of them will lie in the annulus, the space between the two circle outlines (purple area).
That sampling procedure follows the Monte-Carlo method and will here verify (in simulation) that the circle radii are chosen correctly.
Each panel in the figure above shows the location of 2500 sampled points within the sample radius (circle outline not shown). The data points are superimposed onto a human model and the sample radius is scaled proportionally to the distance and character skill in each panel. Points that intersect with the human model are colored in red. Their percentage is indicated under each illustration as Simulated hits. The percentage of points that instead fall inside the hit radius (compare smaller circle in the figure above), are denoted as Monte-Carlo percentage. For reference the numerical hit probability (non-simulated) of Gothic 2 is shown as G2 autoaim.
-
Focus first on the middle column. At 15 meters distance, simulated hits, Monte Carlo sampling and Gothic's auto aim closely match the character skill.
-
At closer distances (left column), simulated hits sometimes falls short of the respective auto aim probabilities. This is due to the choice of the human model in this case, as the Monte Carlo sampling in fact reaches the correct percentages. Slight inaccuracies are to be expected and not all targets in-game are humanoid!
-
At further distances, unlike the auto aim percentage, both Monte Carlo and simulated hits remain at character skill. Indeed, the sampling radius stays fixed beyond a distance of 15 meters. This design choice is explained further below.
As indicated in the bottom right panel, the sample radius is artificially compressed. While the points are in fact sampled from the full area of the sample circle, any point too far outside is clamped to a maximum deviation. This results in many points forming an outline around the sample area. This design choice does not affect the hit probability and is done to avoid projectiles to stray too far for a better visual experience.
The schematic figure before hinted at two regions in the human model that pose additional hit zones. In the Monte Carlo simulation figure here, it is evident that these additional areas create artifacts and increase the hit probability. But the effects are limited and in favor of free aiming at distances.
While simulations offer a good metric, they do not reflect the experience in the game. The radii of both sampling and hit circles (see above) were carefully adjusted in a controlled environment. In a semi-automated process the player character shot at a stationary humanoid target using six different character skill values, at ten different fixed shooting distances with 1000 shots each.
The goal was to mimic the hit probability of the auto aim of Gothic 2 at close distances. Unlike auto aiming, however, the hit probability should remain at the character skill at distances beyond 15 meters. As larger distances become naturally harder to navigate in free aiming, an artificial decrease in hit probability is avoided.
The figure below is setup the same way as the figure at the top of this article: Curves for different character skills show the hit probability (vertical axis) at different distances (horizontal axis). The left axes show the actual hit on the target and the right axes show the hits based Monte Carlo - both in-game. The Monte Carlo sampling serves as a verification of the implementation as it faithfully matches the underlying numerical simulations (underneath in color). The shots on target align well too. Nevertheless, the hit probabilities are slightly elevated. As briefly explained above, this is a variation based on the use of the human model.Most models in the game have a quite small surface area when facing (and running towards) the player. On average across all Gothic 2 NPC and monster models that surface area amounts to a circle with a radius of 47.3 cm. This size matches the implementation closely (50 cm radius for hits considered) and ensures that the hit probability is - on average - in line with the auto aiming.
This concludes the documentation of the hit probability implementation in free aiming. Below, there is further discussion.
This section explains the design choices made. Let's start from the beginning.
The first big question is whether hit percentages should be implemented in free aiming.
-
On the one hand, it is free aiming. There should not be any mechanism to adjust the hit probability. After all, we are shooting where we are aiming!
-
On the other hand, Gothic has the hit chances tightly integrated into the learning element of the game. Free aiming without some sort of hit probability would make the learning points obsolete. This also does not match the role-playing aspect of the game, if the playing character has perfect accuracy when picking up a bow for the very first time in their life.
-
Furthermore, having no hit probability would also be completely imbalanced when comparing auto aiming with free aiming. Using free aiming should not be too superior, because there are players who prefer auto aiming that want to have a similar playing experience.
Note
It is clear that free aiming, too, needs some sort of hit probability scaled by dexterity (Gothic 1) and hit chance talent (Gothic 2).
The next big question is how hit percentages should be implemented in free aiming.
Gothic's auto aiming physically hits every shot. Only when the shot arrives on target, Gothic calculates whether a hit registers based on probabilities. The same could be done for free aiming, but when a shot was aimed well and hits its target physically, it should naturally also register. Otherwise free aiming looses much of its charm and logic.
To detach the player's skill from the in-game character skill, imperfect aerodynamics offer a great solution: random scattering of shots based on character skill!
Tip
If you prefer the hit probability based on Gothic's auto aiming while shooting arrows perfectly, refer to the configuration around GFA_TRUE_HITCHANCE.
During a perfect shot, a projectile arrives exactly where it was aimed at. A shot that is imprecise will arrive slightly off, that is, it deviates from the target. From the perspective of the shooter, the origin of the flight trajectory, this deviation can be described as an angle. Specifically that is the angle between the intended and the actual trajectory.
This angle-based scattering of shots forms a cone expanding from the origin centered around the imaginary aiming line. In the illustration, the projectile is shot from left to right and the possible deviations form an expanding cone around the trajectory around the target (plus sign; colors carry no meaning). The area of the cone base (light gray circle in the illustration) is the spread of shots on the target.
This scattering cone already comes with interesting properties:
- Each shot can be assigned a random deviation in a range based on the character skill.
- The maximum deviation can be decreased with increasing character skill to increase the hit probability: The cone becomes tighter for higher skill level.
- The hit probability naturally decreases with distance as the cone is expanding. The further away the target is, the larger the radius (and area) of the cone base at that distance.
The expanding scattering cone sounds like a fitting solution for a hit probability implementation. Unfortunately, the area of the cone base increases not linearly but proportionally to the square of the radius. That makes the hit probability difficult to control, especially when trying to implement it similarly to Gothic's auto aiming. The scattering cannot match the hit probability at small and also of large distances.
- Either the hit probability is correct at large distances, but close targets are always hit. The character skill does not matter and free aiming is very easy at realistic target distances.
- Or the hit probability is correct for medium range distances, but targets further away are always missed. Free aiming becomes frustrating and objectively worse that auto aiming at large distances.
Gothic Free Aim (versions <= 1.3) attempted to tweak these two extremes as best as possible. This list of forum posts illustrates the thought process, ideas from the community, and a final implementation including equations and videos demonstrating empirical tests. Nevertheless, no matter the effort, the problem could not be solved. The hit probability always left players unsatisfied and certainly did not fully match Gothic's auto aim hit probability.
The new implementation (version >= 1.4) tackles the problem anew. Please view the figures above to convince yourself of the implementation.
First, it is important to acknowledge the unnatural hit probability of Gothic's auto aiming. It is impossible to both have physically realistic spread and also mimic Gothic's hit probability. Compromises have to be made. Let's establish the basic requirements, that hit probability in free aiming needs to meet.
- The hit probability percent matches the character skill value at 15 meters distance. For example, with a skill of 50 (dexterity or hit chance talent), 50% of the shots have to register at 15 meters distance, like they do in Gothic 2.
- The probability should increase with shorter distances. For example, with a skill of 50, targets closer than 15 meters should be hit more that 50%. Ideally matching the probabilities of Gothic 2.
The probability should decrease at greater distances.
Note, that the last point on the list is dropped here: Going back to the start, Gothic's auto aim calculation is explicitly based on distance, because farther targets are naturally harder to hit. Free aiming itself already accounts for that, because it is physically more difficult for the player to aim at targets in the distance.
Based on these points, the hit probability for free aiming should
- Mimic the auto aim hit probability at close range and decrease from 100% to the character skill at 15 meters
- Stay constant beyond 15 meters with character skill = hit probability
That requires the calculation of the hit probability to be split into two regimes (distance < 15 meters and distance >= 15 meters), with the first regime being non-linear and both involving the aiming distance.
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