Finalise base implementation of the Lightning Ring weapon
This commit is contained in:
parent
f3f4ad0409
commit
a05a24dc62
BIN
Content/Weapons/LightningRing/BP_LightningRingWeapon.uasset
(Stored with Git LFS)
BIN
Content/Weapons/LightningRing/BP_LightningRingWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
@ -3,6 +3,8 @@
|
||||
|
||||
#include "LightningRingWeapon.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "vampires/EnemyCharacter.h"
|
||||
#include "vampires/HealthComponent.h"
|
||||
|
||||
@ -27,18 +29,31 @@ void ALightningRingWeapon::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)];
|
||||
UHealthComponent* EnemyHealthComponent = target->GetHealthComponent();
|
||||
|
||||
AController* ownerController = nullptr;
|
||||
if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner()))
|
||||
{
|
||||
ownerController = character->GetController();
|
||||
AEnemyCharacter* target = targetableEnemies[FMath::RandRange(0, targetableEnemies.Num() - 1)];
|
||||
|
||||
TArray<AActor*> actorsToIgnore = TArray<AActor*>({ GetOwner() });
|
||||
TArray<FHitResult> hitResults;
|
||||
UKismetSystemLibrary::SphereTraceMultiByProfile(GetWorld(),
|
||||
target->GetActorLocation(),
|
||||
target->GetActorLocation(),
|
||||
500.0f,
|
||||
FName(TEXT("Funny")),
|
||||
false,
|
||||
actorsToIgnore,
|
||||
EDrawDebugTrace::ForDuration,
|
||||
hitResults,
|
||||
true);
|
||||
|
||||
for (FHitResult EnemyHitResult : hitResults)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(EnemyHitResult.GetActor(), Damage, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
EnemyHealthComponent->TakeDamage(target, Damage, nullptr, ownerController, this);
|
||||
|
||||
targetableEnemies.Remove(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,11 @@ class VAMPIRES_API ALightningRingWeapon : public AWeapon
|
||||
|
||||
TArray<AEnemyCharacter*> OverlappedEnemies;
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int LightningBolts = 1;
|
||||
|
||||
public:
|
||||
ALightningRingWeapon();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user