Example #1
0
CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
	CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
	pGrenade->Spawn();
	// contact grenades arc lower
	pGrenade->pev->gravity = 0.5;// lower gravity since grenade is aerodynamic and engine doesn't know it.
	UTIL_SetOrigin( pGrenade->pev, vecStart );
	pGrenade->pev->velocity = vecVelocity;
	pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity);
	pGrenade->pev->owner = ENT(pevOwner);
	
	// make monsters afaid of it while in the air
	pGrenade->SetThink( &CGrenade::DangerSoundThink );
	pGrenade->pev->nextthink = gpGlobals->time;
	
	// Tumble in air
	pGrenade->pev->avelocity.x = RANDOM_FLOAT ( -100, -500 );
	
	// Explode on contact
	pGrenade->SetTouch( &CGrenade::ExplodeTouch );

	pGrenade->pev->dmg = gSkillData.plrDmgM203Grenade;

	return pGrenade;
}
Example #2
0
CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, unsigned short usEvent)
{
	CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL);
	pGrenade->Spawn();

	UTIL_SetOrigin(pGrenade->pev, vecStart);
	pGrenade->pev->velocity = vecVelocity;
	pGrenade->pev->angles = pevOwner->angles;
	pGrenade->pev->owner = ENT(pevOwner);
	pGrenade->m_usEvent = usEvent;
	pGrenade->m_bLightSmoke = false;
	pGrenade->m_bDetonated = false;
	pGrenade->SetTouch(&CGrenade::BounceTouch);
	pGrenade->pev->dmgtime = gpGlobals->time + time;
	pGrenade->SetThink(&CGrenade::SG_TumbleThink);
	pGrenade->pev->nextthink = gpGlobals->time + 0.1;

	if (time < 0.1)
	{
		pGrenade->pev->nextthink = gpGlobals->time;
		pGrenade->pev->velocity = Vector(0, 0, 0);
	}

	pGrenade->pev->sequence = RANDOM_LONG(3, 6);
	pGrenade->pev->framerate = 1;
	pGrenade->m_bJustBlew = true;
	pGrenade->pev->gravity = 0.5;
	pGrenade->pev->friction = 0.8;
	pGrenade->m_SGSmoke = 0;

	SET_MODEL(ENT(pGrenade->pev), "models/w_smokegrenade.mdl");
	pGrenade->pev->dmg = 35;
	return pGrenade;
}
Example #3
0
CGrenade* CGrenade::ShootTimed2( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int team, unsigned short usEvent )
{
    CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );

    pGrenade->Spawn();
    UTIL_SetOrigin( pGrenade->pev, vecStart );

    pGrenade->pev->velocity	= vecVelocity;
    pGrenade->pev->angles	= pevOwner->angles;
    pGrenade->pev->owner	= ENT( pevOwner );

    pGrenade->m_usEvent	= usEvent;

    pGrenade->SetTouch( &CGrenade::BounceTouch );
    pGrenade->SetThink( &CGrenade::TumbleThink );

    pGrenade->pev->dmgtime	= gpGlobals->time + time;
    pGrenade->pev->nextthink= gpGlobals->time + 0.1;

    pGrenade->pev->sequence	= RANDOM_LONG( 3, 6 );
    pGrenade->pev->framerate= 1.0;

    pGrenade->m_fJustBlew	= TRUE;
    pGrenade->m_iTeam		= team;

    pGrenade->pev->gravity	= 0.55;
    pGrenade->pev->friction = 0.70;
    pGrenade->pev->dmg		= 100;

    SET_MODEL( ENT( pGrenade->pev ), "models/w_hegrenade.mdl" );

    return pGrenade;
}
Example #4
0
CGrenade *CGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time)
{
	CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL);
	pGrenade->Spawn();

	UTIL_SetOrigin(pGrenade->pev, vecStart);
	pGrenade->pev->velocity = vecVelocity;
	pGrenade->pev->angles = pevOwner->angles;
	pGrenade->pev->owner = ENT(pevOwner);
	pGrenade->SetTouch(&CGrenade::BounceTouch);
	pGrenade->pev->dmgtime = gpGlobals->time + time;
	pGrenade->SetThink(&CGrenade::TumbleThink);
	pGrenade->pev->nextthink = gpGlobals->time + 0.1;

	if (time < 0.1)
	{
		pGrenade->pev->nextthink = gpGlobals->time;
		pGrenade->pev->velocity = Vector(0, 0, 0);
	}

	pGrenade->pev->sequence = RANDOM_LONG(3, 6);
	pGrenade->pev->framerate = 1;
	pGrenade->m_bJustBlew = true;
	pGrenade->pev->gravity = 0.5;
	pGrenade->pev->friction = 0.8;

	SET_MODEL(ENT(pGrenade->pev), "models/w_flashbang.mdl");
	pGrenade->pev->dmg = 35;
	return pGrenade;
}
Example #5
0
CGrenade * CGrenade :: ShootFrag( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, int mode )
{
	CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
	pGrenade->Spawn();
	UTIL_SetOrigin( pGrenade->pev, vecStart );
	pGrenade->pev->velocity = vecVelocity;
	pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
	pGrenade->pev->owner = ENT(pevOwner);

	pGrenade->pev->solid = SOLID_BBOX;
	
	if ( mode == 1 )
	{
		SET_MODEL(ENT(pGrenade->pev), "models/w_fgrenade.mdl");
		pGrenade->SetTouch( FragTouch );
		pGrenade->SetThink( FragThink );
		pGrenade->pev->nextthink = gpGlobals->time + 0.1;
	}
	else
	{
		SET_MODEL(ENT(pGrenade->pev), "models/w_frag.mdl");
		pGrenade->SetThink( Detonate );
		pGrenade->pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 2,3 );
		pGrenade->pev->solid = SOLID_NOT;

	}

	MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
		WRITE_BYTE( TE_BEAMFOLLOW );
		WRITE_SHORT(pGrenade->entindex());	// entity
		WRITE_SHORT(iFgTrail );	// model
		WRITE_BYTE( 10 ); // life
		WRITE_BYTE( 1.5 );  // width
		WRITE_BYTE( 240 );   // r, g, b
		WRITE_BYTE( 215 );   // r, g, b
		WRITE_BYTE( 80  );   // r, g, b
		WRITE_BYTE( 200 );	// brightness
	MESSAGE_END();


		
	pGrenade->pev->sequence = 4;
	pGrenade->pev->framerate = 6;

	pGrenade->pev->gravity = 0.35;
	pGrenade->pev->friction = 0.9;

	pGrenade->pev->dmg = 100;

	return pGrenade;

}
Example #6
0
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{
	CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
	pGrenade->Spawn();
	UTIL_SetOrigin( pGrenade->pev, vecStart );
	pGrenade->pev->velocity = vecVelocity;
	pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
	pGrenade->pev->owner = ENT(pevOwner);
	
	pGrenade->SetTouch( &CGrenade::BounceTouch );	// Bounce if touched

#ifdef DEBUG
	if(ns_cvar_float(&avh_bulletcam))
	{
		SET_VIEW(ENT(pevOwner), ENT(pGrenade->pev));
	}
#endif
	
	// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
	// will insert a DANGER sound into the world sound list and delay detonation for one second so that 
	// the grenade explodes after the exact amount of time specified in the call to ShootTimed(). 

	pGrenade->pev->dmgtime = gpGlobals->time + time;
	pGrenade->SetThink( &CGrenade::TumbleThink );
	pGrenade->pev->nextthink = gpGlobals->time + 0.1;
	if (time < 0.1)
	{
		pGrenade->pev->nextthink = gpGlobals->time;
		pGrenade->pev->velocity = Vector( 0, 0, 0 );
	}
		
	pGrenade->pev->sequence = 0;//RANDOM_LONG( 3, 6 );
	pGrenade->pev->framerate = 1.0;

	// Tumble through the air
    pGrenade->pev->avelocity.x = RANDOM_LONG(-800, -300);

	// Also explode on contact
	//pGrenade->SetTouch( ExplodeTouch );

	pGrenade->pev->gravity = 0.5;
	pGrenade->pev->friction = 0.8;

	SET_MODEL(ENT(pGrenade->pev), "models/w_grenade.mdl");

	return pGrenade;
}
Example #7
0
CGrenade *CGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity)
{
	CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL);
	pGrenade->Spawn();

	pGrenade->pev->gravity = 0.5;
	UTIL_SetOrigin(pGrenade->pev, vecStart);
	pGrenade->pev->velocity = vecVelocity;
	pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
	pGrenade->pev->owner = ENT(pevOwner);

	pGrenade->SetThink(&CGrenade::DangerSoundThink);
	pGrenade->pev->nextthink = gpGlobals->time;
	pGrenade->pev->avelocity.x = RANDOM_FLOAT(-100, -500);
	pGrenade->SetTouch(&CGrenade::ExplodeTouch);

	pGrenade->pev->dmg = gSkillData.plrDmgM203Grenade;
	pGrenade->m_bJustBlew = true;
	return pGrenade;
}
Example #8
0
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{
	CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
	pGrenade->Spawn();

	UTIL_SetOrigin( pGrenade, vecStart );
	pGrenade->SetAbsVelocity( vecVelocity );
	pGrenade->SetLocalAngles( UTIL_VecToAngles( pGrenade->GetAbsVelocity( )));
	pGrenade->pev->owner = ENT( pevOwner );
	
	pGrenade->SetTouch( &CGrenade::BounceTouch );	// Bounce if touched
	
	// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
	// will insert a DANGER sound into the world sound list and delay detonation for one second so that 
	// the grenade explodes after the exact amount of time specified in the call to ShootTimed(). 

	pGrenade->pev->dmgtime = gpGlobals->time + time;
	pGrenade->SetThink( &CGrenade::TumbleThink );
	pGrenade->SetNextThink( 0.1 );

	if( time < 0.1 )
	{
		pGrenade->SetNextThink( 0 );
		pGrenade->SetLocalVelocity( g_vecZero );
	}
		
	pGrenade->pev->sequence = RANDOM_LONG( 3, 6 );
	pGrenade->pev->framerate = 1.0;

	pGrenade->pev->gravity = 0.5;
	pGrenade->pev->friction = 0.8;

	SET_MODEL( pGrenade->edict(), "models/w_grenade.mdl" );
	pGrenade->pev->dmg = 100;

	return pGrenade;
}