Here I attached it. Nothing fancy about it, just a p90 with 2 bodygroups, first bodygroup has submodel 1: no p90 (blank) submodel 2: visible p90, and second bodygroup has 4 submodels, each a smaller p90 in different position on screen. Did it for testing purposes only of course. To cycle between pev_body, I made a weaponmod weapon and in the event for fire, I added the fire anim like this:
PHP Code:
fireing[id]++;
if(fireing[id] >=8) fireing[id] = 0;
set_pev(id, pev_weaponanim, anim_shoot1);
message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id);
write_byte(anim_shoot1);
write_byte(fireing[id]);
message_end();
client_cmd(id, "-attack");
The result is that with each click of the mouse the weapon fires one shot like a pistol in semi-auto, and plays the anim with a new pev_body, cycling from 0 to 7, and you can see that it goes through all 8 possible combinations from a submodel from the first group and submodel from the second group. The submodel from each group changes once each 2 shots. So it's probably a checksum or something..
If I find out how to handle this, I intend to use the idea for:
* putting bodygroup of different types of sights, bodygroup with m203 grenadelauncher and foregrip, bodygroup with tac light, bodygroup with silencer and so on, to all weapons that have attachment rails on these places, and adding a menu to purchase these mods;
* putting all w_ models in one file as submodels to save precaches, I will also add the bodygroups with the mods from the previous point so that the player can see what mods are there on the weapon on the ground before he picks it up. If I find a way, may do the same with p_ models but I don't know how to change pev_body on them.
* putting 5 male terrorists in one file, 5 female terrorists as well, 5 female CTs, and 5 male CTs + 1 VIP in 4th file, that will be 21 player models in 4 files only, that the player will be able to choose from a menu after he chooses his team. Also will add 4 skins for each of the 21 models with camos - urban, forest, desert and arctic and try to change them with pev_skin.
The last point is probably the one that I have the most doubts about, because the player models already have a bodygroup with backpack/defuser for DE_ maps, so the bodygroup of player submodels will be a second bodygroup, so even if we find out how is the combination of all bodygroups calculated for pev_body, the combinations with backpack/defuser will not be only pev_body 0/1 as it is by default, so I will have to somehow check if the player has a bomb/defuser kit and set the proper pev_body...
BTW here is SetBodygroup from HLSDK as you said you don't have it:
PHP Code:
void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue )
{
studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel;
if (! pstudiohdr)
return;
if (iGroup > pstudiohdr->numbodyparts)
return;
mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup;
if (iValue >= pbodypart->nummodels)
return;
int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels;
pev->body = (pev->body - (iCurrent * pbodypart->base) + (iValue * pbodypart->base));
}
It's used to set the head and the weapon of hgrunt.mdl independently. You call it with iGroup: the number of the bodygroup and iValue: the number of the submodel in this group, and it does some calculations and returns the proper value for pev_body in order to change only the submodel in this bodygroup and keep the other bodygroups as they were. But the body of the function is too hard for me to understand...