Created
May 14, 2018 07:10
-
-
Save hach-que/b34835172a7fa53b12d95e6f525e3e95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Redpoint Games 2018, All Rights Reserved. | |
#include "CharacterAttributeSet.h" | |
void UCharacterAttributeSet::PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const | |
{ | |
// Clamp health value. | |
if (Attribute == HealthAttribute()) | |
{ | |
NewValue = FMath::Clamp(NewValue, 0.f, MaximumHealth); | |
} | |
// Clamp ammo value. | |
if (Attribute == ActiveWeaponCurrentAmmoInClipAttribute()) | |
{ | |
NewValue = FMath::Clamp(NewValue, 0.f, ActiveWeaponClipSize); | |
} | |
} | |
void UCharacterAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) | |
{ | |
// TODO: Implement if needed. | |
} | |
void UCharacterAttributeSet::PostGameplayEffectExecute(const struct FGameplayEffectModCallbackData &Data) | |
{ | |
// TODO: Implement if needed. | |
} | |
// ------------------------------------------------- | |
#define DEFINE_ATTRIBUTE(name) \ | |
FGameplayAttribute UCharacterAttributeSet:: ## name ## Attribute() \ | |
{ \ | |
static UProperty* Property = FindFieldChecked<UProperty>(UCharacterAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED(UCharacterAttributeSet, name)); \ | |
return FGameplayAttribute(Property); \ | |
} | |
DEFINE_ATTRIBUTE(DashLengthTime); | |
DEFINE_ATTRIBUTE(DashStrength); | |
DEFINE_ATTRIBUTE(JetpackLengthTime); | |
DEFINE_ATTRIBUTE(JetpackStrength); | |
DEFINE_ATTRIBUTE(Health); | |
DEFINE_ATTRIBUTE(MaximumHealth); | |
DEFINE_ATTRIBUTE(HealthRegenDelay); | |
DEFINE_ATTRIBUTE(HealthRegenAmount); | |
DEFINE_ATTRIBUTE(HealthRegenAmountModifier); | |
DEFINE_ATTRIBUTE(WouldStun); | |
DEFINE_ATTRIBUTE(StunTime); | |
DEFINE_ATTRIBUTE(StunRecoveryHealthAmount); | |
DEFINE_ATTRIBUTE(InteractDistance); | |
DEFINE_ATTRIBUTE(MovementSpeed); | |
DEFINE_ATTRIBUTE(CurrentPlayerPoints); | |
DEFINE_ATTRIBUTE(TotalPointsForDestruction); | |
DEFINE_ATTRIBUTE(FinalHitPointsForDestruction); | |
DEFINE_ATTRIBUTE(TotalPointsDroppedOnDestruction); | |
DEFINE_ATTRIBUTE(PointsForRecoveryToExitAfterStun); | |
DEFINE_ATTRIBUTE(ActiveWeaponCurrentAmmoInClip); | |
DEFINE_ATTRIBUTE(ActiveWeaponClipSize); | |
DEFINE_ATTRIBUTE(ActiveWeaponFireRate); | |
DEFINE_ATTRIBUTE(ActiveWeaponReloadTime); | |
DEFINE_ATTRIBUTE(ActiveWeaponMinimumDamage); | |
DEFINE_ATTRIBUTE(ActiveWeaponMaximumDamage); | |
DEFINE_ATTRIBUTE(ActiveWeaponMinimumRange); | |
DEFINE_ATTRIBUTE(ActiveWeaponMaximumRange); | |
DEFINE_ATTRIBUTE(ActiveWeaponSpread); | |
DEFINE_ATTRIBUTE(ActiveWeaponCriticalDamageModifier); | |
DEFINE_ATTRIBUTE(ActiveWeaponProjectileSpeed); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Redpoint Games 2018, All Rights Reserved. | |
#pragma once | |
#include "CoreMinimal.h" | |
#include "AttributeSet.h" | |
#include "CharacterAttributeSet.generated.h" | |
#define DECLARE_ATTRIBUTE(name) static FGameplayAttribute name ## Attribute(); | |
/** | |
* Defines the list of attributes on all kinds of characters and ability systems. | |
*/ | |
UCLASS() | |
class MINUTEOFMAYHEM_API UCharacterAttributeSet : public UAttributeSet | |
{ | |
GENERATED_BODY() | |
public: | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Dash length time")) | |
float DashLengthTime; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Dash strength (forward velocity)")) | |
float DashStrength; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Jetpack strength time")) | |
float JetpackLengthTime; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Jetpack strength (upward velocity)")) | |
float JetpackStrength; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Health")) | |
float Health; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Maximum health")) | |
float MaximumHealth; | |
/** The amount of time since being last hit until health starts to regenerate (0 = indefinite, no health regen) */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Health regen delay")) | |
float HealthRegenDelay; | |
/** The amount of health to regenerate per tick */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Health regen amount")) | |
float HealthRegenAmount; | |
/** % value of your remaining health that modifies the base regen amount (0 = health regen amount should be applied constantly, no modifier) */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Health regen amount modifier")) | |
float HealthRegenAmountModifier; | |
/** (0 = no, 1 = yes) */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Would stun")) | |
float WouldStun; | |
/** Length of time until health starts increasing again */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Stun time")) | |
float StunTime; | |
/** The value of health that the current health is set to after the character has recovered from being stunned */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Stun recovery health amount")) | |
float StunRecoveryHealthAmount; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Interact distance")) | |
float InteractDistance; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Movement speed")) | |
float MovementSpeed; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Current player points")) | |
float CurrentPlayerPoints; | |
/** This is distributed from the total damage done to the character. That is, if someone damages it 50% from it’s total health, then it recovers, and then you do damage it 100% from it’s total health, you get 66% of the points and the other person gets 33%. */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Total points for destruction (distributed)")) | |
float TotalPointsForDestruction; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Final hit points for destruction")) | |
float FinalHitPointsForDestruction; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Total points dropped on destruction")) | |
float TotalPointsDroppedOnDestruction; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Character", DisplayName = "Points for recovery to exit after stun")) | |
float PointsForRecoveryToExitAfterStun; | |
/** This value is persisted in an attribute (not applied via gameplay effect) as per the information in "Implementation notes for Ability System". */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Current ammo in clip")) | |
float ActiveWeaponCurrentAmmoInClip; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Clip size")) | |
float ActiveWeaponClipSize; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Fire rate")) | |
float ActiveWeaponFireRate; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Reload time")) | |
float ActiveWeaponReloadTime; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Minimum damage")) | |
float ActiveWeaponMinimumDamage; | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Maximum damage")) | |
float ActiveWeaponMaximumDamage; | |
/** Used as input into the damage fall-off calculations. This specifies the minimum distance of a weapon, at which it does "Maximum damage". Any distance shorter than this, it does "Maximum damage". */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Minimum range")) | |
float ActiveWeaponMinimumRange; | |
/** Used as input into the damage fall-off calculations. This specifies the maximum distance of a weapon, at which it does "Minimum damage". Any distance further than this, it does "Minimum damage". */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Maximum range")) | |
float ActiveWeaponMaximumRange; | |
/** Defines the random angle range which individual shots are fired out of the weapon. Higher values = less accuracy. */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Spread")) | |
float ActiveWeaponSpread; | |
/** This multiplies the result damage by it’s value using the UV information from the mesh as specified in the section below. */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Critical damage modifier")) | |
float ActiveWeaponCriticalDamageModifier; | |
/** For weapons that shoot projectiles, this is the base speed of the projectile. */ | |
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (Category = "Active Weapon", DisplayName = "Projectile speed")) | |
float ActiveWeaponProjectileSpeed; | |
void PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const override; | |
void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override; | |
void PostGameplayEffectExecute(const struct FGameplayEffectModCallbackData &Data) override; | |
// ------------------------------------------------- | |
DECLARE_ATTRIBUTE(DashLengthTime); | |
DECLARE_ATTRIBUTE(DashStrength); | |
DECLARE_ATTRIBUTE(JetpackLengthTime); | |
DECLARE_ATTRIBUTE(JetpackStrength); | |
DECLARE_ATTRIBUTE(Health); | |
DECLARE_ATTRIBUTE(MaximumHealth); | |
DECLARE_ATTRIBUTE(HealthRegenDelay); | |
DECLARE_ATTRIBUTE(HealthRegenAmount); | |
DECLARE_ATTRIBUTE(HealthRegenAmountModifier); | |
DECLARE_ATTRIBUTE(WouldStun); | |
DECLARE_ATTRIBUTE(StunTime); | |
DECLARE_ATTRIBUTE(StunRecoveryHealthAmount); | |
DECLARE_ATTRIBUTE(InteractDistance); | |
DECLARE_ATTRIBUTE(MovementSpeed); | |
DECLARE_ATTRIBUTE(CurrentPlayerPoints); | |
DECLARE_ATTRIBUTE(TotalPointsForDestruction); | |
DECLARE_ATTRIBUTE(FinalHitPointsForDestruction); | |
DECLARE_ATTRIBUTE(TotalPointsDroppedOnDestruction); | |
DECLARE_ATTRIBUTE(PointsForRecoveryToExitAfterStun); | |
DECLARE_ATTRIBUTE(ActiveWeaponCurrentAmmoInClip); | |
DECLARE_ATTRIBUTE(ActiveWeaponClipSize); | |
DECLARE_ATTRIBUTE(ActiveWeaponFireRate); | |
DECLARE_ATTRIBUTE(ActiveWeaponReloadTime); | |
DECLARE_ATTRIBUTE(ActiveWeaponMinimumDamage); | |
DECLARE_ATTRIBUTE(ActiveWeaponMaximumDamage); | |
DECLARE_ATTRIBUTE(ActiveWeaponMinimumRange); | |
DECLARE_ATTRIBUTE(ActiveWeaponMaximumRange); | |
DECLARE_ATTRIBUTE(ActiveWeaponSpread); | |
DECLARE_ATTRIBUTE(ActiveWeaponCriticalDamageModifier); | |
DECLARE_ATTRIBUTE(ActiveWeaponProjectileSpeed); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment