.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   [CZ] Changing model directory "on the fly"? (http://forums.bots-united.com/showthread.php?t=4158)

Rusty Le Cyborg 28-06-2005 20:33

[CZ] Changing model directory "on the fly"?
 
Hi there

Just a quick question for those more knowledgable than I :)

Is it possible to make a dll which will change CS or CZ's default model directory?

Now.. the explanation...

A while ago "PAF" released the Hostitron which is a plugin for Meta Mod which changes the Hostage models dependant on which map is loaded.

Last year sometime (with help from these forums) Dead_Bwoy released Environskin for CZ which, using a new botprofile.db file, allowed you to choose map specific skins for player models after running a server cfg file.

What I want to know is, rather than using Botprofile.db etc, is it not possible to tell the CZ executable that the default model directory is "czero/models/player/cs_downed_cz/" rather than "czero/models/player"?

This would just be for offline play, so any "hooking" would not interfere with VAC2.

Can anyone help with this?

Pierre-Marie Baty 28-06-2005 21:16

Re: [CZ] Changing model directory "on the fly"?
 
Perhaps yes, if you hook pfnSetModel(), when you detect that the model being passed is something like "*/*/player" just concatenate the map name
Code:

sprintf (model_name, "old_model_base_path/%s/player/etc.", STRING (gpGlobals->mapname));
You see the idea?

Rusty Le Cyborg 28-06-2005 21:55

Re: [CZ] Changing model directory "on the fly"?
 
Hmm.. I see what you mean, and that is how I envisaged it (I think!) but i truly have no idea how to achieve this...

Ideally it would look for a "map/player/whatever..." models. I had thought it would be easier with cl_minmodels set to 1 so you would only need two models per map (i.e. Leet and GIGN).

If it does not find the correct map folder, then perhaps it would default to the original model directories... not sure how this would work though.

Is this a big thing for a knowledgable person to achieve? (i.e.... not me! ???:( )

<edit>

If this IS possible, I presume it would only be a matter of adding a new directory for hostages to be map specific too?

Pierre-Marie Baty 29-06-2005 00:54

Re: [CZ] Changing model directory "on the fly"?
 
It should be very simple to do, at least in the form of a metamod plugin. It could be a matter of 20 minutes.

Yes you can start writing it yourself and post here when you get into trouble, we'll gladly help you out.

Rusty Le Cyborg 29-06-2005 01:24

Re: [CZ] Changing model directory "on the fly"?
 
So it would have to be part of Meta Mod?

Could it not be done with the original dll files or something similar?

Pierre-Marie Baty 29-06-2005 06:07

Re: [CZ] Changing model directory "on the fly"?
 
You have to program it somehow. There are two ways: either you do a metamod plugin that does that, either you do the same thing with a hook DLL, that is, a DLL that will sit between the engine and the game DLL (like the early HPB_bot did). This will be a server-side thingy, anyway.

Rusty Le Cyborg 29-06-2005 19:50

Re: [CZ] Changing model directory "on the fly"?
 
Looks like I'm going to have to do a lot of reading up :)

..any pointers to a good place to start?

Cheers for now

Pierre-Marie Baty 29-06-2005 21:03

Re: [CZ] Changing model directory "on the fly"?
 
Download a simple metamod plugin from our filebase that comes with source code, and use it as an example on how to build yours :)

Rusty Le Cyborg 01-07-2005 02:02

Re: [CZ] Changing model directory "on the fly"?
 
Now then... after much discussion with PM it seems that I would need a basic knowledge of programming to understand the plug-in concept... and I am completely lost now :)

I wonder if anybody here might like to assist me by writing a plug-in for me?

Basically, what it should do is -

On map load... check map name... then make the default player model and hostage model directory used for that map something like "%s/player" or "%s/hostage", if there is no directory like that then it should use defaults...

Meta Mod would be good, but I was wondering about some kind of modified dll file. Though I guess Meta Mod is safer as far as VAC2 goes...

If anyone is able to help I'd be much obliged.

Cheers for now

PS - Thanks to PM for all his help/explanations so far :)

Lazy 02-07-2005 06:56

