Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
npruehs committed Jun 14, 2020
2 parents 761bceb + 8e5a9a6 commit c045c7a
Show file tree
Hide file tree
Showing 94 changed files with 2,250 additions and 148 deletions.
1 change: 1 addition & 0 deletions Documents/Manual/AIPlayers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ The plugin provides basic support for AI players as well. Currently, this doesn'
1. Set up the _Build Order_ of your new player AI controller. The AI will produce the specified actors in order, automatically skipping actors that are already available and replacing those that have been destroyed.
1. Set up the _Primary Resource Type_ of your new player AI controller. The AI will try and prevent blocking paths between its main building and resource sources of that type.
1. Add your resource types to the `PlayerResourcesComponent` of your player AI controller.
1. Check _Gives Bounty_ if killing actors owned by the AI should yield bounties (e.g. for neutral players).
1. Use your player AI controller in your game mode.
1. At your game mode, set _Num AI Players_ to the number of AI players you want to spawn.
14 changes: 14 additions & 0 deletions Documents/Manual/Buildings.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ From the perspective of the plugin, buildings are just units with a few addition
1. Set the _Consumes Builders_ flag if builders working at the construction site should be destroyed when finished (similar to Zerg in StarCraft).
1. Set _Max Assigned Builders_ if you want to require a builder to work at the construction site to make progress, and/or to allow multi-building (similar to Age of Empires).
1. Set the _Progress Made Automatically_ and _Progress Made Per Builder_ factors.
1. Set _Initial Health Percentage_ to a value between 0 and 1 to specify how much health the construction site should start with.
1. Set the _Start Immediately_ flag unless you want to trigger construction start from script.
1. Add an `RTSContainerComponent` if you want builders to enter the building site while building. Its capacity value will be automatically set at runtime to reflect _Max Assigned Builders_ of the construction site.
1. Add your `RTSConstructionProgressBarWidgetComponent` (see [User Interface](UserInterface.md)).
Expand All @@ -31,3 +32,16 @@ _Note that, technically, producing units does not differ from researching techno

1. Add an `RTSResourceDrainComponent` for each type of building gatherers may return resources to.
1. Set the resource types to all resources accepted by the drain.

### Defense

1. If your building has an `RTSAttackComponent`, check _Preview Attack Range_ if you want the attack range of your building to be previewed while placing the building.

### Vision

1. At the `RTSVisible`component of your building, check _Don't Hide After Seen_ if you want your building to stay visible even through for of war.

### Projectile Impacts

