View Single Post
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 06-15-2020 , 11:50   Re: Some pev_body information
Reply With Quote #33

Quote:
Originally Posted by .DeeD. View Post
Thanks for the answer. I manage to do it the way you said plus adding "blank" as the first submodel to see the different models correctly by changing the parts. The problem is that I don't know how to set them since it has more than one body group. I think it's not the same as in the case of the models that have only one SMD = one body group.
Try this:
PHP Code:
/**
 * Calculates model body index from given parameters.
 * 
 * @param parts  Model part indexes from each group
 * @param sizes  Each group's sizes
 * @param count  Total amount of groups
 * @return       Body index
 */
stock CalculateModelBody(const parts[], const sizes[], count)
{
    new 
body;

    while (
count--)
    {
        if (
sizes[count] == 1)
            continue;
        
        new 
temp parts[count];

        for (new 
0counti++)
            
temp *= sizes[i];

        
body += temp;
    }

    return 
body;

Example usage:
PHP Code:
// Let's use HL soldier model hgrunt.mdl
entity_set_model(entity"models/player/hgrunt.mdl");

// hgrunt.mdl has 3 model part groups:
new groupCount 3;

// By inspecting hgrunt.mdl via HLMV we can see it has these model groups and parts:
// body    (1 part)
// heads   (4 parts)
// weapons (3 parts)
new groupSizes[] =
{
    
1// Size of 1st model part group (body)
    
4// Size of 2nd model part group (heads)
    
3  // Size of 3rd model part group (weapons)
};

// Now define which parts we want to use (counting starts from zero)
new modelParts[] =
{
    
0// 1st (and only) part in body group
    
2// 3rd part in heads group (balaclava)
    
1// 2nd part in weapons group (shotgun)
};

// Let's calculate body and set it for entity
new body CalculateModelBody(modelPartsgroupSizesgroupCount);
entity_set_int(entityEV_INT_bodybody); 
__________________
hleV is offline