//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponFrag::ItemPostFrame( void )
{
    if( m_fDrawbackFinished )
    {
        CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

        if (pOwner)
        {
            switch( m_AttackPaused )
            {
            case GRENADE_PAUSED_PRIMARY:
                if( !(pOwner->m_nButtons & IN_ATTACK) )
                {
                    SendWeaponAnim( ACT_VM_THROW );
                    ToHL2MPPlayer(pOwner)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );

                    //Tony; fire the sequence
                    m_fDrawbackFinished = false;
                }
                break;

            case GRENADE_PAUSED_SECONDARY:
                if( !(pOwner->m_nButtons & IN_ATTACK2) )
                {
                    //See if we're ducking
                    if ( pOwner->m_nButtons & IN_DUCK )
                    {
                        //Send the weapon animation
                        SendWeaponAnim( ACT_VM_SECONDARYATTACK );
                    }
                    else
                    {
                        //Send the weapon animation
                        SendWeaponAnim( ACT_VM_HAULBACK );
                    }
                    //Tony; the grenade really should have a secondary anim. but it doesn't on the player.
                    ToHL2MPPlayer(pOwner)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );

                    m_fDrawbackFinished = false;
                }
                break;

            default:
                break;
            }
        }
    }

    BaseClass::ItemPostFrame();

    if ( m_bRedraw )
    {
        if ( IsViewModelSequenceFinished() )
        {
            Reload();
        }
    }
}
예제 #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//
//
//-----------------------------------------------------------------------------
void CWeaponShotgun::SecondaryAttack( void )
{
	// Only the player fires this way so we can cast
	CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );

	if (!pPlayer)
	{
		return;
	}

	pPlayer->m_nButtons &= ~IN_ATTACK2;
	// MUST call sound before removing a round from the clip of a CMachineGun
	WeaponSound(WPN_DOUBLE);

	pPlayer->DoMuzzleFlash();

	SendWeaponAnim( ACT_VM_SECONDARYATTACK );

	// Don't fire again until fire animation has completed
	m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
	m_iClip1 -= 2;	// Shotgun uses same clip for primary and secondary attacks

	// player "shoot" animation
	pPlayer->SetAnimation( PLAYER_ATTACK1 );
	//Tony; does shotgun have a second anim?
	ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );


	Vector vecSrc	 = pPlayer->Weapon_ShootPosition();
	Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );	

	FireBulletsInfo_t info( 12, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
	info.m_pAttacker = pPlayer;

	// Fire the bullets, and force the first shot to be perfectly accuracy
	pPlayer->FireBullets( info );
	pPlayer->ViewPunch( QAngle(SharedRandomFloat( "shotgunsax", -5, 5 ),0,0) );

#ifdef HL2SB
#ifndef CLIENT_DLL
	pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 1.0 );

	CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_SHOTGUN, 0.2 );
#endif
#endif

	if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
	{
		// HEV suit - indicate out of ammo condition
		pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); 
	}

	m_bNeedPump = true;

#ifdef HL2SB
#ifndef CLIENT_DLL
	gamestats->Event_WeaponFired( pPlayer, false, GetClassname() );
#endif
#endif
}
예제 #3
0
//-----------------------------------------------------------------------------
// Animation event handlers
//-----------------------------------------------------------------------------
void CWeaponZMFists::HandleAnimEventMeleeHit( CBaseCombatCharacter *pOperator )
{
	//do the trace stuff here so we can pass it to the Hit() function
	trace_t traceHit;

	// Try a ray
	CBasePlayer *pOwner = ToBasePlayer(pOperator);
	if ( !pOwner )
		return;

	Vector swingStart = pOwner->Weapon_ShootPosition( );
	Vector forward;

	pOwner->EyeVectors( &forward, NULL, NULL );

	Vector swingEnd = swingStart + forward * GetRange();

#ifndef CLIENT_DLL
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
	// Move other players back to history positions based on local player's lag
	lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
	UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit );
	Hit( traceHit, ACT_VM_HITCENTER);
#ifndef CLIENT_DLL
	// Move other players back to history positions based on local player's lag
	lagcompensation->FinishLagCompensation( pPlayer );
