notgoodusename / OsirisAndExtra

Other
127 stars 64 forks source link

My resolver is giving crashes. #508

Closed Smellon69 closed 1 year ago

Smellon69 commented 1 year ago

The Vector calc_angle is causing me issues. Here is my code:

Vector calc_angle(const Vector source, const Vector entity_pos) { const Vector delta{ source.x - entity_pos.x, source.y - entity_pos.y, source.z - entity_pos.z }; const auto& [x, y, z] = cmd->viewangles; Vector angles{ Helpers::rad2deg(atan(delta.z / hypot(delta.x, delta.y))) - x, Helpers::rad2deg(atan(delta.y / delta.x)) - y, 0.f }; if (delta.x >= 0.f) angles.y += 180; return angles; } Or: `Vector calcAngle(Vector source, Vector entityPos) { Vector delta = {}; delta.x = source.x - entityPos.x; delta.y = source.y - entityPos.y; delta.z = source.z - entityPos.z; Vector angles = {}; Vector viewangles = command->viewangles; angles.x = Helpers::rad2deg(atan(delta.z / hypot(delta.x, delta.y))) - viewangles.x; angles.y = Helpers::rad2deg(atan(delta.y / delta.x)) - viewangles.y;
angles.z = 0; if (delta.x >= 0.f) angles.y += 180;

return angles;

}`

The issue is command-> nullptr Seems to be the line Vector viewangles = command->viewangles Also I use UserCmd* command at the top of my resolver.cpp.

Smellon69 commented 1 year ago

I cannot for the life of me to get the markdown stuff working. sowwy <3

notgoodusename commented 1 year ago

you made the same issue twice and i gave you the solution and you didn't apply it

Smellon69 commented 1 year ago

uhm give me solution then. Also I cannot find that issue. I do remember making an issue about it but I cannot find it.

notgoodusename commented 1 year ago

492

Smellon69 commented 1 year ago

Tried to implement it. Now it's giving this: image Should command grabber be above or below and why does hooking command grabber have anything to do with this code?

Smellon69 commented 1 year ago

I just removed calc_angle sense it's not needed. Whatever.

tommyka1 commented 1 year ago

Tried to implement it. Now it's giving this: image Should command grabber be above or below and why does hooking command grabber have anything to do with this code?

You should be calling the command grabber above this code, since the command grabber initializes the variable called "command" by giving it the value of the variable "cmd" (the variable "cmd" has its value from createmove) (createmove is a game function, so we can use it to grab cmd from the game). Initializing a variable in C++ before use is important because uninitialized variables can contain unpredictable values, leading to unintended results and possible bugs in your program. By initializing a variable, you ensure that it has a known and expected value, which helps you write more reliable and predictable code. Simply saying "UserCmd command" does NOT give "command" a value, it just lets the cheat know that there is a variable called "command" and it is of type "UserCmd". By calling (NOT "hooking") cmd_grabber before your code, you are letting your cheat know what the actual value of "command" is. If you don't call it, your cheat has no way of knowing what the value of "command" is and just gives it a value of "nullptr" (this is what you're seeing in the exception that is thrown).

Smellon69 commented 1 year ago

Thanks :)