-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.cpp
898 lines (707 loc) · 24.6 KB
/
client.cpp
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
#include "includes.h"
#include <Windows.h>
#include <LMCons.h>
Client g_cl{ };
#define INFO_BUFFER_SIZE 32767
TCHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE;
typedef void(__thiscall* o_proc_movement)(void*, CMoveData*);
char username[33] = "\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90";
ulong_t __stdcall Client::init(void* arg) {
GetComputerName(infoBuf, &bufCharCount);
g_cl.m_user = XOR("lucid");
if (!g_csgo.init())
return 0;
g_notify.add(tfm::format(XOR("Welcome, %s\n"), GetComputerName));
g_notify.add(tfm::format(XOR("Last updated: '%s'\n"), __DATE__));
return 1;
}
void Client::UnlockHiddenConvars()
{
if (!g_csgo.m_cvar)
return;
auto p = **reinterpret_cast<ConVar***>(g_csgo.m_cvar + 0x34);
for (auto c = p->m_next; c != nullptr; c = c->m_next) {
c->m_flags &= ~FCVAR_DEVELOPMENTONLY;
c->m_flags &= ~FCVAR_HIDDEN;
}
}
void Client::ClanTag()
{
// lambda function for setting our clantag.
auto SetClanTag = [&](std::string tag) -> void {
using SetClanTag_t = int(__fastcall*)(const char*, const char*);
static auto SetClanTagFn = pattern::find(g_csgo.m_engine_dll, XOR("53 56 57 8B DA 8B F9 FF 15")).as<SetClanTag_t>();
SetClanTagFn(tag.c_str(), XOR("lucidity"));
};
std::string szClanTag = XOR("lucidity");
std::string szSuffix = XOR("");
static int iPrevFrame = 0;
static bool bReset = false;
int iCurFrame = ((int)(g_csgo.m_globals->m_curtime * 2.f)) % (szClanTag.size() * 2);
if (g_menu.main.misc.clantag.get()) {
// are we in a new frame?
static auto is_freeze_period = false;
if (g_csgo.m_gamerules->m_bFreezePeriod())
{
if (is_freeze_period)
{
SetClanTag("lucidity"); //Project-X
}
is_freeze_period = false;
return;
}
is_freeze_period = true;
if (iPrevFrame != int(g_csgo.m_globals->m_curtime * 3.2) % 6) {
switch (int(g_csgo.m_globals->m_curtime * 3.2) % 6) {
case 0: { SetClanTag("lucidity"); break; }
case 1: { SetClanTag("lucidity"); break; }
case 2: { SetClanTag("luc1dity"); break; }
case 3: { SetClanTag("luc1d1ty"); break; }
case 4: { SetClanTag("luc1dity"); break; }
case 5: { SetClanTag("lucid?"); break; }
default:;
}
iPrevFrame = int(g_csgo.m_globals->m_curtime * 2.9) % 14;
}
// do we want to reset after untoggling the clantag?
bReset = true;
}
else {
// reset our clantag.
if (bReset) {
SetClanTag(XOR("lucidity"));
bReset = false;
}
}
}
void Client::ClanTag2()
{
// lambda function for setting our clantag.
auto SetClanTag = [&](std::string tag) -> void {
using SetClanTag_t = int(__fastcall*)(const char*, const char*);
static auto SetClanTagFn = pattern::find(g_csgo.m_engine_dll, XOR("53 56 57 8B DA 8B F9 FF 15")).as<SetClanTag_t>();
SetClanTagFn(tag.c_str(), XOR("lucidity"));
};
std::string szClanTag = XOR("lucidity");
std::string szSuffix = XOR("");
static int iPrevFrame = 0;
static bool bReset = false;
int iCurFrame = ((int)(g_csgo.m_globals->m_curtime * 2.f)) % (szClanTag.size() * 2);
if (g_menu.main.misc.clantag2.get()) {
// are we in a new frame?
static auto is_freeze_period = false;
if (g_csgo.m_gamerules->m_bFreezePeriod())
{
if (is_freeze_period)
{
SetClanTag("lucidity"); //Project-X
}
is_freeze_period = false;
return;
}
is_freeze_period = true;
if (iPrevFrame != int(g_csgo.m_globals->m_curtime * 2.5) % 14) {
switch (int(g_csgo.m_globals->m_curtime * 2.5) % 21) {
case 0: { SetClanTag("lucidity"); break; }
case 1: { SetClanTag("lucidity"); break; }
case 2: { SetClanTag("luc1dity"); break; }
case 3: { SetClanTag("luc1d1ty"); break; }
case 4: { SetClanTag("luc1dity"); break; }
case 5: { SetClanTag("lucid?"); break; }
default:;
}
iPrevFrame = int(g_csgo.m_globals->m_curtime * 2.5) % 14;
}
// do we want to reset after untoggling the clantag?
bReset = true;
}
else {
// reset our clantag.
if (bReset) {
SetClanTag(XOR(""));
bReset = false;
}
}
}
void Client::Skybox()
{
static auto sv_skyname = g_csgo.m_cvar->FindVar(HASH("sv_skyname"));
if (g_menu.main.misc.skyboxchange.get()) {
switch (g_menu.main.misc.skybox.get()) {
case 0: //Tibet
//sv_skyname->SetValue("cs_tibet");
sv_skyname->SetValue(XOR("cs_tibet"));
break;
case 1: //Embassy
//sv_skyname->SetValue("embassy");
sv_skyname->SetValue(XOR("embassy"));
break;
case 2: //Italy
//sv_skyname->SetValue("italy");
sv_skyname->SetValue(XOR("italy"));
break;
case 3: //Daylight 1
//sv_skyname->SetValue("sky_cs15_daylight01_hdr");
sv_skyname->SetValue(XOR("sky_cs15_daylight01_hdr"));
break;
case 4: //Cloudy
//sv_skyname->SetValue("sky_csgo_cloudy01");
sv_skyname->SetValue(XOR("sky_csgo_cloudy01"));
break;
case 5: //Night 1
sv_skyname->SetValue(XOR("sky_csgo_night02"));
break;
case 6: //Night 2
//sv_skyname->SetValue("sky_csgo_night02b");
sv_skyname->SetValue(XOR("sky_csgo_night02b"));
break;
case 7: //Night Flat
//sv_skyname->SetValue("sky_csgo_night_flat");
sv_skyname->SetValue(XOR("sky_csgo_night_flat"));
break;
case 8: //Day HD
//sv_skyname->SetValue("sky_day02_05_hdr");
sv_skyname->SetValue(XOR("sky_day02_05_hdr"));
break;
case 9: //Day
//sv_skyname->SetValue("sky_day02_05");
sv_skyname->SetValue(XOR("sky_day02_05"));
break;
case 10: //Rural
//sv_skyname->SetValue("sky_l4d_rural02_ldr");
sv_skyname->SetValue(XOR("sky_l4d_rural02_ldr"));
break;
case 11: //Vertigo HD
//sv_skyname->SetValue("vertigo_hdr");
sv_skyname->SetValue(XOR("vertigo_hdr"));
break;
case 12: //Vertigo Blue HD
//sv_skyname->SetValue("vertigoblue_hdr");
sv_skyname->SetValue(XOR("vertigoblue_hdr"));
break;
case 13: //Vertigo
//sv_skyname->SetValue("vertigo");
sv_skyname->SetValue(XOR("vertigo"));
break;
case 14: //Vietnam
//sv_skyname->SetValue("vietnam");
sv_skyname->SetValue(XOR("vietnam"));
break;
case 15: //Dusty Sky
//sv_skyname->SetValue("sky_dust");
sv_skyname->SetValue(XOR("sky_dust"));
break;
case 16: //Jungle
sv_skyname->SetValue(XOR("jungle"));
break;
case 17: //Nuke
sv_skyname->SetValue(XOR("nukeblank"));
break;
case 18: //Office
sv_skyname->SetValue(XOR("office"));
//game::SetSkybox(XOR("office"));
break;
default:
break;
}
}
/*
Checkbox FogOverride; // butt
Colorpicker FogColor; // color
Slider FogStart; // slider
Slider FogEnd; // slider
Slider Fogdensity; // slider
*/
//g_menu.main.visuals.FogColor.get().r(), g_menu.main.visuals.FogColor.get().g(), g_menu.main.visuals.FogColor.get().b()
float destiny = g_menu.main.visuals.Fogdensity.get() / 100.f;
static const auto fog_enable = g_csgo.m_cvar->FindVar(HASH("fog_enable"));
fog_enable->SetValue(1); //Âêëþ÷àåò òóìàí íà êàðòå åñëè îí âûêëþ÷åí ïî äåôîëòó
static const auto fog_override = g_csgo.m_cvar->FindVar(HASH("fog_override"));
fog_override->SetValue(g_menu.main.visuals.FogOverride.get()); // Ðàçðåøàåò êàñòîìèçàöèþ òóìàíà
static const auto fog_color = g_csgo.m_cvar->FindVar(HASH("fog_color"));
fog_color->SetValue(std::string(std::to_string(g_menu.main.visuals.FogColor.get().r()) + " " + std::to_string(g_menu.main.visuals.FogColor.get().g()) + " " + std::to_string(g_menu.main.visuals.FogColor.get().b())).c_str()); //Öâåò òóìàíà rgb
static const auto fog_start = g_csgo.m_cvar->FindVar(HASH("fog_start"));
fog_start->SetValue(g_menu.main.visuals.FogStart.get()); // Äèñòàíöèÿ ñ êîòîðîé òóìàí ïîÿâëÿåòñÿ
static const auto fog_end = g_csgo.m_cvar->FindVar(HASH("fog_end"));
fog_end->SetValue(g_menu.main.visuals.FogEnd.get()); // Äèñòàíöèÿ ñ êîòîðîé òóìàí ïðîïàäàåò
static const auto fog_destiny = g_csgo.m_cvar->FindVar(HASH("fog_maxdensity"));
fog_destiny->SetValue(destiny); //Ìàêñèìàëüíàÿ íàñûùåííîñòü òóìàíà(0-1)
}
void Client::KillFeed() {
if (!g_menu.main.misc.killfeed.get())
return;
if (!g_csgo.m_engine->IsInGame())
return;
// get the addr of the killfeed.
KillFeed_t* feed = (KillFeed_t*)g_csgo.m_hud->FindElement(HASH("SFHudDeathNoticeAndBotStatus"));
if (!feed)
return;
int size = feed->notices.Count();
if (!size)
return;
for (int i{ }; i < size; ++i) {
NoticeText_t* notice = &feed->notices[i];
// this is a local player kill, delay it.
if (notice->fade == 1.5f)
notice->fade = FLT_MAX;
}
}
void Client::OnPaint() {
// update screen size.
g_csgo.m_engine->GetScreenSize(m_width, m_height);
// render stuff.
g_visuals.think();
g_grenades.paint();
g_notify.think();
g_indicators.Indicators();
g_visuals.aspect_ratio();
KillFeed();
// menu goes last.
g_gui.think();
}
void Client::OnMapload() {
// store class ids.
g_netvars.SetupClassData();
// createmove will not have been invoked yet.
// but at this stage entites have been created.
// so now we can retrive the pointer to the local player.
m_local = g_csgo.m_entlist->GetClientEntity< Player* >(g_csgo.m_engine->GetLocalPlayer());
// world materials.
g_visuals.ModulateWorld();
// init knife shit.
g_skins.load();
m_sequences.clear();
// if the INetChannelInfo pointer has changed, store it for later.
g_csgo.m_net = g_csgo.m_engine->GetNetChannelInfo();
if (g_csgo.m_net) {
g_hooks.m_net_channel.reset();
g_hooks.m_net_channel.init(g_csgo.m_net);
g_hooks.m_net_channel.add(INetChannel::PROCESSPACKET, util::force_cast(&Hooks::ProcessPacket));
g_hooks.m_net_channel.add(INetChannel::SENDDATAGRAM, util::force_cast(&Hooks::SendDatagram));
}
}
void Client::StartMove(CUserCmd* cmd) {
// save some usercmd stuff.
m_cmd = cmd;
m_tick = cmd->m_tick;
m_view_angles = cmd->m_view_angles;
m_buttons = cmd->m_buttons;
// get local ptr.
m_local = g_csgo.m_entlist->GetClientEntity< Player* >(g_csgo.m_engine->GetLocalPlayer());
if (!m_local)
return;
g_csgo.m_net = g_csgo.m_engine->GetNetChannelInfo();
if (!g_csgo.m_net)
return;
if (m_processing && m_tick_to_recharge > 0 && !m_charged && can_recharge) {
m_tick_to_recharge--;
cmd->m_tick = INT_MAX;
*m_packet = true;
}
if (can_recharge && m_tick_to_recharge == 0)
{
m_charged = true;
can_recharge = false;
}
// store max choke
// TODO; 11 -> m_bIsValveDS
m_max_lag = (m_local->m_fFlags() & FL_ONGROUND) ? 16 : 15;
m_lag = g_csgo.m_cl->m_choked_commands;
m_lerp = game::GetClientInterpAmount();
m_latency = g_csgo.m_net->GetLatency(INetChannel::FLOW_OUTGOING);
math::clamp(m_latency, 0.f, 1.f);
m_latency_ticks = game::TIME_TO_TICKS(m_latency);
m_server_tick = g_csgo.m_cl->m_server_tick;
m_arrival_tick = m_server_tick + m_latency_ticks;
// processing indicates that the localplayer is valid and alive.
m_processing = m_local && m_local->alive();
if (!m_processing)
return;
// make sure prediction has ran on all usercommands.
// because prediction runs on frames, when we have low fps it might not predict all usercommands.
// also fix the tick being inaccurate.
g_inputpred.update();
// store some stuff about the local player.
m_flags = m_local->m_fFlags();
// ...
m_shot = false;
}
void Client::BackupPlayers(bool restore) {
if (restore) {
// restore stuff.
for (int i{ 1 }; i <= g_csgo.m_globals->m_max_clients; ++i) {
Player* player = g_csgo.m_entlist->GetClientEntity< Player* >(i);
if (!g_aimbot.IsValidTarget(player))
continue;
g_aimbot.m_backup[i - 1].restore(player);
}
}
else {
// backup stuff.
for (int i{ 1 }; i <= g_csgo.m_globals->m_max_clients; ++i) {
Player* player = g_csgo.m_entlist->GetClientEntity< Player* >(i);
if (!g_aimbot.IsValidTarget(player))
continue;
g_aimbot.m_backup[i - 1].store(player);
}
}
}
void Client::DoMove() {
penetration::PenetrationOutput_t tmp_pen_data{ };
// backup strafe angles (we need them for input prediction)
m_strafe_angles = m_cmd->m_view_angles;
// run movement code before input prediction.
g_movement.JumpRelated();
g_movement.Strafe();
g_movement.FakeWalk();
g_movement.MovementExploit();
g_movement.AutoPeek();
g_movement.AutoStopFIX();
// predict input.
g_inputpred.run();
// restore original angles after input prediction
m_cmd->m_view_angles = m_view_angles;
// convert viewangles to directional forward vector.
math::AngleVectors(m_view_angles, &m_forward_dir);
// store stuff after input pred.
m_shoot_pos = m_local->GetShootPosition();
// reset shit.
m_weapon = nullptr;
m_weapon_info = nullptr;
m_weapon_id = -1;
m_weapon_type = WEAPONTYPE_UNKNOWN;
m_player_fire = m_weapon_fire = false;
// store weapon stuff.
m_weapon = m_local->GetActiveWeapon();
if (m_weapon) {
m_weapon_info = m_weapon->GetWpnData();
m_weapon_id = m_weapon->m_iItemDefinitionIndex();
m_weapon_type = m_weapon_info->m_weapon_type;
// ensure weapon spread values / etc are up to date.
if (m_weapon_type != WEAPONTYPE_GRENADE)
m_weapon->UpdateAccuracyPenalty();
// run autowall once for penetration crosshair if we have an appropriate weapon.
if (m_weapon_type != WEAPONTYPE_KNIFE && m_weapon_type != WEAPONTYPE_C4 && m_weapon_type != WEAPONTYPE_GRENADE) {
penetration::PenetrationInput_t in;
in.m_from = m_local;
in.m_target = nullptr;
in.m_pos = m_shoot_pos + (m_forward_dir * m_weapon_info->m_range);
in.m_damage = 1.f;
in.m_damage_pen = 1.f;
in.m_can_pen = true;
// run autowall.
penetration::run(&in, &tmp_pen_data);
}
// set pen data for penetration crosshair.
m_pen_data = tmp_pen_data;
// can the player fire.
m_player_fire = g_csgo.m_globals->m_curtime >= m_local->m_flNextAttack() && !g_csgo.m_gamerules->m_bFreezePeriod() && !(g_cl.m_flags & FL_FROZEN);
UpdateRevolverCock();
m_weapon_fire = CanFireWeapon(game::TICKS_TO_TIME(g_cl.m_local->m_nTickBase()));
}
// last tick defuse.
// todo - dex; figure out the range for CPlantedC4::Use?
// add indicator if valid (on ground, still have time, not being defused already, etc).
// move this? not sure where we should put it.
if (g_input.GetKeyState(g_menu.main.misc.last_tick_defuse.get()) && g_visuals.m_c4_planted) {
float defuse = (m_local->m_bHasDefuser()) ? 5.f : 10.f;
float remaining = g_visuals.m_planted_c4_explode_time - g_csgo.m_globals->m_curtime;
float dt = remaining - defuse - (g_cl.m_latency / 2.f);
m_cmd->m_buttons &= ~IN_USE;
if (dt <= game::TICKS_TO_TIME(2))
m_cmd->m_buttons |= IN_USE;
}
// grenade prediction.
g_grenades.think();
// run fakelag.
g_hvh.SendPacket();
// run aimbot.
g_aimbot.think();
// run antiaims.
g_hvh.AntiAim();
}
void Client::EndMove(CUserCmd* cmd) {
// update client-side animations.
UpdateInformation();
// if matchmaking mode, anti untrust clamp.
if (g_menu.main.config.mode.get() == 0)
m_cmd->m_view_angles.SanitizeAngle();
// fix our movement.
g_movement.FixMove(cmd, m_strafe_angles);
g_movement.MoonWalk(cmd);
// this packet will be sent.
if (*m_packet) {
g_hvh.m_step_switch = (bool)g_csgo.RandomInt(0, 1);
// we are sending a packet, so this will be reset soon.
// store the old value.
m_old_lag = m_lag;
// get radar angles.
m_radar = cmd->m_view_angles;
m_radar.normalize();
// get current origin.
vec3_t cur = m_local->m_vecOrigin();
// get prevoius origin.
vec3_t prev = m_net_pos.empty() ? cur : m_net_pos.front().m_pos;
// check if we broke lagcomp.
m_lagcomp = (cur - prev).length_sqr() > 4096.f;
// save sent origin and time.
m_net_pos.emplace_front(g_csgo.m_globals->m_curtime, cur);
}
// store some values for next tick.
m_old_packet = *m_packet;
m_old_shot = m_shot;
}
void Client::OnTick(CUserCmd* cmd) {
// TODO; add this to the menu.
if (g_menu.main.misc.ranks.get() && cmd->m_buttons & IN_SCORE) {
static CCSUsrMsg_ServerRankRevealAll msg{ };
g_csgo.ServerRankRevealAll(&msg);
}
// store some data and update prediction.
StartMove(cmd);
// not much more to do here.
if (!m_processing)
return;
// save the original state of players.
BackupPlayers(false);
// run all movement related code.
DoMove();
// store stome additonal stuff for next tick
// sanetize our usercommand if needed and fix our movement.
EndMove(cmd);
// restore the players.
BackupPlayers(true);
// restore curtime/frametime
// and prediction seed/player.
g_aimbot.DoubleTap();
g_inputpred.restore();
}
void Client::SetAngles() {
if (!g_cl.m_local || !g_cl.m_processing)
return;
// set the nointerp flag.
g_cl.m_local->m_fEffects() |= EF_NOINTERP;
// apply the rotation.
g_cl.m_local->SetAbsAngles(m_rotation);
g_cl.m_local->m_angRotation() = m_rotation;
g_cl.m_local->m_angNetworkAngles() = m_rotation;
// set radar angles.
if (g_csgo.m_input->CAM_IsThirdPerson())
g_csgo.m_prediction->SetLocalViewAngles(m_radar);
}
void Client::SetAngles2(ang_t angle) {
if (!g_cl.m_local || !g_cl.m_processing || !g_menu.main.antiaim.fake_yaw.get())
return;
// set the nointerp flag.
g_cl.m_local->m_fEffects() |= EF_NOINTERP;
// apply the rotation.
g_cl.m_local->SetAbsAngles(angle);
g_cl.m_local->m_angRotation() = angle;
g_cl.m_local->m_angNetworkAngles() = angle;
}
void Client::UpdateAnimations() {
if (!g_cl.m_local || !g_cl.m_processing)
return;
CCSGOPlayerAnimState* state = g_cl.m_local->m_PlayerAnimState();
if (!state)
return;
// prevent model sway on player.
g_cl.m_local->m_AnimOverlay()[12].m_weight = 0.f;
// update animations with last networked data.
g_cl.m_local->SetPoseParameters(g_cl.m_poses);
// update abs yaw with last networked abs yaw.
g_cl.m_local->SetAbsAngles(ang_t(0.f, g_cl.m_abs_yaw, 0.f));
// fix model folding
if (!g_visuals.m_thirdperson && state->m_land && !GetAsyncKeyState(0x20)) {
if (g_cl.m_local->m_bDucking()) {
g_hooks.m_UpdateClientSideAnimation(g_cl.m_local);
// stop landing animation.
g_cl.m_local->m_AnimOverlay()[5].m_weight = 0.f;
// prevent model sway on player.
g_cl.m_local->m_AnimOverlay()[12].m_weight = 0.f;
// update animations with last networked data.
g_cl.m_local->SetPoseParameters(g_cl.m_poses);
// update abs yaw with last networked abs yaw.
g_cl.m_local->SetAbsAngles(ang_t(0.f, g_cl.m_abs_yaw, 0.f));
}
else {
g_hooks.m_UpdateClientSideAnimation(g_cl.m_local);
// stop landing animation.
g_cl.m_local->m_AnimOverlay()[5].m_weight = 0.f;
// prevent model sway on player.
g_cl.m_local->m_AnimOverlay()[12].m_weight = 0.f;
// update animations with last networked data.
g_cl.m_local->SetPoseParameters(g_cl.m_poses);
// update abs yaw with last networked abs yaw.
g_cl.m_local->SetAbsAngles(ang_t(0.f, g_cl.m_abs_yaw, 0.f));
}
}
//sync attachments with player position.
static const auto jiggle_bones = g_csgo.m_cvar->FindVar(HASH("r_jiggle_bones"));
jiggle_bones->SetValue(0);
// prevent model sway on player.
g_cl.m_local->m_AnimOverlay()[12].m_weight = 0.f;
// update animations with last networked data.
g_cl.m_local->SetPoseParameters(g_cl.m_poses);
// stop falling animation.
//g_cl.m_local->m_AnimOverlay()[4].m_weight = 0.f;
// update abs yaw with last networked abs yaw.
g_cl.m_local->SetAbsAngles(ang_t(0.f, g_cl.m_abs_yaw, 0.f));
}
void Client::UpdateInformation() {
if (g_cl.m_lag > 0)
return;
CCSGOPlayerAnimState* state = g_cl.m_local->m_PlayerAnimState();
if (!state)
return;
// update time.
m_anim_frame = g_csgo.m_globals->m_curtime - m_anim_time;
m_anim_time = g_csgo.m_globals->m_curtime;
// current angle will be animated.
m_angle = g_cl.m_cmd->m_view_angles;
// fix landing anim.
if (state->m_land && !state->m_dip_air && state->m_dip_cycle > 0.f) {
g_cl.m_local->m_AnimOverlay()[4].m_weight = 0.f;
m_angle.x = -12.f;
}
math::clamp(m_angle.x, -90.f, 90.f);
m_angle.normalize();
// write angles to model.
g_csgo.m_prediction->SetLocalViewAngles(m_angle);
// set lby to predicted value.
g_cl.m_local->m_flLowerBodyYawTarget() = m_body;
// CCSGOPlayerAnimState::Update, bypass already animated checks.
if (state->m_frame == g_csgo.m_globals->m_frame)
state->m_frame = g_csgo.m_globals->m_frame - 1;
// call original, bypass hook.
g_hooks.m_UpdateClientSideAnimation(g_cl.m_local);
// get last networked poses.
g_cl.m_local->GetPoseParameters(g_cl.m_poses);
// store updated abs yaw.
g_cl.m_abs_yaw = state->m_goal_feet_yaw;
// we landed.
if (!m_ground && state->m_ground) {
m_body = m_angle.y;
m_body_pred = m_anim_time;
}
// walking, delay lby update by .22.
else if (state->m_speed > 0.1f) {
if (state->m_ground)
m_body = m_angle.y;
m_body_pred = m_anim_time + 0.22f;
}
// standing update every 1.1s
else if (m_anim_time > m_body_pred) {
m_body = m_angle.y;
m_body_pred = m_anim_time + 1.1f;
}
// save updated data.
m_rotation = g_cl.m_local->m_angAbsRotation();
m_speed = state->m_speed;
m_ground = state->m_ground;
}
void Client::print(const std::string text, ...) {
va_list list;
int size;
std::string buf;
if (text.empty())
return;
va_start(list, text);
// count needed size.
size = std::vsnprintf(0, 0, text.c_str(), list);
// allocate.
buf.resize(size);
// print to buffer.
std::vsnprintf(buf.data(), size + 1, text.c_str(), list);
va_end(list);
// print to console.
g_csgo.m_cvar->ConsoleColorPrintf(colors::light_purple, XOR("[lucidity] "));
g_csgo.m_cvar->ConsoleColorPrintf(colors::white, buf.c_str());
}
bool Client::CanFireWeapon(float curtime) {
// the player cant fire.
if (!m_player_fire)
return false;
if (m_weapon_type == WEAPONTYPE_GRENADE)
return false;
// if we have no bullets, we cant shoot.
if (m_weapon_type != WEAPONTYPE_KNIFE && m_weapon->m_iClip1() < 1)
return false;
// do we have any burst shots to handle?
if ((m_weapon_id == GLOCK || m_weapon_id == FAMAS) && m_weapon->m_iBurstShotsRemaining() > 0) {
// new burst shot is coming out.
if (g_csgo.m_globals->m_curtime >= m_weapon->m_fNextBurstShot())
return true;
}
// r8 revolver.
if (m_weapon_id == REVOLVER) {
int act = m_weapon->m_Activity();
// mouse1.
if (!m_revolver_fire) {
if ((act == 185 || act == 193) && m_revolver_cock == 0)
return g_csgo.m_globals->m_curtime >= m_weapon->m_flNextPrimaryAttack();
return false;
}
}
// yeez we have a normal gun.
if (g_csgo.m_globals->m_curtime >= m_weapon->m_flNextPrimaryAttack())
return true;
return false;
}
void Client::UpdateRevolverCock() {
// default to false.
m_revolver_fire = false;
// reset properly.
if (m_revolver_cock == -1)
m_revolver_cock = 0;
// we dont have a revolver.
// we have no ammo.
// player cant fire
// we are waiting for we can shoot again.
if (m_weapon_id != REVOLVER || m_weapon->m_iClip1() < 1 || !m_player_fire || g_csgo.m_globals->m_curtime < m_weapon->m_flNextPrimaryAttack()) {
// reset.
m_revolver_cock = 0;
m_revolver_query = 0;
return;
}
// calculate max number of cocked ticks.
// round to 6th decimal place for custom tickrates..
int shoot = (int)(0.25f / (std::round(g_csgo.m_globals->m_interval * 1000000.f) / 1000000.f));
// amount of ticks that we have to query.
m_revolver_query = shoot - 1;
// we held all the ticks we needed to hold.
if (m_revolver_query == m_revolver_cock) {
// reset cocked ticks.
m_revolver_cock = -1;
// we are allowed to fire, yay.
m_revolver_fire = true;
}
else {
// we still have ticks to query.
// apply inattack.
if (g_menu.main.config.mode.get() == 0 && m_revolver_query > m_revolver_cock)
m_cmd->m_buttons |= IN_ATTACK;
// count cock ticks.
// do this so we can also count 'legit' ticks
// that didnt originate from the hack.
if (m_cmd->m_buttons & IN_ATTACK)
m_revolver_cock++;
// inattack was not held, reset.
else m_revolver_cock = 0;
}
// remove inattack2 if cocking.
if (m_revolver_cock > 0)
m_cmd->m_buttons &= ~IN_ATTACK2;
}
void Client::UpdateIncomingSequences() {
if (!g_csgo.m_net)
return;
if (m_sequences.empty() || g_csgo.m_net->m_in_seq > m_sequences.front().m_seq) {
// store new stuff.
m_sequences.emplace_front(g_csgo.m_globals->m_realtime, g_csgo.m_net->m_in_rel_state, g_csgo.m_net->m_in_seq);
}
// do not save too many of these.
while (m_sequences.size() > 2048)
m_sequences.pop_back();
}