#endif
}
예제 #4
0
void CWeaponCrowbar::PrimaryAttack()
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetOwner() );
	if (pPlayer)
	{
#ifndef CLIENT_DLL
		if (pPlayer->gorephased)
		{
			//BB: JAM Request... sneak attacks
			pPlayer->DoGorePhase();
			pPlayer->covenStatusEffects &= pPlayer->covenStatusEffects & ~COVEN_FLAG_PHASE;
			pPlayer->SetStatusTime(COVEN_BUFF_PHASE, 0.0f);
		}
		if (pPlayer->covenClassID == COVEN_CLASSID_FIEND && pPlayer->covenStatusEffects & COVEN_FLAG_DODGE)
		{
			pPlayer->VampireUnDodge();
		}
#else
		/*C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
		C_BaseHLPlayer *pPlayer2 = (C_BaseHLPlayer *)local;
		if (pPlayer2->covenClassID == COVEN_CLASSID_FIEND && pPlayer2->GetRenderColor().a < 255)
			return;*/
		//second half of sneak attacks
		/*C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
		C_BaseHLPlayer *pPlayer2 = (C_BaseHLPlayer *)local;
		if (pPlayer2->GetEffects() & EF_NODRAW)
		{
			return;
		}*/
#endif
	}
	BaseClass::PrimaryAttack();
}
예제 #5
0
CHL2MP_Player* CHL2MP_Player::FindNearestAlly()
{
	//Credits goes to JailBreak Source for this

	const Vector &  vAbsOrigin      = GetAbsOrigin();
	float           closestDistSq   = FLT_MAX;
	CHL2MP_Player * pNearest        = NULL;
	float           distSq;

	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = ToHL2MPPlayer(UTIL_PlayerByIndex( i ));
		if ( pPlayer && pPlayer != this)
		{
			if(pPlayer->GetTeamNumber() != this->GetTeamNumber())
				continue;

			distSq = ( vAbsOrigin - pPlayer->GetAbsOrigin() ).LengthSqr();

			if(distSq > closestDistSq)
				continue;

			closestDistSq = distSq;
			pNearest = pPlayer;
		}
	}
	return pNearest;
}
예제 #6
0
파일: weapon_ak47.cpp 프로젝트: js564/final
//-----------------------------------------------------------------------------
// Purpose: This happens if you click and hold the primary fire button
//-----------------------------------------------------------------------------
void CWeaponAK47::PrimaryAttack( void )
{
  //do we have any bullets left from the current burst cycle? 
  if (m_iBurst!=0) 
  {
    CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
    CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
    if ( !pPlayer )
      { return; }
 
    WeaponSound( SINGLE );
    pPlayer->DoMuzzleFlash();
 
    SendWeaponAnim( ACT_VM_PRIMARYATTACK );
    pPlayer->SetAnimation( PLAYER_ATTACK1 );
    ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
 
    // Each time the player fires the gun, reset the view punch.  
    if ( pOwner )
      { pOwner->ViewPunchReset(); }
 
    BaseClass::PrimaryAttack();
 
    // We fired one shot, decrease the number of bullets available for this burst cycle 
    m_iBurst--;
    m_flNextPrimaryAttack =gpGlobals->curtime + ROF;
    m_flAttackEnds = gpGlobals->curtime + SequenceDuration();
  }
}
		float		GetFireRate(void)		{ 
#ifdef MFS
#ifdef CLIENT_DLL
			CHL2MPRules *pRules = HL2MPRules();
			if (pRules->IsFlash() == true)
#else
			if (HL2MPRules()->IsFlash() == true)
#endif
			{
				CHL2MP_Player *pOwner = ToHL2MPPlayer(GetOwner());
				return KNIFE_REFIRE - KNIFE_REFIRE * (pOwner->speed_modifier / 2000 - pOwner->speed_modifier / 4000); //An insane Refire Rate
			}
#endif
#ifdef CLIENT_DLL
#ifdef MFS
			else
#endif
			if (pRules->IsKnifeFight() == true)
#else
#ifdef MFS
			else
#endif
			if (HL2MPRules()->IsKnifeFight() == true)
#endif
				return KNIFE_REFIRE*0.7;
			else
				return KNIFE_REFIRE;
		}
