szapp / gothicfreeaim Goto Github PK
View Code? Open in Web Editor NEWFree aiming for the video games Gothic and Gothic 2
Home Page: https://gfa.szapp.de
License: MIT License
Free aiming for the video games Gothic and Gothic 2
Home Page: https://gfa.szapp.de
License: MIT License
The update of the model rotation by mouse movement needs to be done before the aim position is estimated.
Flip the crosshair and flip the player model's shoulder to look over.
See here:
Only hook functions that really need to be hooked. Outsource common mechanics to functions that can be called by ranged free aim and spell free aim.
For the first level of aiming the crosshair could move, making aiming more difficult in the distance. Higher levels will offer 'steady aim'.
Add free rotation and find correct address to hook to inject aim vob to enable free aiming for spells. Ref #2.
Latest update: The aim vob sometimes returns to the heros hand (for no apparent reason).
Once projectiles get stuck on collision, they are too far in and are not easy to pick up. On impact move them back a little.
A better (and correct way) to calculate the angles is by creating the position vector by
x = 0
y = 0
z = distance (between target position and camera)
Then apply the rotations around y and x axes and finally add the resulting vector onto the camera vector.
Arrows fly in a straight line and never drop down. The trajectory of the arrow could be changed to an arc.
'How' is the big question, since the engine offers no complex flight path for projectiles (it has only a destination and keeps only going in that direction).
Implement a multiplier for headshots.
This might help as guidance:
func int Npc_GetModel(var C_NPC slf) {
CALL__thiscall(_@(slf), 7571232);
return CALL_RetValAsPtr();
};
func int zCModel_SearchNode(var C_NPC slf, var string node) {
var int ptr; ptr = Npc_GetModel(slf);
CALL_zStringPtrParam(node);
CALL__thiscall(ptr, 5758960);
return CALL_RetValAsPtr();
};
func void SomeFunction() {
var int node; node = zCModel_SearchNode(hero, "Bip01 Head"); // zCModelNodeInst*
// Compare projectile bbox with node bbox
};
The aim vob needs to be recognized as valid focus (target) vob of the spell for the spellFX to function.
The camera is aligned with the trajectory of the projectile, which is very good for accurate shots. However, since the camera is exactly behind the trailVob, the pfx is not visible.
The projectile becomes invisible, which is bad because there is no more reference where one is shooting.
The first spell level does not have any FX and is thus an empty instance. It is a little redundant.
The internal y-movement of the mouse while aiming feels sluggish. Replace it by manual control.
Maybe the entire mouse movement can be left to the engine, by just overwriting the memory to by-pass the if-conditions. This does not work so easily.
Find oCVisualFX in IDA and document it.
Fix the target position. Since the camera is shifted to the side of the hero, the aiming is no lined up with the crosshair.
Most settings at the top of the freeAim script are constants - are they modifiable from the scripts?
With the projectile dropping off with distance, the aiming is less accurate as the aim vob is not aligned with the trajectory.
The instance CamModRanged
responsible for aligning the camera, is not located in the content scripts and therefore not easily accessible.
When starting a new game, the recyclable calls are causing the game to crash.
When an enemy stand directly in front of the player, projectiles get stuck in the air.
Find oCSpell in IDA an document it.
The scattering and drop-off need to be scalable with talent and weapon stats.
The time after which the projectile is assigned gravity should be adjusted
The classes oCAIArrow
and zCRigidBody
might be different in gothic 1.
If they are, the code can be shortened with this:
MEM_WriteByte(rigidBody+256, 1); // Turn on gravity (zCRigidBody.bitfield) // Check compatibility with gothic 1
A dynamic accuracy dependent on weapon stats, talent and draw force could be implemented by a function.
Instead of relying on the cursor package of LeGo (which is just another dependency), the mouse handling can be done more straight-forward.
Change this line
var int deltaX; deltaX = mulf(mkf(Cursor_RelX), MEM_ReadInt(Cursor_sX)); // Get mouse change in x
into
var int deltaX; deltaX = mulf(mkf(MEM_ReadInt(mouseDeltaX)), MEM_ReadInt(mouseSensX)); // Get mouse change in x
And add these constants:
const int mouseSensX = 9019720; //0x89A148
const int mouseDeltaX = 9246300; //0x8D165C
Turn off gothic's internal hit chance and implement scattering around the crosshair instead.
Check this post for guidance.
The scattering should happen by adding a random angle to shootTarget()
.
For displaying focus information a trace ray is shot detecting bounding boxes (necessary to detect npcs which are otherwise ignored by trace rays). However, the bounding boxes of (invisible) vobs get in the way, and block the trace ray.
To fix this, shoot a trace ray without bbox detection if there is no focus npc. In the other case shoot a bbox detecting trace ray. If in the second case the found vob is not an oCNpc, ignore the close range and take the distance of the first trace ray or (to be more conservative with performance) set it to the maximum distance.
The focus collection should be set to stricter angles for this to work better.
Shoot a bbox trace ray but also set the ignore vobs flag. What will happen?
The current "normal crosshair" is blocking too much vision. For the ranged weapons (or as standard crosshair) a pointy arrow upwards might be better. Like a cirumflex: ^
When only aiming briefly the force behind the shot should be smaller.
Force could be:
While aiming, it would be nice to be able to strafe to left and right. Is it possible to run the aiming and the strafing animation at the same time?
Free aiming should only be possible with mouse enabled. Add a respective if-phrase in the hooks.
The draw force should be emphasized by longer animation.
A next idea would be to implement two sets of animations, for a "quick reload" talent.
Mouse movement speed is different in different environments. It needs to be locked with framerame.
What happens when projectiles bounce off of armor (happens on unregistered hit on metal material armor) - is the projectile placed in inventory or kept alive on the ground?
To properly clear the focus vob it is probably better to use this engine function.
0x732BC0 void __thiscall oCNpc::ClearFocusVob(void)
Setting the focus and camera is currently done inside the function that is called to verify whether free aiming is active. The issue here is, that this function is called multiple times a frame from different functions - and consequently takes more performance than necessary.
The settings should be outsourced.
The targeting system seems to be broken. Sometimes the arrow flies into random directions.
Free aim should have some options. These could be implemented in the Gothic.ini
and in the game menu.
A good idea would be search for the settings in the Gothic.ini
by MEM_GetModOpt(var string sectionname, var string optionname)
. If they are present take them from there, if not take the settings from a respective constant and also it write it to the Gothic.ini
with MEM_SetGothOpt (var string section, var string option, var string value)
.
Adding the options to be changable by the end-user from the game menu is another step. This could be left to the author of the mod.
For changing the menu see this post for reference.
The mouse gets stuck if it is not moved by a minimum amount of speed. Does this also happen if the internal mouse sensitivity (in the game menu) is set to another value? In this case turn in to the minimum as it is at the maximum value atm.
Show the healthbar and focus name of NPCs that is being aimed at (and only as long as they are being aimed at!). The focus collection (from Focus.d
) does not free the focused NPCs. Thus, another possibility would be to shoot a trace ray and if the intersection polygon is an NPC show their healthbar (how?).
When changing the free aim setting (enabled/disabled), update the camera.
This needs some address ressearch.
Add the following files to repo (for completeness, to secure them, and tracking changes).
Turning is only allowed while aiming. So when an arrow has just been shoot, the player is stuck and mouse movements to the side have no effect until the next arrow is drawn.
This might cause problems when starting a new session while the frame function is active:
var int rigidBody; rigidBody = CALL_RetValAsInt(); // zCRigidBody*
FF_ApplyOnceExtData(dropProjectile, 500, 1, rigidBody); // Safe?
The engine must have some kind of frame lock on mouse movement implemented. Find it.
This does not stop the ff, if another spell is active (only when none is active). Change -1
into SPL_Blink
in line 31.
if (Npc_GetActiveSpell(caster) == -1) { // If blink is not actually being casted
if (FF_Active(Spell_Invest_Blink)) { FF_RemoveData(Spell_Invest_Blink, casterId); };
return;
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.