Re: [CZ] Changing model directory "on the fly"?
 
So basically you want it to change models/player/terrorist/terrorist.mdl to models/mapname/terrorist/terrorist.mdl?

It may be possible but an inconvenience if you don't have a fast download server, I don't have CS installed anymore so I have no idea how many models there are to change.

If you can be very specific on what you want to happen I will write a plugin to do this for you.
I gotta write a team balancer for someone anyway so might aswell grab some coffee and work on both.

*goes off to write new mm plugin framework*

[Added]
Damn, I read the z backwards.
I don't have CZ but that shouldn't be a problem, I'll test it on another mod but you'd have to let me know how it works.
There shouldn't be any problems though :)

Rusty Le Cyborg 02-07-2005 11:23

Re: [CZ] Changing model directory "on the fly"?
 
Superb Lazy... thanks :)

I will make a list and post it soon (just got up and eyes not focusing properly yet!!)

Cheers for now

<edit>

Okay... the eyes are now working after a quick sugar and coffee hit :)

The models used in CZ are as follows -

models/player/arctic/arctic.mdl
models/player/gign/gign.mdl
models/player/gsg9/gsg9.mdl
models/player/guerilla/guerilla.mdl
models/player/leet/leet.mdl
models/player/militia/militia.mdl
models/player/sas/sas.mdl
models/player/spetsnaz/spetsnaz.mdl
models/player/terror/terror.mdl
models/player/urban/urban.mdl
models/player/vip/vip.mdl

It is a little difficult to add the hostages into an updated CZ install as the models have been changed from standard CS type ones.

But would it be possible (not to sound greedy!) to make a second dll which could be used by a standard CD install of CZ and CS?

This would need to change the models for -

models/player/arctic/arctic.mdl
models/player/gign/gign.mdl
models/player/gsg9/gsg9.mdl
models/player/guerilla/guerilla.mdl
models/player/leet/leet.mdl
models/player/sas/sas.mdl
models/player/terror/terror.mdl
models/player/urban/urban.mdl
models/player/vip/vip.mdl
models/hostage.mdl

Now then, I had intended that this be used with "cl_minmodels 1" on, so you would actually only have to change the leet and gign models, but I'm not sure that you can change just the variable "models/player" to "models/mapname/player/". Does it have to be the full path to each model? I shall leave that to you :)

Thanks again for your offer. If you need any more information, just give me a shout!

Cheers for now
</edit>

Rusty Le Cyborg 02-07-2005 13:03

Re: [CZ] Changing model directory "on the fly"?
 
Posting just to add a new "timestamp" in case you already read my reply..

Doh me!

By the way, added your AOL, so I'll try to catch you online too.

Rusty Le Cyborg 02-07-2005 13:49

Re: [CZ] Changing model directory "on the fly"?
 
Hmmm... actually, this may be of some use.

Just for interest, the XBox version of CS uses a "cfg" file to decide which models to use on which map.

It refers to a file called "playermodels.txt" which contains this information -

Code:

