Yes, just add multiple .smd files as different body groups.
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.
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 i = 0; i < count; i++)
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(modelParts, groupSizes, groupCount);
entity_set_int(entity, EV_INT_body, body);
Imagine, you have 3 groups, so:
needed body from group 1 + needed body from group 2 + needed body from group 3 = needed bodygroup to use
also, max bodygroup you can use is 255
Imagine, you have 3 groups, so:
needed body from group 1 + needed body from group 2 + needed body from group 3 = needed bodygroup to use
also, max bodygroup you can use is 255
Hello. I have a question. If i have more if groupbody like hat_id, example backpack_id. So if i want a model player have hat id and backpack id so what is recipe it is?
Hello. I have a question. If i have more if groupbody like hat_id, example backpack_id. So if i want a model player have hat id and backpack id so what is recipe it is?
Each bodygroup have a base param that tell the engine from where it starts (to use for the "pev->body" var).
So, let's say you have a model with 3 bodygroups, like:
They will be 'stacked' (game-engine will interpreter they) something like this:
• "bodygroup 1" base is always '1' (formally, first bodygroup-base is always '1' *)
• all others bodygroups will calculate they base from where the former bodygroup-ends.
*:I DONT KNOW IF when $body directive is parsed, if they is declared before any bodygroup, the will have this base-param to '1' and later, bodygroups are calculated......I would have to check, anyway.
So, let's do it we manually to see:
Spoiler
PHP Code:
bodygroup 1 { base: 1 bodyparts: 5 each bodypart-index is = index - 1
bodygroup 2 { base: later bodygroup-base * later bodygroup-models base: 5 (later bodygroup have 5 bodyparts and base was 1 = 5*1) bodyparts: 3 each bodypart-index is = index * (this bodypart-base)
Now, imagine you want set the current bodygroups (with they bodyparts):
- bodygroup-1 + bodypart-5
- bodygroup-2 + bodypart-2
- bodygroup-3 + bodypart-5
The, value for pev-body will be = 4 + 5 + 60 = 69.
Obviously you need to see the model's bodygroups with a model-editor (like HLMV) to know the base for each group and then you can calculate this value.
On the other hand, I've make this stock to do the job more easily (port of SetBodyGroup from HLSDK):
Spoiler
PHP Code:
stock bool:SetBodyGroup(const iEntity, const iGroup, const iPart) { new bool:bResult;
new iModelPtr = fopen(szModel, "rb"); if (!iModelPtr) goto Result;
new iBodyPartsCount = iGroup; new iBodyPartNumModels; new iBodyPartBase; Model_GetBodyPartInfo(iModelPtr, iBodyPartsCount, iBodyPartNumModels, iBodyPartBase);
new entity // suppose entity is a 'hat' entity and his model has 3 bodygroups SetBodyGroup(entity, 2, 5) // sets bodygroups 3 (from 0 to 2) and bodypart 6 (from 0 to 5)
Finally, i've upload a modified version of the model used on this thread, so you can check for yourself