Repository navigation
Expand file tree
/
Copy pathGodMode.h
More file actions
85 lines (64 loc) · 1.82 KB
/
Copy pathGodMode.h
File metadata and controls
85 lines (64 loc) · 1.82 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
/// @file
/// The GodMode feature: pins the local character's health (and max health) to
/// a very large value while enabled, restoring a normal value on disable.
#include "Feature.h"
#include "../ue/Engine.h"
/// Keeps the local player effectively invulnerable by overwriting Health and
/// MaxHealth every frame while enabled.
class GodMode : public Feature
{
private:
float OriginalHealth = 0; ///< MaxHealth captured at Init (currently unused by Destroy)
APortalWarsCharacter* Player = 0; ///< cached local character; refreshed each Check()
public:
GodMode()
{
Name = "GodMode";
UpdateEnabled();
Log("Created");
};
void UpdateEnabled()
{
Enabled = Settings.EXPLOITS.GodMode;
};
bool Check()
{
if (!Initialized) return false;
if (!Engine::PlayerController) return false;
if (!Engine::IsInGame) return false;
Player = reinterpret_cast<APortalWarsCharacter*>(Engine::PlayerController->Character);
if (!Player) return false;
if (!Player->Health) return false;
return true;
};
void Init()
{
Player = reinterpret_cast<APortalWarsCharacter*>(Engine::PlayerController->Character);
if (!Player || !Player->MaxHealth)
{
Initialized = false;
return;
}
OriginalHealth = Player->MaxHealth;
Initialized = true;
Log("Initialized");
};
/// Revert to a normal 100 HP on disable, but only if health still looks
/// inflated (guards against clobbering a legitimately low value).
void Destroy()
{
if (Player->Health <= 100) return;
Player->MaxHealth = 100;
Player->Health = 100;
return;
};
/// Force Health and MaxHealth to 9999 whenever they drift from it.
void Run()
{
float health = 9999;
if (Player->MaxHealth != health) Player->MaxHealth = health;
if (Player->Health != health) Player->Health = health;
// Instigator->healthRechargeDelay = 0.1f;
};
};