I already searched through the forums and found a couple of threads that suggested using the vfunc GetBoneTransform() for it.
I copied and modified the code of the following post on how to use the above mentioned vfunc.
https://forums.sourcepython.com/viewtopic.php?f=20&t=1638&p=10920&hilit=getbonetransform#p10883
I also checked other referring posts to GetBoneTransform, eg.:
https://sourcepython.com/viewtopic.php?f=38&t=870&p=16038&hilit=getbonetransform&sid=0a4442cabf897bf2381274beed8dd3ac#p16038
https://sourcepython.com/viewtopic.php?f=20&t=1725&p=11399&hilit=getbonetransform+offset&sid=0a4442cabf897bf2381274beed8dd3ac#p11399
The last post is pointing out that the correct offset for the vfunc needs to be found for CS:GO. So my first guess is, that my code does not work because i got the wrong offset. How would one find the correct offset? Or is the offset still correct and i am missing a bug/logic flaw in my code?
Syntax: Select all
OFFSET_GetBoneTransform = 199
@Event('bullet_impact')
def bullet_impact(game_event):
userid = game_event['userid']
player = Player(index_from_userid(userid))
header = player.model_header
for bone_index in range(header.bones_count):
bone_name = header.get_bone(bone_index).name.lower()
if "head" in bone_name:
print(bone_name + ": " + str(bone_index))
break
## Source: viewtopic.php?f=20&t=1638&p=10920&hilit=getbonetransform#p10883
GetBoneTransform = player.pointer.make_virtual_function(OFFSET_GetBoneTransform,Convention.THISCALL,[DataType.POINTER, DataType.INT, DataType.POINTER],DataType.VOID)
matrix = Matrix3x4()
GetBoneTransform(player, bone_index, matrix)
print("player.origin: " + str(player.origin))
print("matrix.position: " + str(matrix.position))
Prints the following on some random shot:
Code: Select all
head_0: 8
player.origin: Vector(-1296.7099609375, -1392.4300537109375, 11488.03125)
matrix.position: Vector(0.0, 4.321107888263927e+27, 0.0)
Those both vectors should be close to each other besides, matrix.position.z which should be around +64 to player.origin.z so those values cant be right.
Thanks for any help!