AI Attachment Ingame Editing

From The DarkMod Wiki
Jump to: navigation, search

Originally written by Ishtvan on http://forums.thedarkmod.com/topic/4374

This page needs updating as we are using a slightly different attachment system now. See Attachment Positions

New Attachment-Related Console Commands

This pertains to attaching any entity to an AI. This may be done to facilitate pickpocketing items off of AI, or simply attaching the AI's weapon to their hand or frog sheath. The only attachment this does not apply to is attaching the head of the AI, which is handled differently by D3.

The following attachment commands must be run while looking at the AI you want to modify, with nothing obstructing your view. I could have made people type in the full name of the AI, but I'd figure we'd see how it works when looking at them. Also, these are meant to be run after you have initially placed the attachments in the def file / spawnArgs of the AI. This step is still done the same as before.

NOTE: In all of these cases, <attachment index> is an integer number. It is the order of the attachment in the AI's def file (or the order it was added in if it was somehow added ingame). For example, if it's the first def_attach in teh def, the index would be 1. If it's the second (def_attach_2 or something), it would be 2, etc.

tdm_attach_offset

Set the vector offset (x y z) for an attachment on an AI you are looking at.

Usage: tdm_attach_offset <attachment name> <attachment position> <x> <y> <z>

tdm_attach_rot

Set the rotation (pitch yaw roll) for an attachment on an AI you are looking at.

Usage: tdm_attach_rot <attachment name> <attachment position> <pitch> <yaw> <roll>

(NOTE: Rotation is applied before translation, angles are relative to the joint orientation)

List of new attachment-related script functions

/**
* Attach an entity to the AI.
* Entity spawnArgs checked for attachments are:
* "origin", "angles", and "joint".
* These must be set prior to calling attach.
**/
scriptEvent void attach( entity ent);
/**
* Reattach an existing attachment
* Effects the attachment at index ind (where the first attachment starts at 1)
* For example to effect the first item that was attached, ind should be = 1
*
* The next arguments are the name of the joint to attach to, the translation
* offset from that joint, and a (pitch, yaw, roll) angle vector that defines the
* rotation of the attachment relative to the joint's orientation.
**/
scriptEvent void reAttach( float ind, string joint, vector offset, vector angles );
/**
* Show or hide an attachment. Index works the same as in ReAttach described above.
* Second argument set to true shows attachment, false hides it.
**/
scriptEvent void showAttachment( float ind, float bShow );  
/**
* Drop the attachment for the given index
**/
scriptEvent void dropAttachment( float ind ); 
/**
* Get the attached entity at the given index
* Will be NULL if the index is invalid or the entity no longer exists
**/
scriptEvent entity getAttachment( float ind );
/**
* Return the number of attachments on an AI.
* Used to iterate through the attachments if desired.
**/
scriptEvent float getNumAttachments( );