void hhCenturion::AimedAttackMissile( const char *jointname, const idDict *projDef) { idProjectile *proj; idVec3 target, origin = GetOrigin(); bool inShuttle = false; if ( shootTarget.IsValid() ) { target = shootTarget->GetOrigin(); } else if ( enemy.IsValid() ) { target = enemy->GetOrigin(); if ( enemy->IsType( idActor::Type ) ) { target.z += enemy->EyeHeight() / 4.0f; } } else { // No target? Do the default attack Event_AttackMissile( jointname, projDef, 1 ); return; } // If target is too close do a non-aimed attack if ( fabsf( origin.x - target.x ) < 256 && fabsf( origin.y - target.y ) < 256 ) { Event_AttackMissile( jointname, projDef, 1 ); return; } idVec3 dist = origin - target; if ( shootTarget.IsValid() ) { proj = LaunchProjectile( jointname, shootTarget.GetEntity(), true, projDef ); } else { proj = LaunchProjectile( jointname, enemy.GetEntity(), true, projDef ); } }
void UTankAimingComponent::Fire() { if (FiringState == EFiringState::Locked || FiringState == EFiringState::Aiming) { if (!ensure(Barrel)) { return; } if (!ensure(ProjectileBlueprint)) { return; } auto Projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileBlueprint, Barrel->GetSocketLocation(FName("Projectile")), Barrel->GetSocketRotation(FName("Projectile"))); Projectile->LaunchProjectile(LaunchSpeed); LastFireTime = FPlatformTime::Seconds(); RoundsLeft--; } }
void UTankAimingComponent::Fire() { //UE_LOG(LogTemp, Warning, TEXT("Firing!")); //bool isReloaded = (FPlatformTime::Seconds() - lastFireTime) > reloadTimeInSeconds; //UE_LOG(LogTemp, Warning, TEXT("trying to Firing")) if (firingState != EFiringStatus::Reloading && ammoCount != 0) { // Spawn a projectile at the socket location auto projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileBlueprint, barrel->GetSocketLocation(FName("canonTip")), barrel->GetSocketRotation(FName("canonTip"))); projectile->LaunchProjectile(launchSpeed); lastFireTime = FPlatformTime::Seconds(); ammoCount -= 1; UE_LOG(LogTemp, Warning, TEXT("Ammo at %i"),ammoCount) }
//----------------------------------------------------------------------------- // Purpose: Primary fire function //----------------------------------------------------------------------------- void CTFFlareGun::PrimaryAttack(void) { // Check for ammunition. if (m_iClip1 <= 0 && m_iClip1 != -1) return; // Are we capable of firing again? if (m_flNextPrimaryAttack > gpGlobals->curtime) return; if (!CanAttack()) return; m_iWeaponMode = TF_WEAPON_PRIMARY_MODE; LaunchProjectile(); }
bool TankGob::Fire(UnitGob *puntTarget, WCoord wx, WCoord wy, WCoord wdx, WCoord wdy) { Direction16 dir16Fire = CalcDir16(wdx, wdy); if (m_dir16Turret != dir16Fire) { m_unvl.MinSkip(); return false; } // Firing rate is limited by ctFiringRate long t = gsim.GetTickCount(); long ctWait = m_pmuntc->ctFiringRate; long ctRemaining = ctWait - (t - m_tLastFire); if (ctRemaining > 0) { m_unvl.MinSkip((ctRemaining + (kctUpdate / 2)) / kctUpdate - 1); return false; } m_tLastFire = t; // Play firing animation (start on frame 1 where the action is) StartAnimation(&m_aniTurret, m_pmuntc->anFiringStripIndices[dir16Fire], kifrmTankAction, kfAniIgnoreFirstAdvance | kfAniResetWhenDone); m_wfMunt |= kfMuntFiring; gsmm.SendDelayedMsg(kmidFireComplete, m_aniTurret.GetRemainingStripTime(), m_gid, m_gid); // Fire off the shot! WCoord wdxRnd = ((GetRandom() & 7) - 3) * kwcTile16th; WCoord wdyRnd = ((GetRandom() & 7) - 3) * kwcTile16th; Point ptSpecial; m_aniTurret.GetSpecialPoint(&ptSpecial, kifrmTankAction); LaunchProjectile(m_wx + WcFromPc(ptSpecial.x), m_wy + WcFromPc(ptSpecial.y), wx + wdxRnd, wy + wdyRnd, GetDamageTo(puntTarget), m_gid, puntTarget->GetId()); // Play sound gsndm.PlaySfx(m_pmuntc->sfxFire); return true; }
void ATank::Fire() { if (!ensure(Barrel)) { return; } bool isReloaded = (FPlatformTime::Seconds() - LastFireTime) > ReloadTimeInSec; if (isReloaded) { // spawn projectile at socket location on barrel auto Projectile = GetWorld()->SpawnActor<AProjectile>( ProjectileBlueprint, Barrel->GetSocketLocation(FName("Projectile")), Barrel->GetSocketRotation(FName("Projectile")) ); Projectile->LaunchProjectile(LaunchSpeed); LastFireTime = FPlatformTime::Seconds(); } }
void UTankAimingComponent::Fire() { if ((FiringState == EFiringState::Aiming)||(FiringState == EFiringState::Lock)) { //Spawn a projectile from the socket location //We return the projectile into a variable called 'projectile' than call the mtehod launchProjectile if (!ensure(Barrel)) { return; } if (!ensure(ProjectileBlueprint)) { return; } auto projectile = GetWorld()->SpawnActor<AProjectile>( ProjectileBlueprint, Barrel->GetSocketLocation(FName("Projectile")), Barrel->GetSocketRotation(FName("Projectile")) ); //Calling launchProjectile projectile->LaunchProjectile(LaunchSpeed); LastFireTime = FPlatformTime::Seconds(); RoundsLeft--; } }
//----------------------------------------------------------------------------- // Purpose: Crane rotates around with +left and +right, and extends/retracts // the cable with +forward and +back. //----------------------------------------------------------------------------- void CPropCannon::DriveCannon( int iDriverButtons, int iButtonsPressed ) { bool bWasExtending = m_bExtending; // Handle rotation of the crane if ( iDriverButtons & IN_MOVELEFT ) { // Try adding some randomness to make it feel shaky? float flTurnAdd = m_flTurnAccel; // If we're turning back on ourselves, use decel speed if ( m_flTurn < 0 ) { flTurnAdd = MAX( flTurnAdd, m_flTurnDecel ); } m_flTurn = UTIL_Approach( m_flMaxTurnSpeed, m_flTurn, flTurnAdd * gpGlobals->frametime ); m_iTurning = CANNON_TURNING_LEFT; } else if ( iDriverButtons & IN_MOVERIGHT ) { // Try adding some randomness to make it feel shaky? float flTurnAdd = m_flTurnAccel; // If we're turning back on ourselves, increase the rate if ( m_flTurn > 0 ) { flTurnAdd = MAX( flTurnAdd, m_flTurnDecel ); } m_flTurn = UTIL_Approach( -m_flMaxTurnSpeed, m_flTurn, flTurnAdd * gpGlobals->frametime ); m_iTurning = CANNON_TURNING_RIGHT; } else { m_flTurn = UTIL_Approach( 0, m_flTurn, m_flTurnDecel * gpGlobals->frametime ); m_iTurning = CANNON_TURNING_NOT; } SetLocalAngularVelocity( QAngle(0,m_flTurn * 10,0) ); // Handle extension / retraction of the arm if ( iDriverButtons & IN_FORWARD ) { m_flExtensionRate = UTIL_Approach( m_flMaxExtensionSpeed, m_flExtensionRate, m_flExtensionAccel * gpGlobals->frametime ); m_bExtending = true; } else if ( iDriverButtons & IN_BACK ) { m_flExtensionRate = UTIL_Approach( -m_flMaxExtensionSpeed, m_flExtensionRate, m_flExtensionAccel * gpGlobals->frametime ); m_bExtending = true; } else { m_flExtensionRate = UTIL_Approach( 0, m_flExtensionRate, m_flExtensionDecel * gpGlobals->frametime ); m_bExtending = false; } //Msg("Turn: %f\nExtensionRate: %f\n", m_flTurn, m_flExtensionRate ); //If we're holding down an attack button, update our state if ( iButtonsPressed & (IN_ATTACK | IN_ATTACK2) ) { if ( m_flNextAttackTime <= gpGlobals->curtime ) { LaunchProjectile(); } } float flSpeedPercentage = clamp( fabs(m_flTurn) / m_flMaxTurnSpeed, 0, 1 ); vbs_sound_update_t params; params.Defaults(); params.bThrottleDown = (m_iTurning != CANNON_TURNING_NOT); params.flCurrentSpeedFraction = flSpeedPercentage; params.flWorldSpaceSpeed = 0; m_ServerVehicle.SoundUpdate( params ); // Play sounds for arm extension / retraction if ( m_bExtending && !bWasExtending ) { m_ServerVehicle.StopSound( VS_ENGINE2_STOP ); m_ServerVehicle.PlaySound( VS_ENGINE2_START ); } else if ( !m_bExtending && bWasExtending ) { m_ServerVehicle.StopSound( VS_ENGINE2_START ); m_ServerVehicle.PlaySound( VS_ENGINE2_STOP ); } }
virtual uint32_t LaunchProjectileAtPoint(entity_id_t source, CFixedVector3D target, fixed speed, fixed gravity) { return LaunchProjectile(source, target, speed, gravity); }
virtual void LaunchProjectileAtPoint(entity_id_t source, CFixedVector3D target, fixed speed, fixed gravity) { LaunchProjectile(source, target, INVALID_ENTITY, speed, gravity); }
virtual void LaunchProjectileAtEntity(entity_id_t source, entity_id_t target, fixed speed, fixed gravity) { LaunchProjectile(source, CFixedVector3D(), target, speed, gravity); }