5 Commits

Author SHA1 Message Date
Kukukakhew
c7d4191214 Cleanup Part 5 2026-06-02 22:40:30 -04:00
Kukukakhew
7e2ce95fa1 Cleanup Part 4 2026-06-02 22:22:18 -04:00
Kukukakhew
f19e42477b Cleanup Part 3 2026-06-02 21:42:21 -04:00
Kukukakhew
32c119b73b Cleanup part 2 2026-06-02 21:32:57 -04:00
Kukukakhew
c14eb09ce7 Reorganizing part 1 2026-06-02 21:10:36 -04:00
12 changed files with 11 additions and 525 deletions

View File

@@ -65,27 +65,19 @@ bool ADDICharacter::Server_SpawnProjectile_Validate()
void ADDICharacter::Server_SpawnProjectile_Implementation()
{
FVector Location = GetActorLocation();
if (GetMesh()->DoesSocketExist("headSocket"))
Location = GetMesh()->GetSocketLocation("headSocket"); //Socket_Projectile
FRotator Rotation = GetViewRotation();
FRotator Rotation = GetActorRotation();
FVector Dir = GetActorForwardVector();
GetActorEyesViewPoint(Location, Rotation);
Location += Dir * 155.f;
Location += Dir * 200.f;
if (!ProjectileClass)
{
GEngine->AddOnScreenDebugMessage(2, 10.f, FColor::Emerald, "No Projectile Set");
GEngine->AddOnScreenDebugMessage(1, 10.f, FColor::Emerald, "No Projectile Set");
return;
}
GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation);
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = GetInstigator();
GEngine->AddOnScreenDebugMessage(-1,10.f,FColor::Red,FString::Printf(TEXT("Server Spawning Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation, SpawnInfo);
}
void ADDICharacter::Client_CharacterHit_Implementation()

View File

@@ -1,124 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "DDICharacter.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "OpenConflict/Weapons/Projectiles/ProjectileBase.h"
// Sets default values
ADDICharacter::ADDICharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
bReplicates = true;
// bReplicateMovement = true;
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
CameraComponent->SetupAttachment(GetMesh(), "headSocket");
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f));
CameraComponent->bUsePawnControlRotation = true;
HealthComponent = CreateDefaultSubobject<UDDIHealth>(TEXT("HealthComponent"));
GetCapsuleComponent()->SetCollisionProfileName(TEXT("BlockAllDynamic"));
GetCapsuleComponent()->SetGenerateOverlapEvents(true);
GetCapsuleComponent()->SetNotifyRigidBodyCollision(true);
}
// Called when the game starts or when spawned
void ADDICharacter::BeginPlay()
{
Super::BeginPlay();
if (GetCapsuleComponent())
{
GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &ADDICharacter::OnHit);
}
}
// Called every frame
void ADDICharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ADDICharacter::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
Server_CharacterHit(HitComponent, OtherActor, OtherComp, NormalImpulse, Hit);
}
void ADDICharacter::TakeDamage(int Damage)
{
HealthComponent->TakeDamage(Damage);
}
bool ADDICharacter::Server_SpawnProjectile_Validate()
{
return true;
}
void ADDICharacter::Server_SpawnProjectile_Implementation()
{
FVector Location = GetActorLocation();
if (GetMesh()->DoesSocketExist("headSocket"))
Location = GetMesh()->GetSocketLocation("headSocket"); //Socket_Projectile
FRotator Rotation = GetViewRotation();
FVector Dir = GetActorForwardVector();
GetActorEyesViewPoint(Location, Rotation);
Location += Dir * 155.f;
if (!ProjectileClass)
{
GEngine->AddOnScreenDebugMessage(2, 10.f, FColor::Emerald, "No Projectile Set");
return;
}
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = GetInstigator();
GEngine->AddOnScreenDebugMessage(-1,10.f,FColor::Red,FString::Printf(TEXT("Server Spawning Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation, SpawnInfo);
}
void ADDICharacter::Client_CharacterHit_Implementation()
{
TakeDamage(10);
OnDamageTaken();
}
bool ADDICharacter::Client_CharacterHit_Validate()
{
return true;
}
void ADDICharacter::Server_CharacterHit_Implementation(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if (AProjectileBase* Projectile = Cast<AProjectileBase>(OtherActor))
{
// if (Cast<ADDICharacter>(Projectile->Owner) == this)
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Emerald, "Damage dealt");
Client_CharacterHit();
}
}
bool ADDICharacter::Server_CharacterHit_Validate(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
return true;
}
void ADDICharacter::OnRep_Health()
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "Health Replicated");
}
void ADDICharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ADDICharacter, HealthComponent);
}

View File

