[ANY/CSGO] Ragdoll PhysicsObject

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

[ANY/CSGO] Ragdoll PhysicsObject

Postby VinciT » Thu Apr 23, 2020 4:20 am

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!
ImageImageImageImageImage
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [ANY/CSGO] Ragdoll PhysicsObject

Postby L'In20Cible » Thu Apr 23, 2020 5:55 am

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')
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [ANY/CSGO] Ragdoll PhysicsObject

Postby VinciT » Thu Apr 23, 2020 4:39 pm

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.
ImageImageImageImageImage
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [ANY/CSGO] Ragdoll PhysicsObject

Postby L'In20Cible » Thu Apr 23, 2020 10:50 pm

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.
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [ANY/CSGO] Ragdoll PhysicsObject

Postby VinciT » Fri Apr 24, 2020 2:32 am

Cool, thanks for the new tools!
ImageImageImageImageImage

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 14 guests