-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWeaponManager.h
More file actions
168 lines (158 loc) · 5.46 KB
/
WeaponManager.h
File metadata and controls
168 lines (158 loc) · 5.46 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#pragma once
#include <unordered_map>
#include <unordered_set>
#define GLM_FORCE_QUAT_DATA_XYZW
#include "glm/glm.hpp"
#include <glm/gtc/type_ptr.hpp>
#include "uevr/API.hpp"
#include "PlayerManager.h"
#include "CameraController.h"
#include "MemoryManager.h"
#include "Utilities.h"
#include "SettingsManager.h"
class WeaponManager {
private:
PlayerManager* const playerManager;
CameraController* const cameraController;
MemoryManager* const memoryManager;
SettingsManager* const settingsManager;
//Shoot detection
bool firstWeaponIsShooting = false;
bool secondWeaponIsShooting = false;
uevr::API::UObject* firstWeaponLastParticleShot = nullptr;
uevr::API::UObject* secondWeaponLastParticleShot = nullptr;
std::vector<uevr::API::UObject*> firstWeaponPreviousParticles;
std::vector<uevr::API::UObject*> secondWeaponPreviousParticles;
//Weapon infos
uevr::API::UObject* firstWeaponMesh = nullptr;
uevr::API::UObject* secondWeaponMesh = nullptr;
uevr::API::UObject* torso = nullptr;
uevr::API::UObject* firstWeaponStaticMesh = nullptr;
uevr::API::UObject* secondWeaponStaticMesh = nullptr;
const std::unordered_map<std::wstring, int> weaponNameToIndex = {
{L"SM_unarmed", 0}, // Unarmed
{L"SM_brassknuckle", 1}, // BrassKnuckles
{L"SM_golfclub", 2}, // GolfClub
{L"SM_nitestick", 3}, // NightStick
{L"SM_knifecur", 4}, // Knife
{L"SM_bat", 5}, // BaseballBat
{L"SM_shovel", 6}, // Shovel
{L"SM_poolcue", 7}, // PoolCue
{L"SM_katana", 8}, // Katana
{L"SM_chnsaw", 9}, // Chainsaw
{L"SM_gun_dildo1", 10}, // Dildo1
{L"SM_gun_dildo2", 11}, // Dildo2
{L"SM_gun_vibe1", 12}, // Vibe1
{L"SM_gun_vibe2", 13}, // Vibe2
{L"SM_flowera", 14}, // Flowers
{L"SM_gun_cane", 15}, // Cane
{L"SM_grenade", 16}, // Grenade
{L"SM_teargas", 17}, // Teargas
{L"SM_molotov", 18}, // Molotov
{L"SM_colt45", 22}, // Pistol Colt 45
{L"SM_silenced", 23}, // Silenced Pistol
{L"SM_desert_eagle", 24}, // Desert Eagle
{L"SM_chromegun", 25}, // Shotgun
{L"SM_sawnoff", 26}, // Sawnoff Shotgun
{L"SM_shotgspa", 27}, // Spas12
{L"SM_micro_uzi", 28}, // MicroUzi
{L"SM_mp5lng", 29}, // MP5
{L"SM_ak47", 30}, // AK47
{L"SM_m4", 31}, // M4
{L"SM_tec9", 32}, // Tec9
{L"SM_cuntgun", 33}, // Rifle (Cuntgun)
{L"SM_sniper", 34}, // Sniper Rifle
{L"SM_rocketla", 35}, // RocketLauncher
{L"SM_heatseek", 36},// RocketLauncherHeatSeek
{L"SM_flame", 37}, // Flamethrower
{L"SM_minigun2", 38}, // Minigun
{L"SM_satchel", 39}, // Satchel
{L"SM_detonator", 40}, // Detonator
{L"SM_spraycan", 41}, // SprayCan
{L"SM_fire_ex", 42}, // Extinguisher
{L"SM_camera", 43}, // Camera
{L"SM_nvgoggles", 44}, // NightVision
{L"SM_irgoggles", 45}, // Infrared
{L"SM_gun_para", 46} // Parachute
};
//aiming
glm::fvec3 crosshairOffset = { 0.0f, -1.0f, 2.0f };
glm::fvec3 calculatedAimForward = { 0.0f, 0.0f, 0.0f };
glm::fvec3 calculatedAimPosition = { 0.0f, 0.0f, 0.0f };
std::unordered_set<int> camModsRequiringAimHandling = {5, 7, 8, 9, 15, 34, 39, 40, 41, 42, 45, 51, 52, 53, 55, 65};
//recoil
glm::fvec3 defaultWeaponRotationEuler = { 0.4f, 0.0f, 0.0f };
glm::fvec3 defaultWeaponPosition = { 0.0f, 0.0f, 0.0f };
glm::fvec3 currentFirstWeaponRecoilPosition = { 0.0f, 0.0f, 0.0f };
glm::fvec3 currentFirstWeaponRecoilRotationEuler = { 0.0f, 0.0f, 0.0f };
glm::fvec3 currentSecondWeaponRecoilPosition = { 0.0f, 0.0f, 0.0f };
glm::fvec3 currentSecondWeaponRecoilRotationEuler = { 0.0f, 0.0f, 0.0f };
struct WeaponRecoilState {
glm::fvec3* position;
glm::fvec3* rotation;
};
float recoilPositionRecoverySpeed = 10.0f;
float recoilRotationRecoverySpeed = 8.0f;
WeaponRecoilState GetRecoilState(uevr::API::UObject* weaponMesh);
void ApplyRecoil(uevr::API::UObject* weaponMesh, bool isShooting, const glm::fvec3& positionRecoilForce, const glm::fvec3& rotationRecoilForceEuler, float delta);
void HandleCameraWeaponAiming();
public:
WeaponManager(PlayerManager* pm, CameraController* cc, MemoryManager* mm, SettingsManager* sm) : playerManager(pm), cameraController(cc), memoryManager(mm), settingsManager(sm) {};
enum WeaponType {
Unarmed = 0,
BrassKnuckles = 1,
GolfClub = 2,
NightStick = 3,
Knife = 4,
BaseballBat = 5,
Shovel = 6,
PoolCue = 7,
Katana = 8,
Chainsaw = 9,
Dildo1 = 10,
Dildo2 = 11,
Vibe1 = 12,
Vibe2 = 13,
Flowers = 14,
Cane = 15,
Grenade = 16,
Teargas = 17,
Molotov = 18,
Pistol = 22,
PistolSilenced = 23,
DesertEagle = 24,
Shotgun = 25,
Sawnoff = 26,
Spas12 = 27,
MicroUzi = 28,
Mp5 = 29,
Ak47 = 30,
M4 = 31,
Tec9 = 32,
Rifle = 33,
Sniper = 34,
RocketLauncher = 35,
RocketLauncherHs = 36,
Flamethrower = 37,
Minigun = 38,
Satchel = 39,
Detonator = 40,
SprayCan = 41,
Extinguisher = 42,
Camera = 43,
NightVision = 44,
Infrared = 45,
Parachute = 46
};
WeaponType currentWeaponEquipped = Unarmed;
WeaponType previousWeaponEquipped = Unarmed;
bool firstWeaponShotDone = false;
void UpdateActualWeaponMesh();
void HideBulletTrace();
void UpdateShootingState(bool firstWeapon);
void ResetShootingState();
void ProcessAiming(bool firstWeapon);
void ProcessWeaponVisibility();
void ProcessWeaponHandling(float delta);
void UnhookAndRepositionWeapon();
};