예제 #8
0
//Pose la mine sur son support une fois l'animation terminée
void CWeaponMine::FinishAttach( void ){
	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
	if (!pOwner)
		return;

	Vector vecSrc, vecAiming;
	vecSrc = pOwner->EyePosition();
	QAngle angles = pOwner->GetLocalAngles();
	AngleVectors( angles, &vecAiming );
	trace_t tr;
	UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 60), MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
	
	if (tr.fraction < 1.0)
	{		
		if (tr.m_pEnt)
		{
			//On attache pas la mine sur une entité vivante
			CBaseEntity *pEntity = tr.m_pEnt;
			CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );
			if (pBCC){
				m_bAttachMine  = false;
				m_bNeedReload = true;
				return;
			}

#ifndef CLIENT_DLL
			//On vérifie qu'il n 'y a pas déjà une mine sur le support visé
			CBaseEntity* pResult = gEntList.FindEntityByClassname(NULL,"npc_mine");
			while (pResult)
			{
				if((pResult->GetAbsOrigin() - tr.endpos).Length() < MINE_DISTANCE){
					m_bAttachMine  = false;
					m_bNeedReload = true;
					return;
				}

				pResult = gEntList.FindEntityByClassname(pResult,"npc_mine");
			}

			if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
			{
				QAngle angles;
				VectorAngles(tr.plane.normal, angles);
				angles.x += 90;

				CBaseEntity *pEnt = CBaseEntity::Create( "npc_mine", tr.endpos + tr.plane.normal * 3, angles, NULL );
				CNPCMine *pMine = (CNPCMine *)pEnt;
				pMine->m_hOwner = GetOwner();
				ChooseMineColor(pMine);
				pMine->AttachToEntity( pEntity );

				pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
			}
#endif
		}
	}

	m_bAttachMine  = false;
	m_bNeedReload = true;
}
예제 #9
0
void CBotComManager::DispatchVCommToBot() {
	//I think the compiler is optimizing the necessary null checks, so I'll do this
	volatile CHL2MP_Player* pContextPlayer = m_pContextPlayer;

	if (m_pContextPlayer) {
		if (m_eForcedContext) {
			m_eContext = m_eForcedContext;
			m_eForcedContext = CONTEXT_NONE;
			if (m_bRedirectForcedContextToTeammate) {
				pContextPlayer = m_pContextPlayer = ToHL2MPPlayer(CPlayerSearch::FriendlyBotNearestTo(m_pContextPlayer));
				m_bRedirectForcedContextToTeammate = false;
			}
		}
		//nearest bot might be null so check it again
		if (pContextPlayer && m_pContextPlayer && m_pContextPlayer->IsFakeClient()) {
			
			//build a vcomm
			static char vcommTemplate[64];
			Q_snprintf(vcommTemplate, sizeof vcommTemplate, "voicecomm %i\n", ParseContext(m_eContext));

			static CCommand vcommCmd;
			vcommCmd.Tokenize(vcommTemplate);
			m_pContextPlayer->ClientCommand(vcommCmd);
		}
	}
}
예제 #10
0
void CWeaponCombatKnife::SecondaryAttack( void )
{
	CBasePlayer* pOwner = ToBasePlayer( GetOwner() );
	Assert( pOwner );

	//Can't throw last knife
	if ( pOwner->GetAmmoCount(GetPrimaryAmmoType()) <= 0 )
	{
		m_flNextSecondaryAttack = gpGlobals->curtime + 0.1f;
		return;
	}

	#ifndef CLIENT_DLL
		CDHLProjectile* pKnife = (CDHLProjectile*)(CreateEntityByName( "dhl_projectile" ));
		Assert( pKnife );
		pKnife->SetOwnerEntity( pOwner );
		pKnife->Spawn();

		//This is just an easy way of getting an eye vector, there isn't really any autoaim in MP
		Vector vecDir = pOwner->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT );
		//HACK - move it forward so it doesn't appear to spawn inside the player's face
		Vector vecSrc = pOwner->Weapon_ShootPosition() + ( vecDir * 6.0f );

		pKnife->Fire( vecSrc, vecDir * 1232.0f /*70mph*/, GetHL2MPWpnData().m_iPlayerDamage, this, pOwner, -1 );
		
		if ( dhl_flamingknives.GetBool() )
			pKnife->Ignite( 30.0f, false );
		
	#endif

		//Make sure this is done after the call to Fire()
		int iAmmo = pOwner->GetAmmoCount(GetPrimaryAmmoType());
		pOwner->RemoveAmmo( 1, GetPrimaryAmmoType() );
		if ( iAmmo <= 0 )
		{
			AddEffects( EF_NODRAW );
			#ifndef CLIENT_DLL
				pOwner->Weapon_Drop( this, NULL, NULL );
				Remove();
			#endif
		}
		else
		{
			SendWeaponAnim( ACT_VM_THROW ); //Need to be able to predict this

			pOwner->SetAnimation( PLAYER_ATTACK1 ); //Use the primary attack anim for now
			ToHL2MPPlayer(pOwner)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );

			m_flNextSecondaryAttack = gpGlobals->curtime + GetFireRate();
		}

		/*IPhysicsObject* pPhysObj = VPhysicsGetObject();
		if ( pPhysObj )
		{
			pPhysObj->Sleep();
			pPhysObj->EnableMotion( false );
			pPhysObj->EnableCollisions( false );
		}
		m_bAllowPickup = false;*/
}
예제 #11
0
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	/*CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		{		
			// respawn player
			pPlayer->Spawn();			
		}
		else
		{
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
		}
	}*/
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		//BG2 - Draco - Start(this is the part that supresses respawns when mp_respawnstyle != 0)
		//if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		//BG2 - Tjoppen - assume this function only gets called if we're allowed to respawn/spawn

		// respawn player
		pPlayer->Spawn();
	}
}
예제 #12
0
void ClientActive( edict_t *pEdict, bool bLoadGame )
{
	// Can't load games in CS!
	Assert( !bLoadGame );

	CHL2MP_Player *pPlayer = ToHL2MPPlayer( CBaseEntity::Instance( pEdict ) );
	FinishClientPutInServer( pPlayer );
}
예제 #13
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponSMG1::SecondaryAttack( void )
{
	// Only the player fires this way so we can cast
	CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
	
	if ( pPlayer == NULL )
		return;

	//Must have ammo
	if ( ( pPlayer->GetAmmoCount( m_iSecondaryAmmoType ) <= 0 ) || ( pPlayer->GetWaterLevel() == 3 ) )
	{
		SendWeaponAnim( ACT_VM_DRYFIRE );
		BaseClass::WeaponSound( EMPTY );
		m_flNextSecondaryAttack = gpGlobals->curtime + 0.5f;
		return;
	}

	if( m_bInReload )
		m_bInReload = false;

	// MUST call sound before removing a round from the clip of a CMachineGun
	BaseClass::WeaponSound( WPN_DOUBLE );

	Vector vecSrc = pPlayer->Weapon_ShootPosition();
	Vector	vecThrow;
	// Don't autoaim on grenade tosses
	AngleVectors( pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), &vecThrow );
	VectorScale( vecThrow, 1000.0f, vecThrow );
	
