diff --git a/Content/Weapons/FireWand/BP_FireWandWeapon.uasset b/Content/Weapons/FireWand/BP_FireWandWeapon.uasset new file mode 100644 index 0000000..046fd15 --- /dev/null +++ b/Content/Weapons/FireWand/BP_FireWandWeapon.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:943b78e4be7f7ac8bb53898027ccc2d2146d4c2c75e9a8cd273b7f3d9d7378f8 +size 24017 diff --git a/Source/vampires/Weapons/FireWandWeapon.cpp b/Source/vampires/Weapons/FireWandWeapon.cpp new file mode 100644 index 0000000..fb4f73b --- /dev/null +++ b/Source/vampires/Weapons/FireWandWeapon.cpp @@ -0,0 +1,37 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "FireWandWeapon.h" + +#include "Kismet/KismetMathLibrary.h" + +AFireWandWeapon::AFireWandWeapon() +{ +} + +void AFireWandWeapon::BeginPlay() +{ + Super::BeginPlay(); +} + +void AFireWandWeapon::FireWeaponAction_Implementation() +{ + if (IsValid(ProjectileTemplate) && OverlappedEnemies.Num() > 0) + { + FActorSpawnParameters actorSpawnParameters; + actorSpawnParameters.Owner = this; + actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot; + + AProjectile* projectile = GetWorld()->SpawnActor(ProjectileTemplate, GetOwner()->GetTransform(), + actorSpawnParameters); + + AActor* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)]; + FVector direction = UKismetMathLibrary::GetDirectionUnitVector( + GetActorLocation(), target->GetActorLocation()); + direction.Z = 0.0; + direction.Normalize(); + + projectile->TargetDirection = direction; + } +} diff --git a/Source/vampires/Weapons/FireWandWeapon.h b/Source/vampires/Weapons/FireWandWeapon.h new file mode 100644 index 0000000..72d1ad5 --- /dev/null +++ b/Source/vampires/Weapons/FireWandWeapon.h @@ -0,0 +1,25 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "ProjectileWeapon.h" +#include "FireWandWeapon.generated.h" + +/** + * + */ +UCLASS() +class VAMPIRES_API AFireWandWeapon : public AProjectileWeapon +{ + GENERATED_BODY() + +public: + AFireWandWeapon(); + +protected: + virtual void BeginPlay() override; + +public: + virtual void FireWeaponAction_Implementation() override; +};