void CC4::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { if (m_pPlayer) return; CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(1); if (pPlayer) { edict_t *target = pPlayer->m_pentCurBombTarget; pPlayer->m_pentCurBombTarget = NULL; #ifndef CLIENT_WEAPONS if (pev->speed != 0 && g_pGameRules) g_pGameRules->m_iC4Timer = (int)pev->speed; #endif EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM); CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0)); CGrenade *pGrenade = NULL; while ((pGrenade = (CGrenade *)UTIL_FindEntityByClassname(pGrenade, "grenade")) != NULL) { if (pGrenade->m_bIsC4 && pGrenade->m_flNextFreq == gpGlobals->time) { pGrenade->pev->target = pev->target; pGrenade->pev->noise1 = pev->noise1; break; } } pPlayer->m_pentCurBombTarget = target; SUB_Remove(); } }
void CDecal :: StaticDecal( void ) { trace_t trace; int entityIndex, modelIndex = 0; Vector position = GetAbsOrigin(); UTIL_TraceLine( position - Vector(5,5,5), position + Vector(5,5,5), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &trace ); entityIndex = (short)trace.m_pEnt ? trace.m_pEnt->entindex() : 0; if ( entityIndex ) { CBaseEntity *ent = trace.m_pEnt; if ( ent ) { modelIndex = ent->GetModelIndex(); VectorITransform( GetAbsOrigin(), ent->EntityToWorldTransform(), position ); } } engine->StaticDecal( position, m_nTexture, entityIndex, modelIndex ); // CRecipientFilter initFilter; // initFilter.MakeInitMessage(); // TE_BSPDecal( initFilter, GetAbsOrigin(), entityIndex, (int)pev->skin ); SUB_Remove(); }
//DHL - Skillet - Fix ammo exploits void CWeaponFrag::Drop( const Vector &vecVelocity ) { if ( !HasPrimaryAmmo() ) { //BaseClass::Drop( vecVelocity ); SUB_Remove(); return; } if ( !GetOwner() ) return; DecrementAmmo( GetOwner() ); Reload(); //Do draw animation and stuff #ifndef CLIENT_DLL CBasePlayer *owner = ToBasePlayer(GetOwner()); Vector vThrowPos = owner->Weapon_ShootPosition() - Vector(0,0,12); //Create a grenade CBaseCombatWeapon* pGrenade; pGrenade = (CBaseCombatWeapon *)CBaseEntity::Create( "weapon_frag", vThrowPos, vec3_angle, NULL ); if ( !pGrenade ) return; pGrenade->SetRemoveable( true ); //If it was dropped then there's no need to respawn it. pGrenade->AddSpawnFlags( SF_NORESPAWN ); pGrenade->StopAnimation(); pGrenade->StopFollowingEntity( ); pGrenade->SetMoveType( MOVETYPE_FLYGRAVITY ); // clear follow stuff, setup for collision pGrenade->SetGravity(1.0); pGrenade->m_iState = WEAPON_NOT_CARRIED; pGrenade->RemoveEffects( EF_NODRAW ); pGrenade->FallInit(); pGrenade->SetGroundEntity( NULL ); pGrenade->SetTouch(NULL); pGrenade->SetOwnerEntity( NULL ); pGrenade->SetOwner( NULL ); //Toss it in the direction of the player's view Vector vecNewVelocity; Vector vecDir; owner->EyeVectors( &vecDir ); vecNewVelocity = ( vecDir * 500.0f ); IPhysicsObject *pObj = pGrenade->VPhysicsGetObject(); if ( pObj != NULL ) { AngularImpulse angImp( 200, 200, 200 ); pObj->AddVelocity( &vecNewVelocity, &angImp ); } #endif }
void CProjectedDecal::StaticDecal( void ) { CBroadcastRecipientFilter initFilter; initFilter.MakeInitMessage(); ProjectDecal( initFilter ); SUB_Remove(); }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOwner - //----------------------------------------------------------------------------- void CWeaponFrag::DecrementAmmo( CBaseCombatCharacter *pOwner ) { pOwner->RemoveAmmo( 1, m_iPrimaryAmmoType ); //DHL - Skillet - Once we throw our last grenade remove weapon_grenade from our inventory #ifndef CLIENT_DLL if ( !HasPrimaryAmmo() /*pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0*/ ) { if ( GetLastWeapon() ) pOwner->SwitchToNextBestWeapon( this ); Drop( vec3_origin ); SUB_Remove(); } #endif }
void CDecal :: StaticDecal( void ) { TraceResult trace; int entityIndex, modelIndex; UTIL_TraceLine( pev->origin - Vector(5,5,5), pev->origin + Vector(5,5,5), ignore_monsters, ENT(pev), &trace ); entityIndex = (short)ENTINDEX(trace.pHit); if ( entityIndex ) modelIndex = (int)VARS(trace.pHit)->modelindex; else modelIndex = 0; g_engfuncs.pfnStaticDecal( pev->origin, (int)pev->skin, entityIndex, modelIndex ); SUB_Remove(); }
/* <18b5f6> ../cstrike/dlls/training_gamerules.cpp:424 */ void CFuncWeaponCheck::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { if (!UTIL_IsMasterTriggered(sMaster, pOther)) return; if (!pOther) return; if (!pOther->IsPlayer()) return; CBasePlayer *pPlayer = (CBasePlayer *)pOther; for (int i = 1; i <= iItemCount; ++i) { if (iAnyWeapon) { if (pPlayer->HasNamedPlayerItem(STRING(sItemName[i]))) { break; } } else { if (!pPlayer->HasNamedPlayerItem(STRING(sItemName[i]))) { if (pev->dmgtime < gpGlobals->time) { if (pev->speed > -1.0f) { FireTargets(STRING(sTriggerNoItems), pOther, pOther, USE_TOGGLE, 0); pev->dmgtime = pev->speed + gpGlobals->time; if (!pev->speed) pev->speed = -1; } } return; } } } FireTargets(STRING(sTriggerWithItems), pOther, pOther, USE_TOGGLE, 0); SUB_Remove(); }
/* <24674f> ../cstrike/dlls/wpn_shared/wpn_c4.cpp:419 */ void CC4::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { if (m_pPlayer != NULL) { return; } CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(1)); if (pPlayer != NULL) { edict_t *m_pentOldCurBombTarget = pPlayer->m_pentCurBombTarget; pPlayer->m_pentCurBombTarget = NULL; if (pev->speed != 0 && g_pGameRules) { g_pGameRules->m_iC4Timer = (int)pev->speed; } EMIT_SOUND(edict(), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM); CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0)); CGrenade *pC4 = NULL; while ((pC4 = (CGrenade *)UTIL_FindEntityByClassname(pC4, "grenade")) != NULL) { if (pC4->m_bIsC4 && pC4->m_flNextFreq == gpGlobals->time) { pC4->pev->target = pev->target; pC4->pev->noise1 = pev->noise1; break; } } pPlayer->m_pentCurBombTarget = m_pentOldCurBombTarget; SUB_Remove(); } }
void CDecal::StaticDecal( void ) { Vector position; CBaseEntity *pEntity = GetDecalEntityAndPosition(&position, true); int entityIndex = 0; int modelIndex = 0; if ( pEntity ) { entityIndex = pEntity->entindex(); modelIndex = pEntity->GetModelIndex(); Vector worldspace = position; VectorITransform( worldspace, pEntity->EntityToWorldTransform(), position ); } else { position = GetAbsOrigin(); } engine->StaticDecal( position, m_nTexture, entityIndex, modelIndex, m_bLowPriority ); SUB_Remove(); }
void CGrappleHook::Killed(entvars_t *pev, int gib) { ALERT( at_console, "^2HLU -> ^3weapon_grapple ^2-> Tongue was killed.\n"); // Fograin92: Clear player myowner->pev->movetype = MOVETYPE_WALK; //Re-apply gravity myowner->m_afPhysicsFlags &= ~PFLAG_ON_GRAPPLE; //Remove "on grapple" flag myowner->m_iGrappleExists = 0; myowner->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; // Fograin92: Clear monster if( (m_iHitMonster == 2) && (myHitMonster->IsAlive()) ) myHitMonster->pev->movetype = MOVETYPE_STEP; // Re-apply gravity to the pulled monster, if it's alive // Fograin92: Clear tongue leftovers bPullBack = false; UTIL_Remove( m_pTongue ); m_pTongue = NULL; m_iHitMonster = 0; SetThink(NULL); SetTouch(NULL); SUB_Remove( ); }
//----------------------------------------------------------------------------- // Place the canister in the world //----------------------------------------------------------------------------- CSkyCamera *CEnvHeadcrabCanister::PlaceCanisterInWorld() { CSkyCamera *pCamera = NULL; // Are we launching from a point? If so, use that point. if ( m_iszLaunchPositionName != NULL_STRING ) { // Get the launch position entity CBaseEntity *pLaunchPos = gEntList.FindEntityByName( NULL, m_iszLaunchPositionName ); if ( !pLaunchPos ) { Warning("%s (%s) could not find an entity matching LaunchPositionName of '%s'\n", GetEntityName().ToCStr(), GetDebugName(), STRING(m_iszLaunchPositionName) ); SUB_Remove(); } else { SetupWorldModel(); Vector vecForward, vecImpactDirection; GetVectors( &vecForward, NULL, NULL ); VectorMultiply( vecForward, -1.0f, vecImpactDirection ); m_Shared.InitInWorld( gpGlobals->curtime, pLaunchPos->GetAbsOrigin(), GetAbsAngles(), vecImpactDirection, m_vecImpactPosition, true ); SetThink( &CEnvHeadcrabCanister::HeadcrabCanisterWorldThink ); SetNextThink( gpGlobals->curtime ); } } else if ( DetectInSkybox() ) { pCamera = GetEntitySkybox(); SetModel( ENV_HEADCRABCANISTER_SKYBOX_MODEL ); SetSolid( SOLID_NONE ); Vector vecForward; GetVectors( &vecForward, NULL, NULL ); vecForward *= -1.0f; m_Shared.InitInSkybox( gpGlobals->curtime, m_vecImpactPosition, GetAbsAngles(), vecForward, m_vecImpactPosition, pCamera->m_skyboxData.origin, pCamera->m_skyboxData.scale ); AddEFlags( EFL_IN_SKYBOX ); SetThink( &CEnvHeadcrabCanister::HeadcrabCanisterSkyboxOnlyThink ); SetNextThink( gpGlobals->curtime + m_Shared.GetEnterWorldTime() + TICK_INTERVAL ); } else { Vector vecStartPosition, vecDirection; QAngle vecStartAngles; ComputeWorldEntryPoint( &vecStartPosition, &vecStartAngles, &vecDirection ); // Figure out which skybox to place the entity in. pCamera = GetCurrentSkyCamera(); if ( pCamera ) { m_Shared.InitInSkybox( gpGlobals->curtime, vecStartPosition, vecStartAngles, vecDirection, m_vecImpactPosition, pCamera->m_skyboxData.origin, pCamera->m_skyboxData.scale ); if ( m_Shared.IsInSkybox() ) { SetModel( ENV_HEADCRABCANISTER_SKYBOX_MODEL ); SetSolid( SOLID_NONE ); AddEFlags( EFL_IN_SKYBOX ); SetThink( &CEnvHeadcrabCanister::HeadcrabCanisterSkyboxThink ); SetNextThink( gpGlobals->curtime + m_Shared.GetEnterWorldTime() ); } else { SetThink( &CEnvHeadcrabCanister::HeadcrabCanisterWorldThink ); SetNextThink( gpGlobals->curtime ); } } else { m_Shared.InitInWorld( gpGlobals->curtime, vecStartPosition, vecStartAngles, vecDirection, m_vecImpactPosition ); SetThink( &CEnvHeadcrabCanister::HeadcrabCanisterWorldThink ); SetNextThink( gpGlobals->curtime ); } } Vector vecEndPosition; QAngle vecEndAngles; m_Shared.GetPositionAtTime( gpGlobals->curtime, vecEndPosition, vecEndAngles ); SetAbsOrigin( vecEndPosition ); SetAbsAngles( vecEndAngles ); return pCamera; }
if ( !canDraw ) { Warning( "Suppressed StaticDecal which would have hit entity %i (class:%s, name:%s) with modelindex = 0\n", ent->entindex(), ent->GetClassname(), STRING( ent->GetEntityName() ) ); } } } if ( canDraw ) { engine->StaticDecal( position, m_nTexture, entityIndex, modelIndex, m_bLowPriority ); } SUB_Remove(); } bool CDecal::KeyValue( const char *szKeyName, const char *szValue ) { if (FStrEq(szKeyName, "texture")) { // FIXME: should decals all be preloaded? m_nTexture = UTIL_PrecacheDecal( szValue, true ); // Found if (m_nTexture >= 0 ) return true; Warning( "Can't find decal %s\n", szValue ); }
void Think( void ) { SUB_Remove(); }
void CDHLProjectile::PhysicsSimulate( void ) { //------------------------------------------------------------------------------- //Our own movement/physics simulation! //------------------------------------------------------------------------------- #ifdef CLIENT_DLL if ( m_bCollided ) return; if ( !m_pShooter && m_hShooter ) m_pShooter = m_hShooter.Get(); #else if ( m_flRemoveAt > 0.0f ) { if ( m_flRemoveAt < gpGlobals->curtime ) { m_flRemoveAt = 0.0f; SUB_Remove(); } return; } if ( IsMarkedForDeletion() ) return; #endif float flFrametime = gpGlobals->frametime; //Scale for slow motion if ( DHLRules() ) { if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) ) flFrametime *= (dhl_bulletspeed.GetFloat() * DHLRules()->GetTimescale()); else if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE ) flFrametime *= (dhl_knifespeed.GetFloat() * DHLRules()->GetTimescale()); else flFrametime *= DHLRules()->GetTimescale(); } Vector vecDir = vec3_origin; #ifndef CLIENT_DLL Vector vecStartPos = m_vecCurPosition; //This is where we are Vector vecEndPos = m_vecCurPosition; //This is where we're going Vector vecVelocity = m_vecCurVelocity; //Velocity #else Vector vecStartPos = GetLocalOrigin(); //This is where we are Vector vecEndPos = GetLocalOrigin(); //This is where we're going Vector vecVelocity = GetLocalVelocity(); //Velocity #endif //Find out where we should move to if ( vecVelocity != vec3_origin ) { static ConVarRef gravVar( "sv_gravity" ); //Gravity float newZVelocity = vecVelocity.z - ( flFrametime * gravVar.GetFloat() * GetGravity() ); vecVelocity.z = ( (vecVelocity.z + newZVelocity) / 2 ); vecDir = vecVelocity; VectorNormalize( vecDir ); //Gravity needs to be cumulative #ifndef CLIENT_DLL m_vecCurVelocity = vecVelocity; #else SetLocalVelocity( vecVelocity ); #endif vecVelocity *= flFrametime; vecEndPos = vecStartPos + vecVelocity; if ( vecEndPos.IsValid() ) { CTraceFilterSkipTwoEntities movetrfilter( this, m_pShooter, COLLISION_GROUP_NONE ); trace_t movetr; UTIL_TraceLine( vecStartPos, vecEndPos, MASK_SHOT, &movetrfilter, &movetr ); #ifndef CLIENT_DLL //Trace to triggers so we can hit surf glass and such CTakeDamageInfo triggerInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET ); if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE ) { //CalculateMeleeDamageForce( &triggerInfo, vecDir, movetr.endpos, 0.7f ); Vector vecForce = vecDir; VectorNormalize( vecForce ); //vecForce *= 10.0f; triggerInfo.SetDamageForce( vecForce ); } else CalculateBulletDamageForce( &triggerInfo, m_iAmmoType, vecDir, movetr.endpos, 1.0f ); triggerInfo.SetDamagePosition( movetr.endpos ); TraceAttackToTriggers( triggerInfo, movetr.startpos, movetr.endpos, vecDir ); #else //Hit ragdolls on the client CBaseEntity* pEnt = DHL_FX_AffectRagdolls( movetr.endpos, movetr.startpos, DMG_BULLET, &m_RagdollHitList ); //Keep track of ones we've hit if ( pEnt ) m_RagdollHitList.AddToTail( pEnt ); #endif if ( movetr.DidHit() ) if ( OnTouch( movetr, false, &movetrfilter ) ) return; MoveProjectileToPosition( vecEndPos ); m_flDistanceTravelled += vecEndPos.DistTo( vecStartPos ); #ifndef CLIENT_DLL //On rare occasions the projectile likes to fly right through the world and keep going forever, causing a memory leak if ( m_flDistanceTravelled > MAX_TRACE_LENGTH ) { SUB_Remove(); //SetThink( &CDHLProjectile::SUB_Remove ); //SetNextThink( gpGlobals->curtime + 0.1 ); } #endif } //Simulate Angles //QAngle angles; #ifdef CLIENT_DLL QAngle angles = GetLocalAngles(); //VectorAngles( vecDir, angles ); //angles.z = GetLocalAngles().z; //Vector conversion loses z QAngle angVel = GetLocalAngularVelocity(); angles += angVel * flFrametime; SetLocalAngles( angles ); SetNetworkAngles( angles ); #endif } }
void CASW_Flamer_Projectile::CollideThink() { if (gpGlobals->curtime >= m_fDieTime) { SUB_Remove(); return; } SetNextThink( gpGlobals->curtime + 0.1f ); if (m_vecOldPos == vec3_origin) m_vecOldPos = GetAbsOrigin(); trace_t tr; UTIL_TraceLine(GetAbsOrigin(), m_vecOldPos, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); bool bHit = false; if (tr.fraction != 1.0) { if (tr.m_pEnt && !dynamic_cast<CASW_Flamer_Projectile*>(tr.m_pEnt)) { //Msg("Flamer projectile CollideThinked %s\n", tr.m_pEnt->GetClassname()); FlameHit(tr.m_pEnt, tr.endpos, false); bHit = true; if (asw_flamer_debug.GetBool()) NDebugOverlay::Cross3D(tr.endpos, 10, 0, 0, 255, true, 10.0f); } } // scan for setting on fire nearby NPCs if (!bHit) { trace_t tr; Ray_t ray; CTraceFilterAliensEggsGoo filter( this, COLLISION_GROUP_NONE ); //UTIL_TraceHull(GetAbsOrigin(), GetAbsOrigin() + Vector(0,0,1), ASW_FLAMER_HULL_MINS, ASW_FLAMER_HULL_MAXS, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); float size_scale = 0.5f + 0.5f * (1.0f - clamp<float>(m_fDieTime - gpGlobals->curtime, 0.0f, 1.0f)); // NOTE: assumes 1.0 lifetime ray.Init( GetAbsOrigin(), m_vecOldPos, ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale ); enginetrace->TraceRay( ray, MASK_SOLID, &filter, &tr ); if ( tr.m_pEnt ) { FlameHit(tr.m_pEnt, tr.endpos, !m_bHurtIgnited); //NDebugOverlay::Cross3D(tr.endpos, 10, 255, 0, 0, true, 10.0f); if (asw_flamer_debug.GetBool()) { Msg("Flame hit %d %s\n", tr.m_pEnt->entindex(), tr.m_pEnt->GetClassname()); NDebugOverlay::SweptBox(GetAbsOrigin(), m_vecOldPos, ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale, vec3_angle, 255, 255, 0, 0 ,0.1f); NDebugOverlay::Line(GetAbsOrigin(), tr.m_pEnt->GetAbsOrigin(), 255, 255, 0, false, 0.1f ); } } else if (tr.allsolid || tr.startsolid) { if (asw_flamer_debug.GetBool()) NDebugOverlay::Box(GetAbsOrigin(), ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale, 0, 0, 255, 0 ,0.1f); } else { if (asw_flamer_debug.GetBool()) NDebugOverlay::Box(GetAbsOrigin(), ASW_FLAMER_HULL_MINS * size_scale, ASW_FLAMER_HULL_MAXS * size_scale, 255, 0, 0, 0 ,0.1f); } } m_vecOldPos = GetAbsOrigin(); }