1. While your building is under attack, you might want to prevent every single projectile hitting the exact same location. You can add a `RTSProjectileTargetComponent` to your actor, and specify the _Target Sockets_ to have projectile fly towards. These sockets have to be added to your static mesh using the built-in Unreal socket manager.
2. If your building has multiple mesh components, add a _component tag_ to the desired mesh component and specify the same tag at your `RTSProjectileTargetComponent`.
3 changes: 3 additions & 0 deletions Documents/Manual/Cheats.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ This will unlock the following built-in cheats to use in your console:
| Cheat | Description |
| --- | --- |
| Boost | Increases construction and production speed. |
| Damage | Increase damage of all own units. |
| God | Invulnerability cheat. |
| NoFog | Toggles fog of war on/off. |
| Money | Adds resources. |
| Victory | Defeat all other players. |
| Weak | Decreases damage of all own units. |
Binary file added Documents/Manual/Images/OnBountyCollected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Documents/Manual/Resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ In case you missed that step earlier, make your to set up your resource types as
1. Add an `RTSResourceSourceComponent`.
1. Set the resource type and maximum and current resources of the source.
1. Set the gathering factor for increasing the yield of any gatherers (e.g. golden minerals in StarCraft).
1. If you want gatherers to enter the resource source (e.g. Refinery in StarCraft), check _Gatherer Must Enter_, set the _Gatherer Capacity_, and add an `RTSContainerComponent`.
1. If you want gatherers to enter the resource source (e.g. Refinery in StarCraft), check _Gatherer Must Enter_, set the _Gatherer Capacity_, and add an `RTSContainerComponent`. In that case, add a `RTSContainableComponent` to all gatherers as well.
8 changes: 8 additions & 0 deletions Documents/Manual/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Occasionally, you want to create additional gameplay (especially when creating a
Feel free to explore the plugin yourself by looking at what other functions and events each component provides, and open an issue if you're missing something.


### RTSBountyComponent
#### Events

| Event | Description |
| --- | --- |
| ![On Bounty Collected](Images/OnBountyCollected.png) | Event when the bounty was collected. |


### RTSContainerComponent
#### Functions

Expand Down
4 changes: 2 additions & 2 deletions Documents/Manual/Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Make sure _View Plugin Content_ is enabled in your view options.
1. Set the _Pawn Behavior Tree Asset_ of the new pawn AI controller to `BT_RTSPawnBehaviorTree`.
1. Set the _Pawn Blackboard Asset_ of the new pawn AI controller to `BB_RTSPawnBlackboard`.
1. Create a player start deriving from `RTSPlayerStart`.
1. Create one or more resource types deriving from `RTSResourceType`.
1. Create one or more resource types deriving from `RTSResourceType`, setting their names and icons to use in your UI.
1. Add the resource types to the `PlayerResourcesComponent` of your player controller.


### Camera Setup

Usually, players control a single [pawn](https://docs.unrealengine.com/en-US/Gameplay/Framework/Pawn/index.html) in Unreal Engine. However, in the case of real-time strategy games, players control many units from a camera perspective far out. Thus, the plugin works best when using a simple pawn with a normal camera whose location reflects what the player wants to see right now. Individual units are not directly possessed by the player controllers (or AI controllers), but just "owned" by them.
Usually, players control a single [pawn](https://docs.unrealengine.com/en-US/Gameplay/Framework/Pawn/index.html) in Unreal Engine. However, in the case of real-time strategy games, players control many units from a camera perspective far out. Thus, the plugin works best when using a simple pawn with a normal camera whose location reflects what the player wants to see right now. Individual units are not directly possessed by the player controllers, but just "owned" by them.

#### Creating The Camera

Expand Down
21 changes: 19 additions & 2 deletions Documents/Manual/Units.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ As mentioned before, most features of the plugin are implemented by the means of
1. Add an `RTSDescriptionComponent` and set its localized text if you want to show it in any kind of ingame UI.
1. Add an `RTSPortraitComponent` and set its portrait if you want to show it in any kind of ingame UI.
1. Add an `RTSSelectableComponent`, and set its selection circle material (e.g. to `M_RTSSelectionCircle`) and selection sound.
1. If the selection order of your actors matters (e.g. for grouping in your UI), set the _Selection Priority_ as well.
1. In case you got special visual effects for highlighting hovered actors, you can listen for the `OnHovered` and `OnUnhovered` events of the component.
1. Add an `RTSOwnerComponent`. This will be used to store (and replicate) the owner of the unit for all players (e.g. for showing team colors).
1. Add your `RTSHoveredActorWidgetComponent` (see [User Interface](UserInterface.md)).

Expand All @@ -26,7 +28,7 @@ As mentioned before, most features of the plugin are implemented by the means of
### Vision

1. Add the `RTSVision` component to your units and set their _Sight Radius_ (e.g. 1000).

1. Add a `RTSVisible`component to your actor. That component will manage vibility of that actor, in case multiple effects want to show/hide it (e.g. fog of war, containers).

### Combat

Expand All @@ -42,6 +44,8 @@ As mentioned before, units are not directly possessed by player controllers in t
1. Add an `RTSAttackableComponent` and `RTSGameplayTagsComponent` to any actors that can be attacked.
1. Add the `Status.Permanent.CanBeAttacked` tag to the `RTSGameplayTagsComponent`.
1. Set the _Maximum Health_ of the `RTSHealthComponent`.
1. In case your actor should regenerate health, check _Regenerate Health_ and set the _Health Regeneration Rate_.
1. If you want to play animations or visual effects when the actor dies, set _Actor Death Type_ to _Stop Gameplay_. In that case, you're responsible of destroying the actor yourself as soon as all of your visual clues have finished playing.
1. Add your `RTSHealthBarWidgetComponent` (see [User Interface](UserInterface.md)).

1. Add the `RTSAttackComponent` to any actors than can attack.
Expand All @@ -56,6 +60,8 @@ If you don't specify a projectile, the damage will be applied immediately. In or
1. Create an actor deriving from `RTSProjectile`.
1. Add a static mesh and any visual effects.
1. At the `ProjectileMovement` component, set its _Initial Speed_ (e.g. to 1000).
1. If you want your projectile to use a ballistic trajectory, check _Ballistic Trajectory_ at the projectile and set the _Ballistic Trajectory Factor_ as you like.
1. For dealing area of effect damage, check _Apply Area Of Effect_ and set your area of effect radius and collision filters.
1. At the `RTSAttackComponent`, reference the new projectile in your attack.


Expand All @@ -73,7 +79,7 @@ If you don't specify a projectile, the damage will be applied immediately. In or

1. Add an `RTSBuilderComponent` to any actors you want to be able to construct buildings.
1. Set the _Constructible Building Classes_ for these builders.
1. Check _Enter Construction Site_ if you want the builder to be unavailable while building (similar to Orcs in WarCraft).
1. Check _Enter Construction Site_ if you want the builder to be unavailable while building (similar to Orcs in WarCraft). In that case, add a `RTSContainableComponent` as well.


### Gathering
Expand All @@ -87,3 +93,14 @@ If you don't specify a projectile, the damage will be applied immediately. In or
1. Set _Range_ as desired.
1. Add all _Resource Source Actor Classes_ the gatherer may gather from (e.g. Undead in Warcraft need Haunted Gold Mine).
1. Set the _Resource Sweep Radius_ to the radius in which the gatherer should look for similar resources if their current source is depleted.


### Bounties

1. Add an `RTSBountyComponent` to any actors you want to grant bounties to killing players.
1. Set the _Bounty_ for these actors.


### Multiplayer

1. If you're working on an online game, check _Always Relevant_ for your actor.
8 changes: 7 additions & 1 deletion Documents/Manual/UserInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ _You might want to make sure that the visibility of the widget is set to Hit Tes
1. In your player controller, set the building cursor reference.


### Range Indicators

1. Create an actor deriving from `RTSRangeIndicator` (or use the `BP_RTSRangeIndicator` shipped with the plugin).
1. At your building cursor, set the range indicator reference.


### Production UI

1. Use `GetAvailableProducts` of a selected production actor to create buttons for your production options (e.g. whenever the player controller raises OnSelectionChanged).
Expand Down Expand Up @@ -128,7 +134,7 @@ _See the [Health Bars](#health-bars) section for an example._
1. Add the `WBP_RTSMinimapWidget` to your UI, with a size matching your minimap volume images (e.g. 256 x 256).
1. Set the _Draw Background, Draw Units With Team Colors, Draw Vision_ and _Draw View Frustum_ flags as desired.
1. If you checked _Draw Units With Team Colors_, set the _Own Units Brush, Enemy Units Brush_ and _Neutral Units Brush_ as desired.

1. If you want damaged units to blink on the minimap, set _Damaged Units Blink Brush_ and _Damaged Unit Blink Time Seconds_ as desired.

### Floating Combat Texts

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Real-Time Strategy Plugin for Unreal Engine 4 currently supports the following U
1. [Clone](https://github.com/npruehs/ue4-rts) the repository or [download](https://github.com/npruehs/ue4-rts/releases) a release.
1. Copy the `RealTimeStrategy` folder to `Plugins` folder next to your `.uproject` file (create if necessary).
1. Right-click your .uproject file and select Re-generate Visual Studio project files.
1. If you want to create C++ subclasses of the plugin classes, add `"RealTimeStrategy"` to the `PublicDependencyModuleNames` of the `Build.cs` file of your project. Note that you might need to add other dependencies as well, depending on the respective class you want to extend. Take a look at `RealTimeStrategy.Build.cs` of the plugin for a full list of referenced engine modules.
1. Build the resulting solution in Visual Studio.
1. Start the Unreal Editor.

Expand Down
4 changes: 1 addition & 3 deletions Source/RTSProject/Config/DefaultInput.ini
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ DoubleClickTime=0.200000
+AxisMappings=(AxisName="MoveCameraUpDown",Scale=-1.000000,Key=Down)
+AxisMappings=(AxisName="ZoomCamera",Scale=-1.000000,Key=MouseWheelAxis)
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
ConsoleKey=None
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde
+ConsoleKeys=Caret

+ConsoleKeys=Comma

Binary file not shown.
Binary file modified Source/RTSProject/Content/Buildings/Starbase/BP_Starbase.uasset
Binary file not shown.
Binary file modified Source/RTSProject/Content/Gameplay/BP_RTSPlayerAIController.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Source/RTSProject/Content/Units/CMV/BP_CMV.uasset
Binary file not shown.
Binary file modified Source/RTSProject/Content/Units/Frigate/BP_Frigate.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion" : 1,
"Version" : 1,
"VersionName" : "1.0.0",
"VersionName" : "1.1.0",
"FriendlyName" : "Real-Time Strategy",
"Description" : "Provides a gameplay framework for developing real-time strategy games.",
"Category" : "RTS",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "CoreMinimal.h"

#include "RTSActorDeathType.generated.h"

/** How to handle depleted health. */
UENUM(BlueprintType)
enum class ERTSActorDeathType : uint8
{
/** Do nothing. */
DEATH_DoNothing,

/** Stop gameplay for the actor, removing most of its components. */
DEATH_StopGameplay,

/** Destroy the actor. */
DEATH_Destroy
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include "CoreMinimal.h"

#include "Components/ActorComponent.h"

#include "Economy/RTSResourceType.h"

#include "RTSBountyComponent.generated.h"


class AController;


DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FRTSBountyComponentBountyCollectedSignature, AActor*, Actor,
AController*, Player, TSubclassOf<URTSResourceType>, ResourceType, float, ResourceAmount);


/** Grants players resources when killing the actor. */
UCLASS(meta = (BlueprintSpawnableComponent))
class REALTIMESTRATEGY_API URTSBountyComponent : public UActorComponent
{
GENERATED_BODY()

public:
/* Event when the bounty was collected. */
UPROPERTY(BlueprintAssignable, Category = "RTS")
FRTSBountyComponentBountyCollectedSignature OnBountyCollected;

protected:
virtual void BeginPlay() override;

private:
/** Resources to grant when killing the actor. */
UPROPERTY(EditDefaultsOnly, Category = "RTS")
TMap<TSubclassOf<URTSResourceType>, float> Bounties;

UFUNCTION()
void OnKilled(AActor* Actor, AController* PreviousOwner, AActor* DamageCauser);

bool GivesBounty(AController* Player);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

#include "Components/ActorComponent.h"

#include "Combat/RTSActorDeathType.h"

#include "RTSHealthComponent.generated.h"


class AActor;


DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FRTSHealthComponentHealthChangedSignature, AActor*, Actor, float, OldHealth, float, NewHealth, AActor*, DamageCauser);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FRTSHealthComponentKilledSignature, AActor*, Actor, AController*, PreviousOwner, AActor*, DamageCauser);

Expand Down Expand Up @@ -35,6 +40,15 @@ class REALTIMESTRATEGY_API URTSHealthComponent : public UActorComponent
UFUNCTION(BlueprintPure)
float GetCurrentHealth() const;

/** Sets the current health of the actor directly. */
void SetCurrentHealth(float NewHealth, AActor* DamageCauser);

/** Kills the actor immediately. */
void KillActor(AActor* DamageCauser = nullptr);

/** Gets the last time the actor has taken damage. */
float GetLastTimeDamageTaken() const;


/** Event when the current health of the actor has changed. */
UPROPERTY(BlueprintAssignable, Category = "RTS")
Expand All @@ -49,10 +63,34 @@ class REALTIMESTRATEGY_API URTSHealthComponent : public UActorComponent
UPROPERTY(EditDefaultsOnly, Category = "RTS", meta = (ClampMin = 0))
float MaximumHealth;

/** Whether the actor is allowed to periodically regenerate health. */
UPROPERTY(EditDefaultsOnly, Category = "RTS")
bool bRegenerateHealth;

/** Health restored for the actor, per second. */
UPROPERTY(EditDefaultsOnly, Category = "RTS", meta = (ClampMin = 0, EditCondition = "bRegenerateHealth"))
float HealthRegenerationRate;

/** How to handle depleted health. */
UPROPERTY(EditDefaultsOnly, Category = "RTS")
ERTSActorDeathType ActorDeathType;

/** Current health of the actor. */
UPROPERTY(Replicated)
UPROPERTY(ReplicatedUsing=ReceivedCurrentHealth)
float CurrentHealth;

/** Last time the actor has taken damage. */
float LastTimeDamageTaken;

/** Timer for ticking health regeneration. */
FTimerHandle HealthRegenerationTimer;

UFUNCTION()
void OnTakeAnyDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);

UFUNCTION()
void OnHealthRegenerationTimerElapsed();

UFUNCTION()
void ReceivedCurrentHealth(float OldHealth);
};
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,37 @@ class REALTIMESTRATEGY_API ARTSProjectile : public AActor
AActor* ProjectileDamageCauser);

private:
/** Whether the projectile should follow a ballistic trajectory on its way. Should not be used with homing projectiles. */
UPROPERTY(EditDefaultsOnly, Category = "RTS")
bool bBallisticTrajectory;

/** How much to exaggerate the ballistic trajectory. */
UPROPERTY(EditDefaultsOnly, Category = "RTS", meta = (EditCondition = bBallisticTrajectory))
float BallisticTrajectoryFactor;

/** Whether this projectile causes an area of effect when hitting its target location. */
UPROPERTY(EditDefaultsOnly, Category = "RTS")
bool bApplyAreaOfEffect;

/** Radius around impact location in which targets take damage. */
UPROPERTY(EditDefaultsOnly, Category = "RTS", meta = (EditCondition = bApplyAreaOfEffect, ClampMin = 0))
float AreaOfEffect;

/** Object types to query when finding area of effect targets near the impact location. */
UPROPERTY(EditDefaultsOnly, Category = "RTS", meta = (EditCondition = bApplyAreaOfEffect))
TArray<TEnumAsByte<EObjectTypeQuery>> AreaOfEffectTargetObjectTypeFilter;

/** Actor class to filter by when finding area of effect targets near the impact location. */
UPROPERTY(EditDefaultsOnly, Category = "RTS", meta = (EditCondition = bApplyAreaOfEffect))
TSubclassOf<AActor> AreaOfEffectTargetClassFilter;

bool bFired;

UPROPERTY()
AActor* Target;

FVector TargetLocation;

float Damage;
TSubclassOf<class UDamageType> DamageType;

Expand All @@ -69,6 +95,28 @@ class REALTIMESTRATEGY_API ARTSProjectile : public AActor

float TimeToImpact;

/** How far away the projectile started flying towards its target. */
float InitialDistance;

/** How far above the ground the projectile started flying towards its target. */
float InitialHeight;

/** How far above the ground the target was when the projectile started flying towards it. */
float TargetHeight;

/** Angle at which the projectile has been launched if following a ballistic trajectory. */
float LaunchAngle;

UPROPERTY(VisibleAnywhere, Category = "RTS")
UProjectileMovementComponent* ProjectileMovement;

UFUNCTION(NetMulticast, Reliable)
void MulticastFireAt(AActor* ProjectileTarget,
float ProjectileDamage,
TSubclassOf<class UDamageType> ProjectileDamageType,
AController* ProjectileEventInstigator,
AActor* ProjectileDamageCauser);

void HitTargetActor(AActor* Actor);
void HitTargetLocation();
};
Loading

0 comments on commit c045c7a

Please sign in to comment.