Ragdoll lets players fall over, be knocked out and get back up, and leaves a ragdoll
behind when they die.
A player who is down is replaced by a ragdoll of their model and sees through its eyes.
Their state is one of the RAGDOLL_ enums and is changed with Player:set_ragdoll_state:
a fallen player (RAGDOLL_FALLENOVER) gets up with the jump key, a knocked out one
(RAGDOLL_KNOCKEDOUT) stays down until the state ends, and a dead one (RAGDOLL_DUMMY)
leaves a corpse that stays for a while after they respawn. Either of the first two can be
given a timer that gets the player up by itself, which can be paused and resumed
(Player:set_getup_time, Player:pause_getup_time, Player:resume_getup_time); it is a
timed action called 'getup', so the player sees it as a progress bar. Damage dealt to
the ragdoll is passed on to the player, except for a moment after they have fallen.
Players use the fall and getup commands on themselves, staff use forcefall,
knockout and forcegetup on others. With the ragdoll_fall_damage and
ragdoll_hit_damage configs, hard falls and heavy hits make players fall over too.
A knockout is what a stunstick does: Player:knock_out puts a player out for a while
and Player:wake_up brings them to. A knocked out player cannot get up, is not heard
over voice chat, cannot switch characters and has no weapons, as nobody on the ground
has. With the ragdoll_knockout_on_damage config a melee hit (DMG_CLUB) that leaves a
player at or below ragdoll_knockout_health knocks them out for
ragdoll_knockout_time seconds, so a schema only has to turn it on. The hooks
PlayerCanKnockOut, PlayerKnockedOut and PlayerWokeUp go with it, and
Player:get_knockout_remaining tells HUDs how long the player stays out.
Plugins can step in with the server hooks PlayerCanRagdoll, PlayerRagdolled,
PlayerCanUnragdoll, PlayerUnragdolled, PlayerCanGetUp, PlayerCanRagdollDecay,
PlayerRagdollDecayed and PlayerRagdollCanTakeDamage, and with the client hook
ShouldFallenHUDPaint.
Player:is_ragdolled, Player:get_ragdoll_state, Player:get_ragdoll_entity,
Player:is_knocked_out, Player:get_knockout_remaining and Entity:get_ragdoll_owner
work on both realms.
Summary
Hooks
Hooks
Moves the view to the eyes of the player's ragdoll while they have one and are not drawn in third person.
Parameters
- client Player
- origin Vector
- angles Angle
- fov Number
Returns
- Map view table, or nil if the view is left alone
Passes damage dealt to the ragdoll of a living player on to that player. Damage that was not dealt by a player is ignored while the ragdoll is immune, which it is for a moment after the player has fallen; PlayerRagdollCanTakeDamage can block the rest.
Parameters
- entity Entity the damaged entity
- damage_info CTakeDamageInfo
Darkens the screen while the local player is fallen over and blacks it out while they are knocked out, and tells them what they can do about it: the 'press jump' prompt for a fallen player who is not getting up yet, a notice for a knocked out one.
Implements hook OnItemEquipped
Moves the weapon that a weapon item gives a player who is lying on the ground, and has been stripped of their weapons, into the weapons they get back when they get up.
Parameters
- owner Player
- item_obj Item the equipped item
Implements hook OnItemUnequipped
Takes the weapon of a weapon item that a player who is lying on the ground unequips out of the weapons they get back when they get up, and stores its clips in the item, so that the weapon does not come back without its item.
Parameters
- owner Player
- item_obj Item the unequipped item
Sends the getup command when the player presses jump while fallen over, once a second at most. Nothing is sent while they are knocked out or already getting up.
Parameters
- client Player
- bind String the bind's command
- pressed Boolean whether the bind was pressed rather than released
Mutes knocked out players: nobody hears them over voice chat. Nothing is returned for everyone else, so that the other handlers may still mute them.
Parameters
- _listener Player
- talker Player
Returns
- Boolean false if the talker is knocked out, nothing otherwise
Ragdoll:PlayerCanSwitchCharacter(actor, _character, _current)
server plugins/ragdoll/plugin/sv_hooks.lua:138Implements hook PlayerCanSwitchCharacter
Keeps knocked out players from switching characters.
Parameters
- actor Player
- _character Character the character the player wants to load
- _current Character their active character
Returns
- Boolean false and String the reason if the player is knocked out, nothing otherwise
Cancels the player's current action and puts them into the RAGDOLL_DUMMY state, which leaves a corpse ragdoll. The ragdoll of a player who died lying on the ground becomes their corpse.
Parameters
- victim Player
Implements hook PlayerDisconnected
Lets go of the ragdoll of a player who is leaving, so that it is removed once the decay time has passed rather than staying on the map.
Parameters
- actor Player
Implements hook PlayerOneSecond
Makes sure that a get up timer does what it promised even if its timed action was canceled or could not start: the action is started again, and the player gets up once the time is up. Nothing is done while the player does any timed action, so that none is cut short; a timer that runs while another action starts is paused for it instead.
Parameters
- actor Player
- cur_time Number CurTime() of the tick
Implements hook PlayerSetupDataTables
Registers the RagdollState and RagdollEntity data table variables on the player.
Parameters
- target Player
Clears the player's ragdoll state when they spawn. Their corpse stays for its decay time.
Parameters
- actor Player
Implements hook PlayerThink
Runs the PlayerDeathThink hook for dead players that are ragdolled.
Parameters
- actor Player
Ragdoll:PlayerTimedActionFinished(actor, action, _success)
server plugins/ragdoll/plugin/sv_hooks.lua:109Implements hook PlayerTimedActionFinished
Resumes the get up timer that was paused for a timed action once that action has ended, unless its callback has started yet another one, in which case the timer waits for that one as well.
Parameters
- actor Player
- action Map the timed action that has ended
- _success Boolean whether it ran for its whole duration
Implements hook PlayerTimedActionStarted
Pauses the get up timer of a player who starts another timed action, which has canceled the get up action; the timer goes on once that action has ended.
Parameters
- actor Player
- action Map the timed action that has started
Ragdoll:PostEntityTakeDamage(entity, damage_info, took)
server plugins/ragdoll/plugin/sv_hooks.lua:267Knocks a player out when a melee hit leaves them at or below the ragdoll_knockout_health config, for the ragdoll_knockout_time config, while ragdoll_knockout_on_damage is on; a fallen player is knocked out where they lie. Otherwise makes a player fall over when they take at least as much damage from a fall as the ragdoll_fall_damage config, or from anything else as the ragdoll_hit_damage config. A fall leaves them down until they get up by themselves; a hit throws them down for the ragdoll_hit_time config. Both are off while their config is 0.
Parameters
- entity Entity the damaged entity
- damage_info CTakeDamageInfo
- took Boolean whether the entity has actually taken the damage
Keeps the ragdoll of the player in what is networked to them, however far it ends up from where they fell.
Parameters
- actor Player
- _view_entity Entity the entity the player sees through