Raised This Month: $7 Target: $400
 1% 

Some pev_body information


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-14-2013 , 15:13   Some pev_body information
Reply With Quote #1

pev_body
is a value that tells the game which sub-model should be visible.

This can be extremely powerful with more player models, except nobody seems to have used this feature to its potential yet. As of now and as far as I know, CS only uses this to display bomb on the player.

What can be done with this value?
For example, you can put all of the custom models and hats on your server into a single model. This has a lot of pros over the cons (below).

How do you change the combinations?
Let's say you have two groups of sub-models like me - models and hats.

THIS IS NOT HOW IT WORKS:
Model1 - ID: 0
Model2 - ID: 1
Model3 - ID: 2
Hat1 - ID: 3
Hat2 - ID: 4
Hat3 - ID: 5

THIS IS HOW IT WORKS:
Model1 - ID: 0
Model2 - ID: 1
Model3 - ID: 2
Hat1 - ID: 0
Hat2 - ID: 1
Hat3 - ID: 2

For only two groups, you want to use this to get the pev_body number you need:
Code:
pev_body = hat_id * amount_of_models + model_id

So let's say you want to give the player Model 2 with Hat 3.
pev_body = 2 * 3 + 1 = 7

I haven't tried working with more groups yet, I'll report back once I do.

What can be done with this?
You can for example make a plugin for full character customization. Create a model with body parts such as face, hair, chest size, etc. and allow the player to choose what suits him.

Pros:
- All models are in one larger file, which gives a better "feeling" when downloading
- A great way to reduce the amount of precached files on your server
- The file size is a lot smaller than all the models one by one together, because the duplicates (model information, animations etc) are removed
- For hats and such, you don't need a 3rd party plugin to handle it (creating a new entity, setting it's origin, etc)
- The model + hat is still one single entity
- A lot of new possibilities

Cons:
- Adding more models will require a new download of the complete file
- Not too easy to work with
- Compiler is a bitch
- The final model requires all the already existing Counter-Strike models, if you want to make hats available for standard models as well
- Players won't be able to see their custom models

