コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponCombat_ChargeablePlasma::PrimaryAttack( void )
{
	CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
	if (!pPlayer)
		return;
	
	WeaponSound(SINGLE);

	// Fire the bullets
	Vector vecSrc = pPlayer->Weapon_ShootPosition( );
	Vector vecAiming;
	pPlayer->EyeVectors( &vecAiming );

	// If we already have a lock target from button down, see if we shouldn't try and get a new one
	// Only do this is the button was released immediately
	if ( !m_hLockTarget || ( m_flLockedAt < gpGlobals->curtime ) )
	{
		m_hLockTarget = GetLockTarget();
	}

	PlayAttackAnimation( GetPrimaryAttackActivity() );

	// Shift it down a bit so the firer can see it
	Vector right;
	AngleVectors( pPlayer->EyeAngles() + pPlayer->m_Local.m_vecPunchAngle, NULL, &right, NULL );
	Vector vecStartSpot = vecSrc + Vector(0,0,-8) + right * 12;

	CGuidedPlasma *pShot = CGuidedPlasma::Create(vecStartSpot, vecAiming, m_hLockTarget, m_vecTargetOffset, pPlayer);

	// Set it's charged power level
	if (m_bHasCharge)
		m_flPower = min( MAX_CHARGED_TIME, gpGlobals->curtime - m_flChargeStartTime );
	else
		m_flPower = 0.0f;

	float flDamageMult = RemapVal( m_flPower, 0, MAX_CHARGED_TIME, 1.0, MAX_CHARGED_POWER );
	pShot->SetPowerLevel( flDamageMult );

	m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
	m_iClip1 = m_iClip1 - 1;
	m_hLockTarget = NULL;
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponCombat_ChargeablePlasma::ItemPostFrame( void )
{
	CBaseTFPlayer *pOwner = ToBaseTFPlayer( GetOwner() );
	if (!pOwner)
		return;

	if ( UsesClipsForAmmo1() )
	{
		CheckReload();
	}

	// If burst shots are firing, ignore input
	if ( m_iBurstShotsRemaining > 0 )
	{
		if ( gpGlobals->curtime < m_flNextBurstShotTime )
			return;

		if ( m_iClip1 > 0 )
		{
			PrimaryAttack();
		}

		m_iBurstShotsRemaining--;
		m_flNextBurstShotTime = gpGlobals->curtime + BURST_FIRE_RATE;
		m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
		return;
	}

	// Handle charge firing
	if ( m_iClip1 > 0 && GetShieldState() == SS_DOWN && !m_bInReload )
	{
		if ( (pOwner->m_nButtons & IN_ATTACK ) )
		{
			if (m_bHasCharge)
			{
				if ( !m_bCharging && (m_flNextPrimaryAttack <= gpGlobals->curtime) )
				{
					m_bCharging = true;
					m_flChargeStartTime = gpGlobals->curtime;

					// Get a lock target right now
					m_hLockTarget = GetLockTarget();
				}
			}
			else
			{
				// Fire the plasma shot
				if (m_flNextPrimaryAttack <= gpGlobals->curtime)
					PrimaryAttack();
			}
		}
		else if ( m_bCharging )
		{
			m_bCharging = false;

			// Fire the plasma shot
			PrimaryAttack();

			// We might be firing a burst shot
			if (m_bHasBurstShot)
			{
				if ( m_flPower >= (MAX_CHARGED_TIME * 0.5) )
				{
					if ( m_flPower >= MAX_CHARGED_TIME )
					{
						m_iBurstShotsRemaining = 2;
					}
					else
					{
						m_iBurstShotsRemaining = 1;
					}

					m_flNextBurstShotTime = gpGlobals->curtime + BURST_FIRE_RATE;
				}
			}
		}
	}

	// Reload button
	if ( m_iBurstShotsRemaining == 0 && !m_bCharging )
	{
		if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload )
		{
			Reload();
		}
	}

	// Prevent shield post frame if we're not ready to attack, or we're charging
	AllowShieldPostFrame( !m_bCharging && ((m_flNextPrimaryAttack <= gpGlobals->curtime) || m_bInReload) );
}
コード例 #3
0
ファイル: Lock.cpp プロジェクト: DYZDNN/herodb
		bool LockManager::OperateObjectLock(
			BufferTransaction owner,
			TArgs arguments,
			PreLockHandler<TArgs> preLockHandler,
			TableLockHandler<TArgs> tableLockHandler,
			PageLockHandler<TArgs> pageLockHandler,
			RowLockHandler<TArgs> rowLockHandler,
			bool createLockInfo,
			bool checkPendingLock
			)
		{
			///////////////////////////////////////////////////////////
			// Check Input
			///////////////////////////////////////////////////////////

			const LockTarget& target = GetLockTarget(arguments);
			auto transInfo = CheckInputUnsafe(owner, target);
			if (!transInfo) return false;
			if (checkPendingLock && transInfo->pendingLock.IsValid())
			{
				return false;
			}

			if (preLockHandler)
			{
				bool stopped = false;
				bool success = (this->*preLockHandler)(transInfo, arguments, stopped);
				if (stopped)
				{
					return success;
				}
			}

			///////////////////////////////////////////////////////////
			// Initialize
			///////////////////////////////////////////////////////////

			Ptr<TableLockInfo> tableLockInfo;
			Ptr<PageLockInfo> pageLockInfo;
			Ptr<RowLockInfo> rowLockInfo;
			BufferPage targetPage;
			vuint64_t targetOffset = ~(vuint64_t)0;
			vint index = -1;

			///////////////////////////////////////////////////////////
			// Find TableLock
			///////////////////////////////////////////////////////////

			if (tableLocks.Count() <= target.table.index)
			{
				if (!createLockInfo)
				{
					return false;
				}
				tableLocks.Resize(target.table.index + 1);
			}

			tableLockInfo = tableLocks[target.table.index];
			if (!tableLockInfo)
			{
				if (!createLockInfo)
				{
					return false;
				}
				tableLockInfo = new TableLockInfo(target.table);
				tableLocks[target.table.index] = tableLockInfo;
			}

			///////////////////////////////////////////////////////////
			// Process TableLock
			///////////////////////////////////////////////////////////

			switch (target.type)
			{
			case LockTargetType::Table:
				return (this->*tableLockHandler)(transInfo, arguments, tableLockInfo);
			case LockTargetType::Page:
				targetPage = target.page;
				break;
			case LockTargetType::Row:
				CHECK_ERROR(bm->DecodePointer(target.address, targetPage, targetOffset), L"vl::database::LockManager::OperateObjectLock(BufferTransaction, const LockTarget&, LockResult&)#Internal error: Unable to decode row pointer.");
				break;
			}

			///////////////////////////////////////////////////////////
			// Find PageLock
			///////////////////////////////////////////////////////////

			index = tableLockInfo->pageLocks.Keys().IndexOf(targetPage);
			if (index == -1)
			{
				if (!createLockInfo)
				{
					return false;
				}
				pageLockInfo = new PageLockInfo(targetPage);
				tableLockInfo->pageLocks.Add(targetPage, pageLockInfo);
			}
			else
			{
				pageLockInfo = tableLockInfo->pageLocks.Values()[index];
			}

			///////////////////////////////////////////////////////////
			// Process PageLock
			///////////////////////////////////////////////////////////

			if (target.type == LockTargetType::Page)
			{
				return (this->*pageLockHandler)(transInfo, arguments, tableLockInfo, pageLockInfo);
			}

			///////////////////////////////////////////////////////////
			// Find RowLock
			///////////////////////////////////////////////////////////

			index = pageLockInfo->rowLocks.Keys().IndexOf(targetOffset);
			if (index == -1)
			{
				if (!createLockInfo)
				{
					return false;
				}
				rowLockInfo = new RowLockInfo(targetOffset);
				pageLockInfo->rowLocks.Add(targetOffset, rowLockInfo);
			}
			else
			{
				rowLockInfo = pageLockInfo->rowLocks.Values()[index];
			}

			///////////////////////////////////////////////////////////
			// Process RowLock
			///////////////////////////////////////////////////////////

			if (target.type == LockTargetType::Row)
			{
				return (this->*rowLockHandler)(transInfo, arguments, tableLockInfo, pageLockInfo, rowLockInfo);
			}

			return false;
		}