Attachments
Attachments
Attachments are reference points linked to bones with the model. They are often used to define points at which effects occur, collision takes place or models link together. If you need particles to come out of a particular point on a gun, or you want to glue items onto characters in the game, then you'll want to use attachments.
There are two ways to define an attachment point: in the actual model (so, in XSI or Maya), and in the qc file. For models, an attachment can be defined as a 'null' bone (make sure you have any "export unused bones" options turned on for this to work). The qc command to create attachments is documented here.
Internally the attachment is defined as a point offset from a parent bone - i.e. the important components are the bone it's parented to, a position offset and a rotation.
Although creating attachments by hand in the qc file may seem easier at first, bear in mind that they may need changing and updating every time the artwork changes. If they are defined in the art, then it's the job of the modeller to keep them up-to-date and working.
Automatically attaching objects to characters
Entities in the game which are linked to parent entities using the "bone merge" option (EF_BONEMERGE in the source code) can be automatically snapped to the correct bone. Weapons use this for instance to make sure they appear in the correct hand. To set this up, create a parent bone for your attachment model named identically to the bone you want it attached to. For instance, if you want your pistol to always link to the character's right hand, make sure it has a parent bone called SK_R_Hand (assuming this is the name of your character model's right hand). After compiling the mdl, it's a good idea to load it up in the HLMV and make sure the parent bone is there (SK_R_Hand). If it's not, chances are you haven't ticked that "export unused bone" option in the exporter.