#ifndef CLIENT_DLL
	//Create the grenade
	CGrenadeAR2 *pGrenade = (CGrenadeAR2*)Create( "grenade_ar2", vecSrc, vec3_angle, pPlayer );
	pGrenade->SetAbsVelocity( vecThrow );

	pGrenade->SetLocalAngularVelocity( RandomAngle( -400, 400 ) );
	pGrenade->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE ); 
	pGrenade->SetThrower( GetOwner() );
	pGrenade->SetDamage( SMG1_GRENADE_DAMAGE );
	pGrenade->SetDamageRadius( SMG1_GRENADE_RADIUS );
#endif

	SendWeaponAnim( ACT_VM_SECONDARYATTACK );

	// player "shoot" animation
	pPlayer->SetAnimation( PLAYER_ATTACK1 );
	//Tony; TODO SECONDARY!
	ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );


	// Decrease ammo
	pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType );

	// Can shoot again immediately
	m_flNextPrimaryAttack = gpGlobals->curtime + 0.5f;

	// Can blow up after a short delay (so have time to release mouse button)
	m_flNextSecondaryAttack = gpGlobals->curtime + 1.0f;
}
예제 #14
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::StartSatchelAttach( void )
{
#ifndef CLIENT_DLL
	CBaseCombatCharacter *pOwner  = GetOwner();
	if (!pOwner)
	{
		return;
	}

	Vector vecSrc	 = pOwner->Weapon_ShootPosition( );
	Vector vecAiming = pOwner->BodyDirection2D( );

	trace_t tr;

	UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 128), MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
	
	if (tr.fraction < 1.0)
	{
		CBaseEntity *pEntity = tr.m_pEnt;
		if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
		{
			// Only the player fires this way so we can cast
			CBasePlayer *pPlayer = ToBasePlayer( pOwner );

			// player "shoot" animation
			pPlayer->SetAnimation( PLAYER_ATTACK1 );
			//Tony; need to check the player models !
			ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );


			// -----------------------------------------
			//  Play attach animation
			// -----------------------------------------
			if (m_bDetonatorArmed)
			{
				SendWeaponAnim(ACT_SLAM_STICKWALL_ATTACH);
			}
			else
			{
				SendWeaponAnim(ACT_SLAM_STICKWALL_ND_ATTACH);
				if (!m_bDetonatorArmed)
				{
					m_bDetonatorArmed		= true;
					m_bNeedDetonatorDraw	= true;
				}
			}
			
			m_bNeedReload		= true;
			m_bAttachSatchel	= true;

			m_flNextPrimaryAttack	= m_flNextSecondaryAttack = SLAM_REFIRE_DELAY + gpGlobals->curtime + SequenceDuration();

		}
	}