Current problems:
- The compiler keeps crashing for some reason, producing an unfinished model (split textures)
- Need to figure out how to add models split into parts as a submodel. Currently, it adds each part as a submodel (see the model example: group 'modely', submodels 5 and 6

- Need to make the bomb visible, I'm going to add it in a completely new group and see what it looks like.
- Edit: Compiler crashing when the file size is above 4 megabytes. Trying to find a way around this (splitting models)

If you know how to solve any of the problems above, please let me know.


Use this small plugin with the included model to see what is this feature capable of
Code:
#include < amxmodx > #include < fakemeta > #include < cstrike >     new const cstModel[ ] = "models/player/testmdl/testmdl.mdl" new const cstModelT[ ] = "models/player/testmdl/testmdlt.mdl" new const cstMdlName[ ] = "testmdl" public plugin_precache( ) {     precache_model( cstModel )     precache_model( cstModelT ) } public plugin_init( ) {     register_clcmd( "pev_body", "_body" )     register_clcmd( "changemdl", "_changemdl" ) } public _body( id ) {     new szArgs[ 4 ]     read_args( szArgs, charsmax( szArgs ) )         remove_quotes( szArgs )     trim( szArgs )         new iPev = str_to_num( szArgs )         set_pev( id, pev_body, iPev )         client_print( id, print_console, "Changing your pev_body value to %d", iPev )         return PLUGIN_HANDLED } public _changemdl( id ) {     cs_set_user_model( id, cstMdlName )     client_print( id, print_console, "Your model was changed to %s. You can now change your pev_body value using console command 'pev_body'.", cstMdlName ) }

Table of values:
Code:
MODEL NAME			HAT			PEV_BODY

T Model 1			Indian Hat		0
T Model 2			Indian Hat		1	
CT Model 1			Indian Hat		2
Hitman				Indian Hat		3
Banana (eyes)			Indian Hat		4
Banana (rest)			Indian Hat		5
CT Model 2			Indian Hat		6
Assassin			Indian Hat		7

T Model 1			Afro			8
T Model 2			Afro			9	
CT Model 1			Afro			10
Hitman				Afro			11
Banana (eyes)			Afro			12
Banana (rest)			Afro			13
CT Model 2			Afro			14
Assassin			Afro			15

T Model 1			Minecraft		16
T Model 2			Minecraft		17	
CT Model 1			Minecraft		18
Hitman				Minecraft		19
Banana (eyes)			Minecraft		20
Banana (rest)			Minecraft		21
CT Model 2			Minecraft		22
Assassin			Minecraft		23

T Model 1			Fly			24
T Model 2			Fly			25	
CT Model 1			Fly			26
Hitman				Fly			27
Banana (eyes)			Fly			28
Banana (rest)			Fly			29
CT Model 2			Fly			30
Assassin			Fly			31

T Model 1			Wings (broken)		32
T Model 2			Wings (broken)		33	
CT Model 1			Wings (broken)		34
Hitman				Wings (broken)		35
Banana (eyes)			Wings (broken)		36
Banana (rest)			Wings (broken)		37
CT Model 2			Wings (broken)		38
Assassin			Wings (broken)		39
You can see the submodels in HLMV in the "Body Parts" tab.

UPDATE

Thanks for reading.

HUGE UPDATE

Okay, this is getting even better than I thought it would be.

Animations
Each model has around 120 sequences. What's funny about this is an average model has 2.3MB filesize - 2 megabytes of that are the animations. Which means if you're going to combine 5 models of size 2.3MB each, your final size will be 2MB for the animations + 5 * 300kB = 3.5MB total.

Bomb and defusal kit
I've implemented those in my new model. The function to get the pev_body ID is as follows:
Code:
stock get_bodyid( iModelId, iHatId, bool: bBomb, bool: bDefusalKit ) {     new iPevBody = iHatId * g_TotalModels + iModelId         if( bBomb )         iPevBody += ( g_TotalModels * g_TotalHats )             if( bDefusalKit )         iPevBody += ( g_TotalModels * g_TotalHats * 2 )         return iPevBody }
I'm not sure about this - haven't tested it yet.

New model
The new model is in attachments. There are 17 models and 39 hats - total size: 11.15MB. I removed the shield animations, because they're useless for me. Two models are duplicate (my bad), because I forgot to rename the textures of these, so they just replaced the other textures.

Limits
The limits for combined models are:
- Max 16MB filesize
- Texture names sometimes need to be changed or they will be overwritten by other models
- Maximum 40 sub-models per group (39 hats, because the first one is empty)

Note the first HatID is no longer 0 (ID 0 is "nothing", we're setting HatID 0 for people without any hat)

Attached Files
File Type: 7z testmodel.7z (4.61 MB, 1320 views)
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 05-17-2014 at 18:43.
Backstabnoob is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 03-14-2013 , 22:55   Re: Some pev_body information
Reply With Quote #2

Oh man.. this is cool, thanks for the tutor, i like it.

**Edited**
Quote:
Compiler crashing when the file size is above 4 megabytes.
You can use Xash Studiomdl to compile model > 16mb. You can see here http://hl.gamebanana.com/tools/5094
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 03-15-2013 at 03:07.
yokomo is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-15-2013 , 08:19   Re: Some pev_body information
Reply With Quote #3

That compiler looks pretty cool. Thanks for the link, I was nearly hopeless.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-15-2013 , 13:17   Re: Some pev_body information
Reply With Quote #4

Nice tutorial, thanks for making it.
__________________
Kia is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-15-2013 , 16:09   Re: Some pev_body information
Reply With Quote #5

Post updated.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
frk_14
Senior Member
Join Date: Jan 2009
Location: Argentina
Old 03-17-2013 , 12:34   Re: Some pev_body information
Reply With Quote #6

the client dont support more than 255 bodies or combinations
__________________

Last edited by frk_14; 03-17-2013 at 12:35.
frk_14 is offline
Send a message via MSN to frk_14 Send a message via Skype™ to frk_14
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-17-2013 , 13:28   Re: Some pev_body information
Reply With Quote #7

As far as I know pev_body can be integer for players and byte only for entities, or is that DoD only?
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 03-17-2013 at 13:35.
Backstabnoob is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-02-2013 , 12:49   Re: Some pev_body information
Reply With Quote #8

frk_14 is right, the pev_body value is limited on CS servers.

It's probably silly of me to ask this, but is it possible to change the type to long (short would certainly suffice though) from byte using a module or directly editing a library? DoD already does this, I'm not sure whether the pev_body works only server-side or client-side as well.

Sorry if it sounds stupid, I have no experience with how it works on client and server side.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 05-02-2013 , 13:44   Re: Some pev_body information
Reply With Quote #9

You can't because it will work only on server side (you can't change clients code).
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-02-2013 , 13:47   Re: Some pev_body information
Reply With Quote #10

Oh, that's a shame. I knew it's impossible to change client side without touching their game, but I had some hope that pev_body is only a server side material.

Geez. 255 combinations is still a lot, though. Enough to fit all the models from a shitty zombie plague server to one larger file.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 05-02-2013 at 13:47.
Backstabnoob is offline
Reply


Thread Tools
Display Modes

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 07:31.


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