Pickup Objects lets players carry light physics objects in their hands, throw them and
drag ragdolls along the ground.
With the fists out, secondary attack picks up the entity the player is looking at, if it is
within two meters and no heavier than the mass limit of the player. While something is
held, secondary attack or reload lets go of it and primary attack throws it. With the
pickup_drag_ragdolls config turned on a ragdoll is not carried: whatever it weighs, it is
dragged by the limb the player has grabbed, for as long as they stay on foot with their
fists out. That includes the fallen players and the corpses of the Ragdoll plugin. A
ragdoll is grabbed as soon as the key is pressed, and the fists do not punch it. A player
whose ragdoll is being dragged takes no physics damage through the ragdoll and has the
dragged networked variable set to true; the Ragdoll plugin asks Player:get_dragger to
keep them from getting up in the meantime.
The plugin has three configs: pickup_max_mass (25) is the heaviest object a player can
carry, pickup_throw_force (1000) is the force of a throw, where 0 turns throwing off,
and pickup_drag_ragdolls (false) turns the dragging of ragdolls on.
Plugins take part through the PlayerPickupObject, PlayerDropObject,
PlayerThrowObject, PlayerCanDragRagdoll and AdjustPickupMassLimit hooks. What is held
and by whom is answered by Player:get_holding_entity, Entity:get_holder and
Player:get_dragger, and the functions of the PickupObjects global make a player pick
up, drop or throw an entity. All of it is serverside.
Summary
Hooks
Methods
Hooks
PickupObjects:EntityTakeDamage(ent, damage_info)
server plugins/pickup_objects/plugin/sv_hooks.lua:130Blocks physics damage to a ragdoll that is being dragged or was let go of less than a second ago, and to the player it belongs to, so that being dragged over the ground does not hurt them.
Parameters
- ent Entity the damaged entity
- damage_info CTakeDamageInfo
Returns
- Boolean true to block the damage, nil otherwise
Picks up an object to carry when secondary attack is released while holding fists and nothing else, and drops the held object when reload is released. Ragdolls that are dragged are left to the StartCommand handler, which grabs them as the key is pressed.
Parameters
- actor Player
- key Number IN_ enum of the released key
PickupObjects:PlayerCanDragRagdoll(_actor, _ragdoll, target)
server plugins/pickup_objects/plugin/sv_hooks.lua:118Implements hook PlayerCanDragRagdoll
Denies dragging the ragdoll of a player who is getting up, as the Ragdoll plugin would remove the ragdoll in the middle of the drag.
Parameters
- _actor Player
- _ragdoll Entity
- target Player the player whose ragdoll it is, nil if it belongs to nobody
Returns
- Boolean false to deny the dragging, nil otherwise
Implements hook PlayerDisconnected
Drops what a player holds when they disconnect.
Parameters
- actor Player
PickupObjects:PlayerPickupObject(actor, ent, drag)
server plugins/pickup_objects/plugin/sv_hooks.lua:88Implements hook PlayerPickupObject
Denies pickups during the player's one second cooldown. Objects that are to be carried are also denied if they are vehicles, are not moved by physics, cannot move or weigh more than the mass limit of the player, counting the mass of all of their physics objects.
Parameters
- actor Player
- ent Entity the object being picked up
- drag Boolean whether the object is a ragdoll that is going to be dragged
Returns
- Boolean false to deny the pickup, nil otherwise
Handles the attack keys of a player before the engine and the weapon see them. While the player holds something, pressing primary attack throws it and pressing secondary attack drops it. With the fists out and nothing held, pressing secondary attack while looking at a ragdoll that can be dragged grabs it. Both keys are taken out of the command for as long as something is held, and after the hold has ended for any reason until the keys are let go of, so that the engine does not drop or throw the carried object by itself and the fists do not punch.
Parameters
- actor Player
- user_cmd CUserCmd
Updates every hold on each tick, and drops what can no longer be held.
Methods
Checks whether the entity a player is looking at is one that is dragged rather than carried.
Parameters
- actor Player
Returns
- Boolean
Makes a player let go of the entity they hold. The PlayerDropObject hook can veto a drop that is not forced.
Parameters
- actor Player the holder; may no longer be valid for a forced drop
- forced Boolean optional, defaults to
falsedrop the entity whatever the hook returns
Returns
- Boolean true if the player has let go of an entity, false if they held nothing or the drop was vetoed
Makes a player hold an entity without asking any hook. What the player held before is dropped, and so is the entity by the player who held it. A carried object is handed to the engine and does not collide with players while it is held. A dragged entity follows the player by the given physics object, which is made heavy enough to pull the rest along; the drag ends by itself once the player dies, leaves their feet, puts the fists away or gets too far from the entity.
Parameters
- actor Player
- ent Entity
- bone Number optional, defaults to
nilindex of the physics object to drag the entity by, as in the PhysicsBone field of a trace; nil carries the entity instead
Returns
- Boolean true if the player holds the entity now, false if the player or the entity is not valid or the entity has no movable physics object to hold it by
Returns the heaviest object a player can carry: the pickup_max_mass config, after the AdjustPickupMassLimit hook.
Parameters
- actor Player
- ent Entity optional, defaults to
nilthe object the player is trying to pick up
Returns
- Number mass limit
Checks whether a player has their fists out.
Parameters
- actor Player
Returns
- Boolean
Checks whether a ragdoll is safe from physics damage: it is being dragged, or was let go of less than a second ago.
Parameters
- ragdoll Entity
Returns
- Boolean
Drops the entity the player is holding, or else picks up the entity they are looking at.
An object to carry must be within 2 meters; a ragdoll to drag must be hit by the eye
trace within 96 units. See PickupObjects:pickup_entity for the other conditions and the
hooks that can veto the pickup, and PickupObjects:drop_entity for the drop.
Parameters
- actor Player
Returns
- Boolean true if an object was picked up, false otherwise; nil if the player is not valid
PickupObjects:pickup_entity(actor, ent, bone)
server plugins/pickup_objects/plugin/sv_plugin.lua:286Makes a player pick up an entity if they are able to and the hooks allow it. The player must be alive, on foot, not ragdolled and hold nothing, and nobody may hold the entity. A ragdoll is dragged if the pickup_drag_ragdolls config is on, which the PlayerCanDragRagdoll hook can veto; everything else is carried. The PlayerPickupObject hook can veto both. The distance to the entity is not checked.
Parameters
- actor Player
- ent Entity
- bone Number optional, defaults to
0index of the physics object to drag a ragdoll by; not used for entities that are carried
Returns
- Boolean true if the entity was picked up, false otherwise
Checks whether an entity is dragged rather than carried when it is picked up: a ragdoll, with the pickup_drag_ragdolls config turned on.
Parameters
- ent Entity
Returns
- Boolean
Makes a player throw the entity they hold in the direction they are looking. The PlayerThrowObject hook can veto the throw and change its force, and the PlayerDropObject hook can veto it as well. The force is scaled with the mass of the entity the way the engine does it for objects carried with the use key, by 0.5 for half a kilogram and less up to 4 for 15 kilograms and more, and is spread over the physics objects of the entity.
Parameters
- actor Player
Returns
- Boolean true if the player has let go of the entity, false if they hold nothing, the throw was vetoed or its force is not positive
PickupObjects:update_hold(actor, data, cur_time)
server plugins/pickup_objects/plugin/sv_plugin.lua:125Keeps a hold going for one tick. A carried object only has to be still held by the engine. A dragged ragdoll is pulled by its grabbed limb towards a point in front of the player, below their eyes, and the fists of the player are kept from punching until the pickup cooldown that follows the drag is over.
Parameters
- actor Player the holder
- data Map the hold, as kept in PickupObjects.holds
- cur_time Number CurTime() of the tick
Returns
- Boolean false if the hold is over: the player or the entity is gone, the engine has let go of the object, or the player can no longer drag the ragdoll or has moved too far away from it