#endif
}
예제 #15
0
//Tony; override for animation purposes.
bool CWeaponHL2MPBase::Reload( void )
{
	bool fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
	if ( fRet )
	{
//		WeaponSound( RELOAD );
		ToHL2MPPlayer(GetOwner())->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
	}
	return fRet;
}
예제 #16
0
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );
	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
			pPlayer->Spawn();
		else
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CWeaponGlock18::Reload( void )
{
	bool fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
	if ( fRet )
	{
		WeaponSound( RELOAD );
		ToHL2MPPlayer(GetOwner())->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
		m_flAccuracyPenalty = 0.0f;
	}
	return fRet;
}
예제 #18
0
int DotaObjective::OnTakeDamage( const CTakeDamageInfo &inputInfo )
{
	if ( m_bMet )
		return 0;	

	if ( !(inputInfo.GetDamageType() & DMG_BULLET) )
	{
		CHL2MP_Player * playerAttacker = ToHL2MPPlayer( inputInfo.GetAttacker() );

		CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName );
		if ( !maker )
			AssertMsg( false, "Objective can't find its creepmaker!\n" );
		
		CAI_BaseNPC * guardian = (CAI_BaseNPC*)gEntList.FindEntityByName( NULL, m_guardianName );	
		if( guardian && guardian->IsAlive() )
		{
			if( playerAttacker )
				ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("The guradian is alive in this lane, you can't hurt the gate.\n") );
		}
		else
		{
			m_timesHit++;
			m_timesHit = min(m_timesHit, OBJECTIVE_HEALTHI); // make sure times hit never goes above the maximum times an objective can be hit!

			CRecipientFilter user;
			user.AddRecipientsByTeam( this->GetTeam() );
			user.MakeReliable();
			char szText[200];
			Q_snprintf( szText, sizeof(szText), "Your ally gate is under attack from an enemy!" );
			UTIL_ClientPrintFilter( user, HUD_PRINTCENTER, szText );
			
			if( playerAttacker )
				ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("Gate has %i health left.\n", OBJECTIVE_HEALTHI - m_timesHit) );

			if (m_timesHit >= OBJECTIVE_HEALTHI)
			{
				TakeAction(DOBJ_ACTION_CLOSE);
			} else {
				IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_attacked" );

				if ( pEvent )
				{
					pEvent->SetString( "lane", GetLane() );
					pEvent->SetInt( "team", this->GetTeamNumber() );
					pEvent->SetFloat( "health", (OBJECTIVE_HEALTHF - m_timesHit)/OBJECTIVE_HEALTHF );
					gameeventmanager->FireEvent( pEvent );
				}
			}
		}
	}

	return 0;
}
예제 #19
0
파일: weapon_ak47.cpp 프로젝트: js564/final
//-----------------------------------------------------------------------------
// Purpose: The gun is being reloaded 
//-----------------------------------------------------------------------------
bool CWeaponAK47::Reload( void )
{
  bool fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
  if ( fRet )
  {
    WeaponSound( RELOAD );
    ToHL2MPPlayer(GetOwner())->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
    //reset the burst counter to the default
    m_iBurst=BURST;
  }
  return fRet;
}
예제 #20
0
bool CItemMoney::MyTouch( CBasePlayer *pPlayer )
{
	if ( pPlayer != m_taker )
		return false;

	CPASAttenuationFilter sndFilter( pPlayer );
	pPlayer->EmitSound( sndFilter, pPlayer->entindex(), "Buttons.snd2" );

	CHL2MP_Player * p = ToHL2MPPlayer( pPlayer );
	p->AddMoney( m_iAmount );

	return true;
}
예제 #21
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CWeaponPistol::Reload( void )
{
	bool fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
	if ( fRet )
	{
		WeaponSound( RELOAD );
#ifdef HL2MP_DEV_DLL
	ToHL2MPPlayer(GetOwner())->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
#endif // HL2MP_DEV_DLL
		m_flAccuracyPenalty = 0.0f;
	}
	return fRet;
}
예제 #22
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
unsigned int CFlechette::PhysicsSolidMaskForEntity() const
{
		int mask = 0;
	#ifdef HL2MP
	if ( HL2MPRules()->IsTeamplay() )
	{
		if(GetOwnerEntity() && ToHL2MPPlayer(GetOwnerEntity()))
		{
			switch ( ToHL2MPPlayer(GetOwnerEntity())->GetTeamNumber() )
			{
			case TEAM_GREEN:
				mask = CONTENTS_TEAM1;
				break;

			case TEAM_PINK:
				mask = CONTENTS_TEAM2;
				break;
			}
		}
	}
	#endif
	return (mask | ( BaseClass::PhysicsSolidMaskForEntity() | CONTENTS_HITBOX ) & ~CONTENTS_GRATE);
}
예제 #23
0
void CWeaponBaseballBat::PrimaryAttack( void )
{
	BaseClass::PrimaryAttack();

	//HACK - our model crashes the decompiler and all the original files are lost so we can't fix the messed up activities
	SendWeaponAnim( ACT_VM_HITCENTER );

	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
	if ( !pOwner )
		return;

	pOwner->SetAnimation( PLAYER_ATTACK1 );
	pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
}
예제 #24
0
//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CBaseHL2MPBludgeonWeapon::PrimaryAttack()
{

#ifndef CLIENT_DLL
    CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
    // Move other players back to history positions based on local player's lag
    lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
    Swing( false );
#ifndef CLIENT_DLL
    // Move other players back to history positions based on local player's lag
    lagcompensation->FinishLagCompensation( pPlayer );
#endif

}
예제 #25
0
void ClientActive( edict_t *pEdict, bool bLoadGame )
{
	// Can't load games in CS!
#ifndef HL2SB
	Assert( !bLoadGame );
#endif

	CHL2MP_Player *pPlayer = ToHL2MPPlayer( CBaseEntity::Instance( pEdict ) );
#ifdef HL2SB
	if( pPlayer )
		FinishClientPutInServer( pPlayer );
#else
	FinishClientPutInServer( pPlayer );
#endif
}
예제 #26
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::TripmineAttach( void )
{
	CHL2MP_Player *pOwner  = ToHL2MPPlayer( GetOwner() );
	if (!pOwner)
	{
		return;
	}

	m_bAttachTripmine = false;

	Vector vecSrc, vecAiming;

	// Take the eye position and direction
	vecSrc = pOwner->EyePosition();
	
	QAngle angles = pOwner->GetLocalAngles();

	AngleVectors( angles, &vecAiming );

	trace_t tr;

	UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 128), MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
	
	if (tr.fraction < 1.0)
	{
		CBaseEntity *pEntity = tr.m_pEnt;
		if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
		{

#ifndef CLIENT_DLL
			QAngle angles;
			VectorAngles(tr.plane.normal, angles);

			angles.x += 90;

			CBaseEntity *pEnt = CBaseEntity::Create( "npc_tripmine", tr.endpos + tr.plane.normal * 3, angles, NULL );

			CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
			pMine->m_hOwner = GetOwner();
			// Attempt to attach to entity, or just sit still in place.
			pMine->AttachToEntity( pEntity );

#endif

			pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
		}
	}
}
예제 #27
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::SatchelThrow( void )
{	
	// Only the player fires this way so we can cast
	CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );

