Merge remote-tracking branch 'origin/shotgun-creation' into dev
This commit is contained in:
commit
7b923429db
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_WeaponStatsPrompt.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_WeaponStatsPrompt.uasset
(Stored with Git LFS)
Binary file not shown.
@ -23,7 +23,7 @@ ABaseWeaponClass::ABaseWeaponClass()
|
|||||||
void ABaseWeaponClass::BeginPlay()
|
void ABaseWeaponClass::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
tempWeaponDamage = WeaponDamage;
|
||||||
collisionParams.AddIgnoredActor(playerInWorld);
|
collisionParams.AddIgnoredActor(playerInWorld);
|
||||||
collisionParams.AddIgnoredActor(this);
|
collisionParams.AddIgnoredActor(this);
|
||||||
|
|
||||||
@ -183,8 +183,16 @@ void ABaseWeaponClass::Fire()
|
|||||||
bStopShooting = false;
|
bStopShooting = false;
|
||||||
if (outHit.bBlockingHit)
|
if (outHit.bBlockingHit)
|
||||||
{
|
{
|
||||||
|
if (outHit.Distance >= FMath::Floor(BulletDistance/2))
|
||||||
|
{
|
||||||
|
tempWeaponDamage = WeaponDamage / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempWeaponDamage = WeaponDamage;
|
||||||
|
}
|
||||||
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||||
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(currentAmmoCount <= 0)
|
else if(currentAmmoCount <= 0)
|
||||||
|
@ -180,12 +180,11 @@ protected:
|
|||||||
UArrowComponent* GunStartArrow;
|
UArrowComponent* GunStartArrow;
|
||||||
bool bStopShooting = false;
|
bool bStopShooting = false;
|
||||||
|
|
||||||
private:
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
int tempWeaponDamage;
|
||||||
|
|
||||||
float originalMagnitude;
|
float originalMagnitude;
|
||||||
float originalMaxAngleLeft;
|
float originalMaxAngleLeft;
|
||||||
float originalMaxAngleRight;
|
float originalMaxAngleRight;
|
||||||
float originalMinMultiplier;
|
float originalMinMultiplier;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2,9 +2,57 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ShotgunClass.h"
|
#include "ShotgunClass.h"
|
||||||
|
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
||||||
|
#include "Engine/DamageEvents.h"
|
||||||
|
|
||||||
AShotgunClass::AShotgunClass()
|
AShotgunClass::AShotgunClass()
|
||||||
{
|
{
|
||||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
ShotgunBulletSpread = FVector(10,10,10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AShotgunClass::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AShotgunClass::Fire()
|
||||||
|
{
|
||||||
|
if(currentAmmoCount > 0)
|
||||||
|
{
|
||||||
|
traceStart = GunStartArrow->GetComponentLocation();
|
||||||
|
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
FVector newStartTrace = UKismetMathLibrary::RandomPointInBoundingBox(traceStart, ShotgunBulletSpread);
|
||||||
|
traceEnd = newStartTrace + (GunStartArrow->GetForwardVector() * BulletDistance);
|
||||||
|
GetWorld()->LineTraceSingleByChannel(outHit, newStartTrace, traceEnd, ECC_Visibility, collisionParams);
|
||||||
|
DrawDebugLine(this->GetWorld(), newStartTrace, traceEnd, FColor::Black , false, 0.2f, 0U, 0.2f);
|
||||||
|
currentAmmoCount --;
|
||||||
|
}
|
||||||
|
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
|
||||||
|
GenerateRecoilVector();
|
||||||
|
ClickDetectionTimer();
|
||||||
|
bulletCountShoot += 1;
|
||||||
|
bStopShooting = false;
|
||||||
|
if (outHit.bBlockingHit)
|
||||||
|
{
|
||||||
|
if (outHit.Distance >= FMath::Floor(BulletDistance/2))
|
||||||
|
{
|
||||||
|
tempWeaponDamage = WeaponDamage / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempWeaponDamage = WeaponDamage;
|
||||||
|
}
|
||||||
|
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||||
|
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(currentAmmoCount <= 0)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -17,5 +17,14 @@ class ENDLESSVENDETTA_API AShotgunClass : public ABaseWeaponClass
|
|||||||
public:
|
public:
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
AShotgunClass();
|
AShotgunClass();
|
||||||
|
|
||||||
|
//How far apart the bullets will be to eachother when shot with a shotgun
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Weapon")
|
||||||
|
FVector ShotgunBulletSpread;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Fire() override;
|
||||||
|
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -58,9 +58,16 @@ void ASniperClass::Fire()
|
|||||||
this->GetWorld()->GetTimerManager().SetTimer(SniperTimerHandle, this, &ASniperClass::StopFire, FireRate, false);
|
this->GetWorld()->GetTimerManager().SetTimer(SniperTimerHandle, this, &ASniperClass::StopFire, FireRate, false);
|
||||||
if (outHit.bBlockingHit)
|
if (outHit.bBlockingHit)
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Hit: %s"), *outHit.GetActor()->GetName());
|
if (outHit.Distance >= FMath::Floor(BulletDistance/2))
|
||||||
|
{
|
||||||
|
tempWeaponDamage = WeaponDamage / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempWeaponDamage = WeaponDamage;
|
||||||
|
}
|
||||||
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||||
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(currentAmmoCount <= 0)
|
else if(currentAmmoCount <= 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user