Fixed not being able to pickup primary while holding secondary

This commit is contained in:
MH261677 2024-02-23 18:09:31 +00:00
parent 6fc0a508cf
commit 27756691ba
2 changed files with 42 additions and 17 deletions

View File

@ -1,2 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Rafal\AppData\Local\JetBrains\Rider2023.3\resharper-host\temp\Rider\vAny\CoverageData\_EndlessVendetta.-1253833435\Snapshot\snapshot.utdcvr</s:String></wpf:ResourceDictionary>

View File

@ -360,11 +360,11 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (bIsReloading) return; if (bIsReloading) return;
if (IsValid(PrimaryWeapon)) if (IsValid(PrimaryWeapon))
{ {
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("IsPrimaryWeapon valid check running"));
PrimaryWeapon->DetachFromActor(DetatchRules); PrimaryWeapon->DetachFromActor(DetatchRules);
PrimaryWeapon->AttachToComponent(Mesh1P, AttachmentRules, FName("UnEquipGunSocket")); PrimaryWeapon->AttachToComponent(Mesh1P, AttachmentRules, FName("UnEquipGunSocket"));
PrimaryWeapon->SetActorHiddenInGame(true); PrimaryWeapon->SetActorHiddenInGame(true);
PrimaryWeapon->SetActorEnableCollision(false); PrimaryWeapon->SetActorEnableCollision(false);
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("Weapon Removing because validated"));
this->GetFirstPersonCameraComponent()->SetFieldOfView(90); this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
UE_LOG(LogTemp, Warning, TEXT("Primary Weapon Is Hidden: %hhd"), PrimaryWeapon->IsHidden()); UE_LOG(LogTemp, Warning, TEXT("Primary Weapon Is Hidden: %hhd"), PrimaryWeapon->IsHidden());
PrimaryWeapon = nullptr; PrimaryWeapon = nullptr;
@ -397,13 +397,16 @@ void AEndlessVendettaCharacter::EquipPrimary()
} }
} }
//For when you already have all your weapons and ur switching with 1 and 2 or when your picking up a weapon with a weapon in hand //For when you already have all your weapons and ur switching with 1 and 2 or when your picking up a weapon with a weapon in hand
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); if (PrimaryWeaponClass != nullptr)
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("non ifstatement code running")); {
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor); GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("non ifstatement code running"));
PrimaryWeapon->SetActorHiddenInGame(false); PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle); PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
bIsCurrentlyHoldingWeapon = true; PrimaryWeapon->SetActorHiddenInGame(false);
bHasRifle = true; GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle);
bIsCurrentlyHoldingWeapon = true;
bHasRifle = true;
}
} }
void AEndlessVendettaCharacter::EquipSecondary() void AEndlessVendettaCharacter::EquipSecondary()
@ -450,11 +453,14 @@ void AEndlessVendettaCharacter::EquipSecondary()
} }
GLog->Log("Secondary Weapon Equipped"); GLog->Log("Secondary Weapon Equipped");
} }
SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("PistolGripPoint")); if (SecondaryWeaponClass != nullptr)
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor); {
SecondaryWeapon->SetActorHiddenInGame(false); SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("PistolGripPoint"));
bIsCurrentlyHoldingWeapon = true; SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
GetWorldTimerManager().ClearTimer(SecondaryWeapon->reloadTimerHandle); SecondaryWeapon->SetActorHiddenInGame(false);
bIsCurrentlyHoldingWeapon = true;
GetWorldTimerManager().ClearTimer(SecondaryWeapon->reloadTimerHandle);
}
} }
void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit) void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
@ -470,8 +476,8 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
{ {
if(bIsCurrentlyHoldingWeapon) if(bIsCurrentlyHoldingWeapon)
{ {
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT("Player is currently holding weapon"));
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams); PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
UE_LOG(LogTemp, Warning, TEXT("PRIMARY WEAPON SPAWNING IN"));
} }
EquipPrimary(); EquipPrimary();
} }
@ -483,7 +489,22 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0); UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
} }
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Yellow, TEXT("Destroy just gets called and equip primary"));
if (IsValid(SecondaryWeapon))
{
if (bIsCurrentlyHoldingWeapon)
{
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("non ifstatement code running"));
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);
GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle);
bIsCurrentlyHoldingWeapon = true;
bHasRifle = true;
}
EquipPrimary();
}
Outhit->Destroy(); Outhit->Destroy();
EquipPrimary(); EquipPrimary();
} }
@ -491,6 +512,12 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
{ {
if (IsValid(SecondaryWeapon)) if (IsValid(SecondaryWeapon))
{ {
if(bIsCurrentlyHoldingWeapon)
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT("bIsCurrentlyHoldingSecondaryCalled, trying to spawn secondary weapon actor"));
SecondaryWeaponActor = GetWorld()->SpawnActor<AActor>(SecondaryWeaponClass, spawnParams);
}
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Orange, TEXT("EquipSecondarycalled skipped bIsCurrentlyHoldingWeapon check"));
EquipSecondary(); EquipSecondary();
} }
bIsWeaponPickedUp = true; bIsWeaponPickedUp = true;