object.add_weapon
This function attempts to create a new weapon of the desired type, and give it to the biped that the function is called on. If that biped is already carrying two weapons, then the function will fail, and no new weapon will be created. Similarly, the function doesn't seem to do anything when called on something that is not a biped.
Arguments
- weapon
A type of object that can exist in the game world.
- mode
-
One of the following values:
- primary
- Attempts to give the weapon to the biped. If successful, then any weapon the biped was already holding will be holstered, and the new weapon will be switched into their hands.
- secondary
- Attempts to give the weapon to the biped.
- force
- Forcibly adds the weapon to the biped and switches them to use it.
Example
global.object[0].add_weapon(assault_rifle, force)
Notes
If the biped is player-controlled and the player's Weapon Pickup trait is set to Disabled, then you must use the "force" mode to add the weapon.
Remember that this function works differently from
player.add_weapon
: the object function takes an object type and spawns a new weapon; while the player function takes an existing weapon object.