Coder Social home page Coder Social logo

Comments (5)

szapp avatar szapp commented on June 2, 2024

Fix #48 #50 scatter

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

The above approaches are incorrect. Refer to this link.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

The code above is completely wrong.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

The distance cannot be adjusted, as it is needed in other functions the way it is now. Instead implement a new function argument in aimRay() to retrieve a "true distance" separately.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

Before:

// Manipulate aiming position (scatter/accuracy): Rotate position by y and z axes
var zMAT4 camPos; camPos = _^(MEM_ReadInt(MEM_ReadInt(MEMINT_oGame_Pointer_Address)+20)+60); //0=right, 2=out, 3=pos
pos[0] = subf(pos[0], camPos.v0[3]); // For modifying the angle, move the vector to origin (afterwards back)
pos[1] = subf(pos[1], camPos.v1[3]);
pos[2] = subf(pos[2], camPos.v2[3]);
var int accuracy; accuracy = 0; // Outsource into a function e.g. getAccurracy();
if (accuracy > 100) { accuracy = 100; } else if (accuracy < 1) { accuracy = 1; };
var int angleMax; angleMax = roundf(mulf(mulf(fracf(1, accuracy), castToIntf(FREEAIM_SCATTER_DEG)), mkf(1000)));
var int angleY; angleY = fracf(r_MinMax(-angleMax, angleMax), 1000);
SinCosApprox(Print_ToRadian(angleY));
var int rotX; rotX = addf(mulf(pos[0], cosApprox), mulf(pos[2], sinApprox));
pos[2] = subf(mulf(pos[2], cosApprox), mulf(pos[0], sinApprox));
angleMax -= roundf(mulf(absf(angleY), mkf(1000))); // Diamond scatter pattern
var int angleZ; angleZ = fracf(r_MinMax(-angleMax, angleMax), 1000);
SinCosApprox(Print_ToRadian(angleZ));
pos[0] = subf(mulf(rotX, cosApprox), mulf(pos[1], sinApprox));
pos[1] = addf(mulf(rotX, sinApprox), mulf(pos[1], cosApprox));
pos[0] = addf(pos[0], camPos.v0[3]); // Move back, past camera position
pos[1] = addf(pos[1], camPos.v1[3]);
pos[2] = addf(pos[2], camPos.v2[3]);

Corrected:

  1. Correct the distance in aimRay to reflect the distance from intersection to camera.
  2. Rework the scattering like so:
/* Retrieve only distance from aimRay(), not position */

// Manipulate aiming position (scatter/accuracy): Rotate position around y and x axes (left/right, up/down)
var int pos[3]; pos[0] = FLOATNULL; pos[1] = FLOATNULL; pos[2] = distance;
var int accuracy; accuracy = 0; // Outsource into a function e.g. getAccurracy();
if (accuracy > 100) { accuracy = 100; } else if (accuracy < 1) { accuracy = 1; };
var int angleMax; angleMax = roundf(mulf(mulf(fracf(1, accuracy), castToIntf(FREEAIM_SCATTER_DEG)), mkf(1000)));
var int angleY; angleY = fracf(r_MinMax(-angleMax, angleMax), 1000);
SinCosApprox(Print_ToRadian(angleY)); // Rotate around y-axis (left-right scatter)
pos[0] = mulf(pos[2], sinApprox); // x*cosθ + z*sinθ = x'
pos[2] = mulf(pos[2], cosApprox); // −x*sinθ + z*cosθ = z'
angleMax = roundf(sqrtf(subf(sqrf(mkf(angleMax)), sqrf(mulf(angleY, mkf(1000)))))); // sqrt(angleMax^2-angleY^2), pattern, see #48
var int angleX; angleX = fracf(r_MinMax(-angleMax, angleMax), 1000);
SinCosApprox(Print_ToRadian(angleX)); // Rotate around x-axis (up-down scatter)
pos[1] = mulf(negf(pos[2]), sinApprox); // y*cosθ − z*sinθ = y'
pos[2] = mulf(pos[2], cosApprox); // y*sinθ + z*cosθ = z'
var zMAT4 camPos; camPos = _^(MEM_ReadInt(MEM_ReadInt(MEMINT_oGame_Pointer_Address)+20)+60); //0=right, 2=out, 3=pos
pos[0] = addf(camPos.v0[3], pos[0]); // Add vector to camera position
pos[1] = addf(camPos.v1[3], pos[1]);
pos[2] = addf(camPos.v2[3], pos[2]);

from gothicfreeaim.

Related Issues (20)

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.