CGrenade *CGrenade::ShootTimed2(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int iTeam, 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; pGrenade->m_bJustBlew = true; pGrenade->pev->gravity = 0.55; pGrenade->pev->friction = 0.7; pGrenade->m_iTeam = iTeam; SET_MODEL(pGrenade->edict(), "models/w_hegrenade.mdl"); pGrenade->pev->dmg = 100; return pGrenade; }
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->SetThink(&CGrenade::SG_TumbleThink); pGrenade->pev->dmgtime = gpGlobals->time + time; 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(pGrenade->edict(), "models/w_smokegrenade.mdl"); pGrenade->pev->dmg = 35; return pGrenade; }
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; }