Esempio n. 1
0
void AWeapon::Fire(AMainCharacter* pWeaponOwner)
{
	WeaponOwner = pWeaponOwner;

	if (Config.AmmoCostPerShot <= Config.CurrentMagazineAmmo && Config.CurrentMagazineAmmo > 0)
	{
		if (ProjectileType == EWeaponProjectile::EBullet)
		{
			FireProjectile();
			PlayWeaponSound(FireSound);
			Config.CurrentMagazineAmmo -= Config.AmmoCostPerShot;
		}
		if (ProjectileType == EWeaponProjectile::EShell)
		{
			for (int32 i = 0; i <= Config.SlugsPerShell; i++)
			{
				FireProjectile();
			}
			Config.CurrentMagazineAmmo -= Config.AmmoCostPerShot;
			PlayWeaponSound(FireSound);
		}
		if (ProjectileType == EWeaponProjectile::ERocket)
		{
		}
	}
}
void AWeapon::Fire()
{
	if (ProjectileType == EWeaponProjectile::EBullet)
	{
		if (CurrentClip > 0)
		{
			GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Bullet"));
			Instant_Fire();
			PlayWeaponSound(FireSound);
			CurrentClip -= WeaponConfig.ShotCost;
		}
		else
		{
			ReloadAmmo();
		}
	}
	if (ProjectileType == EWeaponProjectile::ESpread)
	{
		if (CurrentClip > 0)
		{
			GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Spread"));
			for (int32 i = 0; i <= WeaponConfig.WeaponSpread; i++)
			{
				Instant_Fire();
			}
			PlayWeaponSound(FireSound);
			CurrentClip -= WeaponConfig.ShotCost;
		}
		else
		{
			ReloadAmmo();
		}
	}
	if (ProjectileType == EWeaponProjectile::EProjectile)
	{
		if (CurrentClip > 0)
		{
			GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Projectile"));
			ProjectileFire();
			PlayWeaponSound(FireSound);
			CurrentClip -= WeaponConfig.ShotCost;
		}
		else
		{
			ReloadAmmo();
		}
	}
}
void ASWeapon::StartReload(bool bFromReplication)
{
	/* Push the request to server */
	if (!bFromReplication && Role < ROLE_Authority)
	{
		ServerStartReload();
	}

	/* If local execute requested or we are running on the server */
	if (bFromReplication || CanReload())
	{
		bPendingReload = true;
		DetermineWeaponState();

		float AnimDuration = PlayWeaponAnimation(ReloadAnim);
		if (AnimDuration <= 0.0f)
		{
			AnimDuration = NoAnimReloadDuration;
		}

		GetWorldTimerManager().SetTimer(TimerHandle_StopReload, this, &ASWeapon::StopSimulateReload, AnimDuration, false);
		if (Role == ROLE_Authority)
		{
			GetWorldTimerManager().SetTimer(TimerHandle_ReloadWeapon, this, &ASWeapon::ReloadWeapon, FMath::Max(0.1f, AnimDuration - 0.1f), false);
		}

		if (MyPawn && MyPawn->IsLocallyControlled())
		{
			PlayWeaponSound(ReloadSound);
		}
	}
}
void AShooterWeapon::StartReload(bool bFromReplication)
{
	if (!bFromReplication && Role < ROLE_Authority)
	{
		ServerStartReload();
	}

	if (bFromReplication || CanReload())
	{
		bPendingReload = true;
		DetermineWeaponState();

		float AnimDuration = PlayWeaponAnimation(ReloadAnim);		
		if (AnimDuration <= 0.0f)
		{
			AnimDuration = WeaponConfig.NoAnimReloadDuration;
		}

		GetWorldTimerManager().SetTimer(TimerHandle_StopReload, this, &AShooterWeapon::StopReload, AnimDuration, false);
		if (Role == ROLE_Authority)
		{
			GetWorldTimerManager().SetTimer(TimerHandle_ReloadWeapon, this, &AShooterWeapon::ReloadWeapon, FMath::Max(0.1f, AnimDuration - 0.1f), false);
		}
		
		if (MyPawn && MyPawn->IsLocallyControlled())
		{
			PlayWeaponSound(ReloadSound);
		}
	}
}
Esempio n. 5
0
// Cosmetics - FX of weapon firing effect, sound and camera shaking
void AWeapon::SimulateWeaponFire()
{
	// muzzle particle FX
	if (MuzzleFX)
	{
		if (MuzzlePSC == NULL)
		{
			MuzzlePSC = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, Mesh1P, WeaponConfig.MuzzleAttachPoint);
		}
	}

	// sound
	if (FireAC == NULL)
	{
		FireAC = PlayWeaponSound(FireLoopSound);
	}

	// camera shake on firing
	AHeliPlayerController* PC = (MyPawn != NULL) ? Cast<AHeliPlayerController>(MyPawn->Controller) : NULL;
	if (PC != NULL && PC->IsLocalController())
	{
		if (FireCameraShake != NULL)
		{
			PC->ClientPlayCameraShake(FireCameraShake, 1);
		}
	}

}
void AShooterWeapon::OnEquip(const AShooterWeapon* LastWeapon)
{
	AttachMeshToPawn();

	bPendingEquip = true;
	DetermineWeaponState();

	// Only play animation if last weapon is valid
	if (LastWeapon)
	{
		float Duration = PlayWeaponAnimation(EquipAnim);
		if (Duration <= 0.0f)
		{
			// failsafe
			Duration = 0.5f;
		}
		EquipStartedTime = GetWorld()->GetTimeSeconds();
		EquipDuration = Duration;

		GetWorldTimerManager().SetTimer(TimerHandle_OnEquipFinished, this, &AShooterWeapon::OnEquipFinished, Duration, false);
	}
	else
	{
		OnEquipFinished();
	}

	if (MyPawn && MyPawn->IsLocallyControlled())
	{
		PlayWeaponSound(EquipSound);
	}
}
void AShooterWeapon::StopSimulatingWeaponFire()
{
	if (bLoopedMuzzleFX )
	{
		if( MuzzlePSC != NULL )
		{
			MuzzlePSC->DeactivateSystem();
			MuzzlePSC = NULL;
		}
		if( MuzzlePSCSecondary != NULL )
		{
			MuzzlePSCSecondary->DeactivateSystem();
			MuzzlePSCSecondary = NULL;
		}
	}

	if (bLoopedFireAnim && bPlayingFireAnim)
	{
		StopWeaponAnimation(FireAnim);
		bPlayingFireAnim = false;
	}

	if (FireAC)
	{
		FireAC->FadeOut(0.1f, 0.0f);
		FireAC = NULL;

		PlayWeaponSound(FireFinishSound);
	}
}
Esempio n. 8
0
void AWeapon::OnStopFire() {


    FireAC->Stop();
    PlayWeaponSound(FireFinishSound);
    MuzzleSC->DeactivateSystem();
}
void ASWeapon::OnEquip(bool bPlayAnimation)
{
	bPendingEquip = true;
	DetermineWeaponState();

	if (bPlayAnimation)
	{
		float Duration = PlayWeaponAnimation(EquipAnim);
		if (Duration <= 0.0f)
		{
			// Failsafe in case animation is missing
			Duration = NoEquipAnimDuration;
		}
		EquipStartedTime = GetWorld()->TimeSeconds;
		EquipDuration = Duration;

		GetWorldTimerManager().SetTimer(EquipFinishedTimerHandle, this, &ASWeapon::OnEquipFinished, Duration, false);
	}
	else
	{
		/* Immediately finish equipping */
		OnEquipFinished();
	}

	if (MyPawn && MyPawn->IsLocallyControlled())
	{
		PlayWeaponSound(EquipSound);
	}
}
Esempio n. 10
0
void AAWeapon::HandleFiring()
{
	if (CurrentAmmoInClip > 0 && CanFire())
	{
		if (GetNetMode() != NM_DedicatedServer)
		{
			SimulateWeaponFire();
		}

		if (MyPawn && MyPawn->IsLocallyControlled())
		{
			FireWeapon();

			UseAmmo();

			BurstCounter++;
		}
	}
	else if (CanReload())
	{
		StartReload();
	}
	else if (MyPawn && MyPawn->IsLocallyControlled())
	{
		if (GetCurrentAmmo() == 0 && !bRefiring)
		{
			PlayWeaponSound(OutOfAmmoSound);
		}

		/* Reload after firing last round */
		if (CurrentAmmoInClip <= 0 && CanReload())
		{
			StartReload();
		}

		/* Stop weapon fire FX, but stay in firing state */
		if (BurstCounter > 0)
		{
			OnBurstFinished();
		}
	}

	if (MyPawn && MyPawn->IsLocallyControlled())
	{
		if (Role < ROLE_Authority)
		{
			ServerHandleFiring();
		}

		/* Retrigger HandleFiring on a delay for automatic weapons */
		bRefiring = (CurrentState == EWeaponState::Firing && TimeBetweenShots > 0.0f);
		if (bRefiring)
		{
			GetWorldTimerManager().SetTimer(TimerHandle_HandleFiring, this, &AAWeapon::HandleFiring, TimeBetweenShots, false);
		}
	}

	LastFireTime = GetWorld()->GetTimeSeconds();
}
Esempio n. 11
0
void AFournoidWeapon::PlayShootingFX_Implementation()
{
	if ( GetNetMode() != NM_DedicatedServer )
	{
		PlayWeaponSound(FireSound);
		PlayFireAnimation();
	}
}
Esempio n. 12
0
void ASWeapon::SimulateWeaponFire()
{
	if (MuzzleFX)
	{
		MuzzlePSC = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, Mesh, MuzzleAttachPoint);	
	}

	if (!bPlayingFireAnim)
	{
		PlayWeaponAnimation(FireAnim);
		bPlayingFireAnim = true;
	}

	PlayWeaponSound(FireSound);
}
LTBOOL CPlayerSoundFX::CreateObject(ILTClient *pClientDE)
{
    if (!CSpecialFX::CreateObject(pClientDE)) return LTFALSE;

    uint32 dwId;
    if (m_pClientDE->GetLocalClientID(&dwId) != LT_OK) return LTFALSE;

	// Don't play sounds for this client...

    if (int(dwId) == m_nClientId) return LTFALSE;

	PlayerSoundId eSndType = (PlayerSoundId)m_nType;

	if (::IsWeaponSound(eSndType))
	{
		WEAPON* pWeapon = g_pWeaponMgr->GetWeapon(m_nWeaponId);
		if (!pWeapon) return LTFALSE;

		PlayWeaponSound(pWeapon, m_vPos, (PlayerSoundId)m_nType);
	}
	else
	{
		switch (eSndType)
		{
			case PSI_JUMP :
			{
				char* pSounds[] = { "Chars\\Snd\\jump1.wav", "Chars\\Snd\\jump2.wav" };
				g_pClientSoundMgr->PlaySoundFromPos(m_vPos, pSounds[GetRandom(0,1)], 1000.0f,
					SOUNDPRIORITY_MISC_HIGH);
			}
			break;

			case PSI_LAND :
			{
				char* pSounds[] = { "Chars\\Snd\\player\\landing1.wav", "Chars\\Snd\\player\\landing2.wav" };
				g_pClientSoundMgr->PlaySoundFromPos(m_vPos, pSounds[GetRandom(0,1)], 1000.0f,
					SOUNDPRIORITY_MISC_HIGH);
			}
			break;

			default : break;
		}
	}


    return LTFALSE;  // Delete me, I'm done :)
}
Esempio n. 14
0
void AWeapon::StopSimulatingWeaponFire()
{

	if (MuzzlePSC != NULL)
	{
		MuzzlePSC->DeactivateSystem();
		MuzzlePSC = NULL;
	}

	if (FireAC)
	{
		FireAC->FadeOut(0.1f, 0.0f);
		FireAC = NULL;

		PlayWeaponSound(FireFinishSound);
	}
}
Esempio n. 15
0
void AFournoidWeapon::StartFire()
{
	if ( MyPawn->IsFirstPerson() && (IsClipEmpty() && IsStoreEmpty()) )
	{
		PlayWeaponSound(EmptySound);
		return;
	}
	
	if ( Role < ROLE_Authority )
	{
		ServerStartFire();
		return;
	}
	
	if ( CurrentState == WeaponState::WS_Idle )
	{
    	SetWeaponState(WeaponState::WS_Firing);
	}
}
Esempio n. 16
0
void ASWeapon::SimulateWeaponFire()
{
	if (MuzzleFX)
	{
		MuzzlePSC = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, Mesh, MuzzleAttachPoint);	
	}

	if (!bPlayingFireAnim)
	{
		PlayWeaponAnimation(FireAnim);
		bPlayingFireAnim = true;
	}

	PlayWeaponSound(FireSound);

	// 	ASPlayerController* PC = (MyPawn != nullptr) ? Cast<ASPlayerController>(MyPawn->Controller) : nullptr;
	// 	if (PC && PC->IsLocalController())
	// 	{
	// 		// TODO: Add camera roll oscillation
	// 	}
}
Esempio n. 17
0
void ASWeapon::OnEquip()
{
	AttachMeshToPawn();

	bPendingEquip = true;
	DetermineWeaponState();

	float Duration = PlayWeaponAnimation(EquipAnim);
	if (Duration <= 0.0f)
	{
		// Failsafe
		Duration = 0.5f;
	}
	EquipStartedTime = GetWorld()->TimeSeconds;
	EquipDuration = Duration;

	GetWorldTimerManager().SetTimer(EquipFinishedTimerHandle, this, &ASWeapon::OnEquipFinished, Duration, false);

	if (MyPawn && MyPawn->IsLocallyControlled())
	{
		PlayWeaponSound(EquipSound);
	}
}
void AShooterWeapon::SimulateWeaponFire()
{
	if (Role == ROLE_Authority && CurrentState != EWeaponState::Firing)
	{
		return;
	}

	if (MuzzleFX)
	{
		USkeletalMeshComponent* UseWeaponMesh = GetWeaponMesh();
		if (!bLoopedMuzzleFX || MuzzlePSC == NULL)
		{
			// Split screen requires we create 2 effects. One that we see and one that the other player sees.
			if( (MyPawn != NULL ) && ( MyPawn->IsLocallyControlled() == true ) )
			{
				AController* PlayerCon = MyPawn->GetController();				
				if( PlayerCon != NULL )
				{
					Mesh1P->GetSocketLocation(MuzzleAttachPoint);
					MuzzlePSC = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, Mesh1P, MuzzleAttachPoint);
					MuzzlePSC->bOwnerNoSee = false;
					MuzzlePSC->bOnlyOwnerSee = true;

					Mesh3P->GetSocketLocation(MuzzleAttachPoint);
					MuzzlePSCSecondary = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, Mesh3P, MuzzleAttachPoint);
					MuzzlePSCSecondary->bOwnerNoSee = true;
					MuzzlePSCSecondary->bOnlyOwnerSee = false;				
				}				
			}
			else
			{
				MuzzlePSC = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, UseWeaponMesh, MuzzleAttachPoint);
			}
		}
	}

	if (!bLoopedFireAnim || !bPlayingFireAnim)
	{
		PlayWeaponAnimation(FireAnim);
		bPlayingFireAnim = true;
	}

	if (bLoopedFireSound)
	{
		if (FireAC == NULL)
		{
			FireAC = PlayWeaponSound(FireLoopSound);
		}
	}
	else
	{
		PlayWeaponSound(FireSound);
	}

	AShooterPlayerController* PC = (MyPawn != NULL) ? Cast<AShooterPlayerController>(MyPawn->Controller) : NULL;
	if (PC != NULL && PC->IsLocalController())
	{
		if (FireCameraShake != NULL)
		{
			PC->ClientPlayCameraShake(FireCameraShake, 1);
		}
		if (FireForceFeedback != NULL)
		{
			PC->ClientPlayForceFeedback(FireForceFeedback, false, "Weapon");
		}
	}
}
void AShooterWeapon::HandleFiring()
{
	if ((CurrentAmmoInClip > 0 || HasInfiniteClip() || HasInfiniteAmmo()) && CanFire())
	{
		if (GetNetMode() != NM_DedicatedServer)
		{
			SimulateWeaponFire();
		}

		if (MyPawn && MyPawn->IsLocallyControlled())
		{
			FireWeapon();

			UseAmmo();
			
			// update firing FX on remote clients if function was called on server
			BurstCounter++;
		}
	}
	else if (CanReload())
	{
		StartReload();
	}
	else if (MyPawn && MyPawn->IsLocallyControlled())
	{
		if (GetCurrentAmmo() == 0 && !bRefiring)
		{
			PlayWeaponSound(OutOfAmmoSound);
			AShooterPlayerController* MyPC = Cast<AShooterPlayerController>(MyPawn->Controller);
			AShooterHUD* MyHUD = MyPC ? Cast<AShooterHUD>(MyPC->GetHUD()) : NULL;
			if (MyHUD)
			{
				MyHUD->NotifyOutOfAmmo();
			}
		}
		
		// stop weapon fire FX, but stay in Firing state
		if (BurstCounter > 0)
		{
			OnBurstFinished();
		}
	}

	if (MyPawn && MyPawn->IsLocallyControlled())
	{
		// local client will notify server
		if (Role < ROLE_Authority)
		{
			ServerHandleFiring();
		}

		// reload after firing last round
		if (CurrentAmmoInClip <= 0 && CanReload())
		{
			StartReload();
		}

		// setup refire timer
		bRefiring = (CurrentState == EWeaponState::Firing && WeaponConfig.TimeBetweenShots > 0.0f);
		if (bRefiring)
		{
			GetWorldTimerManager().SetTimer(TimerHandle_HandleFiring, this, &AShooterWeapon::HandleFiring, WeaponConfig.TimeBetweenShots, false);
		}
	}

	LastFireTime = GetWorld()->GetTimeSeconds();
}
Esempio n. 20
0
// ゲーム中の銃の操作に関することをします
int Weapon::TreatmentWhileGame( int Wp_equipment){

	/*変数の初期化*/
	int ech = 0;
	int keyin[20] = {0};
	float LightDistance = 0.0f;//光が届く距離
	float MuzzleFlashAlpha = 0.0f;//マズルフラッシュの透明度
	float MuzzlePosArray[3];//マズルフラッシュを表示させる座標配列 
	static int MuzzleFlashConter = 0;//マズルフラッシュカウンター
	D3DXVECTOR3 MuzzlePos( 0.0, 0.0, 0.0);//銃口位置	
	E3DCOLOR4UC MuzzleFlashColor = { 0, 0, 0, 0};//マズルフラッシュの色を指定

	/*キーを取得する*/
	System::GetKeyData(keyin);



	if( Wp_equipment != -1){//武器があれば

			/*変数の初期化*/
			const int NowAmmo = WeaponDataWhileGame[Wp_equipment][0]; //現在の弾薬数
			const int NowMag = WeaponDataWhileGame[Wp_equipment][1]; //現在のマガジン数
			const int WeaponAmmo = WeaponData[Wp_equipment][2]; //武器性能上の弾薬数



			/*武器に新しいモーションを当てる*/
			ech = E3DSetNewPoseML( WeaponModel[Wp_equipment]);
			if(ech != 0 ){//エラーチェック
						_ASSERT( 0 );//エラーダイアログ
			};


			if( WeaponBone[Wp_equipment][0] != 0){
				/*銃の置くボーンの座標を求めます*/
				ech = E3DGetCurrentBonePos( WeaponModel[Wp_equipment], WeaponBone[Wp_equipment][0], 1, &MuzzlePos);
				if(ech != 0 ){//エラーチェック
							_ASSERT( 0 );//エラーダイアログ
				};
			}

			/*重厚の位置に爆発エフェクトを置きます*/
			ech = E3DSetBillboardPos( WeaponEffect[Wp_equipment][0], MuzzlePos); 
			if(ech != 0 ){//エラーチェック
						_ASSERT( 0 );//エラーダイアログ
			};

			if( WeaponFireFlag == 1){

						/*ビルボードを回転させます*/
						ech = E3DRotateBillboard( WeaponEffect[Wp_equipment][0], float( rand() % 360), 1);
						if(ech != 0 ){//エラーチェック
									_ASSERT( 0 );//エラーダイアログ
						};

						//位置を代入
						MuzzlePosArray[0] = MuzzlePos.x;
						MuzzlePosArray[1] = MuzzlePos.y;
						MuzzlePosArray[2] = MuzzlePos.z;
						//サウンドの再生
						PlayWeaponSound( Wp_equipment, 0, MuzzlePosArray);

						/*変数操作*/

						// マズルフラッシュカウンターを表示させます
						MuzzleFlashConter = 4;
						//弾薬をひとつ減らします
						WeaponDataWhileGame[Wp_equipment][0] = WeaponDataWhileGame[Wp_equipment][0] - 1;
						/*連射カウンタに一定数値を代入し射撃を一定停止させます*/
						WeaponRapidFire = WeaponData[Wp_equipment][6];

			}
			if( WeaponFireFlag == 2){//弾なしで空撃ち状態なら

						//位置を代入
						MuzzlePosArray[0] = MuzzlePos.x;
						MuzzlePosArray[1] = MuzzlePos.y;
						MuzzlePosArray[2] = MuzzlePos.z;
						//サウンドの再生
						PlayWeaponSound( Wp_equipment, 1, MuzzlePosArray);

						/*変数操作*/

						/*連射カウンタに一定数値を代入し射撃を一定停止させます*/
						WeaponRapidFire = WeaponData[Wp_equipment][6];
			}


			if( ( keyin[4] == 1) && ( 0 < NowMag) && //Rキーが押されてて //リロードできる状態(Magがあり、AMMOが満タンでないか銃未使用)でリロードするなら
				/**/ ( ( NowAmmo < WeaponAmmo) || ( NowMag == WeaponData[Wp_equipment][3]))){ 

					if( ( WeaponData[Wp_equipment][0] != 3) && ( WeaponData[Wp_equipment][0] != 7) && //グレネードでなく、ショットガンでもなければ
					/**/( NowAmmo >= WeaponAmmo) && ( NowMag == WeaponData[Wp_equipment][3])){// MAGもAMMOも一個も使ってなければ

							WeaponDataWhileGame[Wp_equipment][0] = WeaponAmmo + 1;//AMMOを満タン+1にする
					}
					else{//通常のリロードであれば

							WeaponDataWhileGame[Wp_equipment][0] = WeaponAmmo;//AMMOを満タンにする
					}
					//
					WeaponDataWhileGame[Wp_equipment][1] -= 1;//MAGをひとつ減らす
			}	


			/*マズルフラッシュカウンターがオンなら*/
			if( 0 < MuzzleFlashConter){

				if( MuzzleFlashConter == 4){
							MuzzleFlashAlpha = 0.7f;
							MuzzleFlashColor.r = 200;
							MuzzleFlashColor.g = 200;
							MuzzleFlashColor.b = 200;
				}
				if( MuzzleFlashConter == 3){
							MuzzleFlashAlpha = 0.9f;
							MuzzleFlashColor.r = 240;
							MuzzleFlashColor.g = 240;
							MuzzleFlashColor.b = 240;
				}
				if( MuzzleFlashConter == 2){
							MuzzleFlashAlpha = 0.6f;
							MuzzleFlashColor.r = 160;
							MuzzleFlashColor.g = 160;
							MuzzleFlashColor.b = 160;
				}
				if( MuzzleFlashConter == 1){
							/*ライトを無効にする*/
							MuzzleFlashAlpha = 0.2f;
							MuzzleFlashColor.r = 0;
							MuzzleFlashColor.g = 0;
							MuzzleFlashColor.b = 0;
				}

				/*透明度を変更する*/
				ech = E3DSetBillboardAlpha( WeaponEffect[Wp_equipment][0], MuzzleFlashAlpha);
				if(ech != 0 ){//エラーチェック
							_ASSERT( 0 );//エラーダイアログ
				};
				/*ライトを付ける*/
				if( MuzzleFlashConter != 1){
							ech = E3DSetPointLight( WeaponMuzzleLight[Wp_equipment], MuzzlePos, 700.0f, MuzzleFlashColor);
							if(ech != 0 ){//エラーチェック
										_ASSERT( 0 );//エラーダイアログ
							};
				}
				else{//ライト消灯のお時間です
							ech = E3DSetPointLight( WeaponMuzzleLight[Wp_equipment], MuzzlePos, 0.0f, MuzzleFlashColor);
							if(ech != 0 ){//エラーチェック
										_ASSERT( 0 );//エラーダイアログ
							};			
				}


				/*爆発のエフェクトを(すべてのビルボード)の描画*/
				ech = E3DRenderBillboard( System::scid1, 0);
				if(ech != 0 ){//エラーチェック
							_ASSERT( 0 );//エラーダイアログ
				};

				/*フラッシュカウントをひとつ下げる*/
				MuzzleFlashConter = MuzzleFlashConter -1;

				/*透明度を変更する*/
				if( MuzzleFlashConter == 0){//カウントが0になったら
							ech = E3DSetBillboardAlpha( WeaponEffect[Wp_equipment][0], 0.0f);
							if(ech != 0 ){//エラーチェック
										_ASSERT( 0 );//エラーダイアログ
							};	
				}
			}

			/*連射停止カウンタがオンなら*/
			if( 0 < WeaponRapidFire){
					WeaponRapidFire = WeaponRapidFire - 1;//連射停止カウンタを一つ繰り下げる
			}
	}

	return 0;
}
Esempio n. 21
0
void AWeapon::OnStartFire() {

    FireAC = PlayWeaponSound(FireLoopSound);
    MuzzleSC = UGameplayStatics::SpawnEmitterAttached(MuzzleFX, RootComponent, TEXT("MuzzleFlashSocket"));

}
Esempio n. 22
0
void ASWeapon::HandleFiring()
{
	if (CurrentAmmoInClip > 0 && CanFire())
	{
		if (GetNetMode() != NM_DedicatedServer)
		{
			SimulateWeaponFire();
		}

		if (MyPawn && MyPawn->IsLocallyControlled())
		{
			FireWeapon();

			UseAmmo();

			// Update firing FX on remote clients if this is called on server
			BurstCounter++;
		}
	}
	else if (CanReload())
	{
		StartReload();
	}
	else if (MyPawn && MyPawn->IsLocallyControlled())
	{
		if (GetCurrentAmmo() == 0 && !bRefiring)
		{
			PlayWeaponSound(OutOfAmmoSound);
		}

		/* Reload after firing last round */
		if (CurrentAmmoInClip <= 0 && CanReload())
		{
			StartReload();
		}

		/* Stop weapon fire FX, but stay in firing state */
		if (BurstCounter > 0)
		{
			OnBurstFinished();
		}
	}

	if (MyPawn && MyPawn->IsLocallyControlled())
	{
		if (Role < ROLE_Authority)
		{
			ServerHandleFiring();
		}

		/* Retrigger HandleFiring on a delay for automatic weapons */
		bRefiring = (CurrentState == EWeaponState::Firing && TimeBetweenShots > 0.0f);
		if (bRefiring)
		{
			GetWorldTimerManager().SetTimer(TimerHandle_HandleFiring, this, &ASWeapon::HandleFiring, TimeBetweenShots, false);
		}
	}

	/* Make Noise on every shot. The data is managed by the PawnNoiseEmitterComponent created in SBaseCharacter and used by PawnSensingComponent in SZombieCharacter */
	if (MyPawn)
	{
		MyPawn->MakePawnNoise(1.0f);
	}

	LastFireTime = GetWorld()->GetTimeSeconds();
}