Posted by: omega
Date posted: Aug 31 2003 User Rating: 3.2 out of 5.0 | Number of views: 7301 Number of comments: 4 | Description: The Updated Way! |
I've now updated this rescale tutorial, it should now REALLY be 100% complete =)
Thanks to Entropy for figuring out the stuff that i missed and didn't really care about (i ended up dropping mmxhl shortly after DOING this for it).
Note: Most of the steps are the same, however some of my older code is being changed to reflect entropy's fixes or simply because i felt like it. (heh)
Step #1: You must create a new hulls.txt file for all your maps to be rebuilt with. I'll use mine as an example. It's designed for a 2:1 scale (50% of the original player size). Just compare the defines and the hull file and it should be pretty easy to figure out different scales.
valve compile tools version:
| | ( 0 0 0 ) ( 0 0 0 ) // point hull, don't change this ( -8 -8 -16 ) ( 8 8 16 ) // standing player hull ( -16 -16 -16 ) ( 16 16 16 ) // 32x32x32 large hull ( -8 -8 -9 ) ( 8 8 9 ) // ducking player hull
|
zoner's tools version:
Step #2: Now it's time for code. We'll start with the server. I tend to do all my pmove editing inside the client project, so we'll cover that later.
First off, we need to change the defines in util.h. Search for VEC_HULL_MIN and you'll find a block of defines like the block below. The sizes here go with a half size rescale (as mentioned above). You'll need to calculate your boxes and hulls yourself for differing scales. Note: the standing hull's HEIGHT is different from the hullfile, it doesn't HAVE to be (it can be identical) i just kept it this way so its identical to HLDM, except 50% smaller.
| |
#define WORLD_HULL_POINT 0 #define WORLD_HULL_GIRLS 1 #define WORLD_HULL_ADULT 3 #define WORLD_HULL_MELEE 2
#define PLAYER_HULL_POINT 2 #define PLAYER_HULL_GIRLS 0 #define PLAYER_HULL_ADULT 1 #define PLAYER_HULL_MELEE 3
#define VEC_HULL_MIN Vector(-8, -8, -18) #define VEC_HULL_MAX Vector( 8, 8, 18) #define VEC_DUCK_HULL_MIN Vector(-8, -8, -9 ) #define VEC_DUCK_HULL_MAX Vector( 8, 8, 9 ) #define VEC_HUMAN_HULL_MIN Vector( -8, -8, 0 ) #define VEC_HUMAN_HULL_MAX Vector( 8, 8, 36 ) #define VEC_HUMAN_HULL_DUCK Vector( 8, 8, 18 ) #define VEC_VIEW Vector( 0, 0, 14 ) #define VEC_DUCK_VIEW Vector( 0, 0, 6 )
|
UNDONE: You don't need to call UTIL_SetSize in CmdStart() or CmdEnd() in client.cpp
Open up world.cpp Find CWorld::Spawn(), place this above it:
| | extern "C" int g_model_hulls_fixed;
|
now add
INSIDE CWorld::Spawn, i placed it at the bottom of the function.
open up client.cpp and find GetHullBounds; do this:
| | int GetHullBounds( int hullnumber, float *mins, float *maxs ) { int iret = 0; switch ( hullnumber ) { case PLAYER_HULL_POINT: mins[0] = mins[1] = mins[2] = 0; maxs[0] = maxs[1] = maxs[2] = 0; iret = 1; break; case PLAYER_HULL_GIRLS: mins[0] = mins[1] = -8;mins[2] = -18; maxs[0] = maxs[1] = -8;maxs[2] = 18; iret = 1; break; case PLAYER_HULL_ADULT: mins[0] = mins[1] = -8;mins[2] = -9; maxs[0] = maxs[1] = 8;maxs[2] = 9; iret = 1; break; case PLAYER_HULL_MELEE: mins[0] = mins[1] = mins[2] = -16; maxs[0] = maxs[1] = maxs[2] = 16; iret = 1; break; } return iret; }
|
Thats it for the Server-Side, now for the client.
Step #3: I got this next little code snippet from Adrian, so thank him. =) Open up StudioModelRenderer.cpp, and take a look at StudioSetupBones() (near the middle of the file). You'll need to scale down each part of the bone matrix. You need to do it for all twelve array elements (three sizes, four parameters for each), like this: IMPORTANT: This is only VISUAL. I cannot stress this enough, this only VISUALLY makes the models smaller; if you rely on hitboxes, they will NOT be scaled down on the server (where the damage happens!) I recommend you scale models properly, and omit this change; if your mod doesn't require hitboxes, and instead uses the full bounding box, its okay.
| | if (pbones[i].parent == -1) { for (int j=0;j<3; j++) { bonematrix[j][0] *= 0.5; bonematrix[j][1] *= 0.5; bonematrix[j][2] *= 0.5; bonematrix[j][3] *= 0.5; } } if ( IEngineStudio.IsHardware() )
|
Step #4: You now need to head over to cdll_int.cpp and modify GetHullBounds(). Make it look something like this. (or just like this if you're a copy and paster!)
| |
#define PLAYER_HULL_POINT 2 #define PLAYER_HULL_GIRLS 0 #define PLAYER_HULL_ADULT 1 #define PLAYER_HULL_MELEE 3 int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) { int iret = 0; switch ( hullnumber ) { case PLAYER_HULL_POINT: mins[0] = mins[1] = mins[2] = 0; maxs[0] = maxs[1] = maxs[2] = 0; iret = 1; break; case PLAYER_HULL_GIRLS: mins[0] = mins[1] = -8; mins[2] = -18; maxs[0] = maxs[1] = -8; maxs[2] = 18; iret = 1; break; case PLAYER_HULL_ADULT: mins[0] = mins[1] = -8; mins[2] = -9; maxs[0] = maxs[1] = 8; maxs[2] = 9; iret = 1; break; case PLAYER_HULL_MELEE: mins[0] = mins[1] = mins[2] = -16; maxs[0] = maxs[1] = maxs[2] = 16; iret = 1; break; } return iret; }
|
Step #5: Pull up hud_msg.cpp add this above Msgfunc_ResetHUD:
| | extern "C" int g_model_hulls_fixed;
|
now add this, INSIDE Msgfunc_ResetHUD:
Step #6: For the final series of edits (yay!), we need to adjust the player's physics. Open up pm_shared.c in either the server or the client (the file is mirrored in both, so it doesn't matter which).
The first step will be to modify the defines near the top to reflect the changes we defined earlier, for heights and so forth:
| | #define VEC_HULL_MIN -18 #define VEC_HULL_MAX 18 #define VEC_DUCK_HULL_MIN -9 #define VEC_DUCK_HULL_MAX 9 #define VEC_DUCK_VIEW 6 #define VEC_VIEW 14
|
Step #7 PM_UpdateClipBox is very important because the *trace* boxes get wiped over. If you skip this step, your trace boxes will remain the standard size on the client, causing no end of grief.
This code is actually from one of my other mods. i'm copy and pasting it as i have it, you'll have to change it to reflect yours. i'm only modifying PARTS of it (the numerical values).
Enter both Entropy's omegafied code, and a modified version of my old PM_UpdateClipBox function: NOTE:You'll need to include com_model.h, so make sure you wipe out any struct at the top of pm_shared.c thats been duplicated from com_model.h as well.
| | int g_model_hulls_fixed = 0; #define WORLD_HULL_POINT 0 #define WORLD_HULL_GIRLS 1 #define WORLD_HULL_ADULT 3 #define WORLD_HULL_MELEE 2 #define PLAYER_HULL_POINT 2 #define PLAYER_HULL_GIRLS 0 #define PLAYER_HULL_ADULT 1 #define PLAYER_HULL_MELEE 3
void PM_UpdateClipBox( void ) { vec3_t POINT_MIN; vec3_t POINT_MAX; vec3_t GIRLS_MIN; vec3_t GIRLS_MAX; vec3_t ADULT_MIN; vec3_t ADULT_MAX; vec3_t MELEE_MIN; vec3_t MELEE_MAX; POINT_MIN[0] = POINT_MIN[1] = POINT_MIN[2] = 0; POINT_MAX[0] = POINT_MAX[1] = POINT_MAX[2] = 0; GIRLS_MIN[0] = -8; GIRLS_MIN[1] = -8; GIRLS_MIN[2] = -18; GIRLS_MAX[0] = 8; GIRLS_MAX[1] = 8; GIRLS_MAX[2] = 18; ADULT_MIN[0] = -8; ADULT_MIN[1] = -8; ADULT_MIN[2] = -9; ADULT_MAX[0] = 8; ADULT_MAX[1] = 8; ADULT_MAX[2] = 9; MELEE_MIN[0] = -16; MELEE_MIN[1] = -16; MELEE_MIN[2] = -16; MELEE_MAX[0] = 16; MELEE_MAX[1] = 16; MELEE_MAX[2] = 16; VectorCopy(POINT_MIN, pmove->player_mins[PLAYER_HULL_POINT]); VectorCopy(POINT_MAX, pmove->player_maxs[PLAYER_HULL_POINT]); VectorCopy(GIRLS_MIN, pmove->player_mins[PLAYER_HULL_GIRLS]); VectorCopy(GIRLS_MAX, pmove->player_maxs[PLAYER_HULL_GIRLS]); VectorCopy(ADULT_MIN, pmove->player_mins[PLAYER_HULL_ADULT]); VectorCopy(ADULT_MAX, pmove->player_maxs[PLAYER_HULL_ADULT]); VectorCopy(MELEE_MIN, pmove->player_mins[PLAYER_HULL_MELEE]); VectorCopy(MELEE_MAX, pmove->player_maxs[PLAYER_HULL_MELEE]); }
model_t * g_modelarray = NULL; void PM_FixModelHulls() { int model; vec3_t POINT_MIN; vec3_t POINT_MAX; vec3_t GIRLS_MIN; vec3_t GIRLS_MAX; vec3_t ADULT_MIN; vec3_t ADULT_MAX; vec3_t MELEE_MIN; so it doesn't trace as big. vec3_t MELEE_MAX; POINT_MIN[0] = POINT_MIN[1] = POINT_MIN[2] = 0; POINT_MAX[0] = POINT_MAX[1] = POINT_MAX[2] = 0; GIRLS_MIN[0] = -8; GIRLS_MIN[1] = -8;GIRLS_MIN[2] = -18; GIRLS_MAX[0] = 8; GIRLS_MAX[1] = 8; GIRLS_MAX[2] = 18; ADULT_MIN[0] = -8; ADULT_MIN[1] = -8; ADULT_MIN[2] = -9; ADULT_MAX[0] = 8; ADULT_MAX[1] = 8; ADULT_MAX[2] = 9; MELEE_MIN[0] = -16; MELEE_MIN[1] = -16; MELEE_MIN[2] = -16; MELEE_MAX[0] = 16; MELEE_MAX[1] = 16; MELEE_MAX[2] = 16; if (!g_modelarray) g_modelarray = pmove->physents[0].model;
VectorCopy(POINT_MIN, pmove->physents[0].model->hulls[WORLD_HULL_POINT].clip_mins); VectorCopy(POINT_MAX, pmove->physents[0].model->hulls[WORLD_HULL_POINT].clip_maxs); VectorCopy(GIRLS_MIN, pmove->physents[0].model->hulls[WORLD_HULL_GIRLS].clip_mins); VectorCopy(GIRLS_MAX, pmove->physents[0].model->hulls[WORLD_HULL_GIRLS].clip_maxs); VectorCopy(ADULT_MIN, pmove->physents[0].model->hulls[WORLD_HULL_ADULT].clip_mins); VectorCopy(ADULT_MAX, pmove->physents[0].model->hulls[WORLD_HULL_ADULT].clip_maxs); VectorCopy(MELEE_MIN, pmove->physents[0].model->hulls[WORLD_HULL_MELEE].clip_mins); VectorCopy(MELEE_MAX, pmove->physents[0].model->hulls[WORLD_HULL_MELEE].clip_maxs); { if (pmove->physents[0].model[model].name[0] == '*') { VectorCopy(POINT_MIN, g_modelarray[model].hulls[WORLD_HULL_POINT].clip_mins); VectorCopy(POINT_MAX, g_modelarray[model].hulls[WORLD_HULL_POINT].clip_maxs); VectorCopy(GIRLS_MIN, g_modelarray[model].hulls[WORLD_HULL_GIRLS].clip_mins); VectorCopy(GIRLS_MAX, g_modelarray[model].hulls[WORLD_HULL_GIRLS].clip_maxs); VectorCopy(ADULT_MIN, g_modelarray[model].hulls[WORLD_HULL_ADULT].clip_mins); VectorCopy(ADULT_MAX, g_modelarray[model].hulls[WORLD_HULL_ADULT].clip_maxs); VectorCopy(MELEE_MIN, g_modelarray[model].hulls[WORLD_HULL_MELEE].clip_mins); VectorCopy(MELEE_MAX, g_modelarray[model].hulls[WORLD_HULL_MELEE].clip_maxs); } } }
|
Finally, you need to call PM_UpdateClipBox() and PM_FixModelHulls() down in PM_Move() right before PM_PlayerMove, like this:
| | PM_UpdateClipBox(); if (!g_model_hulls_fixed) { PM_FixModelHulls(); g_model_hulls_fixed = 1; } PM_PlayerMove( ( server != 0 ) ? true : false );
|
Step #8: There is no step 8! You're done! =) You'll likely want to scale speeds and stuff down, but you can do that on your own. I hardcoded all of mine in input.cpp, but it can be done in the physics code, as well.
Optional: You may want to do this (i did). open up client.cpp, go to SetupVisibility, and change the part that calcs the view offset to simply this:
| | if ( pView->v.flags & FL_DUCKING ) org = pView->v.origin + VEC_DUCK_VIEW; else org = pView->v.origin + VEC_VIEW;
| |
|
User Comments
Showing comments 1-4
void PM_FixModelHulls() { int model; vec3_t POINT_MIN
Make it int model=0; Or it will crash |
|
no it won't.
that model integer it isn't even used, you can take that declaration out entirely.Edited by omega on May 01 2004, 19:29:39
|
|
what u mean with and stuff? |
|
if anyone is interested in a fix for this tutorial just pm me or post here |
|
You must register to post a comment. If you have already registered, you must login.
|
297 Approved Articless
6 Pending Articles
3940 Registered Members
0 People Online (5 guests)
|
|