Repository navigation
Expand file tree
/
Copy pathBulletSpeed.h
More file actions
65 lines (53 loc) · 1.6 KB
/
Copy pathBulletSpeed.h
File metadata and controls
65 lines (53 loc) · 1.6 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
#pragma once
/// @file
/// The BulletSpeed feature: each frame, pushes the local player's own projectiles further along their
/// current velocity, so shots travel faster. Reuses the shared projectile pass (ActorCache).
///
/// NOTE: the boost is per-frame, so effective speed scales with frame rate — tune the slider to taste.
#include "Feature.h"
#include "../ue/Engine.h"
#include "../cache/ActorCache.h"
#include <cmath>
class BulletSpeed : public Feature
{
public:
BulletSpeed()
{
Name = "BulletSpeed";
UpdateEnabled();
Log("Created");
};
void UpdateEnabled()
{
Enabled = Settings.EXPLOITS.BulletSpeed;
};
bool Check()
{
return Initialized && Engine::IsInGame && Engine::World;
};
void Init()
{
Initialized = true;
Log("Initialized");
};
void Destroy() {
};
void Run()
{
auto* localPawn = reinterpret_cast<AActor*>(Engine::PlayerController->AcknowledgedPawn);
if (!localPawn) return;
const float boost = Settings.EXPLOITS.BulletSpeedBoost;
for (AActor* actor : ActorCache::Projectiles())
{
// Only our own shots (Instigator or Owner is the local pawn).
if (reinterpret_cast<AActor*>(actor->Instigator) != localPawn && actor->Owner != localPawn) continue;
const FVector v = actor->GetVelocity();
const float len = sqrtf(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
if (len < 1.f) continue; // not moving yet
const FVector dir{v.X / len, v.Y / len, v.Z / len};
const FVector pos = actor->K2_GetActorLocation();
FHitResult hit{};
actor->K2_SetActorLocation(FVector{pos.X + dir.X * boost, pos.Y + dir.Y * boost, pos.Z + dir.Z * boost}, false, hit, true);
}
};
};