diff --git a/EndlessVendetta/Config/DefaultEditor.ini b/EndlessVendetta/Config/DefaultEditor.ini index 58552fae..e7314343 100644 --- a/EndlessVendetta/Config/DefaultEditor.ini +++ b/EndlessVendetta/Config/DefaultEditor.ini @@ -5,4 +5,7 @@ SimpleMapName=/Game/FirstPerson/Maps/FirstPersonExampleMap bAllowClassAndBlueprintPinMatching=true bReplaceBlueprintWithClass= true bDontLoadBlueprintOutsideEditor= true -bBlueprintIsNotBlueprintType= true \ No newline at end of file +bBlueprintIsNotBlueprintType= true + +[/Script/AdvancedPreviewScene.SharedProfiles] + diff --git a/EndlessVendetta/Config/DefaultEngine.ini b/EndlessVendetta/Config/DefaultEngine.ini index 61a9966a..126166fe 100644 --- a/EndlessVendetta/Config/DefaultEngine.ini +++ b/EndlessVendetta/Config/DefaultEngine.ini @@ -85,3 +85,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/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset b/EndlessVendetta/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset index 69ba91c0..c6396a47 100644 --- a/EndlessVendetta/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset +++ b/EndlessVendetta/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eec8c05a75e7932e3834cbc1cd1b112f29171212b871fa1552f458ceb1b65948 -size 8000 +oid sha256:f9c7063e48c0b3c23194a6a2fc3625da96d20bbd92fece19210001cf0cac8964 +size 8568 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset index 68a7823a..18599c44 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:072d87c768407249e6e50f7b87ab9a88392c17cf82c72934e3c947e2943210bb -size 26284 +oid sha256:a408fa1c344f5612f1ed59bfeefbd99f2fc986c49f66bf42e849db73e65fdc2e +size 42307 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_PickUp_Rifle.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_PickUp_Rifle.uasset index 42fff7f9..a8f825b9 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_PickUp_Rifle.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_PickUp_Rifle.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d156d6fe24779674a35f18f9209313b0c2096d22772400c4d10c241a2e59e9e -size 21649 +oid sha256:118d852be72576a513c2a8c719e1d94450907a5dc00f27dd98914deb48a18c09 +size 21604 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_BaseAssaultRifle.uasset index 50209cd2..f0a16367 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:8b311799aa263b7af6d3eb738da33d39b0d40d7883bf0a4e3cb6024e06157cec -size 37724 +oid sha256:99fdc6f5e7c67d7a44ca185fad64f6c99ad6142011c9de4566761ec07bdd68d0 +size 37860 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset index 0aef22ed..dc2d119d 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4dfbc572d0f67be5a3c6898946ce7fce2895174236407ce9910f99c59690367 -size 28778 +oid sha256:af36276c4e513a207e06ec1eaa8f5c4273ab5634330a999db47ac9128e7d02ec +size 29776 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_GunCameraShake.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_GunCameraShake.uasset new file mode 100644 index 00000000..a24df98a --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_GunCameraShake.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b5bc4f06eaeb74c61b627c02ff6e49dedeebfe047bc79fbfa8941b25c4674ef +size 7209 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Images/crosshair.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Images/crosshair.uasset new file mode 100644 index 00000000..aeb09d75 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Images/crosshair.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:110eea3093bb784d7c237753fcd6f029cc8d3b388991f886a9752d6960195e14 +size 12511 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Images/fadenkreuz-transparent-crosshair-slayer-god-hates-us-all-album-cover-11562902578sasayvkjg8.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Images/fadenkreuz-transparent-crosshair-slayer-god-hates-us-all-album-cover-11562902578sasayvkjg8.uasset new file mode 100644 index 00000000..2caf2972 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Images/fadenkreuz-transparent-crosshair-slayer-god-hates-us-all-album-cover-11562902578sasayvkjg8.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df1398829f499b8a95bd2a912851aa613d1b26519496f1bc38a58db91c2a7730 +size 62044 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/BP_BasePistolWeapon.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/BP_BasePistolWeapon.uasset index 3f00099b..ea240160 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/BP_BasePistolWeapon.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Pistols/BP_BasePistolWeapon.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:202ab16b4ffa35b8b8140c728744b529514cd98e7cf595a674e0bd13bcfbaff9 -size 29227 +oid sha256:71b1463641785fe268bbea7f26c1e1d12cb0703f47b2ec1c50afd19ed3f061ed +size 30046 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WeaonRecoil/AssaultRecoilPattern.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WeaonRecoil/AssaultRecoilPattern.uasset new file mode 100644 index 00000000..423c7283 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WeaonRecoil/AssaultRecoilPattern.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b63c754fc78a67f950a91e30dd31a6778bac31a485191b9cc14560515d5012a5 +size 2033 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset new file mode 100644 index 00000000..bdd28701 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a3c0a70c5b68ec66372ae8e29abcb76deb385319f24202e43395c9061b3d0f8a +size 24854 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset new file mode 100644 index 00000000..e3118a9f --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_GunAimIn.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b9f2db74a440d4cbe20066719467311b6d43de3676027ec2162fc39a2c7ac85 +size 1370 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_HoldShoot.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_HoldShoot.uasset deleted file mode 100644 index ac52169f..00000000 --- a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_HoldShoot.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1360a5e75da75d76374ea2091191ab85eab8ae0407f660ec7e242bdb51056670 -size 1659 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset new file mode 100644 index 00000000..5ed3f2f9 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85ff514d76166f7c202ee64b678abe6314dcc24d3d662883b53edb7608ea2bfe +size 1647 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Shoot.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Shoot.uasset new file mode 100644 index 00000000..0186b774 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Shoot.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d92be41146c90185585f7a2de5a18d31a688d2cc8dfb22b24b9a7a92dbfd1ce1 +size 1355 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_TapShoot.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_TapShoot.uasset deleted file mode 100644 index b951ed44..00000000 --- a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_TapShoot.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3d02927e6f81929b1b6715400ce5f1a62361f239a5baad938902ae86b61ddc55 -size 1657 diff --git a/EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset b/EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset index 55abcd6c..4cea87c6 100644 --- a/EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset +++ b/EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3af06cb5478091fcf55d1069e28395f32708276bd53cc5dce82faa2a2d1f822b -size 16317 +oid sha256:ff3f732c27d0c0064f659482af85f116bc5eb967b29d3ca42bdc2324c3662cd8 +size 16910 diff --git a/EndlessVendetta/Content/FirstPerson/Input/IMC_Weapons.uasset b/EndlessVendetta/Content/FirstPerson/Input/IMC_Weapons.uasset index e0d25572..0f7cd254 100644 --- a/EndlessVendetta/Content/FirstPerson/Input/IMC_Weapons.uasset +++ b/EndlessVendetta/Content/FirstPerson/Input/IMC_Weapons.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:99664f7a2d02cd77eec769cd0a690345e80de975fcacb8a615346583218e1b15 -size 4138 +oid sha256:24bf0d5a1ecce706cf33ff99e0ba7c1e0601dea5433ffd1f61732d522c9f4488 +size 4115 diff --git a/EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset b/EndlessVendetta/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset index c514eab5..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:175427d440d7f510cbbfa4630c82a677a83348f3b3b5cc555e09a7b03cf2e4ee -size 473991 +oid sha256:bd95413d072ec5535444d09946cfb0ec3f4f6392ff5712e60fa521c845b23cdc +size 478510 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index 0f990580..a76d9a83 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc35eb2d43a47427d30aba0196f9eac90d089dd3abca319528c5d25c83510d0d -size 72364642 +oid sha256:35965626ed27917622aa4630a23b7a047248cb9b9b0e66e1843969c4b1e0aadb +size 66790690 diff --git a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/0/3Z/SNIBJQL2L6YHSC7MTTK1C2.uasset b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/0/3Z/SNIBJQL2L6YHSC7MTTK1C2.uasset deleted file mode 100644 index 4f6bab25..00000000 --- a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/0/3Z/SNIBJQL2L6YHSC7MTTK1C2.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fdab805d14a7bc4f2fa61abc0106161cf2626e8857ae14089d5e4c93f9a320d6 -size 5061 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 448d805c..fa579aa4 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -59,7 +59,7 @@ void AEndlessVendettaCharacter::BeginPlay() GadgetManager->SpawnGadgets(Cast(PlayersCamera)); break; } - + } //////////////////////////////////////////////////////////////////////////// Input @@ -82,13 +82,18 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent* // Gadget Toggling EnhancedInputComponent->BindAction(ReconAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::ToggleRecon); EnhancedInputComponent->BindAction(CombatAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::ToggleCombat); - + //Weapon Switching EnhancedInputComponent->BindAction(EquipPrimaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipPrimary); EnhancedInputComponent->BindAction(EquipSecondaryWeapon, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::EquipSecondary); //Weapon Shooting - EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::TapFireCaller); + EnhancedInputComponent->BindAction(TapShootAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::FireCaller); + EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::GunRightClick); + EnhancedInputComponent->BindAction(GunAimInAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopGunRightClick); + + //Weapon Reloading + EnhancedInputComponent->BindAction(GunReloadAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::GunReload); } } @@ -139,18 +144,17 @@ void AEndlessVendettaCharacter::EquipPrimary() if (IsValid(PrimaryWeapon)) { PrimaryWeapon->Destroy(); + this->GetFirstPersonCameraComponent()->SetFieldOfView(90); PrimaryWeapon = nullptr; bHasRifle = false; return; } if (IsValid(SecondaryWeapon)) EquipSecondary(); - - // Marcel I respect you, like you and what not, please for the love of god don't touch these two guard clauses - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;///////////////////////// - if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;/////////////////////// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + + if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return; + if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return; + FActorSpawnParameters spawnParams; spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; @@ -163,131 +167,109 @@ void AEndlessVendettaCharacter::EquipPrimary() //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor PrimaryWeapon = Cast(PrimaryWeaponActor); - - //If primary weapon is not there but secondary weapon is it will call equipSecondary. - //EquipSecondary checks and sees that secondary is there so it will call to destroy itself - //Code goes back and sees primary weapon is not there anymore and spawns it in. - //Same thing for the EquipSecondary() - - // if (!IsValid(PrimaryWeapon)) - // { - // if (IsValid(SecondaryWeapon)) EquipSecondary(); - // - // UE_LOG(LogTemp, Display, TEXT("Primary equipped")); - // bHasRifle = true; - // FActorSpawnParameters spawnParams; - // spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - // FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); - // //Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass - // AActor* PrimaryWeaponActor = GetWorld()->SpawnActor(PrimaryWeaponClass, spawnParams); - // PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); - // //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object - // //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor - // PrimaryWeapon = Cast(PrimaryWeaponActor); - // - // } - // else if (IsValid(PrimaryWeapon)) - // { - // PrimaryWeapon->Destroy(); - // bHasRifle = false; - // } } void AEndlessVendettaCharacter::EquipSecondary() { if (IsValid(SecondaryWeapon)) - { - SecondaryWeapon->Destroy(); + { + SecondaryWeapon->Destroy(); + this->GetFirstPersonCameraComponent()->SetFieldOfView(90); SecondaryWeapon = nullptr; - bHasRifle = false; - return; - } + bHasRifle = false; + return; + } if (IsValid(PrimaryWeapon)) EquipPrimary(); - - // Marcel I respect you, like you and what not, please for the love of god don't touch these two guard clauses - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;///////////////////////// - if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;/////////////////////// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + + if (GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return; + if (GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return; + FActorSpawnParameters spawnParams; spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); - + bHasRifle = true; AActor* SecondaryWeaponActor = GetWorld()->SpawnActor(SecondaryWeaponClass, spawnParams); SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); SecondaryWeapon = Cast(SecondaryWeaponActor); - - // if (!IsValid(SecondaryWeapon)) - // { - // if (IsValid(PrimaryWeapon)) EquipPrimary(); - // - // UE_LOG(LogTemp, Display, TEXT("Secondary equipped")); - // bHasRifle = true; - // FActorSpawnParameters spawnParams; - // spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - // FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); - // AActor* SecondaryWeaponActor = GetWorld()->SpawnActor(SecondaryWeaponClass, spawnParams); - // SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); - // SecondaryWeapon = Cast(SecondaryWeaponActor); - // } - // else if (IsValid(SecondaryWeapon)) - // { - // SecondaryWeapon->Destroy(); - // bHasRifle = false; - // } - } //Calls the fire function in the baseWeaponClass -void AEndlessVendettaCharacter::TapFireCaller() +void AEndlessVendettaCharacter::FireCaller() { UE_LOG(LogTemp, Warning, TEXT("Tap Fire")); - // if (IsValid(PrimaryWeapon) || IsValid(SecondaryWeapon)) - // { - // PrimaryWeaponClass.GetDefaultObject()->TapFire(); - // } + if (IsValid(PrimaryWeapon)) + { + PrimaryWeapon->Fire(); + } + if (IsValid(SecondaryWeapon)) + { + SecondaryWeapon->Fire(); + } } -//POTENTIAL PICKUP SYSTEM NEEDS CHANGING BUT YES - -//Called from Player BluePrints -/*void AEndlessVendettaCharacter::WeaponPickUpSystem(AActor* PickedUpWeapon) +void AEndlessVendettaCharacter::GunRightClick() { - ABaseWeaponClass* WeaponInWorld = Cast(PickedUpWeapon); - if(WeaponInWorld->IsA(ABaseWeaponClass::StaticClass())) + if (IsValid(PrimaryWeapon) && !bIsScoped) { - if(PrimaryWeapon) + for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow"))) { - UE_LOG(LogTemp, Display, TEXT("Primary Weapon Picked up")); - bHasRifle = true; - FVector loc = GetActorLocation() + FVector(-50, 0, 0); - FRotator rot = GetActorRotation(); - FActorSpawnParameters spawnParams; - spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); - //WeaponInWorld = Cast(GetWorld()->SpawnActor(PrimaryWeapon, loc, rot, spawnParams)); - WeaponInWorld->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); - WeaponInWorld->Destroy(); - - //for some reason the spawning of the weapon is broken to the players hand so need to fix this. - - // potentially add a varibable to check if its a secondary or priamry weapon being picked up - // add this in the baseweaponclass variable + ScopedLocationArrow = Cast(actorComp); + break; } + 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(WeaponInWorld->IsA(ABaseWeaponClass::StaticClass())) + if (IsValid(SecondaryWeapon) && !bIsScoped) { - if(SecondaryWeapon) + for (UActorComponent* actorComp : this->GetComponentsByTag(UArrowComponent::StaticClass(), FName("ScopedLocationArrow"))) { - UE_LOG(LogTemp, Display, TEXT("Secondary Weapon Picked up")); - + 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 } -}*/ +} + +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); + } +} + +void AEndlessVendettaCharacter::GunReload() +{ + if (IsValid(PrimaryWeapon)) + { + PrimaryWeapon->WeaponReload(); + } + if (IsValid(SecondaryWeapon)) + { + SecondaryWeapon->WeaponReload(); + } +} void AEndlessVendettaCharacter::Move(const FInputActionValue& Value) diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index cf41bef6..fdd1718f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -58,9 +58,12 @@ class AEndlessVendettaCharacter : public ACharacter UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) class UInputAction* TapShootAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) + class UInputAction* GunAimInAction; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) - class UInputAction* HoldShootAction; + class UInputAction* GunReloadAction; public: AEndlessVendettaCharacter(); @@ -101,8 +104,21 @@ public: ABaseWeaponClass* SecondaryWeapon; UFUNCTION(BlueprintCallable, Category = "Weapons") - void TapFireCaller(); + void FireCaller(); + UFUNCTION(BlueprintCallable, Category = "Weapons") + void GunRightClick(); + + UFUNCTION(BlueprintCallable, Category = "Weapons") + void StopGunRightClick(); + + UFUNCTION(BlueprintCallable, Category = "Weapons") + void GunReload(); + + UArrowComponent* ScopedLocationArrow; + + UPROPERTY(EditAnywhere, Category = "Dont Touch") + bool bIsScoped; protected: /** Called for movement input */ @@ -119,9 +135,6 @@ protected: void EquipSecondary(); - //Called from Player BluePrints - //UFUNCTION(BlueprintCallable, Category = "Weapons") - //void WeaponPickUpSystem(AActor* PickedUpWeapon); protected: // APawn interface @@ -133,6 +146,7 @@ public: USkeletalMeshComponent* GetMesh1P() const { return Mesh1P; } /** Returns FirstPersonCameraComponent subobject **/ UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; } + }; diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp index 52c807f9..eb11bf58 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp @@ -60,12 +60,11 @@ void AVisionLinkEnemyLOSTest::TestLOS(TArray EnemiesInLink, AActor* LOSA return; } - for (AActor* Enemy : OverlappingEnemies) + /*for (AActor* Enemy : OverlappingEnemies) { FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(LOSActor->GetActorLocation(), Enemy->GetActorLocation()); UE_LOG(LogTemp, Warning, TEXT("Look at Rotation: %f"), LookAtRotation.Yaw); - UE_LOG(LogTemp, Warning, TEXT("enemy name: %s"), *Enemy->GetName()); - } + }*/ Destroy(); diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index 0d14f19d..65dcbc96 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -2,7 +2,11 @@ #include "BaseWeaponClass.h" + +#include "AIHelpers.h" +#include "GeneratedCodeHelpers.h" #include "EndlessVendetta/EndlessVendettaCharacter.h" +#include "Kismet/KismetMathLibrary.h" #include "Components/CapsuleComponent.h" #include "Kismet/GameplayStatics.h" @@ -21,46 +25,180 @@ void ABaseWeaponClass::BeginPlay() // Attempt to find the player character APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0); - player = Cast(PlayerController->GetCharacter()); - if (PlayerController) + playerInWorld = Cast(PlayerController->GetCharacter()); + + endlessVendettaChar = Cast(playerInWorld); + + for (UActorComponent* actorComp : playerInWorld->GetComponentsByTag(UArrowComponent::StaticClass(), FName("GunStart"))) { - if (player) - { - UE_LOG(LogTemp, Display, TEXT("BeginPlay: Player found.")); - } - else - { - UE_LOG(LogTemp, Error, TEXT("BeginPlay: Player not found.")); - } + GunStartArrow = Cast(actorComp); + break; } - else + + if (!playerControllerRef) { - UE_LOG(LogTemp, Error, TEXT("BeginPlay: Player controller not found.")); + playerControllerRef = UGameplayStatics::GetPlayerController(GetWorld(), 0); } + + originalMagnitude = recoilMagnitude; + originalMaxAngleLeft = recoilMaxAngleLeft; + originalMaxAngleRight = recoilMaxAngleRight; + originalMinMultiplier = recoilMinMultiplier; + + currentAmmoCount = MagazineSize; + + UE_LOG(LogTemp, Display, TEXT("crnnt ammo: %d"), MagazineSize); } // Called every frame void ABaseWeaponClass::Tick(float DeltaTime) { Super::Tick(DeltaTime); -} -void ABaseWeaponClass::TapFire() -{ - FHitResult outHit; - FVector traceStart; - FVector traceEnd; - traceStart = player->GetActorLocation(); - traceEnd = traceStart + (player->GetActorForwardVector() * 50); - UE_LOG(LogTemp, Display, TEXT("World: %s"), *GetWorld()->GetName()); - FCollisionQueryParams collisionParams; - GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams); - - //Debug line to see where the trace hit - DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, true); - if (outHit.bBlockingHit) + if (playerInWorld) { - UE_LOG(LogTemp, Display, TEXT("Hit something")); + ApplyRecoil(DeltaTime); } - UE_LOG(LogTemp, Display, TEXT("BOOMBOOMBIMBAMBIM")); } + + +// Recoil Handling //////////////////////////////////////////////////////////////////////////////////////////////////////////// +void ABaseWeaponClass::GenerateRecoilVector() +{ + float angle = FMath::RandRange(recoilMaxAngleLeft, -recoilMaxAngleRight); //randomg recoil vector angle between left and right + float recMag = recoilMagnitude * 252.f; //converting degrees to controller units + float tempMag = -FMath::RandRange(recMag * recoilMinMultiplier, recMag); // recoil magnitude + + recoilResultYaw = FMath::Sin(FMath::DegreesToRadians(angle)); + recoilResultPitch = FMath::Cos(FMath::DegreesToRadians(angle)); + + //scaling direction to magnitude + recoilResultPitch *= -tempMag; + recoilResultYaw *= tempMag; + + //reset recoil to 0 of curve + recoilTime = 0; +} + +void ABaseWeaponClass::ApplyRecoil(float DeltaTime) +{ + if (recoilTime < 0.3) + { + float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time + recoilTime += DeltaTime; + playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime)); + playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime)); + UpdateSamples(amplitude, recoilTime); + } +} + +void ABaseWeaponClass::nullSamples() +{ + recoilCurvet = 0; + recoilCurvez1 = 0; +} + +float ABaseWeaponClass::GetRecoilPitch(float Amp, float Time) +{ + //Using the trapez method and we are getting the surface under the curve, each trapezoid consist of square and right triangle + float lower = recoilCurvez1 < Amp ? recoilCurvez1 : Amp; //get which point is common for both triangle and square of trapezoid + //lower point + float mult = (Time - recoilCurvet) * lower; //getting surface of square + mult += (Time - recoilCurvet) * (Amp - recoilCurvez1) / 2.0f; //getting and adding surface of triangle + return (recoilResultPitch * mult) / playerControllerRef->InputPitchScale_DEPRECATED; //calculating and return recoil force for current frame +} + + +//Same as getrecoilpitch +float ABaseWeaponClass::GetRecoilYaw(float Amp, float Time) +{ + float lower = recoilCurvez1 < Amp ? recoilCurvez1 : Amp; + float mult = (Time - recoilCurvet) * lower; + + mult += (Time - recoilCurvet) * (Amp - recoilCurvez1) / 2.0f; + return (recoilResultYaw * mult) / playerControllerRef->InputYawScale_DEPRECATED; +} + +void ABaseWeaponClass::UpdateSamples(float Amp, float Time) +{ + recoilCurvez1 = Amp; + recoilCurvet = Time; +} + +// Fire handling ////////////////////////////////////////////////////////////////////////////////////////////////////////// +void ABaseWeaponClass::ClickDetectionTimer() +{ + GetWorldTimerManager().SetTimer(timerHandle, this, &ABaseWeaponClass::Fire, 1 / FireRate, false); +} + +void ABaseWeaponClass::CancelFire() +{ + GetWorldTimerManager().ClearTimer(timerHandle); +} + +void ABaseWeaponClass::Fire() +{ + if(currentAmmoCount > 0) + { + //do damage fallof based off distance + FHitResult outHit; + FVector traceStart; + FVector traceEnd; + traceStart = GunStartArrow->GetComponentLocation(); + traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance); + FCollisionQueryParams collisionParams; + collisionParams.AddIgnoredActor(playerInWorld); + collisionParams.AddIgnoredActor(this); + if (GetWorldTimerManager().IsTimerActive(timerHandle)) + { + return; + } + GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams); + //Debug line to see where the trace hit + DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, false, 5.0f, 0U, 2.5f); + playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1); + currentAmmoCount -= 1; + UE_LOG(LogTemp, Display, TEXT("Ammo Count: %d"), currentAmmoCount); + GenerateRecoilVector(); + ClickDetectionTimer(); + if (outHit.bBlockingHit) + { + UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName()); + } + } + else if(currentAmmoCount <= 0) + { + UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount); + } + +} + +void ABaseWeaponClass::WeaponScopedFire() +{ + if (endlessVendettaChar->bIsScoped) + { + recoilMagnitude -= 0.2f; + recoilMaxAngleLeft /= 2.f; + recoilMaxAngleRight /= 2.f; + recoilMinMultiplier -= 0.2f; + + } + else + { + recoilMagnitude = originalMagnitude; + recoilMaxAngleLeft = originalMaxAngleLeft; + recoilMaxAngleRight = originalMaxAngleRight; + recoilMinMultiplier = originalMinMultiplier; + } +} + +void ABaseWeaponClass::WeaponReload() +{ + if(MagazineSize > currentAmmoCount) + { + UE_LOG(LogTemp, Display, TEXT("Weapon Reloading: mag size: %d"), MagazineSize); + currentAmmoCount = MagazineSize; + } +} + + diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 2fc1219a..1d07fb65 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -4,6 +4,8 @@ #include "CoreMinimal.h" #include "WeaponItemClass.h" +#include "Components/ArrowComponent.h" +#include "Kismet/KismetMathLibrary.h" #include "BaseWeaponClass.generated.h" class AEndlessVendettaCharacter; @@ -22,6 +24,23 @@ protected: // Called when the game starts or when spawned virtual void BeginPlay() override; + void GenerateRecoilVector(); + + void ApplyRecoil(float DeltaTime); + + void nullSamples(); + + //recoil previous curve + float recoilCurvez1 = 0; + + //recoil previous curve time + float recoilCurvet = 0; + + float recoilTime = 0; + + float recoilResultPitch = 0; + float recoilResultYaw = 0; + public: // Called every frame virtual void Tick(float DeltaTime) override; @@ -42,17 +61,70 @@ public: UTexture2D* WeaponImage; UFUNCTION(BlueprintCallable, Category = "Weapons") - void TapFire(); + virtual void Fire(); + + UFUNCTION(BlueprintCallable, Category = "Weapons") + void ClickDetectionTimer(); + + void CancelFire(); UPROPERTY(VisibleAnywhere) - ACharacter* player; + ACharacter* playerInWorld; + + AEndlessVendettaCharacter* endlessVendettaChar; + + APlayerController* playerControllerRef; - - + FTimerHandle timerHandle; - //Add HoldFire functionality after pistol is complete for holding fire for pistol and make it start spraying innacuratly. - - // UFUNCTION(BlueprintCallable, Category = "Weapons") - // void HoldFire(); + bool bFirstBulletShot = false; + + UPROPERTY(EditAnywhere) + TSubclassOf CameraShakeClass; + + /* How far the gun goes up*/ + UPROPERTY(EditAnywhere, Category = "Recoil") + float recoilMagnitude; + + UPROPERTY(EditAnywhere, Category = "Recoil") + float recoilMaxAngleLeft; + + UPROPERTY(EditAnywhere, Category = "Recoil") + float recoilMaxAngleRight; + + UPROPERTY(EditAnywhere, Category = "Recoil") + float recoilMinMultiplier; + + UPROPERTY(EditAnywhere, Category = "Recoil") + class UCurveFloat* RecoilCurve; + + UFUNCTION(BlueprintCallable, Category = "Recoil") + float GetRecoilPitch(float Amp, float Time); + + UFUNCTION(BlueprintCallable, Category = "Recoil") + float GetRecoilYaw(float Amp, float Time); + + UFUNCTION(BlueprintCallable, Category = "Recoil") + void UpdateSamples(float Amp, float Time); + + UFUNCTION(BlueprintCallable, Category = "Weapons") + void WeaponScopedFire(); + + UFUNCTION(BlueprintCallable, Category = "Weapons") + void WeaponReload(); + +private: + + UArrowComponent* GunStartArrow; + + UPROPERTY(EditAnywhere) + float BulletDistance; + + float originalMagnitude; + float originalMaxAngleLeft; + float originalMaxAngleRight; + float originalMinMultiplier; + + int currentAmmoCount; }; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.cpp index c40b9fdc..2b7dc95a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.cpp @@ -24,3 +24,9 @@ void APistolClass::Tick(float DeltaTime) Super::Tick(DeltaTime); } +void APistolClass::Fire() +{ + Super::Fire(); + UE_LOG(LogTemp, Display, TEXT("Testing overrides: Pistol has been fired")); +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.h index 4ad676b2..ca85b67e 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/PistolClass.h @@ -22,4 +22,6 @@ protected: public: // Called every frame virtual void Tick(float DeltaTime) override; + + virtual void Fire() override; }; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/WeaponCameraShake.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/WeaponCameraShake.cpp new file mode 100644 index 00000000..03a594a9 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/WeaponCameraShake.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "WeaponCameraShake.h" diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/WeaponCameraShake.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/WeaponCameraShake.h new file mode 100644 index 00000000..604113b5 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/WeaponCameraShake.h @@ -0,0 +1,16 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" + +#include "WeaponCameraShake.generated.h" + +/** + * + */ +UCLASS() +class ENDLESSVENDETTA_API UWeaponCameraShake : public UCameraShakeBase +{ + GENERATED_BODY() +};