.:: 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)

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 03:19.

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