LucasForums

LucasForums (http://www.lucasforums.com/index.php)
-   JA Coding (http://www.lucasforums.com/forumdisplay.php?f=539)
-   -   setting new bolt indexes (http://www.lucasforums.com/showthread.php?t=167278)

Tinny 07-08-2006 12:53 PM

setting new bolt indexes
 
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 :(

stubert 07-09-2006 02:20 AM

jesus was a jedi =S

Tinny 07-09-2006 10:09 PM

You might be right, but that is debatable.

razorace 07-10-2006 09:50 PM

How exactly does SOF2 do it? What sort of syscalls are we talking here? :)

Tinny 07-10-2006 11:08 PM

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(we aponInfo->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");
}
}
}
}
}

razorace 07-10-2006 11:23 PM

The good news is that those at least look similar to the traps used in JKA. :) What differences have you noticed so far?

ensiform 07-10-2006 11:53 PM

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:

Code:

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


Tinny 07-11-2006 12:05 AM

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 :/

ensiform 07-11-2006 01:19 AM

Quote:

Originally Posted by Tinny
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

razorace 07-11-2006 02:05 AM

I'm with ensiform on this. trap_G2API_AddBolt should work as well as the findbolt syscall. Check out the OJP True View code to see how I used it for determining the camera positioning.

Tinny 07-11-2006 06:58 PM

Alright, thanks a ton Razor and Ensi :). Btw Ensi, know of any way of going around trap_G2API_CopySpecificGhoul2Model in jka so that something like it can return the required int?

ensiform 07-11-2006 09:47 PM

you can't.

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

Code:

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

for a void syscall it looks like this:

Code:

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.

razorace 07-11-2006 10:06 PM

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.

Tinny 07-11-2006 11:15 PM

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.

Griswald 07-11-2006 11:24 PM

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

You can google his name to bring up his website.

ensiform 07-11-2006 11:25 PM

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.

razorace 07-11-2006 11:51 PM

Quote:

Originally Posted by Tinny
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.

Quote:

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.

Quote:

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.

Vruki Salet 07-13-2006 02:17 AM

Quote:

Originally Posted by razorace
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:

Tinny 07-13-2006 04:44 AM

Hehe, i'm not gonna do it with knives though ;)

MeleeMaster 07-13-2006 10:32 AM

LOL, to make it more RPG like, why don't you make a weapon model of a sandwich so you could throw it into somebodys mouth and it would stay there lol.


All times are GMT -4. The time now is 07:09 AM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
LFNetwork, LLC ©2002-2011 - All rights reserved.