67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
#include "UnrealProject.h"
|
|
#include "NetworkCharacter.h"
|
|
#include "DealDamageProxy.h"
|
|
#include "DefaultPlayerState.h"
|
|
#include "ScalingGraph.h"
|
|
#include "AbilityInfo.h"
|
|
|
|
float ADealDamageProxy::GetAbilityPowerScale() const
|
|
{
|
|
if(!character)
|
|
return 0.0f;
|
|
AAbilityState* state = character->GetAbilityState(abilityInfo);
|
|
if(!state)
|
|
return 0.0f;
|
|
return state->power;
|
|
}
|
|
|
|
float ADealDamageProxy::ScaleGraphCurve(const UCurveFloat* val)
|
|
{
|
|
if (!IsValid(val))
|
|
{
|
|
GEngine->AddOnScreenDebugMessage((int32)abilityInfo->GetUniqueID(), 2.0f, FColor(255, 20, 20, 255), FString("Invalid curve argument in ") + GetName() + " [" + abilityInfo->GetName() + "]");
|
|
JERROR("Invalid curve argument in " + GetName() + " [" + abilityInfo->GetName() + "]");
|
|
return 0;
|
|
}
|
|
|
|
if(abilityInfo->abilityType == EAbilityType::Basic)
|
|
{
|
|
return ScaleGraphCurveByLevel(val);
|
|
}
|
|
float f = GetAbilityPowerScale();
|
|
f = FMath::Clamp(f, 0.0f, 1.0f);
|
|
return val->GetFloatValue(f);
|
|
}
|
|
|
|
float ADealDamageProxy::ScaleGraphCurveByLevel(const UCurveFloat* val)
|
|
{
|
|
if(!IsValid(val))
|
|
{
|
|
GEngine->AddOnScreenDebugMessage((int32)abilityInfo->GetUniqueID(), 2.0f, FColor(255, 20, 20, 255), FString("Invalid curve argument in ") + GetName() + " [" + abilityInfo->GetName() + "]");
|
|
JERROR("Invalid curve argument in " + GetName() + " [" + abilityInfo->GetName() + "]");
|
|
return 0;
|
|
}
|
|
|
|
float f = 0.0f;
|
|
if(character)
|
|
{
|
|
ADefaultPlayerState* ps = Cast<ADefaultPlayerState>(character->PlayerState);
|
|
if(ps)
|
|
{
|
|
f = FMath::Clamp((float)ps->GetLevel() / (float)ps->GetMaxLevel(), 0.0f, 1.0f);
|
|
}
|
|
}
|
|
return val->GetFloatValue(f);
|
|
}
|
|
|
|
float ULevelScaleLibrary::ScaleGraphCurveFloat(float in, const UCurveFloat* val)
|
|
{
|
|
if (!IsValid(val))
|
|
{
|
|
JERROR("Invalid curve argument");
|
|
return 0;
|
|
}
|
|
|
|
in = FMath::Clamp(in, 0.0f, 1.0f);
|
|
return val->GetFloatValue(in);
|
|
} |