Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added debug spheres on explosion #97

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Config/DefaultGame.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ InsertPack = (PackSource="StarterContent.upack",PackName="StarterContent")
bIsDrawHitCursorLine=0
bIsDrawDeprojectedCursorLine=0
bIsShowMouseCursor=1
bIsDrawExplosionSpheres=0
NetGraph=1
CameraVerticalSpeedLag=0.000000
UnUsedEnum=Everything
Expand Down
Binary file modified Content/Maps/warmup.umap
Binary file not shown.
7 changes: 7 additions & 0 deletions Source/Cloud9/Game/Cloud9DeveloperSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ UCloud9DeveloperSettings::UCloud9DeveloperSettings(const FObjectInitializer& Obj
bIsShowMouseCursor = 0;
bIsDrawDeprojectedCursorLine = 0;
bIsDrawHitCursorLine = 0;
bIsDrawExplosionSpheres = 0;
NetGraph = 0;
Volume = 0.1;
}
Expand Down Expand Up @@ -98,6 +99,12 @@ void UCloud9DeveloperSettings::InitializeCVars()
TEXT("Whether to show mouse cursor on screen or not in game")
);

RegisterConsoleVariable(
bIsDrawExplosionSpheres,
TEXT("r.bIsDrawExplosionSpheres"),
TEXT("Whether to debug explosions spheres")
);

RegisterConsoleVariable(
NetGraph,
TEXT("r.NetGraph"),
Expand Down
3 changes: 3 additions & 0 deletions Source/Cloud9/Game/Cloud9DeveloperSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class CLOUD9_API UCloud9DeveloperSettings : public UDeveloperSettings
UPROPERTY(config, EditAnywhere, BlueprintReadWrite, Category=Debug)
int32 bIsShowMouseCursor;

UPROPERTY(config, EditAnywhere, BlueprintReadWrite, Category=Debug)
int32 bIsDrawExplosionSpheres;

UPROPERTY(config, EditAnywhere, BlueprintReadWrite, Category=Debug)
int32 NetGraph;

Expand Down
51 changes: 49 additions & 2 deletions Source/Cloud9/Weapon/Classes/Cloud9WeaponGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "Cloud9WeaponGrenade.h"

#include "DrawDebugHelpers.h"

#include "Cloud9/Character/Cloud9Character.h"
#include "Cloud9/Game/Cloud9DeveloperSettings.h"
#include "Cloud9/Game/Cloud9GameInstance.h"
Expand Down Expand Up @@ -90,8 +92,9 @@ bool ACloud9WeaponGrenade::OnInitialize(const FWeaponId& NewWeaponId, FName NewW
}

let CommonData = WeaponDefinition.GetCommonData();
Explosion->Radius = CommonData->Grenade.ExplosionRadius;
Explosion->ImpulseStrength = CommonData->Grenade.ImpulseStrength;

Explosion->Radius = GetWeaponInfo()->Radius;
Explosion->ImpulseStrength = GetWeaponInfo()->Damage * CommonData->Grenade.ImpulseMultiplier;
Explosion->bIgnoreOwningActor = true;
Explosion->bImpulseVelChange = true;

Expand Down Expand Up @@ -232,6 +235,7 @@ bool ACloud9WeaponGrenade::OnGrenadeActionLoop()
return false;
}

// TODO: look like active effect not required (can be replaced by niagara effect)
if (IsValid(ActiveEffect))
{
ActiveEffect->Activate();
Expand Down Expand Up @@ -262,6 +266,49 @@ bool ACloud9WeaponGrenade::OnGrenadeActionLoop()
UCloud9SoundPlayer::PlayRandomSound(ExplodeSounds, GetActorLocation(), Settings->Volume);
}

if (Settings->bIsDrawExplosionSpheres)
{
constexpr int SphereSegments = 32;
constexpr int SphereLifeTime = 4.0f;
constexpr int SphereThickness = 1.0f;

DrawDebugSphere(
GetWorld(),
GetActorLocation(),
Explosion->Radius * 0.5f,
SphereSegments,
FColor::Red,
false,
SphereLifeTime,
0,
SphereThickness
);

DrawDebugSphere(
GetWorld(),
GetActorLocation(),
Explosion->Radius * 0.75f,
SphereSegments,
FColor::Yellow,
false,
SphereLifeTime,
0,
SphereThickness
);

DrawDebugSphere(
GetWorld(),
GetActorLocation(),
Explosion->Radius * 1.0f,
SphereSegments,
FColor::Green,
false,
SphereLifeTime,
0,
SphereThickness
);
}

// Activate action finished timer
ActiveTimerHandle = GetWorld()
| EUWorld::AsyncAfter{
Expand Down
10 changes: 5 additions & 5 deletions Source/Cloud9/Weapon/Tables/WeaponCommonData.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ struct FGrenadeCommonData
{
GENERATED_BODY()

UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Explosive)
float ExplosionRadius = 200.0f;

UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Explosive)
float ImpulseStrength = 2000.0f;
/**
* Only relevant for frag (explosive)
*/
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Damage)
float ImpulseMultiplier = 10.0f;

UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Throw)
float MaxThrowImpulse = 800.0f;
Expand Down
19 changes: 11 additions & 8 deletions Source/Cloud9/Weapon/Tables/WeaponTableGrenade.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,28 @@ struct FGrenadeWeaponInfo : public FBaseWeaponInfo
TSubclassOf<ACloud9WeaponGrenade> Class;

/**
* --
* Only relevant for frag (explosive) and molotov grenade
*/
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Damage,
meta=(UIMin="0", UIMax="1000", ClampMin="0", ClampMax="1000"))
float Damage;

/**
* Damage against armored opponents is multiplied by ArmorPenetration * 0.5
* Effective radius for grenade
* - Explosive - Explosive radius
* - Molotov - Radius of burning
* - Smoke - Radius of smoke
* - Flash - Not relevant
*/
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Damage,
meta=(UIMin="0", UIMax="1.0", ClampMin="0", ClampMax="2.0"))
float ArmorPenetration = 2.0f;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Damage)
float Radius = 200.0f;

/**
* --
* Damage against armored opponents is multiplied by ArmorPenetration * 0.5
*/
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category=Damage,
meta=(UIMin="0", UIMax="1.0", ClampMin="0", ClampMax="1.0"))
float RangeModifier = 1.0f;
meta=(UIMin="0", UIMax="1.0", ClampMin="0", ClampMax="2.0"))
float ArmorPenetration = 2.0f;

/**
* Time to pull out pin of grenade before throw
Expand Down