diff --git a/EndlessVendetta/Config/DefaultEngine.ini b/EndlessVendetta/Config/DefaultEngine.ini index f61108f4..8a52ed56 100644 --- a/EndlessVendetta/Config/DefaultEngine.ini +++ b/EndlessVendetta/Config/DefaultEngine.ini @@ -87,3 +87,6 @@ ConnectionType=USBOnly bUseManualIPAddress=False ManualIPAddress= + +[CoreRedirects] ++PropertyRedirects=(OldName="/Script/EndlessVendetta.BaseWeaponClass.player",NewName="/Script/EndlessVendetta.BaseWeaponClass.playerInWorld") \ No newline at end of file diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset index ef248e2a..075055c8 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cff6a88ce5641de43b7168dbe156dc6c743108fd4fe22dd89647224cdc5249fc -size 37804 +oid sha256:4473a9d8bdd893373d3b489bc1ccb878bc568d94b9b495b1e2be83880bac0959 +size 37793 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset index 59590b50..e3118a9f 100644 --- a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset +++ b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75503df8d15af2a4661c6cd18bc8f690d50f79cafe5ea8e2b3665db0b882cc24 +oid sha256:8b9f2db74a440d4cbe20066719467311b6d43de3676027ec2162fc39a2c7ac85 size 1370 diff --git a/EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset b/EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset index 20a95d4b..44d21afa 100644 --- a/EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset +++ b/EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc9b39a1c54d40b77f7893a00f72fc8e3feedec1d19fbdfa2db4f64d47e63bc3 +oid sha256:bd95413d072ec5535444d09946cfb0ec3f4f6392ff5712e60fa521c845b23cdc size 478510 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index d7a13fac..93a21cd9 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -141,6 +141,7 @@ void AEndlessVendettaCharacter::EquipPrimary() if (IsValid(PrimaryWeapon)) { PrimaryWeapon->Destroy(); + this->GetFirstPersonCameraComponent()->SetFieldOfView(90); PrimaryWeapon = nullptr; bHasRifle = false; return; @@ -171,6 +172,7 @@ void AEndlessVendettaCharacter::EquipSecondary() if (IsValid(SecondaryWeapon)) { SecondaryWeapon->Destroy(); + this->GetFirstPersonCameraComponent()->SetFieldOfView(90); SecondaryWeapon = nullptr; bHasRifle = false; return; @@ -208,7 +210,7 @@ void AEndlessVendettaCharacter::FireCaller() void AEndlessVendettaCharacter::GunRightClick() { - if (IsValid(PrimaryWeapon)) + if (IsValid(PrimaryWeapon) && !bIsScoped) { for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow"))) { @@ -217,11 +219,19 @@ void AEndlessVendettaCharacter::GunRightClick() } if (!IsValid(ScopedLocationArrow)) return; PrimaryWeapon->SetActorLocation(ScopedLocationArrow->GetComponentLocation()); + bIsScoped = true; PrimaryWeapon->WeaponScopedFire(); this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually } - if (IsValid(SecondaryWeapon)) + if (IsValid(SecondaryWeapon) && !bIsScoped) { + for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow"))) + { + ScopedLocationArrow = Cast(actorComp); + break; + } + if (!IsValid(ScopedLocationArrow)) return; + bIsScoped = true; SecondaryWeapon->WeaponScopedFire(); SecondaryWeapon->SetActorLocation(ScopedLocationArrow->GetComponentLocation()); this->GetFirstPersonCameraComponent()->SetFieldOfView(50); //change this number to a number you can change in editor eventually @@ -232,11 +242,15 @@ void AEndlessVendettaCharacter::StopGunRightClick() { if (IsValid(PrimaryWeapon)) { + bIsScoped = false; + PrimaryWeapon->WeaponScopedFire(); PrimaryWeapon->SetActorRelativeLocation(FVector(0,0,0)); this->GetFirstPersonCameraComponent()->SetFieldOfView(90); } if (IsValid(SecondaryWeapon)) { + bIsScoped = false; + SecondaryWeapon->WeaponScopedFire(); SecondaryWeapon->SetActorRelativeLocation(FVector(0,0,0)); this->GetFirstPersonCameraComponent()->SetFieldOfView(90); } diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index 597364e8..8762426a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -111,6 +111,9 @@ public: UArrowComponent* ScopedLocationArrow; + UPROPERTY(EditAnywhere, Category = "Dont Touch") + bool bIsScoped; + protected: /** Called for movement input */ void Move(const FInputActionValue& Value); diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index 1e914665..b0ff8a20 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -25,9 +25,11 @@ void ABaseWeaponClass::BeginPlay() // Attempt to find the player character APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0); - player = Cast(PlayerController->GetCharacter()); + playerInWorld = Cast(PlayerController->GetCharacter()); + + endlessVendettaChar = Cast(playerInWorld); - for (UActorComponent* actorComp : player->GetComponentsByTag(UArrowComponent::StaticClass(), FName("GunStart"))) + for (UActorComponent* actorComp : playerInWorld->GetComponentsByTag(UArrowComponent::StaticClass(), FName("GunStart"))) { GunStartArrow = Cast(actorComp); break; @@ -37,7 +39,11 @@ void ABaseWeaponClass::BeginPlay() { playerControllerRef = UGameplayStatics::GetPlayerController(GetWorld(), 0); } - + + originalMagnitude = recoilMagnitude; + originalMaxAngleLeft = recoilMaxAngleLeft; + originalMaxAngleRight = recoilMaxAngleRight; + originalMinMultiplier = recoilMinMultiplier; } // Called every frame @@ -45,7 +51,7 @@ void ABaseWeaponClass::Tick(float DeltaTime) { Super::Tick(DeltaTime); - if (player) + if (playerInWorld) { ApplyRecoil(DeltaTime); } @@ -76,8 +82,8 @@ void ABaseWeaponClass::ApplyRecoil(float DeltaTime) { float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time recoilTime += DeltaTime; - player->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime)); - player->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime)); + playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime)); + playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime)); UpdateSamples(amplitude, recoilTime); } } @@ -135,7 +141,7 @@ void ABaseWeaponClass::Fire() traceStart = GunStartArrow->GetComponentLocation(); traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance); FCollisionQueryParams collisionParams; - collisionParams.AddIgnoredActor(player); + collisionParams.AddIgnoredActor(playerInWorld); collisionParams.AddIgnoredActor(this); if (GetWorldTimerManager().IsTimerActive(timerHandle)) { @@ -155,11 +161,21 @@ void ABaseWeaponClass::Fire() void ABaseWeaponClass::WeaponScopedFire() { - UE_LOG(LogTemp, Display, TEXT("Activated WeaponScopedFire function in BaseWeaponClass")); - recoilMagnitude -= 0.2f; - recoilMaxAngleLeft /= 2.f; - recoilMaxAngleRight /= 2.f; - recoilMinMultiplier -= 2.f; + if (endlessVendettaChar->bIsScoped) + { + recoilMagnitude -= 0.2f; + recoilMaxAngleLeft /= 2.f; + recoilMaxAngleRight /= 2.f; + recoilMinMultiplier -= 0.2f; + + } + else + { + recoilMagnitude = originalMagnitude; + recoilMaxAngleLeft = originalMaxAngleLeft; + recoilMaxAngleRight = originalMaxAngleRight; + recoilMinMultiplier = originalMinMultiplier; + } } diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 4e3e498a..8eb2d617 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -69,9 +69,10 @@ public: void CancelFire(); UPROPERTY(VisibleAnywhere) - ACharacter* player; - - UPROPERTY() + ACharacter* playerInWorld; + + AEndlessVendettaCharacter* endlessVendettaChar; + APlayerController* playerControllerRef; FTimerHandle timerHandle; @@ -115,5 +116,10 @@ private: UPROPERTY(EditAnywhere) float BulletDistance; + + float originalMagnitude; + float originalMaxAngleLeft; + float originalMaxAngleRight; + float originalMinMultiplier; };