jrNinja2
06-24-2007, 02:42 PM
I would like to say hello to everyone on these forums, as I am completely new to modding and development on the Source engine. I have just begun developing using the SDK and have followed the instructions on creating "My First Mod" in the SDK docs, but I cannot figure out how to get HL2 frag grenades to "stick" on their targets... similar to the plasma grenade effect from Halo.
I have located the GrenadeThrown.cpp file, but nothing I modify within it seems to affect the actual grenade, and I cannot even see a Warning() message I have put inside the Throw() function.
I have also looked at the base_grenade.cpp file and added the function:
void CBaseGrenade::StickTouch( CBaseEntity *pOther )
{
// don't hit the guy that launched this grenade
if ( pOther == GetThrower() )
return;
Vector vel;
vel.Init();
SetAbsVelocity( vel );
}
The attempt here was to initialize a 0 vector when SetTouch() is called from:
void CThrownGrenade::Spawn( void )
{
// point sized, solid, bouncing
//SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM );
//SetSolid( SOLID_BBOX );
SetSolid( SOLID_CUSTOM );
UTIL_SetSize(this, vec3_origin, vec3_origin);
// Movement
//SetGravity( UTIL_ScaleForGravity( 628 ) );
SetGravity(0.0f);
//SetFriction(0.6);
SetFriction(100.0f);
QAngle angles;
VectorAngles( GetAbsVelocity(), angles );
SetLocalAngles( angles );
QAngle vecAngVel( random->RandomFloat ( -100, -500 ), 0, 0 );
SetLocalAngularVelocity( vecAngVel );
SetTouch( &CThrownGrenade::StickTouch );
Warning("Grenade set to StickTouch in Spawn function...\n");
}
I never actually see the Warning message in the console, so it appears the function is never being called. Is there another place to affect the way a grenade would "stick" to a target, as opposed to bouncing or sliding?
I am really stuck here, thanks for any help.
-John
I have located the GrenadeThrown.cpp file, but nothing I modify within it seems to affect the actual grenade, and I cannot even see a Warning() message I have put inside the Throw() function.
I have also looked at the base_grenade.cpp file and added the function:
void CBaseGrenade::StickTouch( CBaseEntity *pOther )
{
// don't hit the guy that launched this grenade
if ( pOther == GetThrower() )
return;
Vector vel;
vel.Init();
SetAbsVelocity( vel );
}
The attempt here was to initialize a 0 vector when SetTouch() is called from:
void CThrownGrenade::Spawn( void )
{
// point sized, solid, bouncing
//SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM );
//SetSolid( SOLID_BBOX );
SetSolid( SOLID_CUSTOM );
UTIL_SetSize(this, vec3_origin, vec3_origin);
// Movement
//SetGravity( UTIL_ScaleForGravity( 628 ) );
SetGravity(0.0f);
//SetFriction(0.6);
SetFriction(100.0f);
QAngle angles;
VectorAngles( GetAbsVelocity(), angles );
SetLocalAngles( angles );
QAngle vecAngVel( random->RandomFloat ( -100, -500 ), 0, 0 );
SetLocalAngularVelocity( vecAngVel );
SetTouch( &CThrownGrenade::StickTouch );
Warning("Grenade set to StickTouch in Spawn function...\n");
}
I never actually see the Warning message in the console, so it appears the function is never being called. Is there another place to affect the way a grenade would "stick" to a target, as opposed to bouncing or sliding?
I am really stuck here, thanks for any help.
-John