de_dust        models/player/de_dust/leet.mdl models/player/de_dust/seal.mdl
de_dust2        models/player/de_dust2/leet.mdl models/player/de_dust2/seal.mdl
de_fastline models/player/de_fastline/militia.mdl models/player/de_fastline/gsg9.mdl
cs_italy        models/player/cs_italy/militia.mdl models/player/cs_italy/gign.mdl models/hostages/businessman_young.mdl
cs_training        models/player/cs_italy/militia.mdl models/player/cs_italy/gign.mdl models/hostages/schoolgirl.mdl
de_truth        models/player/de_truth/guerilla.mdl models/player/de_truth/gsg9.mdl
cs_havana        models/player/cs_havana/militia.mdl models/player/cs_havana/seal.mdl models/hostages/latina.mdl
cs_miami        models/player/cs_miami/militia.mdl models/player/cs_miami/seal.mdl models/hostages/blonde.mdl
cs_militia        models/player/cs_militia/arctic.mdl models/player/cs_militia/spetsnaz.mdl models/hostages/jumpsuit.mdl
de_tides        models/player/de_tides/guerilla.mdl models/player/de_tides/gign.mdl
de_vostok        models/player/de_vostok/arctic.mdl models/player/de_vostok/spetsnaz.mdl
cs_office        models/player/cs_office/arctic.mdl models/player/cs_office/gsg9.mdl models/hostages/businessman.mdl
de_airstrip        models/player/de_airstrip/arctic.mdl models/player/de_airstrip/seal.mdl
de_aztec        models/player/de_aztec/guerilla.mdl models/player/de_aztec/seal.mdl
de_cbble        models/player/de_cbble/terror.mdl models/player/de_cbble/gsg9.mdl
de_chateau        models/player/de_chateau/guerilla.mdl models/player/de_chateau/sas.mdl
de_inferno        models/player/de_inferno/terror.mdl models/player/de_inferno/gign.mdl
de_piranesi        models/player/de_piranesi/arctic.mdl models/player/de_piranesi/gign.mdl
de_prodigy        models/player/de_prodigy/militia.mdl models/player/de_prodigy/spetsnaz.mdl
de_stadium        models/player/de_stadium/arctic.mdl models/player/de_stadium/sas.mdl
de_training        models/player/de_dust/leet.mdl models/player/de_dust/seal.mdl
cs_downed        models/player/cs_downed/guerilla.mdl models/player/cs_downed/seal.mdl models/hostages/pilot.mdl
de_corruption        models/player/de_corruption/guerilla.mdl models/player/de_corruption/gsg9.mdl

Would this be an easier way to do this?

Lazy 02-07-2005 15:23

Re: [CZ] Changing model directory "on the fly"?
 
The one dll I create should work across all mods, all it needs to do is adjust some paths.

ie. from "models/hostage.mdl"
to "models/cs_office/hostage.mdl"

It doesn't get any easier than creating a directory with the same name of the map in your models directory.
When the model is being precached, I'll tell it to look for it in models/mapname/ first. If that doesn't work ( pfnPrecacheModel returns <= 0 ) then it will use the default model instead.

No config files needed :)

Rusty Le Cyborg 02-07-2005 15:38

Re: [CZ] Changing model directory "on the fly"?
 
Ah right.. I understand :)

That will be excellent as it will work with the spetsnaz and militia for CZ also.

Thanks again!! :D

Lazy 02-07-2005 23:53

Re: [CZ] Changing model directory "on the fly"?
 
Shouldn't be too much longer, the code to change models is already complete.
I just have to figure out why the version of gcc that comes with cygwin won't compile it.

Rusty Le Cyborg 03-07-2005 01:24

Re: [CZ] Changing model directory "on the fly"?
 
Sounds good Lazy!

But....

I had a thought earlier about the updated Hostages in CZ. It seems that instead of just being called hostage.mdl they are called hostageA.mdl, hostageB.mdl, hostageC.mdl and hostageD.mdl

Would this cause an issue if it were to be added in a possible future release?

Then there are the hostage sound files to consider :)

I will have to check it all out once you have figured your compile problem.

Good luck and good night!!

Lazy 03-07-2005 01:29

Re: [CZ] Changing model directory "on the fly"?
 
Well, to override a default model all you'd need to do is put the replacement in models/mapname/ and it should be done automatically.

Rusty Le Cyborg 03-07-2005 10:54

Re: [CZ] Changing model directory "on the fly"?
 
Ah yes of course. I had forgotn that you were making "global" changes to the path :)

Just another question then, would it be to much of an issue to add a change to sounds? So that it would look in "sound/mapname/player or hostage" and then check "sound/player or hostage"?

Or is this a big change?

Cheers for now

Lazy 03-07-2005 19:54

Re: [CZ] Changing model directory "on the fly"?
 
Not at all, the only problem may be with playermodels but that can be fixed easily ( models on the server are models/player.mdl for everyone ).

I'm just going to install visual studio for now, I've spent all the time I should have been coding on trying to get it to compile under cygwin.

Rusty Le Cyborg 03-07-2005 22:55

Re: [CZ] Changing model directory "on the fly"?
 
Okay. Thanks for going to all this trouble, it's much appreciated :)

Lazy 04-07-2005 09:26

