Merge branch 'dev' into Dialogue-System

This commit is contained in:
Philip W 2024-01-11 20:41:33 +00:00
commit 15ca1add73
18 changed files with 156 additions and 136 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -69,14 +69,15 @@ void AEndlessVendettaCharacter::BeginPlay()
}
InventoryComponent = Cast<UInventoryComponent>(GetWorld()->GetFirstPlayerController()->GetComponentByClass(UInventoryComponent::StaticClass()));
WalkSpeed = CharacterMovement->MaxWalkSpeed;
OriginalWalkSpeed = CharacterMovement->MaxWalkSpeed;
CurrentStamina = MaxStamina;
}
void AEndlessVendettaCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
WeaponPickUpSystem();
MoveGroundSpeed = Cast<UMovementComponent>(GetComponentByClass(UMovementComponent::StaticClass()))->Velocity.Size();
if (MoveGroundSpeed > 0)
@ -85,8 +86,40 @@ void AEndlessVendettaCharacter::Tick(float DeltaTime)
}
else if (MoveGroundSpeed <= 0)
{
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
bIsPlayerMoving = false;
}
if (bPressedJump)
{
if(CurrentStamina <= 0.0f)
{
CurrentStamina -= 20.0f;
}
}
//PLAYER STAMINA HANDLING
if (MoveGroundSpeed > 0)
{
if (bIsPlayerSprinting)
{
CurrentStamina -= FMath::Clamp(StaminaDecreaseRate, 0.0f, 100.0f);
if (CurrentStamina <= 0.0f)
{
bIsPlayerSprinting = false;
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
CurrentStamina = 0.0f;
CharacterMovement->MaxWalkSpeed = OriginalWalkSpeed;
}
}
}
if (!bIsPlayerSprinting)
{
if(CurrentStamina >= 100.0f)
{
CurrentStamina = 100.0f;
return;
}
CurrentStamina += FMath::Clamp(StaminaRegenRate, 0.0f, 100.0f);
}
}
void AEndlessVendettaCharacter::RegenHealth()
@ -129,11 +162,13 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
{
//Jumping
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Jumping);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopJump);
//Moving
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move);
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Sprint);
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopSprint);
//Looking
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
@ -511,6 +546,54 @@ void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
}
}
void AEndlessVendettaCharacter::Sprint()
{
bIsPlayerSprinting = true;
if (bIsPlayerSprinting)
{
if (MoveGroundSpeed > 0)
{
CharacterMovement->MaxWalkSpeed = SprintSpeed;
this->GetFirstPersonCameraComponent()->SetFieldOfView(100);
}
}
}
void AEndlessVendettaCharacter::StopSprint()
{
bIsPlayerSprinting = false;
if (!bIsPlayerSprinting)
{
UE_LOG(LogTemp, Display, TEXT("Player stopped sprinting"));
CharacterMovement->MaxWalkSpeed = OriginalWalkSpeed;
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
}
}
void AEndlessVendettaCharacter::Jumping()
{
if (CurrentStamina > 10.0f)
{
bHasPlayerJumped = true;
if (bHasPlayerJumped)
{
Super::Jump();
if (!CharacterMovement->IsFalling())
{
CurrentStamina -= 10.0f;
}
bHasPlayerJumped = false;
}
}
}
void AEndlessVendettaCharacter::StopJump()
{
Super::StopJumping();
UE_LOG(LogTemp, Display, TEXT("Player has stopped jumping"));
bHasPlayerJumped = false;
}
void AEndlessVendettaCharacter::Look(const FInputActionValue& Value)
{
// input is a Vector2D

View File

@ -73,6 +73,9 @@ class AEndlessVendettaCharacter : public ACharacter
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputAction* InteractAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputAction* SprintAction;
public:
AEndlessVendettaCharacter();
@ -83,6 +86,23 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float DefaultHealth = 100.0f;
//STAMINA AND SPRINT SPEED
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float MaxStamina = 100;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float CurrentStamina;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float StaminaDecreaseRate = 0.2;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float StaminaRegenRate = 0.05;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
float SprintSpeed = 900;
//Getting the charMovementComp
UCharacterMovementComponent* CharacterMovement = GetCharacterMovement();
float WalkSpeed;
float OriginalWalkSpeed;
AActor* PrimaryWeaponActor;
AActor* SecondaryWeaponActor;
bool bIsPrimaryWeaponCreated = false;
@ -107,6 +127,9 @@ public:
bool bIsPlayerMoving = false;
UPROPERTY(VisibleAnywhere)
bool bIsPlayerSprinting = false;
double MoveGroundSpeed;
/** Look Input Action */
@ -149,6 +172,13 @@ public:
UFUNCTION(BlueprintCallable, Category = "Weapons")
void StopFire();
void Sprint();
void StopSprint();
void Jumping();
void StopJump();
bool bHasPlayerJumped = false;
UArrowComponent* ScopedLocationArrow;
UPROPERTY(EditAnywhere, Category = "Dont Touch")

View File

@ -6,7 +6,7 @@
#include "CollisionDebugDrawingPublic.h"
#include "Kismet/KismetMathLibrary.h"
#include "Camera/CameraComponent.h"
#include "VisionLinkEnemyLOSTest.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "GameFramework/Character.h"
void AVisionLink::BeginPlay()
@ -47,9 +47,16 @@ void AVisionLink::SendOutPingPulse()
GetWorld()->GetTimerManager().SetTimer(PulseHandle, this, &AVisionLink::SendOutPingPulse, TimeInbetweenPingPulses, false);
PlayPingPulseAnim(TimeInbetweenPingPulses);
UCameraComponent* PlayerCamComp = Cast<UCameraComponent>(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UCameraComponent::StaticClass()));
ACharacter* PlayersCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter();
UCameraComponent* PlayerCamComp = Cast<UCameraComponent>(PlayersCharacter->GetComponentByClass(UCameraComponent::StaticClass()));
// Ignored Actors
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(GetWorld()->GetFirstPlayerController()->GetCharacter());
AEndlessVendettaCharacter* EV_Character = Cast<AEndlessVendettaCharacter>(PlayersCharacter);
if ( IsValid(EV_Character) && IsValid(EV_Character->PrimaryWeaponActor)) ActorsToIgnore.Add(EV_Character->PrimaryWeaponActor);
if ( IsValid(EV_Character) && IsValid(EV_Character->SecondaryWeaponActor)) ActorsToIgnore.Add(EV_Character->SecondaryWeaponActor);
ActorsToIgnore.Add(PlayersCharacter);
TestLOS(PlayerCamComp->GetComponentTransform(), ActorsToIgnore);
}
@ -75,7 +82,7 @@ void AVisionLink::TestLOS(FTransform StartingPos, TArray<AActor*> &ActorsToIgnor
if (!GetWorld()->LineTraceSingleByChannel(outHit, StartingPos.GetLocation(), LT_EndPoint, ECC_Camera, QueryParams)) continue;
AActor* HitActor = outHit.GetActor();
if (!HitActor->ActorHasTag(FName("Enemy"))) continue;
if (!HitActor->ActorHasTag(FName("Enemy")) || HitActor->ActorHasTag("Dead")) continue;
//DrawDebugLine(GetWorld(), outHit.TraceStart, outHit.ImpactPoint, FColor::Blue, false, 3, 0, 3);
ActorsToIgnore.Add(HitActor);

View File

@ -3,7 +3,6 @@
#pragma once
#include "CoreMinimal.h"
#include "VisionLinkEnemyLOSTest.h"
#include "EndlessVendetta/GadgetSystem/ReconGadget.h"
#include "VisionLink.generated.h"

View File

@ -1,74 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VisionLinkEnemyLOSTest.h"
#include "Components/BoxComponent.h"
#include "Kismet/KismetMathLibrary.h"
// Sets default values
AVisionLinkEnemyLOSTest::AVisionLinkEnemyLOSTest()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AVisionLinkEnemyLOSTest::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AVisionLinkEnemyLOSTest::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AVisionLinkEnemyLOSTest::TestLOS(TArray<uint32> EnemiesInLink, AActor* LOSActor)
{
// Get all overlapping Actors
UBoxComponent* CollisionBox = Cast<UBoxComponent>(GetComponentByClass(UBoxComponent::StaticClass()));
if (!IsValid(CollisionBox))
{
Destroy();
return;
}
TArray<AActor*> OverlappingEnemies;
CollisionBox->GetOverlappingActors(OverlappingEnemies);
if (OverlappingEnemies.IsEmpty())
{
Destroy();
return;
}
for (int i = 0; i < OverlappingEnemies.Num(); i++)
{
// Overlapping Enemies Array should only contain enemies which aren't already in the link
if (!OverlappingEnemies[i]->ActorHasTag(FName("Enemy")) || EnemiesInLink.Contains(OverlappingEnemies[i]->GetUniqueID()))
{
UE_LOG(LogTemp, Warning, TEXT("enemy name: %s"), *OverlappingEnemies[i]->GetName());
OverlappingEnemies.RemoveAt(i);
}
}
if (OverlappingEnemies.IsEmpty())
{
Destroy();
return;
}
/*for (AActor* Enemy : OverlappingEnemies)
{
FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(LOSActor->GetActorLocation(), Enemy->GetActorLocation());
UE_LOG(LogTemp, Warning, TEXT("Look at Rotation: %f"), LookAtRotation.Yaw);
}*/
Destroy();
}

View File

@ -1,30 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "VisionLinkEnemyLOSTest.generated.h"
UCLASS()
class ENDLESSVENDETTA_API AVisionLinkEnemyLOSTest : public AActor
{
GENERATED_BODY()
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
UPROPERTY(EditDefaultsOnly, Category = "Vision Link")
float SpawnOffset = 0;
// Sets default values for this actor's properties
AVisionLinkEnemyLOSTest();
// Called every frame
virtual void Tick(float DeltaTime) override;
void TestLOS(TArray<uint32> EnemiesInLink, AActor* LOS_Actor);
};

View File

@ -12,3 +12,11 @@ https://docs.google.com/presentation/d/18K_XKPOnZg56S7NocoEVEdA8lVHvtSVWkflCJFtD
## Endless Vendetta Script
https://docs.google.com/document/d/1MvQ3F871koZ53Iz9kEm1RQPiGyirKYcUlOa3ygn4et8/edit?usp=sharing
## Storyboard
https://docs.google.com/presentation/d/19U0EaM-FMOQF1PJK32SKJUJZpXn9ee6TqFE8gCitA64/edit?usp=sharing
## Asset List
https://docs.google.com/document/d/1Fdbr4cpkdt6jJFpZQmIbvP3FGk25JDIMfuRHyolwX_Y/edit?usp=sharing
## Dialogue tree
https://drive.google.com/file/d/11lsDzHkY9VMklJm8PkwArHKXqH1wdvxN/view?usp=sharing