From 66a07e621dc5ca27fb13419579a6a167736dc12e Mon Sep 17 00:00:00 2001 From: baz Date: Wed, 31 Jul 2024 15:27:45 +0100 Subject: [PATCH] Add Gun Weapon --- .../BP_PhieraDerTuphelloWeapon.uasset | 3 ++ Source/vampires/Weapons/GunWeapon.cpp | 42 +++++++++++++++++++ Source/vampires/Weapons/GunWeapon.h | 25 +++++++++++ 3 files changed, 70 insertions(+) create mode 100644 Content/Weapons/PhieraDerTuphello/BP_PhieraDerTuphelloWeapon.uasset create mode 100644 Source/vampires/Weapons/GunWeapon.cpp create mode 100644 Source/vampires/Weapons/GunWeapon.h diff --git a/Content/Weapons/PhieraDerTuphello/BP_PhieraDerTuphelloWeapon.uasset b/Content/Weapons/PhieraDerTuphello/BP_PhieraDerTuphelloWeapon.uasset new file mode 100644 index 0000000..1da2ed3 --- /dev/null +++ b/Content/Weapons/PhieraDerTuphello/BP_PhieraDerTuphelloWeapon.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c6a7ab728482871de79a5bc7c079f9fa525ea2348b1c12e69f4b0fea8ce9f52 +size 24212 diff --git a/Source/vampires/Weapons/GunWeapon.cpp b/Source/vampires/Weapons/GunWeapon.cpp new file mode 100644 index 0000000..603ed22 --- /dev/null +++ b/Source/vampires/Weapons/GunWeapon.cpp @@ -0,0 +1,42 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "GunWeapon.h" + +AGunWeapon::AGunWeapon() +{ +} + +void AGunWeapon::BeginPlay() +{ + Super::BeginPlay(); +} + +void AGunWeapon::FireWeaponAction_Implementation() +{ + Super::FireWeaponAction_Implementation(); + + if (IsValid(ProjectileTemplate)) + { + FActorSpawnParameters actorSpawnParameters; + actorSpawnParameters.Owner = this; + actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot; + + AProjectile* projectile = GetWorld()->SpawnActor(ProjectileTemplate, GetOwner()->GetTransform(), + actorSpawnParameters); + projectile->TargetDirection = FVector(1.0f, 1.0f, 0.0f); + + projectile = GetWorld()->SpawnActor(ProjectileTemplate, GetOwner()->GetTransform(), + actorSpawnParameters); + projectile->TargetDirection = FVector(-1.0f, 1.0f, 0.0f); + + projectile = GetWorld()->SpawnActor(ProjectileTemplate, GetOwner()->GetTransform(), + actorSpawnParameters); + projectile->TargetDirection = FVector(1.0f, -1.0f, 0.0f); + + projectile = GetWorld()->SpawnActor(ProjectileTemplate, GetOwner()->GetTransform(), + actorSpawnParameters); + projectile->TargetDirection = FVector(-1.0f, -1.0f, 0.0f); + } +} \ No newline at end of file diff --git a/Source/vampires/Weapons/GunWeapon.h b/Source/vampires/Weapons/GunWeapon.h new file mode 100644 index 0000000..0dc6777 --- /dev/null +++ b/Source/vampires/Weapons/GunWeapon.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 "GunWeapon.generated.h" + +/** + * + */ +UCLASS() +class VAMPIRES_API AGunWeapon : public AProjectileWeapon +{ + GENERATED_BODY() + +public: + AGunWeapon(); + +protected: + virtual void BeginPlay() override; + +public: + virtual void FireWeaponAction_Implementation() override; +};