.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   monstermaker tweak (http://forums.bots-united.com/showthread.php?t=1277)

desNotes 07-04-2004 00:41

monstermaker tweak
 

What I want to do is enhance monstermaker to be able to call out a specific model when it runs. I have modifed all the individual monster classnames and made it so a model other than default can be specified and it works.

I am able to get the model information from the monstermaker and set pev->model to the model I want. This seems to work as I added a few alerts and it verifies my model change.

However, when the classname is called (i.e. monster_barney) and runs through the following code:

if (pev->model)
SET_MODEL(ENT(pev), STRING(pev->model));


else
SET_MODEL(ENT(pev), "models/barney.mdl");

It always comes up as the default model. Apparently when it gets to the Precache(); for the classname the model is wiped out.

Any ideas of what I can do?

Thanks,

desNotes

Pierre-Marie Baty 07-04-2004 01:45

Re: monstermaker tweak
 
*edit* stupid me, my reply was bullsh*t, please ignore this post. I need to get more sleep these days...

botman 07-04-2004 03:38

Re: monstermaker tweak
 
The model of the entity should be set in the Spawn() function for that entity.

Monstermaker is just a 'helper' entity that spawns other entities. It spawns the particular type of entity based on the Monstermaker 'monstertype' key...

http://collective.valve-erc.com/inde...t=monstermaker

What 'monstertype' are you using when you spawn your custom monster? Perhaps you should create a 'generic' monster that doesn't specify the model in the Spawn() function, let Monstermaker spawn the generic monster, then set that generic monster's model based on the new key you added to Monstermaker.

botman

desNotes 07-04-2004 04:13

Re: monstermaker tweak
 
Quote:

Originally Posted by botman
The model of the entity should be set in the Spawn() function for that entity.

Monstermaker is just a 'helper' entity that spawns other entities. It spawns the particular type of entity based on the Monstermaker 'monstertype' key...

http://collective.valve-erc.com/inde...t=monstermaker

What 'monstertype' are you using when you spawn your custom monster? Perhaps you should create a 'generic' monster that doesn't specify the model in the Spawn() function, let Monstermaker spawn the generic monster, then set that generic monster's model based on the new key you added to Monstermaker.

botman

What I did was to incorporate a feature from Spirit of Half Life and make it so when the classname is called, a model other than the default can be called. For an example, I will use Barney. When monster_barney is called, there is an option to specify the model. I actually do this running Stripper2 and Metamod (after making some changes to Metamod).

So when CBarney :: Spawn() is called the model is checked in pev->model and if it is not there it gets the default. I did the same thing in monstermaker (I thought). I pull the model from the modified monstermaker format but when monstermaker calls CBarney :: Precache() I lose the pev->model. I am not up to speed on the namespaces and am wondering if I am just not calling the correct 'saved' variable in monstermaker while in monster_barney.

Thanks,

desNotes

botman 07-04-2004 14:58

Re: monstermaker tweak
 
It's a little hard to understand what you are saying without seeing your code.

Precache() should only be precacheing resources needed by that monster. For example, in the SDK barney.cpp file, the CBarney::Precache() is...
Code:

void CBarney :: Precache()
{
PRECACHE_MODEL("models/barney.mdl");
PRECACHE_SOUND("barney/ba_attack1.wav" );
PRECACHE_SOUND("barney/ba_attack2.wav" );
PRECACHE_SOUND("barney/ba_pain1.wav");
PRECACHE_SOUND("barney/ba_pain2.wav");
PRECACHE_SOUND("barney/ba_pain3.wav");
PRECACHE_SOUND("barney/ba_die1.wav");
PRECACHE_SOUND("barney/ba_die2.wav");
PRECACHE_SOUND("barney/ba_die3.wav");
 
// every new barney must call this, otherwise
// when a level is loaded, nobody will talk (time is reset to 0)
TalkInit();
CTalkMonster::Precache();
}

...the Spawn() function calls Precache(), then it sets the model...
Code:

void CBarney :: Spawn()
{
Precache( );
SET_MODEL(ENT(pev), "models/barney.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);

...what your code should be doing is CHANGING that model AFTER the Spawn() function returns back to the engine.

Is that what you are doing?

(edit: stupid smilies)

botman

desNotes 07-04-2004 15:17

Re: monstermaker tweak
 
Quote:

Originally Posted by botman
It's a little hard to understand what you are saying without seeing your code.

Precache() should only be precacheing resources needed by that monster. For example, in the SDK barney.cpp file, the CBarney::Precache() is...
Code:

void CBarney :: Precache()
{
PRECACHE_MODEL("models/barney.mdl");
PRECACHE_SOUND("barney/ba_attack1.wav" );
PRECACHE_SOUND("barney/ba_attack2.wav" );
PRECACHE_SOUND("barney/ba_pain1.wav");
PRECACHE_SOUND("barney/ba_pain2.wav");
PRECACHE_SOUND("barney/ba_pain3.wav");
PRECACHE_SOUND("barney/ba_die1.wav");
PRECACHE_SOUND("barney/ba_die2.wav");
PRECACHE_SOUND("barney/ba_die3.wav");
 
// every new barney must call this, otherwise
// when a level is loaded, nobody will talk (time is reset to 0)
TalkInit();
CTalkMonster::Precache();
}

...the Spawn() function calls Precache(), then it sets the model...
Code:

void CBarney :: Spawn()
{
Precache( );
SET_MODEL(ENT(pev), "models/barney.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);

...what your code should be doing is CHANGING that model AFTER the Spawn() function returns back to the engine.

Is that what you are doing?

(edit: stupid smilies)

botman

I have tried to change the model after the Spawn() function and what I get is the regular Barney on the ground and the new model floating above. The new model is like monster_furniture (not killable) and if the default Barney is killed, he will come back with the default model.

desNotes 07-04-2004 16:39

Re: monstermaker tweak
 
Here is some additional information that may explain my problem.


In monstermaker.cpp I added m_iszMonsterModel as part of the TYPEDESCRIPTION.

TYPEDESCRIPTION CMonsterMaker::m_SaveData[] =
{
DEFINE_FIELD( CMonsterMaker, m_iszMonsterClassname, FIELD_STRING ),
DEFINE_FIELD( CMonsterMaker, m_cNumMonsters, FIELD_INTEGER ),
DEFINE_FIELD( CMonsterMaker, m_cLiveChildren, FIELD_INTEGER ),
DEFINE_FIELD( CMonsterMaker, m_flGround, FIELD_FLOAT ),
DEFINE_FIELD( CMonsterMaker, m_iMaxLiveChildren, FIELD_INTEGER ),
DEFINE_FIELD( CMonsterMaker, m_fActive, FIELD_BOOLEAN ),
DEFINE_FIELD( CMonsterMaker, m_fFadeChildren, FIELD_BOOLEAN ),
DEFINE_FIELD( CMonsterMaker, m_iszMonsterModel, FIELD_STRING ),
};

When I attempt to call it up in barney.cpp

ALERT( at_console, "m_iszMonsterModel= (%s)\n",STRING( CMonsterMaker::m_iszMonsterModel)); //alert - desNotes

I receive the following errors:


C:\...\barney.cpp(453) : error C2653: 'CMonsterMaker' : is not a class or namespace name
C:\...\barney.cpp(453) : error C2065: 'm_iszMonsterModel' : undeclared identifier

How do I share the class monstermaker in barney.cpp?

Thanks,

desNotes

botman 08-04-2004 16:21

Re: monstermaker tweak
 
"How do I share the class monstermaker in barney.cpp?"

Create a monstermaker.h file and put the CMonsterMaker class definition in it.

Include monstermaker.h at the top of monstermaker.cpp and include it at the top of barney.cpp. For both of these, include it AFTER all the other existing include files.

botman

desNotes 19-04-2004 15:01

Re: monstermaker tweak - Success
 
Just to follow-up I was able to add 'model' and 'body' to the monstermaker code. I thought I needed to do something in the classname of the monster being called but it was much too simple. By going into MakeMonster I just added model and body to pevCreate.

pevCreate->model = m_iszMonsterModel;
pevCreate->body = m_iszBody;


Thanks for all the help,

desNotes

sfx1999 20-04-2004 22:06

Re: monstermaker tweak
 
Forgive me for not knowing much about programming, but maybe it is possible to set that in the Barney's constructor, have it change a private variable, and check it in the spawn function.

BTW, can't you have more than one constructor, too? Like with different types? That way you can still have other classes call it differently.

Make sure you put in some kind of protection against models that don't exist.


All times are GMT +2. The time now is 11:57.

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