#ifndef CLIENT_DLL
	m_bThrowSatchel = false;


	Vector vecSrc	 = pPlayer->WorldSpaceCenter();
	Vector vecFacing = pPlayer->BodyDirection3D( );
	vecSrc = vecSrc + vecFacing * 18.0;
	// BUGBUG: is this because vecSrc is not from Weapon_ShootPosition()???
	vecSrc.z += 24.0f;

	Vector vecThrow;
	GetOwner()->GetVelocity( &vecThrow, NULL );
	vecThrow += vecFacing * 500;

	// Player may have turned to face a wall during the throw anim in which case
	// we don't want to throw the SLAM into the wall
	if (CanAttachSLAM())
	{
		vecThrow = vecFacing;
		vecSrc   = pPlayer->WorldSpaceCenter() + vecFacing * 5.0;
	}	

	CSatchelCharge *pSatchel = (CSatchelCharge*)Create( "npc_satchel", vecSrc, vec3_angle, GetOwner() );

	if ( pSatchel )
	{
		pSatchel->SetThrower( GetOwner() );
		pSatchel->ApplyAbsVelocityImpulse( vecThrow );
		pSatchel->SetLocalAngularVelocity( QAngle( 0, 400, 0 ) );
		pSatchel->m_bIsLive = true;
		pSatchel->m_pMyWeaponSLAM = this;
	}

	pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType );
	pPlayer->SetAnimation( PLAYER_ATTACK1 );