@@ -1,63 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MagazineActor.h"
#include "OpenConflict/PlayerCharacter/Components/DDIHealth.h"
// Sets default values
AMagazineActor::AMagazineActor()
{
// 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;
bReplicates = true;
}
// Called when the game starts or when spawned
void AMagazineActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMagazineActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (!ActiveMag && CurrentCount < MAX_COUNT )
{
GetWorld()->GetTimerManager().SetTimer(RepackTimer, this, &AMagazineActor::PackMag, RepackDelay, true, RepackDelay);
}
}
void AMagazineActor::PackMag()
{
if (hasReserveAmmo)
{
CurrentCount += 1;
AMMO_REPACK.Broadcast();
}
if (CurrentCount >= MAX_COUNT)
{
CurrentCount = MAX_COUNT;
GetWorld()->GetTimerManager().ClearTimer(RepackTimer);
}
}
void AMagazineActor::StripRound()
{
CurrentCount -= 1;
if (CurrentCount <= 0)
{
CurrentCount = 0;
}
}
void AMagazineActor::SetAmmoValues(int MaxCount)
{
MAX_COUNT = MaxCount;
CurrentCount = MAX_COUNT;
}

View File

@@ -1,76 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MagazineActor.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FAMMO_REPACK);
UCLASS()
class OPENCONFLICT_API AMagazineActor : public AActor
{
GENERATED_BODY()
/*UPROPERTY and UFUNCTION declarations*/
private:
/*Properties*/
UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
int MAX_COUNT;
UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
int CurrentCount;
UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
bool ActiveMag = false;
UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
float RepackDelay = 0.5f;
/*Functions*/
protected:
/*Properties*/
/*Functions*/
public:
/*Properties*/
UPROPERTY(BlueprintAssignable)
FAMMO_REPACK AMMO_REPACK;
/*Functions*/
UFUNCTION(BlueprintImplementableEvent)
void EmptyMagEvent();
/*C++ only declarations*/
private:
/*Properties*/
/*Functions*/
void PackMag();
protected:
/*Properties*/
FTimerHandle RepackTimer;
/*Functions*/
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
/*Properties*/
bool hasReserveAmmo = true;
/*Functions*/
// Sets default values for this actor's properties
AMagazineActor();
AMagazineActor(int MaxCount);
// Called every frame
virtual void Tick(float DeltaTime) override;
void StripRound();
void SetAmmoValues(int MaxCount);
};

View File

@@ -1,34 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MagazineComponenet.h"
// Sets default values for this component's properties
UMagazineComponenet::UMagazineComponenet()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UMagazineComponenet::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UMagazineComponenet::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}

View File

@@ -1,28 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MagazineComponenet.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class OPENCONFLICT_API UMagazineComponenet : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMagazineComponenet();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};

View File