Re: [CZ] Changing model directory "on the fly"?
 
Np, though hl is fighting me along the way though lol.
I have it at the point where it should work but then I get a "bad character in client command" error when I join my server.

That makes absolutely no sense at all, the path only gets the mapname added to the start :/

What goes in: weapons/emp_1.wav
What comes out: 2fort/weapons/emp_1.wav

All is good, no precache errors, the file was checked to exist and I even unhooked EmitSound to be sure.

Heres it so far, I did some re-designing so only the sound stuff is in right now.
The plugin framework is turning out nice too, so much easier now :)
Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mplugin.h"

// Converts forward slashes to backslashes so the paths
// work under win32
void LinuxToWinPath( char* pszPath, int nCount ) {
#ifdef _WIN32
  register int _nCount = nCount;  // I wonder if "register" actually does anything these days

  // Chose to use _nCount so hopefully the compiler would choose to
  // compare to registers rather than a memory location on each iteration.
  for ( register int i = 0; i < _nCount; i++ ) {
          // Convert forward slashes to backslashes so
          // this will work under windows
          if ( pszPath[ i ] == '/' )
                pszPath[ i ] = '\\';
  }
#endif
}

// NOTE:
// Make SURE pszSearchdir is set! ( ie. "sound" or "models" )
// Otherwise, fopen will fail and so will this function!
int CheckFileExists( const char* pszFile, const char* pszSearchdir ) {
  char szGamedir[ _MAX_PATH ];  // Mod root directory
  char szNewpath[ _MAX_PATH ];  // Where to look
  FILE* pFile = NULL;                  // Temporary file handle

  // Get the mod directory and setup our filename string
  GET_GAME_DIR( szGamedir );
  _snprintf( szNewpath, sizeof( szNewpath ), "%s\\%s\\%s", szGamedir, pszSearchdir, pszFile );

  // Make sure the slashes are right if running under win32
  // Note:
  // Under linux, the LinuxToWinPath function will do nothing.
  LinuxToWinPath( szNewpath, strlen( szNewpath ) );

  // Attempt to open the file, if it exists pFile should be a valid pointer.
  if ( ( pFile = fopen( szNewpath, "rb" ) ) != NULL ) {
          fclose( pFile );
          return 1;
  }

  // Not found
  return 0;
}

// Old : weapons/dbarrel1.wav
// New : 2fort/weapons/dbarrel1.wav
int ChangeSearchPath( const char* pszFile, const char* pszSearchdir, char* pszNewpathbuf, size_t lMaxbuflen ) {
  char szNewpath[ _MAX_PATH ];

  // Add the mapname to the beginning of the string
  _snprintf( szNewpath, sizeof( szNewpath ), "%s/%s", STRING( gpGlobals->mapname ), pszFile );

  // If the file exists, give the caller the new path and return success
  if ( CheckFileExists( szNewpath, pszSearchdir ) == 1 ) {
          strncpy( pszNewpathbuf, szNewpath, lMaxbuflen );
          return 1;
  }

  // No updated version of this file
  return 0;
}

int PrecacheModel( char* pszModel ) {
  RETURN_META_VALUE( MRES_IGNORED, 1 ); 
}
 
int PrecacheSound( char* pszSound ) {
  char szNewpath[ _MAX_PATH ];

 RETURN_META_VALUE( MRES_SUPERCEDE, ChangeSearchPath( pszSound, "sound", szNewpath, sizeof( szNewpath ) ) == 0 ? PRECACHE_SOUND( pszSound ) : PRECACHE_SOUND( szNewpath ) );
}
 
void SetModel( edict_t* pEntity, const char* pszModel ) {
  RETURN_META( MRES_IGNORED );
}

void EmitSound( edict_t* pEntity, int nChan, const char* pszSample, float flVolume, float flAttenuation, int iFlags, int iPitch ) {
  char szNewpath[ _MAX_PATH ];

 RETURN_META_VALUE( MRES_SUPERCEDE, ChangeSearchPath( pszSample, "sound", szNewpath, sizeof( szNewpath ) ) == 0 ? g_engfuncs.pfnEmitSound( pEntity, nChan, pszSample, flVolume, flAttenuation, iFlags, iPitch ) : g_engfuncs.pfnEmitSound( pEntity, nChan, szNewpath, flVolume, flAttenuation, iFlags, iPitch ) );
}

