Author
|
Message
|
AlliedModders Donor
Join Date: Jun 2019
Location: Israel
|
08-10-2021
, 16:38
[INC] StudioHdr - Entity Model Information
|
#1
|
StudioHdr - Entity Model Information
Description:
StudioHdr is a SourcePawn library (.inc) that lets developers get information about entity models.
Credits:
Феникс#1337 (Phoenix): For the base code:
Spoiler
PHP Code:
methodmap CStudioHdr
{
public int GetNumBodyGroups()
{
int m_pStudioHdr = LoadFromAddress(view_as<Address>(this), NumberType_Int32);
return LoadFromAddress(view_as<Address>(m_pStudioHdr + 232), NumberType_Int32);
}
public int GetBodygroupCount(int iGroup)
{
int m_pStudioHdr = LoadFromAddress(view_as<Address>(this), NumberType_Int32);
// if(iGroup < this.GetNumBodyGroups())
if(iGroup < LoadFromAddress(view_as<Address>(m_pStudioHdr + 232), NumberType_Int32))
{
int pbodypart = m_pStudioHdr + LoadFromAddress(view_as<Address>(m_pStudioHdr + 236), NumberType_Int32) + 16 * iGroup;
// nummodels - 4
return LoadFromAddress(view_as<Address>(pbodypart + 4), NumberType_Int32);
}
return 0;
}
public void SetBodygroup(int& body, int iGroup, int iValue)
{
int m_pStudioHdr = LoadFromAddress(view_as<Address>(this), NumberType_Int32);
// if(iGroup < this.GetNumBodyGroups())
if(iGroup < LoadFromAddress(view_as<Address>(m_pStudioHdr + 232), NumberType_Int32))
{
int pbodypart = m_pStudioHdr + LoadFromAddress(view_as<Address>(m_pStudioHdr + 236), NumberType_Int32) + 16 * iGroup;
// nummodels - 4
int nummodels = LoadFromAddress(view_as<Address>(pbodypart + 4), NumberType_Int32);
if(nummodels > iValue)
{
int base = LoadFromAddress(view_as<Address>(pbodypart + 8), NumberType_Int32);
body += (iValue - body / base % nummodels) * base;
}
}
}
}
CStudioHdr CBaseAnimating_GetModelPtr(int iEnt)
{
// CBaseAnimating::GetModelPtr - по нормальному нужно вызывать
// Но делаем так [url]https://github.com/qubka/Zombie-Plague/blob/67266c6b90d88180264745ccebff709531c722d0/gamedata/plugin.turret.txt#L8[/url]
static int iStudioHdrOffs = 0;
if(iStudioHdrOffs == 0)
{
iStudioHdrOffs = FindSendPropInfo("CBaseAnimating", "m_hLightingOrigin") + 68;
}
return view_as<CStudioHdr>(GetEntData(iEnt, iStudioHdrOffs));
}
{
int iEnt;
CStudioHdr pstudiohdr = CBaseAnimating_GetModelPtr(iEnt);
int iBody, int iGroups = pstudiohdr.GetNumBodyGroups();
for(int i = 0; i < iGroups; i++)
{
pstudiohdr.SetBodygroup(iBody, i, GetRandomInt(0, pstudiohdr.GetBodygroupCount(i) - 1));
}
SetEntProp(iEnt, Prop_Send, "m_nBody", iBody);
}
KoNLiG: For letting me scream at him while the code didn't work and crashed the server.
List of features:
Quote:
StudioHdr methodmap
Bones
• `GetBone()` - Get a specific bone object by index.
• `FindBone()` - Find bone index by name.
• Get model 'NumBones'.
Hitbox Sets
• `GetHitboxSet()` - Get a specific hitbox set object by index.
• Get model 'NumHitboxSets'.
Skin Families
• Get model 'SkinFamiliesCount'.
Body Parts
• `GetBodyPart()` - Get a specific body part object by index.
• `FindBodyPart()` - Find body part index by name.
• Get model 'NumBodyParts'.
Attachments
• `GetAttachment()` - Get a specific attachment object by index.
• `FindAttachment()` - Find an attachment index by name.
• Get model 'AttachmentCount'.
Pose Parameters
• `GetPoseParameter()` - Get a specific pose parameter object by index.
• `FindPoseParameter()` - Find a pose parameter index by name.
• Get model 'NumPoseParameters'.
Bone methodmap
• `GetName()` - Get the name of the body part.
• `GetPos()` - Get the position of the bone (relative to model).
Hitbox methodmap
• `bone` - The related bone of the specific hitbox.
• `group` - The intersection group of the specific hitbox.
bounding box, or the ends of the capsule if flCapsuleRadius > 0
• `bbmin`
• `bbmax`
• `GetAngOffsetOrientation()` - Gets the angle offset orientation.
• `flCapsuleRadius` - The radius of the capsule (if not a capsule = 0.0)
HitboxSet methodmap
• `GetHitbox()` - Get a specific hitbox object by index.
• `NumHitboxs` - Number of hitboxes in the hitbox set.
BodyPart methodmap
• `GetName()` - Get the name of the body part.
• `base` - The base value of the body part.
• `nummodels` - Number of sub-models.
Attachment methodmap
• `GetName()` - Get the name of the attachment.
Pose Parameter methodmap
• `GetName()` - Get the name of the pose parameter.
• `start` - The minimum value of the pose parameter.
• `end` - The maximum value of the pose parameter.
|
Note:
This include was tested only in CS:GO (Linux).
This should work in any source engine based game (i am pretty sure).
If you want to support other games (and you can test), please write here below or add me on Discord!
Links:
GitHub Repository
__________________
You like my work? You want to support?
Consider Donating!
Need signatures / offsets for CS:GO?
Contact me:
Last edited by LuqS; 08-17-2021 at 17:01.
Reason: New version update
|
|
|
|