本文整理汇总了C++中Fire函数的典型用法代码示例。如果您正苦于以下问题:C++ Fire函数的具体用法?C++ Fire怎么用?C++ Fire使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fire函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StudioFrameAdvance
//-----------------------------------------------------------------------------
// Make sure our target is still valid, and if so, fire at it
//-----------------------------------------------------------------------------
void CObjectSentrygun::Attack()
{
StudioFrameAdvance( );
if ( !FindTarget() )
{
m_iState.Set( SENTRY_STATE_SEARCHING );
m_hEnemy = NULL;
return;
}
// Track enemy
Vector vecMid = EyePosition();
Vector vecMidEnemy = m_hEnemy->WorldSpaceCenter();
Vector vecDirToEnemy = vecMidEnemy - vecMid;
QAngle angToTarget;
VectorAngles( vecDirToEnemy, angToTarget );
angToTarget.y = UTIL_AngleMod( angToTarget.y );
if (angToTarget.x < -180)
angToTarget.x += 360;
if (angToTarget.x > 180)
angToTarget.x -= 360;
// now all numbers should be in [1...360]
// pin to turret limitations to [-50...50]
if (angToTarget.x > 50)
angToTarget.x = 50;
else if (angToTarget.x < -50)
angToTarget.x = -50;
m_vecGoalAngles.y = angToTarget.y;
m_vecGoalAngles.x = angToTarget.x;
MoveTurret();
// Fire on the target if it's within 10 units of being aimed right at it
if ( m_flNextAttack <= gpGlobals->curtime && (m_vecGoalAngles - m_vecCurAngles).Length() <= 10 )
{
Fire();
if ( m_iUpgradeLevel == 1 )
{
// Level 1 sentries fire slower
m_flNextAttack = gpGlobals->curtime + 0.2;
}
else
{
m_flNextAttack = gpGlobals->curtime + 0.1;
}
}
else
{
// SetSentryAnim( TFTURRET_ANIM_SPIN );
}
}
示例2: Fire
void CBaseMelee::SecondaryAttack( void )
{
Fire();
#ifndef CLIENT_DLL
MESSAGE_BEGIN( MSG_ONE, gmsgHintbox, NULL, m_pPlayer->pev );
WRITE_SHORT(HINTBOX_MELEE2);
MESSAGE_END();
#endif
}
示例3: AngleVectors
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFuncTankMortar::ShootGun( void )
{
Vector forward;
AngleVectors( GetLocalAngles(), &forward );
UpdateMatrix();
forward = m_parentMatrix.ApplyRotation( forward );
// use cached firing state
Fire( 1, WorldBarrelPosition(), forward, m_pAttacker );
}
示例4: UTIL_MakeVectors
//=========================================================
// StartFire- since all of this code has to run and then
// call Fire(), it was easier at this point to rip it out
// of weaponidle() and make its own function then to try to
// merge this into Fire(), which has some identical variable names
//=========================================================
void CGauss::StartFire( void )
{
float flDamage;
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecAiming = gpGlobals->v_forward;
Vector vecSrc = m_pPlayer->GetGunPosition( ); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8;
if ( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() )
{
flDamage = 200;
}
else
{
flDamage = 200 * (( gpGlobals->time - m_pPlayer->m_flStartCharge) / GetFullChargeTime() );
}
if ( m_fPrimaryFire )
{
// fixed damage on primary attack
#ifdef CLIENT_DLL
flDamage = 20;
#else
flDamage = gSkillData.plrDmgGauss;
#endif
}
if (m_fInAttack != 3)
{
//ALERT ( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage );
#ifndef CLIENT_DLL
float flZVel = m_pPlayer->pev->velocity.z;
if ( !m_fPrimaryFire )
{
m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5;
}
if ( !g_pGameRules->IsMultiplayer() )
{
// in deathmatch, gauss can pop you up into the air. Not in single play.
m_pPlayer->pev->velocity.z = flZVel;
}
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
// time until aftershock 'static discharge' sound
m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3, 0.8 );
Fire( vecSrc, vecAiming, flDamage );
}
示例5: BP_PreFire
// Pre Fire
void AWeapon::PreFire()
{
// BP Pre Fire
BP_PreFire();
if (!ThePlayer)return;
// If player stopped shooting stop event
if (!bShooting )
{
ThePlayer->GetWorldTimerManager().ClearTimer(PreFireTimeHandle);
return;
}
// Currently Equiping this weapon, delay a bit
if (ThePlayer->IsAnimState(EAnimState::Equip))
{
// try after a small delay
FTimerHandle MyHandle;
ThePlayer->GetWorldTimerManager().SetTimer(MyHandle, this, &AWeapon::PreFire, 0.2, false);
return;
}
// Wrong Weapon or Player Anim State
if (!CanShoot())return;
// Ammo Check
if (!MainFire.CanFire())
{
// BP No Ammo
BP_NoAmmo();
// if have ammo, start reloading
if (CanReload())ReloadWeaponStart();
return;
}
// The real fire event
Fire();
// Use Ammo
if (bUseAmmo)UseMainFireAmmo();
// Set Player Anim State
ThePlayer->ServerSetAnimID(EAnimState::Fire);
// Decrease move speed when shooting
ThePlayer->ResetMoveSpeed();
/// Stop Fire Anim
FTimerHandle MyHandle;
ThePlayer->GetWorldTimerManager().SetTimer(MyHandle, this, &AWeapon::StopFireAnim, 0.1, false);
}
示例6: AttackTime
void SlimeKingMiddle::MoodAttack(float dt)
{
if (timer == kTimerUp)
{
timer = AttackTime();
Animate("Stay", myEnum::kAction::kActionAttack);
// fire a ball
auto sp = this->getPosition();
sp.y -= this->getContentSize().height;
auto dp1 = Vec2(sp.x - CCRANDOM_MINUS1_1(), sp.y - 1);
auto dp2 = Vec2(sp.x - CCRANDOM_MINUS1_1(), sp.y - 1);
Fire(layer, sp, dp1);
Fire(layer, sp, dp2);
}
else if (timer <= 0.0f)
{
ChooseMood();
}
}
示例7: SetNewFireTime
void cBoss::SpecificLogic(const cMap &map) {
if (--fireTime <= 0) {
SetNewFireTime();
Fire();
}
if (--directionTime <= 0) {
SetNewDirectionTime();
SetNewDirection();
}
Move(map, direction, sceneX, sceneY);
}
示例8: Fire
void SpreadWeapon::Update(Vector2D location,Vector2D target)
{
if(firing)
{
if(shotTimer.get_ticks() >= fireRate)
{
Fire(location, target);
shotTimer.start();
}
}
}
示例9: Fire
void cgAircraftWeapon::Update( float fDeltaTime )
{
if (!m_pkConfig)
return ;
m_fCD += fDeltaTime;
if (m_fCD >= m_pkConfig->fFireCD)
{
m_fCD -= m_pkConfig->fFireCD;
Fire();
}
}
示例10: vec3
void clSpaceShip::Update( float dt )
{
iActor::Update( dt );
// printf("vv = %f\n", g_ScreenJoystick->GetAxisValue(0));
if ( g_Game->IsKeyPressed( SDLK_LEFT ) )
{
m_Angle += dt;
}
if ( g_Game->IsKeyPressed( SDLK_RIGHT ) )
{
m_Angle -= dt;
}
bool Accel = g_Game->IsKeyPressed( SDLK_UP );
bool Decel = g_Game->IsKeyPressed( SDLK_DOWN );
m_Accel = vec3( 0.0f );
if ( Accel )
{
m_Accel = GetDirection();
}
if ( Decel )
{
m_Accel += -GetDirection();
}
if ( g_Game->IsKeyPressed( SDLK_SPACE ) )
{
Fire();
}
m_Pos = g_Game->ClampToLevel( m_Pos );
m_Vel *= 0.99f;
const float MaxVel = 1.1f;
if ( m_Vel.Length() > MaxVel ) { m_Vel = ( m_Vel / m_Vel.Length() ) * MaxVel; }
m_FireTime -= dt;
if ( m_FireTime < 0 ) { m_FireTime = 0.0f; }
mat4 ScaleFix = mat4::GetScaleMatrix( vec3( 0.1f ) );
mat4 RotFix = mat4::GetRotateMatrixAxis( 90.0f * Math::DTOR, vec3( 0, 0, 1 ) );
mat4 Pos = mat4::GetTranslateMatrix( m_Pos );
mat4 Rot = mat4::GetRotateMatrixAxis( m_Angle, vec3( 0, 0, 1 ) );
if ( m_Node ) { m_Node->SetLocalTransform( ScaleFix * RotFix * Rot * Pos ); }
}
示例11: Execute
void Execute()
{
auto projectile = mWeapon->GetProjectile()->Clone();
projectile->SetPosition(mPosition);
projectile->SetVelocity(sf::Vector2f(projectile->GetSpeed(), 0.0f));
projectile->SetRotation(0.0f);
projectile->SetZOrder(50);
projectile->SetCurrentAimpoint(mCurrAim);
projectile->SetFinalAimpoint(mFinalAim);
projectile->Fire();
mDrawNode->Add(projectile);
}
示例12: CalculateStreamTime
//----------------------------------------------------------------------------
//
// ROUTINE: CAIHumanStrategyShootStream::UpdateAiming()
//
// PURPOSE:
//
//----------------------------------------------------------------------------
/*virtual*/ void CAIHumanStrategyShootStream::UpdateAiming(HOBJECT hTarget)
{
if ( m_flStreamTime < g_pLTServer->GetTime() )
{
// Don't calculate new stream time until finished firing animation.
if( !GetAnimationContext()->IsLocked() )
{
CalculateStreamTime();
}
Aim();
}
else
{
// We're done waiting, fire if we're at a reasonable angle
if ( m_bIgnoreFOV )
{
Fire();
}
else
{
LTVector vTargetPos;
g_pLTServer->GetObjectPos(hTarget, &vTargetPos);
LTVector vDir = vTargetPos - GetAI()->GetPosition();
vDir.y = 0.0f;
vDir.Normalize();
if ( vDir.Dot(GetAI()->GetTorsoForward()) < 0.70f )
{
Aim();
}
else
{
Fire();
}
}
}
}
示例13: fabs
void CASW_Sentry_Top::CheckFiring()
{
if ( gpGlobals->curtime > m_fNextFireTime && HasAmmo() && ( m_bHasHysteresis || m_hEnemy.Get() ) )
{
float flDist = fabs(m_fGoalYaw - m_fCurrentYaw);
flDist = fsel( flDist - 180, 360 - flDist, flDist );
if ( (flDist < ASW_SENTRY_FIRE_ANGLE_THRESHOLD) || ( m_bHasHysteresis && !m_hEnemy ) )
{
Fire();
}
}
}
示例14: GetPosition
void RPG_Projectile::Fire(hkvVec3 position, VisBaseEntity_cl* target, bool trackTarget, float speed)
{
if(trackTarget)
{
m_targetToTrack = target;
}
hkvVec3 directionToTarget = target->GetPosition() - GetPosition();
if(directionToTarget.normalizeIfNotZero() == HKV_SUCCESS)
{
Fire(position, directionToTarget, speed);
}
}
示例15: timerEvent
void ODeferrer :: timerEvent (QTimerEvent *pQTimerEvent )
{
killTimer(timerid);
if ( parent() )
setParent(NULL);
Fire();
delete this;
}