Raised This Month: $ Target: $400
 0% 

How to change Sub-Model on player model?


Post New Thread Reply   
 
Thread Tools Display Modes
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-20-2011 , 07:30   Re: How to change Sub-Model on player model?
Reply With Quote #31

Sorry for bumping so soon, but I think my question is on topic and not answered before.
I want to ask how to activate more than 1 submodel attachments at the same time? Setting pev_body or playing anim with second write_byte and the number of the submodel, allows for only one submodel at a time. This doesn't allow me to, for example, attach both a m203 grenade launcher and optic sights at the same time to the weapon.

In half life, the bot soldiers (hgrunts) have a bodygroup with 4 heads, and another bodygroup with their weapon (mp5, shotgun, no gun), and In the hlsdk I see that in their spawn function they use SetBodyGroup to set both their head and their weapon. Does amxx have an analogue for this function? And does it work on something other than player models?

Plus another question, if I set the body of w_ models by their entity id in the drop function and set the body of v_ models when playing SVC_WEAPONANIM, then how do I set the body of p_ models?
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-20-2011 , 07:55   Re: How to change Sub-Model on player model?
Reply With Quote #32

Quote:
how to activate more than 1 submodel attachments at the same time
You can probably if you use severals groups.

Quote:
SetBodyGroup
You can see the source yourself. It set basically a value in pev->body.

Quote:
Plus another question,
Don't understand. Why setting body on w_ ? Your w_ weapon has groups ?
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-20-2011 , 09:31   Re: How to change Sub-Model on player model?
Reply With Quote #33

I'm not familiar with hlsdk, I only opened hgrunt.cpp and searched for body to see where is it set, and I noticed this SetBodyGroup func being used. I don't know where is it defined, it's not in hgrunt.cpp

Well, I want to add purchasable weapon attachments in my mod (different types of sights, m203 grenade launcher or foregrip or masterkey shotgun, tac light, laser aiming module, bigger magazines, stuff like that) as well as forest, arctic, desert and urban camo skins with pev_skin. Basically, just like COD:MW2 does. And I want to make it work with p_ models so that you can see what other players have, as well as with w_ models so that you can see what are you picking up from dead bodies. I can easily edit the models in milkshape3d to add the attachments, but the hard part is coding them to work in game.

Even further, I'd like to put all w_ models in one file as submodels to lower the number of precached files, since I'm close to 100 weapons now, and each with p_, v_ and w_ file and firing sound, so on some maps I get the error for reaching the 512 limit and I have to disable some of the less used guns for that map, which I don't like.

Anyways, I'm weak in programing, I haven't yet been able to pass my exams in java and c++, so if you can give me some code examples in pawn it will be very helpfull.

Quote:
Originally Posted by Arkshine View Post
You can probably if you use severals groups.
That's what I see in hgrunt.cpp, they are setting submodels by bodygroups, thus activating more than 1 submodels at the same time, so how is this done in pawn?
__________________

Last edited by SeriousSam; 04-20-2011 at 11:50.
SeriousSam is offline
Send a message via Skype™ to SeriousSam
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-25-2011 , 20:45   Re: How to change Sub-Model on player model?
Reply With Quote #34

Sorry for bumping so soon, but I kind of found out what was bugging me. Arkshine, I think that you might have a mistake here:

Quote:
Originally Posted by Arkshine View Post
Yes.

It doesn't matter how many bodygroup you have, it's linear.

Group1

0 - submodel 1
1 - submodel 2

Group2

2 - submodel 3
3 - submodel 4

etc..

To get the second submodel of the group2, just use pev_body with 3 as value.
I made a model for testing purposes with 2 bodigroups. First bodygroup - 2 submodels. Second bodygroup - 4 submodels. This results in 8 possible combinations of all submodels.

Then I tried cycling between the submodels with pev_body. Following what you said, pev_body 0 and 1 should give the 2 submodels from the first group, and pev_body 2 to 5 should give the 4 submodels from the second group. But it doesn't work this way. In fact, from 2 to 5 gives combinations from both bodygroups, but not all possible combinations. Then I realized - pev_body is not the number of one submodel, but the number of combination from all possible combinations with each submodels in all groups. In other words, 2 submodels in 1st group x 4 submodels in 2nd group = 8 combinations. Then I tried cycling pev_body from 0 to 7, and this gave me all possible combinations from both groups.

Now I only need to find out how to calculate what number to give to pev_body to get the combination that I want. Seems like SetBodygroup and GetBodygroup in HLSDK in animation.cpp do just that, but they are too hard for me to understand, can you please translate them into pawn code for me?
__________________

Last edited by SeriousSam; 04-25-2011 at 21:24.
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-26-2011 , 02:45   Re: How to change Sub-Model on player model?
Reply With Quote #35

Not sure to understand what you're saying. Can you attach your model ? I would like to test myself. I'm not at home, I don't have hldsk nor can test right now, will do later.
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-26-2011 , 10:03   Re: How to change Sub-Model on player model?
Reply With Quote #36

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] >=8fireing[id] = 0;
            
set_pev(idpev_weaponanimanim_shoot1);
    
            
message_begin(MSG_ONESVC_WEAPONANIM, {000}, 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 SetBodygroupvoid *pmodelentvars_t *pevint iGroupint 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...
Attached Files
File Type: zip v_subs.zip (195.6 KB, 384 views)
__________________

Last edited by SeriousSam; 04-26-2011 at 10:19.
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2011 , 09:00   Re: How to change Sub-Model on player model?
Reply With Quote #37

So I've done some tests, though I'm still confused on few things.

What I can say for sure :

- The body value is calculated from the current body value and a base value. (pbodypart->base). I've not idea what is the "base" thing, for example for your model, group0 : 1, group1 : 1, group2 : 1, group3 : 2.
- [Set|Get]BodyGroup can't be used on v_ weapons. Don't know why exactly, but GET_MODEL_PTR returns a null pointer. If you put the v_ model on a dummy entity it works. So, maybe it's because model in not drawn or because attached or not designed to work on player's weapons.
- You can't set different bodygroup on a weapon because the way it works, because you need to send an animation with the body. So to do what you want you need to create one bodygroup and severals bodypart, like : silencer, red dot, silencer + red dot. You get the idea. This way you don't need to be bother about body, it's linear. I know a HL1 developper which wanted to do something like you do, and he had no choice to do like said. It will work, though you will experience bug client-side since it appears that it doesn't always use the right pev_body value and through a plugin you can't fix it. So good luck.
__________________
Arkshine is offline
SeriousSam
Senior Member
Join Date: Aug 2009
Location: Bulgaria
Old 04-27-2011 , 10:03   Re: How to change Sub-Model on player model?
Reply With Quote #38

Thanks a lot about the information, I get what you mean now. But having all combinations as submodels would be too much work, if I have 4 magazine sizes, 6 scopes or iron sights, m203 / masterkey / foregrip / none, tac light / lam / none, and silencer / none, making a submodel with each possible combination of these will result in too much, so I guess I'll use predefined modifications on the weapons as I've done till now, and only use submodel to switch between male and female hands

Anyways, it's not like this idea will be lost, after I finish the modifications on my server, I intend to try to remake the whole game as a mod to the game serious sam the second encounter, since it has better engine than half-life in my opinion, and also the map editor is way more powerfull and easier to use. And supports much larger map size with less fps drops. The only drawback is that the max players are limited to 16, and in half-life they are 32 It has a SDK with a lot of code, so I will have to learn it first. So, whatever I can't do as a mod for cs, I will keep it as an idea for then Thanks a lot for the help again
__________________
SeriousSam is offline
Send a message via Skype™ to SeriousSam
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode