Closed ghost closed 2 years ago
Fixed it, I'll do a release later. Here if you need it for something.
I think i found another issue but examining the source code i can't find it. It is about cleo.call_method function and possibiliy also cleo.call_function (didn't test yet).
I'm exposing the CVector class, which has the constructor method at address 0x420b10
.
It accepts as arguments 3 floats representing x, y and z coordinates. The function i created is this:
def Constructor(self, x: float, y: float, z: float):
call_method(0x420B10, self.address, 3, 3, float(x), float(y), float(z))
where self.address
is the memory address of the vector.
When i call this function and the print the vector fields, it basically prints numbers in scientific notation really close to 0.
Here is my test:
vec = Vector(0xc8b47c) # address of pistol's fire offset when skill is normal
print(vec)
vec.Constructor(10.0, 20.0, 30.0)
print(vec)
and here is the output
test.py: Vector dynamic instance at 0xc8b47c:
x = 0.25
y = 0.05000000074505806
z = 0.09000000357627869
test.py: Vector dynamic instance at 0xc8b47c:
x = 1.401298464324817e-44
y = 2.802596928649634e-44
z = 4.203895392974451e-44
The first print, before calling the constructor is fine, but the second should be x = 10.0, y = 20.0, z = 30.0 (or at least numbers close to them)
I will search again in PyCLEO.cpp to find if there's something wrong (or maybe I'm doing wrong...)
Aight, I'll take a look too.
I think I've fixed that too,
x = memory.read_float(0xc8b47c + 0x0)
y = memory.read_float(0xc8b47c + 0x4)
z = memory.read_float(0xc8b47c + 0x8)
print("x: {}, y: {}, z :{}".format(x, y, z))
cleo.call_method(0x420B10, 0xc8b47c, 3, 3, 10.0, 20.0, 30.0)
x = memory.read_float(0xc8b47c + 0x0)
y = memory.read_float(0xc8b47c + 0x4)
z = memory.read_float(0xc8b47c + 0x8)
print("x: {}, y: {}, z :{}".format(x, y, z))
hud.CHud.set_help_message("TEST222")
This outputs,
Events.py: x: 0.25, y: 0.05000000074505806, z :0.09000000357627869
Events.py: x: 10.0, y: 20.0, z :30.0
Events.py: x: 10.0, y: 20.0, z :30.0
Events.py: x: 10.0, y: 20.0, z :30.0
...
Here is the binary.
Well done, now it's working.
There is an error in the functions memory.get_raw and memory.set_float: if called, an error will inform that the function must be called with one more argument besides others provided in the documentation. I searched in the cpp source code and the issue is in the function
PyArg_ParseTuple
.write_float
the format string asks for a size argument which is not used elsewhere in the function but raises an exception when called in python. I solved it editing the memory.py module, putting a 4 in the size argument.get_raw
, the format string ofPyArg_ParseTuple
asks for 4 integers, but only 3 are needed and referenced as parameters when calling it. This raises an error even if a put one more argument in the function call.I haven't done a pull request because i have not python 3.8 installed and i can't compile for testing.