void CRpgRocket::IgniteThink(void) { pev->movetype = MOVETYPE_FLY; pev->effects |= EF_LIGHT; CreateTrail(); m_flIgniteTime = gpGlobals->time; // set to follow laser spot SetThink(&CRpgRocket::FollowThink); SetNextThink(0.1); }
//----------------------------------------------------------------------------- // Purpose: Sets up the entity's initial state //----------------------------------------------------------------------------- void GhostEntity::Spawn( void ) { Precache(); if (GhostEngine::getEngine()->shouldDrawTrails()) { if (ghostData.trailLength > 0) { CreateTrail(); } } RemoveEffects(EF_NODRAW); SetModel(MODEL); SetSolid( SOLID_NONE ); SetRenderMode(kRenderTransColor); SetRenderColor(ghostData.ghostRed, ghostData.ghostGreen, ghostData.ghostBlue); SetRenderColorA(75); SetMoveType( MOVETYPE_NOCLIP ); isActive = true; }
void CRpgRocket::FollowThink(void) { CBaseEntity *pOther = NULL; Vector vecTarget; Vector vecDir; float flDist, flMax, flDot; TraceResult tr; UTIL_MakeAimVectors(pev->angles); CreateTrail(); vecTarget = gpGlobals->v_forward; flMax = 4096; // Examine all entities within a reasonable radius while ((pOther = UTIL_FindEntityByClassname(pOther, "laser_spot")) != NULL) { UTIL_TraceLine(pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT(pev), &tr); // ALERT( at_console, "%f\n", tr.flFraction ); if (tr.flFraction >= 0.90) { vecDir = pOther->pev->origin - pev->origin; flDist = vecDir.Length(); vecDir = vecDir.Normalize(); flDot = DotProduct(gpGlobals->v_forward, vecDir); if ((flDot > 0) && (flDist * (1 - flDot) < flMax)) { flMax = flDist * (1 - flDot); vecTarget = vecDir; } } } pev->angles = UTIL_VecToAngles(vecTarget); // this acceleration and turning math is totally wrong, but it seems to respond well so don't change it. float flSpeed = pev->velocity.Length(); if (gpGlobals->time - m_flIgniteTime < 1.0) { pev->velocity = pev->velocity * 0.2 + vecTarget * (flSpeed * 0.8 + 400); if (pev->waterlevel == 3 && pev->watertype > CONTENT_FLYFIELD) { // go slow underwater if (pev->velocity.Length() > 300) { pev->velocity = pev->velocity.Normalize() * 300; } UTIL_BubbleTrail(pev->origin - pev->velocity * 0.1, pev->origin, 4); } else { if (pev->velocity.Length() > 2000) { pev->velocity = pev->velocity.Normalize() * 2000; } } } else { if (pev->effects & EF_LIGHT) { pev->effects = 0; STOP_SOUND(ENT(pev), CHAN_VOICE, "weapons/rocket1.wav"); } pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if ((pev->waterlevel == 0 || pev->watertype == CONTENT_FOG) && pev->velocity.Length() < 1500) { Detonate(); } } //ALERT( at_console, "%.0f\n", flSpeed ); SetNextThink(0.05); }