Posted by: omega
Date posted: Aug 31 2003 User Rating: 4 out of 5.0 | Number of views: 3494 Number of comments: 7 | Description: A system to Revamp the Player Model system so that it doesn't use Infokeys (which are easily hackable, and insecure) this also prevents hltv bugs. |
About a week ago on the forum someone was asking how to change the player models so that each class can have its own animations and hitboxes. The benefits of doing this means your models don't have to match skeleton wise, nor do they have to be the same size (you could make one class a large cyborg and another could be an average sized human). FLFII: Defiance uses a method very similar to this to distinguish between the male and female classes.
Here is a rundown on the required steps:
- get rid of any "model" infokey usage
- change the draw player function on the client to not use the infokey
- create a method on the server to set and update the model
- replace the old SET_MODEL() calls with said function
- get rid of everything related to g_ulModelIndexPlayer, except in CreateBaseline, make that identical to the non-player version.
An optional step could be:
- create new animation functions to match different classes
Now that we've gathered the steps required, we have to establish where we need to make the changes. The first obvious location is inside the function StudioDrawPlayer, which is found in StudioModelRenderer.cpp. I mentioned in the steps that we need to change it to not use the infokey, which makes the model be drawn like regular models. Take a look at StudioDrawModel, compare the differences in where it grabs the modelindex and modify it accordingly.
On the server of course we need a function that can change the players model specific to what their class is. Assuming all models have been precached with PRECACHE_MODEL() all we have to do is something like this:
| | void SetCorrectModel() { char modelname[512];
switch(pev->playerclass) { case 1: sprintf(modelname, "models/player/cyborg.mdl"); break; case 2: sprintf(modelname, "models/player/mhuman.mdl"); break; }
pev->modelindex = MODEL_INDEX(modelname); pev->model = MAKE_STRING(modelname); }
|
I've realized when doing this myself that SET_MODEL doesn't always work correctly, so when I discovered this method I of course chose to use it.
Thats all I'm going to cover here. It should be self explanatory, obviously you can't just copy and paste this (I only gave you one block of code; You should already know how to use it, mind you!) and the other steps you'll have to figure out on your own.
Good Luck! |
|
User Comments
Showing comments 1-7
After some help on IRC i got this to work fine, it's really awesome :) Basically, to ive you some more hints, you need to change the clientside function to use the modelindex instead of the infoKey. StudioDrawModel() uses the modelindex , and that's where you should look to find the right code to modify in StudioDrawPlayer(). After that, the rest is quite easy. Anywhere where you want to change your player model you would use the last 2 lines of the function in the tutorial above (assuming you have Prechached the model correctly) and all should be well! Enjoy :) |
|
I think MODEL_INDEX should have STRING(modelname) ALSO, its g_ulModelIndexPlayerEdited by ts2do on Aug 04 2004, 18:27:32
|
|
you only need STRING(modelname) if modelname is a string_t or integer, using the string table. |
|
does this txt exist somewhere?
nice tut btw |
|
i don't think so, i think i deleted it and don't have the file on my HD anymore. |
|
is there a plugin that u can just intall that admins can add more models to load or click on? |
|
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (11 guests)
|
|