Coder Social home page Coder Social logo

gothicfreeaim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gothicfreeaim's Issues

Clean up hooks

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.

Implement steady aim

For the first level of aiming the crosshair could move, making aiming more difficult in the distance. Higher levels will offer 'steady aim'.

Implement rotation and free shooting

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).

Move collectible projectiles

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.

Scattering angles are calculated incorrectly

  1. The second angular axis should not be z but x
  2. The axes are world axes and not the ones of the camera

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.

Implement trajectory drop-off

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).

Headshot detection

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
};

Set aim vob as focus vob

The aim vob needs to be recognized as valid focus (target) vob of the spell for the spellFX to function.

With aligned camera the arrow trail is not visible

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.

Remove first spell level

The first spell level does not have any FX and is thus an empty instance. It is a little redundant.

Revise mouse y-movement

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.

Camera shift

Fix the target position. Since the camera is shifted to the side of the hero, the aiming is no lined up with the crosshair.

Circular scattering pattern

Right now the scattering pattern is in a diamond (see below). This should be adjusted into a circle or ellipse.

Also check the rgn: The center seems to be less populated.

e82COa7[1].jpg

Enable two shoulder views

The instance CamModRanged responsible for aligning the camera, is not located in the content scripts and therefore not easily accessible.

Ensure classes are the same in gothic 1

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

Improve mouse handling

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

Alternative hit chance

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().

Focus trace ray gets stuck on invisible vobs/bboxes

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.

Possible Fix

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.

Alternative

Shoot a bbox trace ray but also set the ignore vobs flag. What will happen?

Create new crosshair

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: ^

Implement draw force

When only aiming briefly the force behind the shot should be smaller.

Force could be:

  • Solely the animation (draw speed)?
  • Decrease in arrow speed?
  • Increase in drop-off? Moved to #29
  • Decrease in damage?
  • Or don't allow shooting until bow is fully drawn?

Old attempts at strafing

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?

Draw force animations

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.

Properly clear the focus vob

To properly clear the focus vob it is probably better to use this engine function.

0x732BC0  void __thiscall oCNpc::ClearFocusVob(void)

Move focus and camera settings out of free aim check

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.

Implement options frame work

Free aim should have some options. These could be implemented in the Gothic.ini and in the game menu.

  • Enable/disable free aiming.
  • Enable/disable trace ray while aiming (for performance +-10 fps).
  • Enable/disable crosshair coloring (requires trace ray while aiming to be enabled).
  • Set the shoulder to look over (left/right).
  • Set the default crosshair (does this have to be change-able by the user)?

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.

Check mouse sensitivity

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 focus information (healthbar and name)

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?).

Add FX scripts to repo

Add the following files to repo (for completeness, to secure them, and tracking changes).

  • VisualFX_Inst.d
  • PfxInstMagic.d

Allow turning while/after shooting

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.

Update trace ray start vector

By means of Pythagoras, shift the start vector to be aligned with the distance between camera and player model to be more consistent and allow different camera-model-distances.

targetVector.png

Make sure rigidBody pointer is sound on session loading.

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?

Specify spell ID in spell active check

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;
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.