Jump to content

Home

setting new bolt indexes


Tinny

Recommended Posts

This probably might be impossible but I remember either ghoul2 or md3 models were dynamically anywhere on the model in soldier of fortune 2 (e.g. when you throw a knife at an opponent it sticks where it hit the player). Is there any way to replicate it in ja? Setting bolt indexes on models on parts with or without a bone name there. I looked at the sof2 function but the sticking missile function does not compile because of different trap functions :(

Link to comment
Share on other sites

Lemme show you the cg syscalls used in each of the trap_functions of the function then I will show the whole function:

 

 

//The trap functions w/ cg syscalls:

 

qboolean trap_G2_HaveWeGhoul2Models( void *ghoul2)

{

return (qboolean)(syscall(CG_G2_HAVEWEGHOULMODELS, ghoul2));

}

 

int trap_G2API_CopySpecificGhoul2Model(void *g2From, int modelFrom, void *g2To, int modelTo)

{

return syscall(CG_G2_COPYSPECIFICGHOUL2MODEL, g2From, modelFrom, g2To, modelTo);

}

 

int trap_G2API_FindBoltIndex(TGhoul2 ghoul2, const int modelIndex, const char *boneName)

{

return syscall(CG_G2_FINDBOLTINDEX, ghoul2, modelIndex, boneName);

}

 

qboolean trap_G2API_AttachG2Model(void *ghoul2From, int modelFrom, void *ghoul2To, int toBoltIndex, int toModel)

{

return (qboolean)(syscall(CG_G2_ATTACHG2MODEL, ghoul2From, modelFrom, ghoul2To, toBoltIndex, toModel));

}

 

//function to make the missile stick

 

void CG_HandleStickyMissile(centity_t *cent,entityState_t *es,vec3_t dir,int targetEnt)

{

int hitLoc;

qboolean altFire;

int ammoIndex;

weaponInfo_t *weaponInfo;

qboolean addBoltedMiss;

int missileIndex;

int boltIndex;

 

hitLoc=es->otherEntityNum2;

altFire=(cent->currentState.eFlags & EF_ALT_FIRING)!=0;

 

if ( cent->currentState.eFlags & EF_ALT_FIRING )

{

ammoIndex = weaponData[es->weapon].attack[ATTACK_ALTERNATE].ammoIndex;

}

else

{

ammoIndex = weaponData[es->weapon].attack[ATTACK_NORMAL].ammoIndex;

}

 

// Currently the only type of sticky missile is the thrown knife. Others might be added in future though.

addBoltedMiss=qfalse;

switch(es->weapon)

{

case AMMO_KNIFE:

if(altFire)

{

addBoltedMiss=qtrue;

}

break;

 

default:

break;

}

 

if(addBoltedMiss==qtrue)

{

centity_t* centTarget;

 

weaponInfo=&cg_weapons[es->weapon];

if(!trap_G2_HaveWeGhoul2Models(weaponInfo->weaponG2Model))

{

return;

}

 

centTarget = CG_GetEntity ( targetEnt );

 

missileIndex=trap_G2API_CopySpecificGhoul2Model(weaponInfo->weaponG2Model,0,centTarget->ghoul2,-1);

if(missileIndex!=-1)

{

// Com_Printf("Missile index=%i\n",missileIndex);

boltIndex=trap_G2API_FindBoltIndex(centTarget->ghoul2,0,"rhand");

if(boltIndex==-1)

{

boltIndex=trap_G2API_AddBolt(centTarget->ghoul2,0,"rhand");

}

if(boltIndex!=-1)

{

// Com_Printf("Bolt index=%i\n",boltIndex);

if(!trap_G2API_AttachG2Model(centTarget->ghoul2,missileIndex,centTarget->ghoul2,boltIndex,0))

{

// Com_Printf("Couldn't attach!\n");

}

}

}

}

}

Link to comment
Share on other sites

qboolean trap_G2_HaveWeGhoul2Models(void *ghoul2) - same in jka

 

int trap_G2API_CopySpecificGhoul2Model(void *g2From, int modelFrom, void *g2To, int modelTo) - same in jka

 

int trap_G2API_FindBoltIndex(TGhoul2 ghoul2, const int modelIndex, const char *boneName) - not in jka at all

 

qboolean trap_G2API_AttachG2Model(void *ghoul2From, int modelFrom, void *ghoul2To, int toBoltIndex, int toModel) - same in jka

 

i suppose a way around trap_G2API_FindBoltIndex, is just store the boltindex somewhere when you copy/add the bolt. because trap_G2API_AddBolt you can do something like:

 

int boltIndex;
boltIndex = trap_G2API_AddBolt(ghoul2, 0, "jaw_bone");

Link to comment
Share on other sites

Also trap_G2API_CopySpecificGhoul2Model is a void in jka whereas in Sof2 it returns an int. I tried making the changes in the whole sdk make it an int but it would crash :/

 

thats because its in cl_cgame.c that way to return for sof2 and in jka its not returning anything.

 

i think they did it this way is because they didn't intend for someone to make bolts like this in jedi :sweat

Link to comment
Share on other sites

you can't.

 

for a syscall to return an it, the engine must intercept the syscall like this:

 

case COPY_SPECIFIC_MODEL_G2_WHATEVER:
return theEngineCall(...............);

 

for a void syscall it looks like this:

 

case COPY_SPECIFIC_MODEL_G2_WHATEVER:
theEngineCall(...............);
return 0;

 

so even if you changed the cg_syscall.c function to return int, it would always be giving you a 0.

Link to comment
Share on other sites

Oh, I see what you're talking about. It looks like SOF2 allows you to have the engine auto-decide the model index for ghoul2 copy. As far as I know, JKA uses specific defines, probably to ensure that the attached models are consistant. IE, first is main weapon, second is secondary saber, third is jetpack, etc.

Link to comment
Share on other sites

Soo hmmm, could I do this? Set random values for the indeces not used. Say values between 4 and 20 and keep using them until they're all used up then start replacing the ones that were used the longest.

Link to comment
Share on other sites

you probably could.

 

also when i was looking over the jka code, what does the trap_G2API_CopyGhoul2Instance really do, because it seems it returns an int in jka. the parameters are a little different than copymodel but i dunno you could have a look at that too i guess. but my guess is again they wanted it to be the way it is in jka on purpose like razor has said again. i also don't have the sof2 sdk so i can't really help with their code.

Link to comment
Share on other sites

Soo hmmm, could I do this? Set random values for the indeces not used. Say values between 4 and 20 and keep using them until they're all used up then start replacing the ones that were used the longest.

There's no need to do it randomly. You could just set the lower and upper model limits, scan thru that range for an open model slot, and then use it.

 

You're best bet is to contact Rich Whitehouse (author of Ninjamod), as Ninja mod contained this very thing... I dunno if he'd honestly share how he did it though. :X

I actually asked this several years ago. According to Rich, he lost the source code shortly after the last release of the mod. As for his technique, I beleive he used the manual rendering method similar to what I used for the holstered weapons in OJP. You could technically use the ghoul2 method used in SOF2, but I don't think there's a way to define the position and orientation of the resulting model. As such, the model would just stick out of the player at what positioning the bone is at.

 

also when i was looking over the jka code, what does the trap_G2API_CopyGhoul2Instance really do, because it seems it returns an int in jka.

Because it's not actually used in the code, it's hard to tell. Its function is probably very similar to what is used in SOF2. Just from the description, it sounds like it whole hog ghoul2 "instances" rather than specific ghoul2 "models" like trap_G2API_CopySpecificGhoul2Model.

Link to comment
Share on other sites

the model would just stick out of the player at what positioning the bone is at

 

This might not be too much of a problem Tinny, if you only make hits to certain areas stick. Maybe it would look fine if you made it work just for the chest, stomach and back parts. Say parts that bend around more like arms don't have enough meat to make the knife stay in. Besides, as far as goes people running around with lots of knives sticking out them at funny angles, perhaps they shouldn't be running very far after they've got just *1* sticking out of them. :ninja1:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...