Compare commits

..

2 Commits

Author SHA1 Message Date
baz
7497f8edce Add Upgrades to Lightning Ring 2025-04-15 22:12:09 +01:00
baz
a05a24dc62 Finalise base implementation of the Lightning Ring weapon 2025-04-15 21:49:05 +01:00
3 changed files with 76 additions and 12 deletions

Binary file not shown.

View File

@ -3,6 +3,8 @@
#include "LightningRingWeapon.h" #include "LightningRingWeapon.h"
#include "Components/SphereComponent.h" #include "Components/SphereComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetSystemLibrary.h"
#include "vampires/EnemyCharacter.h" #include "vampires/EnemyCharacter.h"
#include "vampires/HealthComponent.h" #include "vampires/HealthComponent.h"
@ -27,23 +29,75 @@ void ALightningRingWeapon::FireWeaponAction_Implementation()
{ {
Super::FireWeaponAction_Implementation(); Super::FireWeaponAction_Implementation();
if (OverlappedEnemies.Num() > 0) TArray<AEnemyCharacter*> targetableEnemies = OverlappedEnemies;
for (int i = 0; i < LightningBolts && targetableEnemies.Num() > 0; i++)
{ {
AEnemyCharacter* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)]; AEnemyCharacter* target = targetableEnemies[FMath::RandRange(0, targetableEnemies.Num() - 1)];
UHealthComponent* EnemyHealthComponent = target->GetHealthComponent();
TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes;
traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_Pawn));
AController* ownerController = nullptr; TArray<AActor*> actorsToIgnore = TArray<AActor*>({ GetOwner() });
if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner()))
{ TArray<AActor*> hitResults;
ownerController = character->GetController();
UKismetSystemLibrary::SphereOverlapActors(GetWorld(),
target->GetActorLocation(),
LightingBoltRadius,
traceObjectTypes,
AEnemyCharacter::StaticClass(),
actorsToIgnore,
hitResults);
for (AActor* EnemyHitResult : hitResults)
{
UGameplayStatics::ApplyDamage(EnemyHitResult, Damage, nullptr, this, nullptr);
} }
EnemyHealthComponent->TakeDamage(target, Damage, nullptr, ownerController, this); targetableEnemies.Remove(target);
} }
} }
bool ALightningRingWeapon::UpgradeWeapon_Implementation()
{
if (!Super::UpgradeWeapon_Implementation()) return false;
switch (CurrentLevel)
{
case 1:
LightningBolts++;
break;
case 2:
LightingBoltRadius += LightingBoltRadius;
Damage += 10;
break;
case 3:
LightningBolts++;
break;
case 4:
LightingBoltRadius += LightingBoltRadius;
Damage += 20;
break;
case 5:
LightningBolts++;
break;
case 6:
LightingBoltRadius += LightingBoltRadius;
Damage += 20;
break;
case 7:
LightningBolts++;
break;
default:
return false;
}
return true;
}
void ALightningRingWeapon::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, void ALightningRingWeapon::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{ {
if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor))
{ {

View File

@ -20,6 +20,14 @@ class VAMPIRES_API ALightningRingWeapon : public AWeapon
TArray<AEnemyCharacter*> OverlappedEnemies; TArray<AEnemyCharacter*> OverlappedEnemies;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int LightningBolts = 1;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float LightingBoltRadius = 200.0f;
public: public:
ALightningRingWeapon(); ALightningRingWeapon();
@ -29,6 +37,8 @@ protected:
public: public:
virtual void FireWeaponAction_Implementation() override; virtual void FireWeaponAction_Implementation() override;
virtual bool UpgradeWeapon_Implementation() override;
protected: protected:
UFUNCTION() UFUNCTION()
void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,