BEGIN_GIVEFNPTRSTODLL( )
END_GIVEFNPTRSTODLL( )

BEGIN_META_ATTACH( )
END_META_ATTACH( )

BEGIN_META_QUERY( )
END_META_QUERY( )

BEGIN_META_DETACH( )
END_META_DETACH( )

BEGIN_GETENGINEFUNCTIONS( )
  //HOOK_ENGINE_FN( pfnPrecacheModel, PrecacheModel );
  HOOK_ENGINE_FN( pfnPrecacheSound, PrecacheSound );
  //HOOK_ENGINE_FN( pfnEmitSound, EmitSound );
  //HOOK_ENGINE_FN( pfnSetModel, SetModel );
END_GETENGINEFUNCTIONS( )

It's 3:32am here and I'm just not seeing it, maybe someone knows why this is happening?

I put a breakpoint just before PrecacheSound returns, the updated path is normal with no unusual characters of any kind.
That is whats bothering me so much.

Only a small delay though, this will get fixed.

Rusty Le Cyborg 04-07-2005 20:33

Re: [CZ] Changing model directory "on the fly"?
 
Hmm.. not being knowledgable about these things I had a look at Steampowered about this...and there was a particular support query about this...

Does this help?

http://steampowered.custhelp.com/cgi...i=&p_topview=1

Lazy 04-07-2005 20:42

Re: [CZ] Changing model directory "on the fly"?
 
Thanks but the server is running on the same machine I play/develop on and the problem goes away when my code is disabled.

I'm going to take another look at it now but I can't see anything wrong.

Pierre-Marie Baty 04-07-2005 21:10

Re: [CZ] Changing model directory "on the fly"?
 
Lazy, for the player models, you will certainly need to set them in the client's key/value data.

Another tip, don't bother converting forward slashes to backwards slashes, even on Windows. Always use forward slashes, everywhere.

And at least one big mistake: define your local character arrays as static if you return pointers to them, else they are deallocated when the function exits.

Lazy 04-07-2005 21:30

Re: [CZ] Changing model directory "on the fly"?
 
I never return pointers to local variables, what I did is make the caller pass a pointer to it's own local variable which gets the new string copied into it.

And the only time I convert to backslashes is when I use fopen to check if the file exists or not, but I still have no idea why I'm getting this error.

OR, is hl keeping a pointer to szNewpath when I call PRECACHE_SOUND?
That would explain a lot but I'd assume it makes a copy first.

[Added]
Well, it looks like HL needs a copy of the string.
The problem was solved by changing szNewpath to STRING( ALLOC_STRING( szNewpath ) ).
Bah, I would never keep a string pointer like that.

Thanks PMB, now I can get back to finishing this thing http://forums.bots-united.org/images...es/biggrin.gif

CyKo74 05-07-2005 00:22

Re: [CZ] Changing model directory "on the fly"?
 
...And dont worry about register thingy. c & cpp copilers are "smart" enough to do it automaticaly. Check youreself by compiling & re-engeneering the output code. Btw why dont make those lil func's inline or macros?

Lazy 05-07-2005 00:36

Re: [CZ] Changing model directory "on the fly"?
 
The only time I read code output was when I was trying to make my function hooking class, took me a long time to get it right but I finally got that JMP instruction to work :)

Anyway, which functions are you talking about?
The BEGIN_xxx functions are just macros that handle setting up the dll automatically and hooking various APIs.

Rusty Le Cyborg 06-07-2005 18:26

Re: [CZ] Changing model directory "on the fly"?
 
Quote:

Originally Posted by Lazy

What goes in: weapons/emp_1.wav
What comes out: 2fort/weapons/emp_1.wav

Just a quick question (again!)

Having the directory structure like this will mean that your mod root directory will be rather full of "extra" entries...

Would it be better to have a new directory to dump your map specific models/sounds into?

Something like "MOD ROOT / lazy / %s / weapons / ..." etc or is that a different kettle of fish entirely?

