View Single Post
Old 07-10-2006, 10:08 PM   #5
Tinny
 
Tinny's Avatar
 
Join Date: Apr 2002
Posts: 1,188
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");
}
}
}
}
}


Redeemed!

An old school mod for jedi academy.
Tinny is offline   you may: quote & reply,