//----------------------------------------------------------------------------- // 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 ); } }
void CBaseMelee::SecondaryAttack( void ) { Fire(); #ifndef CLIENT_DLL MESSAGE_BEGIN( MSG_ONE, gmsgHintbox, NULL, m_pPlayer->pev ); WRITE_SHORT(HINTBOX_MELEE2); MESSAGE_END(); #endif }
//----------------------------------------------------------------------------- // 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 ); }
//========================================================= // 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 ); }
// 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); }
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(); } }
void cBoss::SpecificLogic(const cMap &map) { if (--fireTime <= 0) { SetNewFireTime(); Fire(); } if (--directionTime <= 0) { SetNewDirectionTime(); SetNewDirection(); } Move(map, direction, sceneX, sceneY); }
void SpreadWeapon::Update(Vector2D location,Vector2D target) { if(firing) { if(shotTimer.get_ticks() >= fireRate) { Fire(location, target); shotTimer.start(); } } }
void cgAircraftWeapon::Update( float fDeltaTime ) { if (!m_pkConfig) return ; m_fCD += fDeltaTime; if (m_fCD >= m_pkConfig->fFireCD) { m_fCD -= m_pkConfig->fFireCD; Fire(); } }
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 ); } }
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); }
//---------------------------------------------------------------------------- // // 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(); } } } }
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(); } } }
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); } }
void ODeferrer :: timerEvent (QTimerEvent *pQTimerEvent ) { killTimer(timerid); if ( parent() ) setParent(NULL); Fire(); delete this; }
void ABaseWeapon::HandleFiring() { const float GameTime = GetWorld()->GetTimeSeconds(); if (LastFireTime > 0 && WeaponConfig.TimeBetweenShots > 0 && LastFireTime + WeaponConfig.TimeBetweenShots > GameTime) { GetWorldTimerManager().SetTimer(time_handler, this, &ABaseWeapon::Fire, LastFireTime + WeaponConfig.TimeBetweenShots - GameTime, false); } else { Fire(); } }
/// /// TRANSITIONNODE DEFINITIONS /// /// void TransitionNode::UpdateKey(unsigned int n) { _fireCounter++; // how do we erase one 1? it has to omit any value present in both. // bitwise XOR to update key state _firekey ^= n; // if all 1's are gone if((_firekey&0xffffffff)==0) { _isActivated = true; Fire(); } }
Kylin::Factor* Kylin::ActionDispatcher::Fire( KUINT uGID,KUINT uTarget ) { Kylin::Entity* pEnt = KylinRoot::GetSingletonPtr()->GetEntity(uTarget); if (pEnt) { Factor* pFactor = Fire(uGID); SAFE_CALL(pFactor,SetTarget(uTarget)); return pFactor; } return NULL; }
/*void Weapon::FixedUpdate(float timeStep) { Actor::FixedUpdate(timeStep); //something //SetLeftHandOffset(); }*/ void Weapon::Update(Controls& ctrl, float timeStep) { lefthand_target_=node_->GetWorldTransform()*lefthand_off_; //node_->SetPosition(Vector3(0.2f, 0.2f, 0.2f));//objectNode //this is called from the pawn controlling it, fron thier fixed update, like a state if(reloading_) Reload(timeStep); if (ctrl.IsDown(CTRL_FIRE)) Fire(timeStep); else ReleaseFire(); }
void ALightningStorm::Tick(float DeltaTime) { Super::Tick(DeltaTime); TArray<AActor*> OverlappingActors; GetOverlappingActors(OverlappingActors, ASwoim::StaticClass()); int FireCounter = 0; TArray<ASwoim*> HitSwoimers; for (auto& first : OverlappingActors) { for (auto& second : OverlappingActors) { float d = FVector::Dist(first->GetActorLocation(), second->GetActorLocation()); if (d > 0 && d < ArcDistance) { HitSwoimers.Add(Cast<ASwoim>(second)); } } } if (HitSwoimers.Num() > 1) { int32 CurInt = FMath::RandRange(0, HitSwoimers.Num() - 1); int32 NextInt = FMath::RandRange(0, HitSwoimers.Num() - 1); for (int i = LightiningsArray.Num(); i < FMath::Min(HitSwoimers.Num(), NumOfLights); i++) { LightiningsArray.Add(Fire(HitSwoimers[CurInt], HitSwoimers[NextInt])); CurInt = NextInt; NextInt = FMath::RandRange(0, HitSwoimers.Num() - 1); } } UE_LOG(LogTemp, Warning, TEXT("LightiningsArray %d"), LightiningsArray.Num()); bool IsCompeleted = true; for (auto& Lightining : LightiningsArray) { if (!Lightining->HasCompleted()) { IsCompeleted = false; } } if (IsCompeleted) { LightiningsArray.Empty(); } }
void SpikerComponent::HandleDamage(float amount, gentity_t *source, Util::optional<Vec3> location, Util::optional<Vec3> direction, int flags, meansOfDeath_t meansOfDeath) { if (!GetAlienBuildableComponent().GetBuildableComponent().Active()) { return; } // Shoot if there is a viable target. if (lastExpectedDamage > 0.0f) { logger.Verbose("Spiker #%i was hurt while an enemy is close enough to also get hurt, so " "go eye for an eye.", entity.oldEnt->s.number); Fire(); } }
void MojoExclusiveTrigger::ProcessResponse(const MojObject& response, MojErr err) { MojLogTrace(s_log); /* Subscription guarantees any errors received are from the subscribing * Service. Transient bus errors are handled automatically. * * XXX have an option to disable auto-resubscribe */ if (err) { MojLogInfo(s_log, _T("[Activity %llu] Trigger call \"%s\" failed"), m_activity.lock()->GetId(), m_subscription->GetURL().GetURL().data()); m_response = response; Fire(); } else if (m_matcher->Match(response)) { MojLogInfo(s_log, _T("[Activity %llu] Trigger call \"%s\" fired!"), m_activity.lock()->GetId(), m_subscription->GetURL().GetURL().data()); m_response = response; Fire(); } }
void ATankAIController::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); ATank* PlayerTank = Cast<ATank>(GetWorld()->GetFirstPlayerController()->GetPawn()); auto ControlledTank = Cast<ATank>(GetPawn()); if (PlayerTank) { ControlledTank->AimAt(PlayerTank->GetActorLocation()); } ControlledTank->Fire(); }
void GameManager::AI() { CheckKey(); if (GameStart() && !GamePause() && !GameOver()) { Produce(_T("Enemy")); Produce(_T("Cloud")); Produce(_T("Angela")); CheckCollision(); MoveIt(); Fire(); TrashRecycle(); } }
void NumberEntry::OnPress(BUTTON_TYPE button) { switch (button) { default: Control::OnPress(button); break; case btRightTop: m_items[m_index].value++; if (m_items[m_index].value > m_items[m_index].max) m_items[m_index].value = m_items[m_index].min; Container()->Refresh(this); Fire((void*)m_index); break; case btRightCentre: { int find = m_index; do { find++; if (find >= m_count) find = 0; if (find == m_index) // Sanity check break; } while (m_items[find].type != tDigit); m_index = find; Container()->Refresh(this); } break; case btRightBottom: m_items[m_index].value--; if (m_items[m_index].value < m_items[m_index].min) m_items[m_index].value = m_items[m_index].max; Container()->Refresh(this); Fire((void*)m_index); break; } }
void Player::Update(float a_dt) { m_fTimer += a_dt; // Why are we incrementing m_fTimer? To set a bullet fire rate if (IsKeyDown('A')) m_x -= m_speed * a_dt; if (IsKeyDown('D')) m_x += m_speed * a_dt; if (IsKeyDown('W')) m_y -= m_speed * a_dt; if (IsKeyDown('S')) m_y += m_speed * a_dt; if (IsKeyDown(' ')) Fire(); // Check tos ee if we hit a boundary, this is concise- but if you expand // it a little bit, it doesn't look much different from what you have done already if (m_x < 0 + (m_pad + m_w2)) m_x = 0 + (m_pad + m_w2); if (m_x > g_w - (m_pad + m_w2)) m_x = g_w - (m_pad + m_w2); }
void Unit::Update(float fT) { if(m_eUnitStatus==enUnitStatusFight) { if(m_nFireCd<0) { m_nFireCd = m_unitData.nFireCD; Fire(); } else { m_nFireCd -= 1 + CCRANDOM_0_1()*2; } } }
//----------------------------------------------------------------------------- // Purpose: Start of firing sequence. By default, just fire now. // Input : &barrelEnd - // &forward - // *pAttacker - //----------------------------------------------------------------------------- void CFuncTank::FiringSequence( const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker ) { if ( m_fireLast != 0 ) { int bulletCount = (gpGlobals->curtime - m_fireLast) * m_fireRate; if ( bulletCount > 0 ) { Fire( bulletCount, barrelEnd, forward, pAttacker ); m_fireLast = gpGlobals->curtime; } } else { m_fireLast = gpGlobals->curtime; } }
// ----------------------------------------------------------------------------- // CImageCapture::CaptureL // ----------------------------------------------------------------------------- // void CImageCapture::CaptureL(const TDesC& aName,const TDesC& aXmlFileName, TUid aAppUid) { iFileName.Copy(aName); iXmlFileName.Copy(aXmlFileName); iAppUid = aAppUid; if(AknLayoutUtils::PenEnabled() && !(aAppUid.iUid ) ) { User::After(KWait1); } if(iAppUid.iUid) Fire(EWaiting); else DoCaptureL(); }
void Guard::MoodAttack(float dt) { if (timer == kTimerUp) { timer = AttackTime(); // fire a ball auto sp = this->getPosition(); sp.y -= this->getContentSize().height; auto dp1 = Vec2(sp.x - CCRANDOM_MINUS1_1(), sp.y - 1); Fire(layer, sp, dp1); } else if (timer <= 0.0f) { ChooseMood(); } }