Cheers for now

Lazy 10-07-2005 01:34

Re: [CZ] Changing model directory "on the fly"?
 
I don't think its possible for sounds since hl will only play whats inside the sound directory and its subdirectories.
It used to be possible under won, in tfc I would have it speak sounds from cs under tfc by using something like ../../../../cstrike/sound/terwin and it worked for those who had cs installed.
But since steam that sort of thing wont work, which is why I chose that layout.

sPlOrYgOn 10-07-2005 03:25

Re: [CZ] Changing model directory "on the fly"?
 
yea sound changing is still possible
8.3.5.155:27015 -highly modded server..

this server dumps all of it's own server's sounds into a folder in the sound folder.

Rusty Le Cyborg 10-07-2005 10:17

Re: [CZ] Changing model directory "on the fly"?
 
Well I guess whatever works will be good :D

I'm quite looking forward to this!

<edit>

That server only seems to have custom sounds for "say" commands and "round win", which are usually just different "Terrorist Win" wav files.

It also has skin selection, but this isn't automatic.

http://www.radclan.net/index.php?page=Plugins

Rusty Le Cyborg 10-07-2005 16:19

Re: [CZ] Changing model directory "on the fly"?
 
Quote:

Originally Posted by Lazy
I don't think its possible for sounds since hl will only play whats inside the sound directory and its subdirectories.

So would you still be able to have it as -

MOD ROOT / sound / %s / hostage /

or

MOD ROOT / models / %s / player /

or

MOD ROOT / models / %s /

etc....

PS - If you need any testing doing, just hit me up :)

Lazy 10-07-2005 17:36

Re: [CZ] Changing model directory "on the fly"?
 
I have finished the normal model changing and the sound should be done today.
The player models will require me to research it first since I have never changed them in a server-side plugin.
Also, new player models have to be precached manually so players download them and won't be invisible due to the missing model.

But the playermodel changing shouldn't be too hard, it does seem odd though.
If I change the client's model keyvalue to "models/rock2/player/demo/demo.mdl" the model dissappears.
I know it's been done so it shouldn't be too hard to get it working.

Lazy 12-07-2005 05:15

Re: [CZ] Changing model directory "on the fly"?
 
Can anyone confirm that you can change a player's model in cs/cz by changing the "model" keyvalue on the client?
It doesn't work that way in tfc and I'm still downloading CS from steam so I can't test it for myself.

I hope this works out for player models, if it doesn't then I apologize for suggesting it could be done.
Though the gameplay models and sounds will have no problems at all being switched.

sPlOrYgOn 12-07-2005 06:07

Re: [CZ] Changing model directory "on the fly"?
 
yes it seems possible.
as here is some code from VexdUM module for amx
VexdUM.cpp:
Code:

static cell AMX_NATIVE_CALL CS_SetModel(AMX *amx, cell *params) {
  int iIndex = params[1];

  if (check_player(iIndex)) {
    AMX_RAISEERROR(amx,AMX_ERR_NATIVE);
        return 0;
  }

  int iLength;
  char *szModel = GET_AMXSTRING(amx, params[2], 0, iLength);
  edict_t *pPlayer = INDEXENT(iIndex);
  strcpy(PlInfo[iIndex].szModel, szModel);
  PlInfo[iIndex].bModeled = true;
  SET_CLIENT_KEYVALUE(iIndex, GET_INFO_KEYBUFFER(pPlayer), "model", PlInfo[iIndex].szModel);

  return 1;
}

meta_api.cpp:
Code:

// pfnPlayerPostThink, this code is to set the model at a specified time.
// The second part of the code activates the plugin forward functionality.
void PlayerPostThink(edict_t *pEntity) {
  int index = ENTINDEX(pEntity);

  if((PlInfo[index].bModeled) && (PlInfo[index].fModelSet != 0) && (PlInfo[index].fModelSet < gpGlobals->time)) {
    SET_CLIENT_KEYVALUE(index, GET_INFO_KEYBUFFER(pEntity), "model", PlInfo[index].szModel);
  }

  cell iRetVal = 0;

  for(AmxCallList::AmxCall* i = vPostThinkCallList.head; i ; i = i->next ) {
    if(IS_PLUGIN_RUNNING(i->amx)) {
          AMX_EXEC(i->amx, &iRetVal, i->iFunctionIdx, 1, index);
          if(iRetVal & (1 || 2)) {
                  RETURN_META(MRES_SUPERCEDE);
          }
        }
  }
  RETURN_META(MRES_IGNORED);
}

