-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAbilities.h
More file actions
45 lines (39 loc) · 1.86 KB
/
Abilities.h
File metadata and controls
45 lines (39 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include "Includes.h"
namespace Abilities {
void GrantAbility(AFortPlayerPawn* Pawn, UGameplayAbility* AbilityClass) {
//Make the Gameplay Ability Spec
FGameplayAbilitySpecHandle Handle{};
Handle.Handle = rand();
FGameplayAbilitySpec Spec = FGameplayAbilitySpec{ -1, -1, -1, Handle, (UGameplayAbility*)AbilityClass, 1, -1, nullptr, 0, false, false, false };;
static auto GiveAbility = reinterpret_cast<FGameplayAbilitySpecHandle(*)(UAbilitySystemComponent*, const FGameplayAbilitySpecHandle*, FGameplayAbilitySpec)>(uintptr_t(GetModuleHandle(0)) + Offsets::GiveAbility);
GiveAbility(Pawn->AbilitySystemComponent, &Handle, Spec);
}
void GiveBaseAbilities(AFortPlayerPawn* Pawn) {
static auto Jump = UObject::FindObjectFast<UGameplayAbility>("Default__FortGameplayAbility_Jump");
static auto Sprint = UObject::FindObjectFast<UGameplayAbility>("Default__FortGameplayAbility_Sprint");
static auto Consumable = UObject::FindObjectFast<UGameplayAbility>("Default__GA_DefaultPlayer_Consumable_C");
static auto Shoot = UObject::FindObjectFast<UGameplayAbility>("Default__GA_Ranged_GenericDamage_C");
static auto Use = UObject::FindObjectFast<UGameplayAbility>("Default__GA_DefaultPlayer_InteractUse_C");
static auto Search = UObject::FindObjectFast<UGameplayAbility>("Default__GA_DefaultPlayer_InteractSearch_C");
GrantAbility(Pawn, Jump);
GrantAbility(Pawn, Sprint);
GrantAbility(Pawn, Consumable);
GrantAbility(Pawn, Shoot);
GrantAbility(Pawn, Use);
GrantAbility(Pawn, Search);
}
FGameplayAbilitySpec* FindAbilitySpecFromHandle(UAbilitySystemComponent* AbilitySystemComponent, FGameplayAbilitySpecHandle Handle)
{
auto Specs = AbilitySystemComponent->ActivatableAbilities.Items;
for (int i = 0; i < Specs.Num(); i++)
{
auto& Spec = Specs[i];
if (Spec.Handle.Handle == Handle.Handle)
{
return &Spec;
}
}
return nullptr;
}
}