@@ -33,14 +33,13 @@ void AProjectileBase::BeginPlay()
if (collision)
collision->OnComponentHit.AddDynamic(this, &AProjectileBase::OnHit);
}
// Called every frame
void AProjectileBase::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
FVector Location = GetActorLocation();
GEngine->AddOnScreenDebugMessage(3,10.f,FColor::Red,FString::Printf(TEXT("Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
}

View File

@@ -8,23 +8,13 @@ AWeaponBase::AWeaponBase()
{
// 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;
bReplicates = true;
WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Weapon Component"));
}
// Called when the game starts or when spawned
void AWeaponBase::BeginPlay()
{
Super::BeginPlay();
// AMMO_REPACK.AddDynamic(this, &AWeaponBase::MagRepacking);
for (int i = 0; i < RESERVE_MAG_COUNT; i++)
{
// AMagazineActor* mag = new AMagazineActor();
// mag->SetAmmoValues(MAX_AMMO_COUNT);
// ActiveMags.Add(mag);
}
}
@@ -35,94 +25,3 @@ void AWeaponBase::Tick(float DeltaTime)
}
void AWeaponBase::MagRepacking()
{
RESERVE_AMMO_POOL_DEFAULT -= 1;
if (RESERVE_AMMO_POOL_DEFAULT <= 0)
{
RESERVE_AMMO_POOL_DEFAULT = 0;
// for (AMagazineActor* mag : ActiveMags)
// {
// mag->hasReserveAmmo = false;
// }
}
}
void AWeaponBase::Server_SpawnProjectile_Implementation()
{
FVector Location;
if (WeaponMesh->DoesSocketExist("Socket_Projectile"))
Location = WeaponMesh->GetSocketLocation("Socket_Projectile");
FRotator Rotation = GetActorRotation();
FVector Dir = GetOwner()->GetActorForwardVector();
// GetActorEyesViewPoint(Location, Rotation);
if (Location.Equals(FVector::ZeroVector))
Location += Dir * 55.f;
else
{
GEngine->AddOnScreenDebugMessage(2,10.f,FColor::Green,TEXT("Server Failed to get Socket Location"));
return;
}
if (!ProjectileClass)
{
GEngine->AddOnScreenDebugMessage(2, 10.f, FColor::Emerald, "Server No Projectile Set");
return;
}
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = GetOwner();
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
GEngine->AddOnScreenDebugMessage(2,10.f,FColor::Red,FString::Printf(TEXT("Server Spawning Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
AActor* projectile = GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation, SpawnInfo);
if (!projectile)
GEngine->AddOnScreenDebugMessage(2,10.f,FColor::Red,TEXT("Failed to Spawn"));
Client_SpawnProjectile();
}
bool AWeaponBase::Server_SpawnProjectile_Validate()
{
return true;
}
void AWeaponBase::Client_SpawnProjectile_Implementation()
{
FVector Location;
if (WeaponMesh->DoesSocketExist("Socket_Projectile"))
Location = WeaponMesh->GetSocketLocation("Socket_Projectile");
FRotator Rotation = GetActorRotation();
FVector Dir = GetActorForwardVector();
// GetActorEyesViewPoint(Location, Rotation);
if (Location.Equals(FVector::ZeroVector))
Location += Dir * 55.f;
else
{
GEngine->AddOnScreenDebugMessage(1,10.f,FColor::Green,TEXT("Client Failed to get Socket Location"));
return;
}
if (!ProjectileClass)
{
GEngine->AddOnScreenDebugMessage(1, 10.f, FColor::Emerald, "Client No Projectile Set");
return;
}
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
GEngine->AddOnScreenDebugMessage(1,10.f,FColor::Red,FString::Printf(TEXT("Client Spawning Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation, SpawnInfo);
}
bool AWeaponBase::Client_SpawnProjectile_Validate()
{
return true;
}

View File

@@ -4,8 +4,6 @@
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "WeaponEnums.h"
// #include "UMagazine.h"
#include "WeaponBase.generated.h"
UCLASS()
@@ -13,80 +11,16 @@ class OPENCONFLICT_API AWeaponBase : public AActor
{
GENERATED_BODY()
/*UPROPERTY and UFUNCTION declarations*/
private:
/*Properties*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon HUD", meta=(AllowPrivateAccess=true))
UTexture2D* Texture;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon Anims", meta=(AllowPrivateAccess=true))
WeaponNames WeaponNameEnum;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon Anims", meta=(AllowPrivateAccess=true))
FName AttachSocketName;
/*Ammo counter for in mags*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon Ammo", meta=(AllowPrivateAccess=true))
int MAX_AMMO_COUNT = 30; //Tracks max ammo in one mag, not to be edited during runtime ever
UPROPERTY(BlueprintReadOnly, Category="Weapon Ammo", meta=(AllowPrivateAccess=true))
int MagIndex; //Tracks index for ActiveMags Array
// UPROPERTY(BlueprintReadOnly, Category="Weapon Ammo", meta=(AllowPrivateAccess=true))
// TArray<UMagazine*> ActiveMags; //Tracks all mags for weapon
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon Ammo", meta=(AllowPrivateAccess=true))
int RESERVE_MAG_COUNT = 2; //Tracks how many mags are kept in reserve. DO NOT INCLUDE MAG IN WEAPON
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Weapon Ammo", meta=(AllowPrivateAccess=true))
int RESERVE_AMMO_POOL_DEFAULT = 120;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Weapon Ammo", meta=(AllowPrivateAccess=true))
TSubclassOf<AActor> ProjectileClass;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta=(AllowPrivateAccess=true))
USkeletalMeshComponent* WeaponMesh;
/*Functions*/
protected:
/*Properties*/
/*Functions*/
public:
/*Properties*/
// UPROPERTY(BlueprintAssignable)
// FAMMO_REPACK AMMO_REPACK;
/*Functions*/
UFUNCTION()
void MagRepacking();
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
void Server_SpawnProjectile();
UFUNCTION(Client, Reliable, WithValidation, BlueprintCallable)
void Client_SpawnProjectile();
/*C++ only declarations*/
private:
/*Properties*/
/*Functions*/
// Sets default values for this actor's properties
AWeaponBase();
protected:
/*Properties*/
/*Functions*/
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
/*Properties*/
/*Functions*/
// Called every frame
virtual void Tick(float DeltaTime) override;
// Sets default values for this actor's properties
AWeaponBase();
};

View File

@@ -1,13 +0,0 @@
#pragma once
#include "CoreMinimal.h"
#include "WeaponEnums.generated.h"
UENUM(BlueprintType)
enum class WeaponNames : uint8
{
Pistol = 0 UMETA(DisplayName = "Pistol"),
Rifle = 1 UMETA(DisplayName = "Rifle"),
Shotgun = 2 UMETA(DisplayName = "Shotgun"),
Sniper = 3 UMETA(DisplayName = "Sniper")
};