Compare commits
2 Commits
f3f4ad0409
...
7497f8edce
Author | SHA1 | Date | |
---|---|---|---|
7497f8edce | |||
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 "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))
|
||||||
{
|
{
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user