forked from faggotman69/Prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListener.h
More file actions
277 lines (226 loc) · 7.6 KB
/
Listener.h
File metadata and controls
277 lines (226 loc) · 7.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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#pragma once
#include "singleton.hpp"
#include "MiscClasses.h"
#include "Interfaces.h"
#include "Interface.h"
#include "Sounds.h"
#include "DamageIndicator.h"
char* HitgroupToName(int hitgroup)
{
switch (hitgroup)
{
case 1:
return "head";
case 6:
case 7:
return "leg";
case 3:
return "stomach";
default:
return "body";
}
}
std::vector<cbullet_tracer_info> logs;
#pragma comment(lib, "winmm.lib")
class item_purchase
: public singleton<item_purchase>
{
class item_purchase_listener
: public IGameEventListener2
{
public:
void start()
{
g_EventManager->AddListener(this, "item_purchase", false);
g_EventManager->AddListener(this, "player_hurt", false);
g_EventManager->AddListener(this, "bullet_impact", false);
}
void stop()
{
g_EventManager->RemoveListener(this);
}
void FireGameEvent(IGameEvent *event) override
{
singleton()->on_fire_event(event);
}
int GetEventDebugID(void) override
{
return 42 /*0x2A*/;
}
};
public:
static item_purchase* singleton()
{
static item_purchase* instance = new item_purchase;
return instance;
}
void initialize()
{
listener.start();
}
void remove()
{
listener.stop();
}
void on_fire_event(IGameEvent* event)
{
if (!strcmp(event->GetName(), "item_purchase"))
{
C_BaseEntity* local = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
auto buyer = event->GetInt("userid");
std::string gun = event->GetString("weapon");
if (strstr(gun.c_str(), "molotov")
|| strstr(gun.c_str(), "nade")
|| strstr(gun.c_str(), "kevlar")
|| strstr(gun.c_str(), "decoy")
|| strstr(gun.c_str(), "suit")
|| strstr(gun.c_str(), "flash")
|| strstr(gun.c_str(), "vest")
|| strstr(gun.c_str(), "cutter")
|| strstr(gun.c_str(), "defuse")
) return;
auto player_index = g_Engine->GetPlayerForUserID(buyer);
C_BaseEntity* player = (C_BaseEntity*)g_EntityList->GetClientEntity(player_index);
player_info_t pinfo;
if (player && local && g_Engine->GetPlayerInfo(player_index, &pinfo))
{
if (g_Options.Misc.eventlogs2)
{
if (player->GetTeamNum() == local->GetTeamNum())
{
gun.erase(gun.find("weapon_"), 7);
G::Msg("[ENEMY] %s bought %s\n", pinfo.name, gun.c_str());
}
else
{
G::Msg("[ENEMY] %s bought %s\n", pinfo.name, gun.c_str());
}
}
}
}
if (!strcmp(event->GetName(), "player_hurt"))
{
int deadfag = event->GetInt("userid");
int attackingfag = event->GetInt("attacker");
C_BaseEntity* pLocal = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
if (g_Engine->GetPlayerForUserID(deadfag) != g_Engine->GetLocalPlayer() && g_Engine->GetPlayerForUserID(attackingfag) == g_Engine->GetLocalPlayer())
{
C_BaseEntity* hittedplayer = (C_BaseEntity*)(g_Engine->GetPlayerForUserID(deadfag));
int hit = event->GetInt("hitgroup");
if (hit >= 0 && hittedplayer && deadfag && attackingfag)
{
Globals::missedshots++;
}
else
{
Globals::missedshots++;
}
}
}
if (!strcmp(event->GetName(), "player_hurt"))
{
auto bitch = event->GetInt("userid");
auto coolguy49 = event->GetInt("attacker");
int dmg = event->GetInt("dmg_health");
C_BaseEntity* local = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
auto bitch_index = g_Engine->GetPlayerForUserID(bitch);
auto coolguy49_index = g_Engine->GetPlayerForUserID(coolguy49);
C_BaseEntity* bitch_ = (C_BaseEntity*)g_EntityList->GetClientEntity(bitch_index);
C_BaseEntity* coolguy49_ = (C_BaseEntity*)g_EntityList->GetClientEntity(coolguy49_index);
if (coolguy49_ == local)
{
G::hitmarkeralpha = 1.f;
switch (g_Options.Misc.Hitsound)
{
case 0: break;
case 1: PlaySoundA(rawData, NULL, SND_ASYNC | SND_MEMORY); break; // Default
case 2: PlaySoundA(roblox, NULL, SND_ASYNC | SND_MEMORY); break; // Anime
case 3: PlaySoundA(china, NULL, SND_ASYNC | SND_MEMORY); break; // CHINA
case 4: PlaySoundA(skeethitmarker_wav, NULL, SND_ASYNC | SND_MEMORY); break; // Skeet
}
}
if (g_Options.Visuals.demageidicator)
{
DamageIndicator_t DmgIndicator;
DmgIndicator.iDamage = dmg;
DmgIndicator.Player = bitch_;
DmgIndicator.flEraseTime = local->GetTickBase() * g_Globals->interval_per_tick + 3.f;
DmgIndicator.bInitialized = false;
damage_indicators.data.push_back(DmgIndicator);
}
if (g_Options.Misc.eventlogs)
{
int iAttacker = g_Engine->GetPlayerForUserID(event->GetInt("attacker"));
int iVictim = g_Engine->GetPlayerForUserID(event->GetInt("userid"));
if (iAttacker == g_Engine->GetLocalPlayer() && iVictim != g_Engine->GetLocalPlayer())
{
auto pVictim = reinterpret_cast<C_BaseEntity*>(g_EntityList->GetClientEntity(iVictim));
player_info_t pinfo;
g_Engine->GetPlayerInfo(iVictim, &pinfo);
g_CVar->ConsoleColorPrintf(Color(200, 255, 0, 255), "[Prometheus] ");
G::Msg("Hit %s in the %s for %d damage (%d health remaining) \n", pinfo.name, HitgroupToName(event->GetInt("hitgroup")), event->GetInt("dmg_health"), event->GetInt("health"));
}
}
}
if (!strcmp(event->GetName(), "bullet_impact"))
{
C_BaseEntity* LocalPlayer = g_EntityList->GetClientEntity(g_Engine->GetLocalPlayer());
if (LocalPlayer)
{
auto index = g_Engine->GetPlayerForUserID(event->GetInt("userid"));
if (index != g_Engine->GetLocalPlayer())
return;
auto local = static_cast<C_BaseEntity*>(g_EntityList->GetClientEntity(index));
if (!local)
return;
Vector position(event->GetFloat("x"), event->GetFloat("y"), event->GetFloat("z"));
Ray_t ray;
ray.Init(local->GetEyePosition(), position);
CTraceFilter filter;
filter.pSkip = local;
trace_t tr;
g_EngineTrace->TraceRay(ray, MASK_SHOT, &filter, &tr);
logs.push_back(cbullet_tracer_info(local->GetEyePosition(), position, g_Globals->curtime, g_Options.Colors.flTracers));
if (!local)
return;
for (size_t i = 0; i < logs.size(); i++)
{
auto current = logs.at(i);
current.color = Color(g_Options.Colors.flTracers); //color of local player's tracers
BeamInfo_t beamInfo;
beamInfo.m_nType = TE_BEAMPOINTS;
beamInfo.m_pszModelName = "sprites/physbeam.vmt";
beamInfo.m_nModelIndex = -1;
beamInfo.m_flHaloScale = 0.0f;
beamInfo.m_flLife = g_Options.Visuals.flTracersDuration;
beamInfo.m_flWidth = g_Options.Visuals.flTracersWidth;
beamInfo.m_flEndWidth = g_Options.Visuals.flTracersWidth;
beamInfo.m_flFadeLength = 0.0f;
beamInfo.m_flAmplitude = 2.0f;
beamInfo.m_flBrightness = 255.f;
beamInfo.m_flSpeed = 0.2f;
beamInfo.m_nStartFrame = 0;
beamInfo.m_flFrameRate = 0.f;
beamInfo.m_flRed = current.color.r();
beamInfo.m_flGreen = current.color.g();
beamInfo.m_flBlue = current.color.b();
beamInfo.m_nSegments = 2;
beamInfo.m_bRenderable = true;
beamInfo.m_nFlags = FBEAM_ONLYNOISEONCE | FBEAM_NOTILE | FBEAM_HALOBEAM;
beamInfo.m_vecStart = LocalPlayer->GetEyePosition();
beamInfo.m_vecEnd = current.dst;
if (g_Options.Visuals.bulletshow && g_Options.Visuals.Enabled)
{
auto beam = g_pViewRenderBeams->CreateBeamPoints(beamInfo);
if (beam)
g_pViewRenderBeams->DrawBeam(beam);
}
logs.erase(logs.begin() + i);
}
}
}
}
private:
item_purchase_listener listener;
};
item_purchase purchase;