Add LookupEntityAttachment & GetEntityAttachment natives (#1653)

Using the virtual `CBaseAnimating::GetAttachment(int, matrix3x4_t &)` was a deliberate choice because virtual offsets are generally easier to maintain than signatures. The `matrix3x4_t` is converted to world position and world angles internally.
Some of the other overloads are also inlined on a few games, making this the best choice.

Since this call can only be used on classes inheriting `CBaseAnimating`, we check if the `DT_BaseAnimating` SendTable exists on the entity, throwing a native error if it doesn't.
This safeguard could be greatly improved with a call to `CBaseEntity::GetBaseAnimating`, but would require more gamedata (maybe something to consider for the future?)
This commit is contained in:
Mikusch
2022-01-03 13:13:54 +00:00
committed by GitHub
parent bf898dd45f
commit afc9310704
8 changed files with 246 additions and 0 deletions
+22
View File
@@ -377,3 +377,25 @@ native void EntityCollisionRulesChanged(int entity);
* @error Invalid entity or lack of mod support.
*/
native void SetEntityOwner(int entity, int owner=INVALID_ENT_REFERENCE);
/**
* Returns the index number of a given named attachment.
*
* @param entity The entity index.
* @param name The attachment name.
* @return An attachment index, or 0 if the attachment name is invalid or unused.
* @error Invalid entity or lack of mod support.
*/
native int LookupEntityAttachment(int entity, const char[] name);
/**
* Returns the world location and world angles of an attachment.
*
* @param entity The entity index.
* @param attachment The attachment index.
* @param origin Destination vector to store the attachment's origin vector.
* @param angles Destination vector to store the attachment's position angle.
* @return True on success, otherwise false.
* @error Invalid entity or lack of mod support.
*/
native bool GetEntityAttachment(int entity, int attachment, float origin[3], float angles[3]);