//========================================================= // roach's move function //========================================================= void CRoach :: Move ( float flInterval ) { float flWaypointDist; Vector vecApex; // local move to waypoint. flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length2D(); MakeIdealYaw ( m_Route[ m_iRouteIndex ].vecLocation ); ChangeYaw ( pev->yaw_speed ); UTIL_MakeVectors( pev->angles ); if ( RANDOM_LONG(0,7) == 1 ) { // randomly check for blocked path.(more random load balancing) if ( !WALK_MOVE( ENT(pev), pev->ideal_yaw, 4, WALKMOVE_NORMAL ) ) { // stuck, so just pick a new spot to run off to PickNewDest( m_iMode ); } } WALK_MOVE( ENT(pev), pev->ideal_yaw, m_flGroundSpeed * flInterval, WALKMOVE_NORMAL ); // if the waypoint is closer than step size, then stop after next step (ok for roach to overshoot) if ( flWaypointDist <= m_flGroundSpeed * flInterval ) { // take truncated step and stop SetActivity ( ACT_IDLE ); m_flLastLightLevel = GETENTITYILLUM( ENT ( pev ) );// this is roach's new comfortable light level if ( m_iMode == ROACH_SMELL_FOOD ) { m_iMode = ROACH_EAT; } else { m_iMode = ROACH_IDLE; } } if ( RANDOM_LONG(0,149) == 1 && m_iMode != ROACH_SCARED_BY_LIGHT && m_iMode != ROACH_SMELL_FOOD ) { // random skitter while moving as long as not on a b-line to get out of light or going to food PickNewDest( FALSE ); } }
//========================================================= // GetSchedule //========================================================= Schedule_t *CHoundeye :: GetSchedule( void ) { switch ( m_MonsterState ) { case MONSTERSTATE_COMBAT: { // dead enemy if ( HasConditions( bits_COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. return CBaseMonster :: GetSchedule(); } if ( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { if ( RANDOM_FLOAT( 0 , 1 ) <= 0.4 ) { TraceResult tr; UTIL_MakeVectors( pev->angles ); UTIL_TraceHull( pev->origin, pev->origin + gpGlobals->v_forward * -128, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); if ( tr.flFraction == 1.0 ) { // it's clear behind, so the hound will jump return GetScheduleOfType ( SCHED_HOUND_HOP_RETREAT ); } } return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ); } if ( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) ) { if ( OccupySlot ( bits_SLOTS_HOUND_ATTACK ) ) { return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ); } return GetScheduleOfType ( SCHED_HOUND_AGITATED ); } break; } default: break; } return CSquadMonster :: GetSchedule(); }
Vector GetMovedir( Vector vecAngles ) { if (vecAngles == Vector(0, -1, 0)) { return Vector(0, 0, 1); } else if (vecAngles == Vector(0, -2, 0)) { return Vector(0, 0, -1); } else { UTIL_MakeVectors(vecAngles); return gpGlobals->v_forward; } }
void CHellKnight :: ShootSpike( float flOffset ) { Vector ang = UTIL_VecToAngles( m_hEnemy->pev->origin - pev->origin ); ang.y += flOffset * 6; UTIL_MakeVectors( ang ); Vector org = pev->origin + pev->mins + pev->size * 0.5f + gpGlobals->v_forward * 20; // set missile speed Vector vec = gpGlobals->v_forward.Normalize(); vec.z = -vec.z + RANDOM_FLOAT( -0.05f, 0.05f ); EMIT_SOUND( edict(), CHAN_WEAPON, "hknight/attack1.wav", 1.0, ATTN_NORM ); CNail::CreateKnightSpike( org, vec, this ); }
void CHgun::PrimaryAttack() { Reload( ); if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { return; } #ifndef CLIENT_DLL UTIL_MakeVectors( m_pPlayer->pev->v_angle ); CBaseEntity *pHornet = CBaseEntity::Create( "hornet", m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); pHornet->pev->velocity = gpGlobals->v_forward * 300; m_flRechargeTime = gpGlobals->time + 0.5; #endif m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, FIREMODE_TRACK, 0, 0, 0 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.25; if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) { m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); }
//========================================================= // GetSmallFlinchActivity - determines the best type of flinch // anim to play. //========================================================= Activity CBaseMonster :: GetSmallFlinchActivity ( void ) { Activity flinchActivity; BOOL fTriedDirection; float flDot; fTriedDirection = FALSE; UTIL_MakeVectors ( pev->angles ); flDot = DotProduct ( gpGlobals->v_forward, g_vecAttackDir * -1 ); switch ( m_LastHitGroup ) { // pick a region-specific flinch case HITGROUP_HEAD: flinchActivity = ACT_FLINCH_HEAD; break; case HITGROUP_STOMACH: flinchActivity = ACT_FLINCH_STOMACH; break; case HITGROUP_LEFTARM: flinchActivity = ACT_FLINCH_LEFTARM; break; case HITGROUP_RIGHTARM: flinchActivity = ACT_FLINCH_RIGHTARM; break; case HITGROUP_LEFTLEG: flinchActivity = ACT_FLINCH_LEFTLEG; break; case HITGROUP_RIGHTLEG: flinchActivity = ACT_FLINCH_RIGHTLEG; break; case HITGROUP_GENERIC: default: // just get a generic flinch. flinchActivity = ACT_SMALL_FLINCH; break; } // do we have a sequence for the ideal activity? if ( LookupActivity ( flinchActivity ) == ACTIVITY_NOT_AVAILABLE ) { flinchActivity = ACT_SMALL_FLINCH; } return flinchActivity; }
bool FInViewCone(Vector *pOrigin, edict_t *pEdict) { Vector2D vec2LOS; float flDot; UTIL_MakeVectors ( pEdict->v.angles ); vec2LOS = ( *pOrigin - pEdict->v.origin ).Make2D(); vec2LOS = vec2LOS.Normalize(); flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() ); if ( flDot > 0.50 ) // 60 degree field of view return TRUE; else return FALSE; }
void CGrenade::SG_Smoke( void ) { if( UTIL_PointContents( pev->origin ) == CONTENTS_WATER ) { UTIL_Bubbles( pev->origin - Vector( 64, 64, 64 ), pev->origin + Vector( 64, 64, 64 ), 100 ); } else { UTIL_MakeVectors( pev->angles ); Vector randomDir = gpGlobals->v_forward * RANDOM_FLOAT( 3, 8 ); m_fLightSmoke = (int)(( ( m_fLightSmoke * 180 / M_PI ) + 30 )) % 360; // TODO: Check me. PLAYBACK_EVENT_FULL( 0, NULL, m_usEvent, 0.0, pev->origin, m_SGExplosionPos, randomDir.x * cos( 180 / M_PI ) - randomDir.y * cos( 180 / M_PI ), randomDir.x * sin( 180 / M_PI ) + randomDir.y * sin( 180 / M_PI ), cos( 180 / M_PI ) * 100.0, 4, m_bSGMulti, 6 ); } if( m_SGSmoke <= 20 ) { pev->nextthink = gpGlobals->time + 1.0; SetThink( &CGrenade::SG_Smoke ); ++m_SGSmoke; } else { pev->effects |= EF_NODRAW; // TODO: Implements this. //TheBots->RemoveGrenade( this ); UTIL_Remove( this ); } }
void CHostageImprov::ClearPath() { Vector start; Vector end; TraceResult result; if (!m_clearPathTimer.IsElapsed()) return; m_clearPathTimer.Start(RANDOM_FLOAT(0.3f, 0.5f)); const Vector eye = GetEyes(); start = eye; UTIL_MakeVectors(m_hostage->pev->angles); end = gpGlobals->v_forward * 64 + start; UTIL_TraceLine(start, end, ignore_monsters, dont_ignore_glass, m_hostage->edict(), &result); if (result.flFraction == 1.0f) return; if (result.pHit != NULL) { entvars_t *entity = VARS(result.pHit); if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) { CBaseEntity *pObject = CBaseEntity::Instance(entity); if (pObject != NULL) { pObject->Touch(m_hostage); } } else if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) { CBaseEntity *pObject = CBaseEntity::Instance(entity); if (pObject != NULL) { pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET); } } } }
void CFuncVehicle::Blocked(CBaseEntity *pOther) { entvars_t *pevOther = pOther->pev; if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev) { pevOther->velocity = pev->velocity; return; } pevOther->velocity = (pevOther->origin - pev->origin).Normalize() * pev->dmg; pevOther->velocity.z += 300; pev->velocity = pev->velocity * 0.85; ALERT(at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING(pev->targetname), STRING(pOther->pev->classname), pev->dmg); UTIL_MakeVectors(pev->angles); Vector forward, right, vOrigin; Vector vFrontLeft = (gpGlobals->v_forward * -1) * (m_length * 0.5); Vector vFrontRight = (gpGlobals->v_right * -1) * (m_width * 0.5); Vector vBackLeft = pev->origin + vFrontLeft - vFrontRight; Vector vBackRight = pev->origin - vFrontLeft + vFrontRight; float minx = Q_min(vBackLeft.x, vBackRight.x); float miny = Q_min(vBackLeft.y, vBackRight.y); float maxx = Q_max(vBackLeft.x, vBackRight.x); float maxy = Q_max(vBackLeft.y, vBackRight.y); float minz = pev->origin.z; #ifdef REGAMEDLL_FIXES float maxz = pev->origin.z + (2 * Q_abs(pev->mins.z - pev->maxs.z)); #else float maxz = pev->origin.z + (2 * Q_abs(int(pev->mins.z - pev->maxs.z))); #endif if (pOther->pev->origin.x < minx || pOther->pev->origin.x > maxx || pOther->pev->origin.y < miny || pOther->pev->origin.y > maxy || pOther->pev->origin.z < pev->origin.z || pOther->pev->origin.z > maxz) { pOther->TakeDamage(pev, pev, 150, DMG_CRUSH); } }
BOOL CFuncVehicle::OnControls(entvars_t *pevTest) { Vector offset = pevTest->origin - pev->origin; if (pev->spawnflags & SF_TRACKTRAIN_NOCONTROL) return FALSE; UTIL_MakeVectors(pev->angles); Vector local; local.x = DotProduct(offset, gpGlobals->v_forward); local.y = -DotProduct(offset, gpGlobals->v_right); local.z = DotProduct(offset, gpGlobals->v_up); return (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z && local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z); }
//========================================================= // Shoot //========================================================= void CHAssassin :: Shoot ( void ) { if (m_hEnemy == NULL) { return; } Vector vecShootOrigin = GetGunPosition(); Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); if (m_flLastShot + 2 < gpGlobals->time) { m_flDiviation = 0.10; } else { m_flDiviation -= 0.01; if (m_flDiviation < 0.02) m_flDiviation = 0.02; } m_flLastShot = gpGlobals->time; UTIL_MakeVectors ( pev->angles ); Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40,90) + gpGlobals->v_up * RANDOM_FLOAT(75,200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40); EjectBrass ( pev->origin + gpGlobals->v_up * 32 + gpGlobals->v_forward * 12, vecShellVelocity, pev->angles.y, m_iShell, TE_BOUNCE_SHELL); FireBullets(1, vecShootOrigin, vecShootDir, Vector( m_flDiviation, m_flDiviation, m_flDiviation ), 2048, BULLET_MONSTER_9MM ); // shoot +-8 degrees switch(RANDOM_LONG(0,1)) { case 0: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT(0.6, 0.8), ATTN_NORM); break; case 1: EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT(0.6, 0.8), ATTN_NORM); break; } pev->effects |= EF_MUZZLEFLASH; Vector angDir = UTIL_VecToAngles( vecShootDir ); SetBlending( 0, angDir.x ); m_cAmmoLoaded--; }
Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj) { float flGravity = CVAR_GET_FLOAT("sv_gravity") * flGravityAdj; if (vecSpot2.z - vecSpot1.z > 500) return g_vecZero; UTIL_MakeVectors(pev->angles); vecSpot2 = vecSpot2 + gpGlobals->v_right * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16)); vecSpot2 = vecSpot2 + gpGlobals->v_forward * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16)); TraceResult tr; Vector vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0, 0, 500), ignore_monsters, ENT(pev), &tr); vecMidPoint = tr.vecEndPos; vecMidPoint.z -= 50; if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z) return g_vecZero; float distance1 = (vecMidPoint.z - vecSpot1.z); float distance2 = (vecMidPoint.z - vecSpot2.z); float time1 = sqrt(distance1 / (0.5 * flGravity)); float time2 = sqrt(distance2 / (0.5 * flGravity)); if (time1 < 0.1) return g_vecZero; Vector vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2); vecGrenadeVel.z = flGravity * time1; Vector vecApex = vecSpot1 + vecGrenadeVel * time1; vecApex.z = vecMidPoint.z; UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); if (tr.flFraction != 1) return g_vecZero; UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); if (tr.flFraction != 1) return g_vecZero; return vecGrenadeVel; }
void CMGargantua::StompAttack( void ) { TraceResult trace; UTIL_MakeVectors( pev->angles ); Vector vecStart = pev->origin + Vector(0,0,60) + 35 * gpGlobals->v_forward; Vector vecAim = ShootAtEnemy( vecStart ); Vector vecEnd = (vecAim * 1024) + vecStart; UTIL_TraceLine( vecStart, vecEnd, ignore_monsters, edict(), &trace ); CStomp::StompCreate( vecStart, trace.vecEndPos, 0 ); UTIL_ScreenShake( pev->origin, 12.0, 100.0, 2.0, 1000 ); EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pStompSounds[ RANDOM_LONG(0,ARRAYSIZE(pStompSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) ); UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,20), ignore_monsters, edict(), &trace ); if ( trace.flFraction < 1.0 ) UTIL_DecalTrace( &trace, DECAL_GARGSTOMP1 ); }
/* QuakeEd only writes a single float for angles (bad idea), so up and down are just constant angles. */ void SetMovedir( entvars_t *pev ) { if (pev->angles == Vector(0, -1, 0)) { pev->movedir = Vector(0, 0, 1); } else if (pev->angles == Vector(0, -2, 0)) { pev->movedir = Vector(0, 0, -1); } else { UTIL_MakeVectors(pev->angles); pev->movedir = gpGlobals->v_forward; } pev->angles = g_vecZero; }
CShockBeam* CShockBeam::CreateShockBeam( const Vector& vecOrigin, const Vector& vecAngles, CBaseEntity* pOwner ) { Vector vecNewAngles = vecAngles; vecNewAngles.x = -vecNewAngles.x; CShockBeam* pBeam = static_cast<CShockBeam*>( Create( "shock_beam", vecOrigin, vecNewAngles, pOwner->edict(), false ) ); pBeam->SetAbsOrigin( vecOrigin ); UTIL_MakeVectors( vecAngles ); pBeam->SetAbsVelocity( gpGlobals->v_forward * 2000.0 ); pBeam->Spawn(); return pBeam; }
void CShotgun::PrimaryAttack() { if (m_pPlayer->pev->waterlevel == 3 || m_iClip <= 0) { PlayEmptySound( ); m_flNextPrimaryAttack = gpGlobals->time + 0.5; return; } //LLAPb begin if (m_fInSpecialReload) { SendWeaponAnim( SHOTGUN_PUMP ); m_flNextPrimaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.7; if(m_iClip<8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_fInSpecialReload == 2) { m_iClip += 1; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 1; } m_fInSpecialReload = 0; return; } //LLAPb end m_iClip--; m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); for (int i=0; i<8; i++) m_pPlayer->FireMagnumBullets(m_pPlayer->GetGunPosition(), gpGlobals->v_forward, (m_pPlayer->pev->flags & FL_DUCKING)?VECTOR_CONE_10DEGREES:VECTOR_CONE_11DEGREES, 16384, BULLET_BUCKSHOT, m_pPlayer->pev); FX_FireGun(m_pPlayer->pev->v_angle, m_pPlayer->entindex(), (m_pPlayer->m_fHeavyArmor)?SHOTGUN_FIRE_SOLID:SHOTGUN_FIRE, m_pPlayer->m_fHeavyArmor?1:0, FIREGUN_SHOTGUN ); SetThink( shellcasing ); (m_pPlayer->m_fHeavyArmor)?pev->nextthink = gpGlobals->time + 0.25:pev->nextthink = gpGlobals->time + 0.5; if (m_iClip != 0) m_flPumpTime = gpGlobals->time + 0.5; (m_pPlayer->m_fHeavyArmor)?m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5:m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.75; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1; m_fInSpecialReload = 0; }
void CGrenade::SG_Smoke(void) { if (UTIL_PointContents(pev->origin) != CONTENTS_WATER) { Vector vecDir; float interval[2]; int maxSmokePuffs; UTIL_MakeVectors(pev->angles); vecDir = gpGlobals->v_forward * RANDOM_FLOAT(3, 8); maxSmokePuffs = (int)(RANDOM_FLOAT(1.5, 3.5) * 100); interval[0] = vecDir.x * cos((float)m_angle * (180 / M_PI)) - vecDir.y * sin((float)m_angle * (180 / M_PI)); interval[1] = vecDir.x * sin((float)m_angle * (180 / M_PI)) + vecDir.y * cos((float)m_angle * (180 / M_PI)); m_angle = (m_angle + 30) % 360; PLAYBACK_EVENT_FULL(0, NULL, m_usEvent, 0, pev->origin, m_vSmokeDetonate, interval[0], interval[1], maxSmokePuffs, 4, m_bLightSmoke, 6); } else { UTIL_Bubbles(pev->origin - Vector(64, 64, 64), pev->origin + Vector(64, 64, 64), 100); } if (m_SGSmoke <= 20) { pev->nextthink = gpGlobals->time + 1.0; SetThink(&CGrenade::SG_Smoke); m_SGSmoke++; } else { pev->effects |= EF_NODRAW; // TODO: Implement me // TheBots->CBotManager::RemoveGrenade( this ); UTIL_Remove(this); } }
void AvHSpitGun::FireProjectiles(void) { #ifdef AVH_SERVER // Spawn spit AvHSpit* theSpit = GetClassPtr((AvHSpit*)NULL ); theSpit->Spawn(); UTIL_MakeVectors(this->m_pPlayer->pev->v_angle); Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = this->m_pPlayer->GetGunPosition( ) + vecAiming; UTIL_SetOrigin(theSpit->pev, vecSrc); // This needs to be the same as in EV_SpitGun Vector theBaseVelocity; VectorScale(this->pev->velocity, kSpitParentVelocityScalar, theBaseVelocity); Vector theStartVelocity; VectorMA(theBaseVelocity, kSpitVelocity, vecAiming, theStartVelocity); VectorCopy(theStartVelocity, theSpit->pev->velocity); // Set owner theSpit->pev->owner = ENT(this->m_pPlayer->pev); // Set spit's team :) theSpit->pev->team = this->m_pPlayer->pev->team; // Set amount of damage it will do float theFocusScalar = 1.0f; if(AvHSHUGetIsWeaponFocusable(AvHWeaponID(this->m_iId))) { theFocusScalar = AvHPlayerUpgrade::GetFocusDamageUpgrade(this->m_pPlayer->pev->iuser4); } float theDamage = this->mDamage*AvHPlayerUpgrade::GetAlienRangedDamageUpgrade(this->m_pPlayer->pev->iuser4)*theFocusScalar; theSpit->SetDamage(theDamage); #endif }
// this function only gets called in multiplayer void CCrossbow::FireSniperBolt() { m_flNextPrimaryAttack = GetNextAttackDelay(0.75); if (m_iClip == 0) { PlayEmptySound( ); return; } TraceResult tr; m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; m_iClip--; int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; UTIL_MakeVectors( anglesAim ); Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2; Vector vecDir = gpGlobals->v_forward; UTIL_TraceLine(vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr); #ifndef CLIENT_DLL if ( tr.pHit->v.takedamage ) { ClearMultiDamage( ); CBaseEntity::Instance(tr.pHit)->TraceAttack(m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB ); ApplyMultiDamage( pev, m_pPlayer->pev ); } #endif }
void CCaptureObject::Drop(CBaseEntity *pPlayer) { if (pPlayer != NULL) { if (pPlayer->IsAlive())// player used 'drop' command { UTIL_MakeVectors (pPlayer->pev->angles); pev->velocity = pPlayer->pev->velocity + gpGlobals->v_forward * 200; } else pev->velocity = pPlayer->pev->velocity; } Reset(pPlayer); pev->impulse = CO_DROPPED; pev->movetype = MOVETYPE_TOSS; pev->sequence = 0; pev->dmgtime = gpGlobals->time + ctf_flagstay.value;//give 45 seconds }
void CUsas::MakeLaserSight( void ) { #ifndef CLIENT_DLL if (m_fSpotActive) { if (!m_pSpot) { KillLaserSight(); TraceResult tr; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector m_vecSrc = m_pPlayer->GetGunPosition( ); Vector m_vecDir = gpGlobals->v_forward; Vector m_vecEnd = pev->origin + m_vecDir * 2048; Vector m_vecOri = pev->origin; // UTIL_TraceLine( m_vecSrc, m_vecEnd, dont_ignore_monsters, ENT(pev), &tr ); UTIL_TraceLine( m_vecSrc, m_vecSrc + m_vecDir * 8192, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr ); // m_flBeamLength = tr.flFraction; Vector vecTmpEnd = (pev->origin + Vector( 0, 0, 27 ) ) + m_vecDir * 2048 * m_flBeamLength; Vector m_vecFinalEnd = vecTmpEnd + Vector( 0, 0, 25); m_pBeam = CBeam::BeamCreate( g_pModelNameLaser, 1 ); m_pBeam->PointEntInit( vecTmpEnd, entindex() ); m_pBeam->PointsInit(vecTmpEnd, (m_vecOri + Vector( 0, 0, 21)) ); m_pBeam->PointsInit( vecTmpEnd, m_vecSrc ); m_pBeam->SetColor( 255, 0, 0 ); m_pBeam->SetScrollRate( 255 ); m_pBeam->SetBrightness( 64 ); m_pBeam->SetWidth( 25 ); } } #endif }
void CFroster::PrimaryAttack( void ) { if (m_pPlayer->pev->waterlevel == 3 || m_iClip <= 0) { PlayEmptySound(5); m_flNextPrimaryAttack = gpGlobals->time + 0.5; return; } m_iFiredAmmo++; m_iClip--; m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); CFrostball::ShootFrostball( m_pPlayer->pev, m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 24 + gpGlobals->v_right * 4 + gpGlobals->v_up * -2, gpGlobals->v_forward * 5000); FX_FireGun(m_pPlayer->pev->v_angle, m_pPlayer->entindex(), (m_pPlayer->m_fHeavyArmor)?FROSTER_FIRE_SOLID:FROSTER_FIRE, 0, FIREGUN_FROSTER ); m_flNextPrimaryAttack = gpGlobals->time + 0.22; m_flTimeWeaponIdle = gpGlobals->time + 5; }
void UTIL_ParametricRocket( entvars_t *pev, Vector vecOrigin, Vector vecAngles, edict_t *owner ) { pev->startpos = vecOrigin; // Trace out line to end pos TraceResult tr; UTIL_MakeVectors( vecAngles ); UTIL_TraceLine( pev->startpos, pev->startpos + gpGlobals->v_forward * 8192, ignore_monsters, owner, &tr); pev->endpos = tr.vecEndPos; // Now compute how long it will take based on current velocity Vector vecTravel = pev->endpos - pev->startpos; float travelTime = 0.0; if ( pev->velocity.Length() > 0 ) { travelTime = vecTravel.Length() / pev->velocity.Length(); } pev->starttime = gpGlobals->time; pev->impacttime = gpGlobals->time + travelTime; }
bool BotCantMoveForward( bot_t *pBot, TraceResult *tr ) { edict_t *pEdict = pBot->pEdict; // use some TraceLines to determine if anything is blocking the current // path of the bot. Vector v_src, v_forward; UTIL_MakeVectors( pEdict->v.v_angle ); // first do a trace from the bot's eyes forward... v_src = pEdict->v.origin + pEdict->v.view_ofs; // EyePosition() v_forward = v_src + gpGlobals->v_forward * 40; // trace from the bot's eyes straight forward... UTIL_TraceLine( v_src, v_forward, dont_ignore_monsters, pEdict->v.pContainingEntity, tr); // check if the trace hit something... if (tr->flFraction < 1.0) { return TRUE; // bot's head will hit something } // bot's head is clear, check at waist level... v_src = pEdict->v.origin; v_forward = v_src + gpGlobals->v_forward * 40; // trace from the bot's waist straight forward... UTIL_TraceLine( v_src, v_forward, dont_ignore_monsters, pEdict->v.pContainingEntity, tr); // check if the trace hit something... if (tr->flFraction < 1.0) { return TRUE; // bot's body will hit something } return FALSE; // bot can move forward, return false }
// // The door has been shifted. Move slide now // void CBaseTrainDoor::DoorSlideUp( void ) { // emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't // filter them out and leave a client stuck with looping door sounds! EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise1 ), 1, ATTN_NORM ); UTIL_MakeVectors( m_vecOldAngles ); // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big Vector vecSize = pev->size - Vector( 2, 2, 2 ); float width = (fabs( gpGlobals->v_forward.x * vecSize.x ) + fabs( gpGlobals->v_forward.y * vecSize.y ) + fabs( gpGlobals->v_forward.z * vecSize.z )); door_state = TD_SLIDING_UP; m_vecPosition2 = m_vecPosition3 + pev->movedir * width; SetMoveDone( &CBaseTrainDoor:: DoorHitTop ); LinearMove( m_vecPosition2, pev->speed ); }
BOOL CFuncMachinegun::OnControls( entvars_t *pevTest ) { Vector vecToPlayer = pevTest->origin - pev->origin; vecToPlayer.z = 0; if ( vecToPlayer.Length() > 75 ) return FALSE; if ( pev->health <=0 ) return FALSE; UTIL_MakeVectors(pev->angles); vecToPlayer = vecToPlayer.Normalize(); if (DotProduct(vecToPlayer, gpGlobals->v_forward) > -0.7) return FALSE; return TRUE; }
bool CHostageImprov::__MAKE_VHOOK(IsPlayerLookingAtMe)(CBasePlayer *other, float cosTolerance) const { Vector2D toOther = (other->pev->origin - GetCentroid()).Make2D(); toOther.NormalizeInPlace(); UTIL_MakeVectors(other->pev->punchangle + other->pev->v_angle); Vector2D otherDir = gpGlobals->v_forward.Make2D(); otherDir.NormalizeInPlace(); if (-cosTolerance > DotProduct(toOther, otherDir)) { if (IsVisible(other->EyePosition())) { return true; } } return false; }
void CFroster::GrenadeLauncher( void ) { if (m_pPlayer->pev->waterlevel == 3 || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] <= 0) { PlayEmptySound( ); m_flNextSecondaryAttack = gpGlobals->time + 0.5; return; } m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType]--; m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); CClMomma::ShootClusterMomma( m_pPlayer->pev, m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 28 + gpGlobals->v_right * 10 + gpGlobals->v_up * -5, gpGlobals->v_forward * 1500, 3 ); FX_FireGun(m_pPlayer->pev->v_angle, m_pPlayer->entindex(), (m_pPlayer->m_fHeavyArmor)?FROSTER_FIRE_GREN_SOLID:FROSTER_FIRE_GREN, 1, FIREGUN_FROSTER ); m_flNextPrimaryAttack = gpGlobals->time + 1; m_flNextSecondaryAttack = gpGlobals->time + 2.1; if (!m_pPlayer->m_fHeavyArmor) m_pPlayer->pev->punchangle.x -= 6; }
void CGrenade :: FragTouch( CBaseEntity *pOther ) { for ( int i = 0 ; i < 7 ; i++ ) { Vector ang; ang.x = RANDOM_LONG( -90,-30 ); ang.y = RANDOM_LONG( -180, 180 ); float flVel = fabs ( (ang.x / 90) * 300 ) + 100; UTIL_MakeVectors ( ang ); CGrenade :: ShootFrag( pev, pev->origin, gpGlobals->v_forward * flVel , 0 ); } SetTouch( NULL ); SetThink( Detonate ); pev->nextthink = gpGlobals->time + 0.1; }