Code:

// Engine message functions.
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {

  static int gmsgResetHUD = GET_USER_MSG_ID(PLID, "ResetHUD", NULL);

  // Reset player model a couple milliseconds after this if they are using an edited model.
  if(msg_type == gmsgResetHUD ) {

    int index = ENTINDEX(ed);

    if(PlInfo[index].bModeled) {
      PlInfo[index].fModelSet = gpGlobals->time + AMS_OFFSET;
    }
  }

  // ...

  RETURN_META(MRES_IGNORED);
}


Lazy 12-07-2005 06:32

Re: [CZ] Changing model directory "on the fly"?
 
Thanks alot, I'll get around to finishing this once I get a test server set up.

[Update]
I have it partially working, though it will only load models if it has its own directory under models/player.
What this means is that models/player/cs_assault/blah will not work, what will work is if you make the "blah" directory in your models/player folder.

I have tried to get it to work the other way but it _really_ screws up the path, something like "models/player/cs_assault/onos/onos.mdl/cs_as".
I'm guessing config files will be needed for each map but for player models only, it will also setup precaching so that all clients have the new models.

Rusty Le Cyborg 12-07-2005 19:29

Re: [CZ] Changing model directory "on the fly"?
 
So, if I understand this properly -

If CS/CZ wants to load the leet.mdl for instance, it will now try to load -

mod root/models/player/mapname/leet/leet.mdl ?

If that's correct, what will the path be to the other models and the sounds directory?

Would it even be easier to just have a config frile for each map so you don't need to make global changes? If there is no config, then standard models apply etc...

Lazy 12-07-2005 19:39

Re: [CZ] Changing model directory "on the fly"?
 
The way CS works is the "model" value on the client specifies a directory and model name in the "models/player" folder.
Unfortunately this means that you cannot just create a "mapname" subdirectory and redirect model paths to use it since the path gets messed up somehow.

So if you want to change a model you need to do this:
NOTE: This is only for player models! Normal ones are automatic!

- Create the "modchange_cfgs" directory in the mod root ( ie. "cstrike" )
- For each map you want to switch the models on create a new file called "mapname".txt
- Make a new directory in your models/player folder with a name you can remember ( ie. "cs_assault_onos" )
- Copy your replacement model into that folder and rename it to the folder name

The format of the config file is very simple, all it is is this - original_model=new_model.
Example:
Code:


leet=onos
gsg9=onos

That will change both the leet and gsg9 models from cs into the alien onos from NS.
All the replacement models in the config will be precached to make sure they download to all the clients.

Still working on it now, will have a screenshot soon.

Rusty Le Cyborg 12-07-2005 19:56

Re: [CZ] Changing model directory "on the fly"?
 
Okay, so that is a bit clearer :)

Just to recap (in CZ terms!)

I will have a folder in my czero directory named "modchange_cfgs" or something a little easier to remember :)

In that folder I will have various .txt files named after each map I want to alter.

In, for example, de_piranesi_cz.txt I will need to type something like -

sas=ct
gign=ct
gsg9=ct
urban=ct
spetsnaz=ct
leet=t
terror=t
guerilla=t
militia=t
arctic=t

Then in my models/player directory I need two directories called -

models/player/de_piranesi_cz_ct and
models/player/de_piranesi_cz_t

with models in them called -

de_piranesi_cz_ct.mdl and
de_piranesi_cz_t.mdl

PHEW!!

(I've made a CZ map an example as they have the most confusing mapnames yet! If I can understand that, then I am set!)

....or am I a bit tired from being in the sun too long? 8D

<edit>

Oh yes, and will the other models and sounds take the same structure?


All times are GMT +2. The time now is 08:34.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.