#endif

	//Tony; is there a different anim in the player? must check..
	ToHL2MPPlayer(pPlayer)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );

	// Play throw sound
	EmitSound( "Weapon_SLAM.SatchelThrow" );
}
예제 #28
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pActivator - 
//			*pCaller - 
//			useType - 
//			value - 
//-----------------------------------------------------------------------------
void Dota_Resupply::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pActivator );

	if ( pPlayer == NULL )
		return;

	int iSequence = LookupSequence( "Open" );

	// See if we're not opening already
	if ( GetSequence() != iSequence )
	{
		Vector mins, maxs;
		trace_t tr;

		CollisionProp()->WorldSpaceAABB( &mins, &maxs );

		Vector vOrigin = GetAbsOrigin();
		vOrigin.z += ( maxs.z - mins.z );
		mins = (mins - GetAbsOrigin()) * 0.2f;
		maxs = (maxs - GetAbsOrigin()) * 0.2f;
		mins.z = ( GetAbsOrigin().z - vOrigin.z );  
		
		UTIL_TraceHull( vOrigin, vOrigin, mins, maxs, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );

		if ( tr.startsolid || tr.allsolid )
			 return;
			
		m_hActivator = pPlayer;
		m_hActivator->SetCanShop( true );

		// Animate!
		ResetSequence( iSequence );

		// Make sound
		CPASAttenuationFilter sndFilter( this, "AmmoCrate.Open" );
		EmitSound( sndFilter, entindex(), "AmmoCrate.Open" );

		// Start thinking to make it return
		SetThink( &Dota_Resupply::CrateThink );
		SetNextThink( gpGlobals->curtime + 0.1f );
	}

	// Don't close again for two seconds
	m_flCloseTime = gpGlobals->curtime + AMMO_CRATE_CLOSE_DELAY;
}
예제 #29
0
//-----------------------------------------------------------------------------
// Purpose: 
//
//
//-----------------------------------------------------------------------------
void CWeaponShotgun::PrimaryAttack( void )
{
	// Only the player fires this way so we can cast
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetOwner() );

	if (!pPlayer)
	{
		return;
	}

	// MUST call sound before removing a round from the clip of a CMachineGun
	WeaponSound(SINGLE);

	pPlayer->DoMuzzleFlash();

	SendWeaponAnim( ACT_VM_PRIMARYATTACK );

	// Don't fire again until fire animation has completed
	m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
	m_iClip1 -= 1;

	// player "shoot" animation
	pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );


	Vector	vecSrc		= pPlayer->Weapon_ShootPosition( );
	Vector	vecAiming	= pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );	

	FireBulletsInfo_t info( 7, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
	info.m_pAttacker = pPlayer;

	// Fire the bullets, and force the first shot to be perfectly accuracy
	pPlayer->FireBullets( info );
	
	QAngle punch;
	punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 );
	pPlayer->ViewPunch( punch );

	if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
	{
		// HEV suit - indicate out of ammo condition
		pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); 
	}

	m_bNeedPump = true;
}
예제 #30
0
bool CWeaponUzi::Reload( void )
{
	bool fRet;
	float fCacheTime = m_flNextSecondaryAttack;

	fRet = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
	if ( fRet )
	{
		// Undo whatever the reload process has done to our secondary
		// attack timer. We allow you to interrupt reloading to fire
		// a grenade.
		m_flNextSecondaryAttack = GetOwner()->m_flNextAttack = fCacheTime;

		WeaponSound( RELOAD );
		ToHL2MPPlayer(GetOwner())->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
	}
	m_flNextPrimaryAttack = gpGlobals->curtime + 1,466666666666667;
	return fRet;
}