Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
Added Burst firemode (with 2round and 3round blueprints).
Browse files Browse the repository at this point in the history
Fixed overriding GetWorld() in BaseEmpiresWeapon and BaseFiremode
  • Loading branch information
RoyAwesome committed Nov 4, 2014
1 parent 6971361 commit db59ffd
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 4 deletions.
Binary file removed Content/Blueprints/BE_Pistol.uasset
Binary file not shown.
Binary file modified Content/Blueprints/BE_Rifle.uasset
Binary file not shown.
Binary file modified Content/Blueprints/EmpPlayerState.uasset
Binary file not shown.
Binary file modified Content/Blueprints/EmpiresCharacter.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Content/Blueprints/Weapons/BE_Pistol.uasset
Binary file not shown.
Binary file added Content/Blueprints/Weapons/BE_Rifle.uasset
Binary file not shown.
Binary file modified Content/Blueprints/emp_bullet.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/Empires2/Private/BaseEmpiresWeapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void UBaseEmpiresWeapon::PostInitProperties()
}
}

UWorld* UBaseEmpiresWeapon::GetWorld()
UWorld* UBaseEmpiresWeapon::GetWorld() const
{
check(OwningCharacter);
return OwningCharacter->GetWorld();
Expand Down
2 changes: 1 addition & 1 deletion Source/Empires2/Private/BaseFiremode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ UBaseFiremode::UBaseFiremode(const class FPostConstructInitializeProperties& PCI

}

UWorld* UBaseFiremode::GetWorld()
UWorld* UBaseFiremode::GetWorld() const
{
check(Weapon);
return Weapon->GetWorld();
Expand Down
46 changes: 46 additions & 0 deletions Source/Empires2/Private/BurstFiremode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Fill out your copyright notice in the Description page of Project Settings.

#include "Empires2.h"
#include "BurstFiremode.h"


UBurstFiremode::UBurstFiremode(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{

}

void UBurstFiremode::BeginFire()
{
Super::BeginFire();

BurstsRemaining = ShotsInBurst;

//Start a timer based off the first shot time
float FirstShotTime = Weapon->GetActiveFiremodeData().FirstShotFireDelay;
if (FirstShotTime != 0)
{
GetWorld()->GetTimerManager().SetTimer(this, &UBurstFiremode::HandleFire, FirstShotTime, false);
}
else
{
HandleFire();
}
}

void UBurstFiremode::HandleFire()
{
BurstsRemaining--;

Weapon->FireShot();

if (IsFiring() && BurstsRemaining > 0)
{
//get the time until the next shot
float FireTime = (1.0f / Weapon->GetActiveFiremodeData().RoundsPerMinute) * 60.0f;

GetWorld()->GetTimerManager().SetTimer(this, &UBurstFiremode::HandleFire, FireTime, false);
}

}

2 changes: 1 addition & 1 deletion Source/Empires2/Public/BaseEmpiresWeapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class EMPIRES2_API UBaseEmpiresWeapon : public UObject

virtual void PostInitProperties() override;

virtual UWorld* GetWorld();
virtual UWorld* GetWorld() const override;

//Display Properties
public:
Expand Down
10 changes: 9 additions & 1 deletion Source/Empires2/Public/BaseFiremode.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EMPIRES2_API UBaseFiremode : public UObject
public:
virtual void SetWeapon(class UBaseEmpiresWeapon* Weapon);

virtual UWorld* GetWorld();
virtual UWorld* GetWorld() const override;
protected:

UBaseEmpiresWeapon* Weapon;
Expand All @@ -27,12 +27,20 @@ class EMPIRES2_API UBaseFiremode : public UObject
//FIRE CONTROL
public:

/* Start the firing sequence. */
virtual void BeginFire();

/* End the firing sequence */
virtual void EndFire();

//Actually Fire the bullet
virtual void HandleFire();

virtual bool CanFire()
{
return true;
}


//TODO: Implement Blueprint Hooks so designers can create their own firemodes
/*
Expand Down
28 changes: 28 additions & 0 deletions Source/Empires2/Public/BurstFiremode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "BaseFiremode.h"
#include "BurstFiremode.generated.h"

/**
*
*/
UCLASS(Blueprintable)
class EMPIRES2_API UBurstFiremode : public UBaseFiremode
{
GENERATED_UCLASS_BODY()

public:
virtual void BeginFire() override;

virtual void HandleFire() override;


UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Firemode)
int32 ShotsInBurst;
protected:
int32 BurstsRemaining;


};

0 comments on commit db59ffd

Please sign in to comment.