Page 1 of 1

[ANY/CSGO] Ragdoll PhysicsObject

Posted: Thu Apr 23, 2020 4:20 am
by VinciT
I've been messing around with server side ragdolls (prop_ragdoll), and I've ran into a wall. Since the ragdoll is made up of individual parts, I need to access certain bones, but I have no idea where to start (well.. sort of). There's this ragdoll_t struct that I keep seeing within the SDK, which has a list of ragdollelement_t and this element struct has what I need - an IPhysicsObject. Any suggestions as to how I could access this would be greatly appreciated!

Re: [ANY/CSGO] Ragdoll PhysicsObject

Posted: Thu Apr 23, 2020 5:55 am
by L'In20Cible

Syntax: Select all

for i in range(1, ragdoll.get_datamap_property_int('m_ragdoll.listCount')):
ragdoll.get_datamap_property_pointer(f'm_ragdoll.list[{i}].pObject')

Re: [ANY/CSGO] Ragdoll PhysicsObject

Posted: Thu Apr 23, 2020 4:39 pm
by VinciT
Thank you so much L'In20Cible! While I have you here, could you tell me what I'm doing wrong with this?

Syntax: Select all

# ../ragdolls/ragdolls.py

# Source.Python
from entities.entity import Entity
from events import Event
from memory import make_object
from physics import PhysicsObject
from players.dictionary import PlayerDictionary


player_instances = PlayerDictionary()


@Event('player_death')
def player_death(event):
player = player_instances.from_userid(event['userid'])

ragdoll = Entity.create('prop_ragdoll')
ragdoll.model = player.model
ragdoll.owner_handle = player.owner_handle
ragdoll.origin = player.origin
ragdoll.angles = player.angles
ragdoll.spawn()
ragdoll.delay(4.1, ragdoll.remove)

for i in range(1, ragdoll.get_datamap_property_int('m_ragdoll.listCount')):
ptr = ragdoll.get_datamap_property_pointer(
f'm_ragdoll.list[{i}].pObject')

physics_object = make_object(PhysicsObject, ptr)

Syntax: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\events\listener.py", line 92, in fire_game_event
callback(game_event)
File "..\addons\source-python\plugins\ragdolls\ragdolls.py", line 30, in player_death
physics_object = make_object(PhysicsObject, ptr)

ValueError: Unable to make an object using this class.

Re: [ANY/CSGO] Ragdoll PhysicsObject

Posted: Thu Apr 23, 2020 10:50 pm
by L'In20Cible
VinciT wrote:Thank you so much L'In20Cible! While I have you here, could you tell me what I'm doing wrong with this?

Nothing wrong, it's just that memory tools were not implemented for that class. Those have been added into 895338e.

Re: [ANY/CSGO] Ragdoll PhysicsObject

Posted: Fri Apr 24, 2020 2:32 am
by VinciT
Cool, thanks for the new tools!