forked from LyNnz01/eon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
10432 lines (10278 loc) · 691 KB
/
Source.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
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <signal.h>
#include "enet/include/enet.h"
#include "include/nlohmann/json.hpp"
#include "include/proton/rtparam.hpp"
#include "include/HTTPRequest.hpp"
#include "Item.h"
#include "Base.h"
#include "Player.h"
#include "Packet.h"
#include "Guilds.h"
#include "skStr.h"
#include "World.h"
#pragma comment(lib, "Ws2_32.lib")
BOOL WINAPI ConsoleHandler(DWORD dwType)
{
switch (dwType) {
case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: case CTRL_CLOSE_EVENT:
{
trigger_save_(false);
return TRUE;
}
default:
{
break;
}
}
return FALSE;
}
/*
void ubitoken_reset() {
if (ubitoken_time - time(nullptr) < 0 && ubi_sold_3 >= ubi_item_3) {
ubi_sold_3 = 0;
ubitoken_time = time(nullptr) + 3600;
}
}*/
int ancientprice(int z) {
switch (z) {
case 5078: case 5080: case 5084: case 5082: case 7166:
return -50;
case 5126: case 5144: case 5162: case 5180: case 7168:
return -75;
case 5128: case 5146: case 5164: case 5182: case 7170:
return -100;
case 5130: case 5148: case 5166: case 5184: case 7172:
return -125;
case 5132: case 5150: case 5168: case 5186: case 7174:
return -200;
case 5134: case 5152: case 5170: case 5188: case 9212:
return -200;
default:
return 0;
}
}
string ancientdialog(ENetPeer* peer, int ril) {
int price = abs(ancientprice(ril)), ewe = inventory_contains(peer, 1796);
return "\nadd_textbox|`2- " + items[pInfo(peer)->ances].name + " (OK!)|" + (ewe >= price ? "\nadd_textbox|`2- " + to_string(price) + " Diamond Locks (OK!)" : "\nadd_textbox|`o- " + to_string(price) + " Diamond Locks (" + to_string(ewe) + "/" + to_string(price) + ")") + "|\nadd_spacer|small|\nadd_smalltext|`1The upgraded item will be untradeable|" + (ewe >= price ? "\nadd_button|ancientaltar|`0Complete the ritual" : "") + "|\nend_dialog|tolol12|Return||\nadd_quick_exit";
}
void loop_worlds() {
if (server_port != main_port && server_port != 17098) return;
if (f_saving_ == false) {
long long ms_time = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
if (beach_party_game) {
if (last_beach_event != 0 and (last_beach_event - ms_time <= 0 || beach_players.size() == 0)) {
string name_ = "BEACHPARTYGAME";
vector<BYTE*>blocks;
for (int i_ = 0; i_ < change_id_beach.size(); i_++) blocks.push_back(packBlockType(3, 8676, change_id_beach[i_] % 100, change_id_beach[i_] / 100));
vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name_](const World& a) { return a.name == name_; });
if (p != worlds.end()) {
World* world_ = &worlds[p - worlds.begin()];
for (uint16_t i_ = 4400; i_ < 5300; i_++) if (world_->blocks[i_].fg != 12252)blocks.push_back(packBlockType(3, world_->blocks[i_].fg = 12252, (i_ % 100), (i_ / 100)));
}
if (beach_players.size() != 0) {
gamepacket_t p;
p.Insert("OnEndMission");
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != "BEACHPARTYGAME") continue;
for (auto& b : blocks)send_raw(currentPeer, 4, b, 56, ENET_PACKET_FLAG_RELIABLE);
if (find(beach_players.begin(), beach_players.end(), pInfo(currentPeer)->tankIDName) != beach_players.end()) {
gamepacket_t p;
p.Insert("OnTalkBubble"), p.Insert(pInfo(currentPeer)->netID), p.Insert("The game is over!"), p.Insert(0), p.Insert(1), p.CreatePacket(currentPeer);
pInfo(currentPeer)->c_x = 0, pInfo(currentPeer)->c_y = 0;
SendRespawn(currentPeer, true, 0, 1);
p.CreatePacket(currentPeer);
}
}
beach_players.clear();
}
else {
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != "BEACHPARTYGAME") continue;
for (auto& b : blocks)send_raw(currentPeer, 4, b, 56, ENET_PACKET_FLAG_RELIABLE);
}
}
last_beach_event = 0;
for (auto& b : blocks) free(b);
blocks.clear();
}
}
if (last_time2_ - ms_time <= 0 && Server_Security.restart_server_status) {
gamepacket_t p;
p.Insert("OnConsoleMessage"), p.Insert("`4Global System Message``: Restarting server for update in `4" + to_string(Server_Security.restart_server_time) + "`` minutes");
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
packet_(currentPeer, "action|play_sfx\nfile|audio/ogg/suspended.ogg\ndelayMS|700");
p.CreatePacket(currentPeer);
}
Server_Security.restart_server_time -= 1;
if (Server_Security.restart_server_time == 0) {
last_time2_ = ms_time + 10000, Server_Security.restart_server_status_seconds = true, Server_Security.restart_server_status = false;
Server_Security.restart_server_time = 50;
}
else last_time2_ = ms_time + 60000;
}
if (Server_Security.restart_server_status_seconds && last_time2_ - ms_time <= 0) {
bool save_ = false, send_now = false;
gamepacket_t p;
p.Insert("OnConsoleMessage"), p.Insert("`4Global System Message``: Restarting server for update in `4" + (Server_Security.restart_server_time > 0 ? to_string(Server_Security.restart_server_time) : "ZERO") + "`` seconds" + (Server_Security.restart_server_time > 0 ? "" : "! Should be back up in a minute or so. BYE!") + "");
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
p.CreatePacket(currentPeer);
send_now = true;
}
if (Server_Security.restart_server_time > 0) save_ = false;
else save_ = true;
last_time2_ = ms_time + 10000;
if (save_ && send_now) {
Server_Security.restart_server_status_seconds = false;
trigger_save_(false);
}
else Server_Security.restart_server_time -= 10;
}
if (last_time - ms_time <= 0) {
if (Hide_N_Seek.last_hide_event != 0 and (Hide_N_Seek.last_hide_event - ms_time <= 0 || Hide_N_Seek.hide_players.size() == Hide_N_Seek.seeker.size())) finish_hide();
else if (Hide_N_Seek.hide_time - time(nullptr) <= 0 && Hide_N_Seek.hide_time != 0) {
Hide_N_Seek.hide_time = 0;
gamepacket_t p3, pe;
p3.Insert("OnSetMissionTimer"), p3.Insert(Hide_N_Seek.hide_gamemode_time - 30);
pe.Insert("OnEndMission");
string start = Hide_N_Seek.hidenseekworld;
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->seeker) {
pe.CreatePacket(currentPeer);
Hide_N_Seek.seeker_start = true;
pInfo(currentPeer)->ghost = false;
pInfo(currentPeer)->invis = false;
update_clothes_value(currentPeer);
join_world(currentPeer, start);
p3.CreatePacket(currentPeer);
}
else if (pInfo(currentPeer)->hider) {
Hide_N_Seek.total_players++;
pe.CreatePacket(currentPeer);
string worldas = Hide_N_Seek.hidenseekworld;
if (pInfo(currentPeer)->world != worldas) join_world(currentPeer, worldas);
gamepacket_t p;
p.Insert("OnTalkBubble"), p.Insert(pInfo(currentPeer)->netID);
p.Insert("Hiding time is over.. Seeker is coming!"), p.Insert(0), p.Insert(0), p.CreatePacket(currentPeer);
p3.CreatePacket(currentPeer);
Hide_N_Seek.hider_start = true;
}
}
}
if (Hide_N_Seek.wait_players_time - time(nullptr) <= 0 && Hide_N_Seek.wait_players_time != 0 && Hide_N_Seek.last_hide_event == 0) {
Hide_N_Seek.seeker.clear();
vector<int> types = { 7874, 454, 988,3818, 2962, 554 , 1766, 6 };
Hide_N_Seek.hidenseekworld = Hide_N_Seek.hide_worlds[rand() % Hide_N_Seek.hide_worlds.size()];
if (Hide_N_Seek.hidenseekworld == "HIDENSEEK2") types = { 1004 , 884 , 1042 , 846 , 170 };
else if (Hide_N_Seek.hidenseekworld == "HIDENSEEK3") types = { 1446 , 482 , 954 , 1100 , 188 };
else if (Hide_N_Seek.hidenseekworld == "HIDENSEEK4") types = { 1044 , 1042 , 5196 , 652 , 16, 1046, 688 };
string world = Hide_N_Seek.hidenseekworld;
Hide_N_Seek.seeker.push_back(to_lower(Hide_N_Seek.hide_players[rand() % Hide_N_Seek.hide_players.size()]));
if (Hide_N_Seek.hide_players.size() > 6) {
string random_seeker = to_lower(Hide_N_Seek.hide_players[rand() % Hide_N_Seek.hide_players.size()]);
if (find(Hide_N_Seek.seeker.begin(), Hide_N_Seek.seeker.end(), random_seeker) != Hide_N_Seek.seeker.end()) {
random_seeker = to_lower(Hide_N_Seek.hide_players[rand() % Hide_N_Seek.hide_players.size()]);
}
else Hide_N_Seek.seeker.push_back(to_lower(Hide_N_Seek.hide_players[rand() % Hide_N_Seek.hide_players.size()]));
}
Hide_N_Seek.hide_time = time(nullptr) + 20;
gamepacket_t p2c;
p2c.Insert("OnConsoleMessage");
Hide_N_Seek.last_hide_event = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count() + (Hide_N_Seek.hide_gamemode_time * 1000);
bool found_seaker = false;
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (find(Hide_N_Seek.seeker.begin(), Hide_N_Seek.seeker.end(), to_lower(pInfo(currentPeer)->tankIDName)) != Hide_N_Seek.seeker.end()) {
found_seaker = true;
break;
}
}
string seekers = join(Hide_N_Seek.seeker, ", ");
gamepacket_t p3;
p3.Insert("OnSetMissionTimer");
p3.Insert(30);
if (found_seaker == false) p2c.Insert("The game is canceled because the seeker left!");
else p2c.Insert("CP:_PL:0_OID:_CT:[S]_ `5***`` `9[HIDE AND SEEK]: The game has started! There is " + to_string(Hide_N_Seek.hide_players.size() - Hide_N_Seek.seeker.size()) + " hiders and "+to_string(Hide_N_Seek.seeker.size()) + " Seeker (" + seekers + ")!");
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (find(Hide_N_Seek.hide_players.begin(), Hide_N_Seek.hide_players.end(), pInfo(currentPeer)->tankIDName) != Hide_N_Seek.hide_players.end()) {
gamepacket_t pt;
pt.Insert("OnTalkBubble"), pt.Insert(pInfo(currentPeer)->netID);
if (found_seaker == false) pt.Insert("The game is canceled because the seeker left!");
else {
int remove = -1;
if (modify_inventory(currentPeer, 10016, remove) != 0) exit_(currentPeer);
else {
if (find(Hide_N_Seek.seeker.begin(), Hide_N_Seek.seeker.end(), to_lower(pInfo(currentPeer)->tankIDName)) != Hide_N_Seek.seeker.end()) {
pInfo(currentPeer)->seeker = true;
gamepacket_t p;
p.Insert("OnAddNotification"), p.Insert("interface/large/special_event.rttex"), p.Insert("`wYou are seeker!``"), p.Insert("audio/cumbia_horns.wav"), p.Insert(0), p.CreatePacket(currentPeer);
pt.Insert("The game has started and your ticket has been removed from your inventory! You are seeker! Players are hiding for 20 seconds.");
}
else {
pInfo(currentPeer)->hider = true;
pInfo(currentPeer)->hiden_clothing = types[rand() % types.size()];
pt.Insert("The game has started and your ticket has been removed from your inventory! You have 20 seconds to hide!");
join_world(currentPeer, world);
}
p3.CreatePacket(currentPeer);
}
}
p2c.CreatePacket(currentPeer);
pt.Insert(0), pt.Insert(1), pt.CreatePacket(currentPeer);
}
}
if (found_seaker == false) Hide_N_Seek.hide_players.clear();
}
if (Honors_Update.last_honors_reset - ms_time <= 0) {
top_wls_leaderboard();
account_rid_detect.clear();
time_t currentTime;
time(¤tTime);
const auto localTime = localtime(¤tTime);
const auto Hour = localTime->tm_hour; const auto Min = localTime->tm_min; const auto Sec = localTime->tm_sec; const auto Year = localTime->tm_year + 1900; const auto Day = localTime->tm_mday; const auto Month = localTime->tm_mon + 1;
if (Hour >= 6 and Hour < 15) {
DaylightDragon.param1 = 0, DaylightDragon.param2 = 0, DaylightDragon.param3 = 1, DaylightDragon.param4 = 5, DaylightDragon.param5 = 0, DaylightDragon.param6 = 2;
}
if (Hour >= 15 and Hour < 18) {
DaylightDragon.param1 = 1, DaylightDragon.param2 = 0, DaylightDragon.param3 = 1, DaylightDragon.param4 = 5, DaylightDragon.param5 = 0, DaylightDragon.param6 = 0;
}
if (Hour >= 18 and Hour <= 0 or Hour > 0 and Hour < 6) {
DaylightDragon.param1 = 2, DaylightDragon.param2 = 0, DaylightDragon.param3 = 1, DaylightDragon.param4 = 5, DaylightDragon.param5 = 0, DaylightDragon.param6 = 1;
}
honors_reset();
Honors_Update.last_honors_reset = ms_time + 7200000;
cout << "LEADERBOARD RESTART" << endl;
}
/*
if (bonanza_time - time(nullptr) <= 0 && bonanza_item_current != 0) {
bonanza_sold = 0;
bonanza_item_current = 0;
}*/
if (current_event - time(nullptr) <= 0 && can_event == false) {
clear_event();
}
if (next_event - time(nullptr) <= 0 && can_event == true) {
start_event();
}
if (Crypto_Update.crypto_time - time(nullptr) <= 0) {
vector<int> added;
janeway_.janeway_item.clear();
janeway_.janeway_payout = janeway_.random_janeway_payout[rand() % janeway_.random_janeway_payout.size()];
for (int i = 0; i < 5; i++) {
int random_item = rand() % janeway_.janeway_items.size();
if (find(added.begin(), added.end(), janeway_.janeway_items[random_item].first) == added.end()) {
added.push_back(janeway_.janeway_items[random_item].first);
janeway_.janeway_item.push_back(make_pair(janeway_.janeway_items[random_item].first, janeway_.janeway_items[random_item].second));
janeway_.janeway_item.push_back(make_pair(janeway_.janeway_items[random_item].first + 1, janeway_.janeway_items[random_item].second * 4));
}
}
Crypto_Update.crypto_list.clear();
Crypto_Update.crypto_sale_list.clear();
Crypto_Update.crypto_list = "\ntext_scaling_string|Crypto Currency|";
string info = "";
std::ifstream ifs("db/crypto_prices.json");
json j = json::parse(ifs);
info += "\nBitcoin|" + j["Bitcoin"].get<string>() + "\n";
info += "Ethereum|" + j["Ethereum"].get<string>() + "\n";
info += "Litecoin|" + j["Litecoin"].get<string>();
vector<string> d_ = explode("\n", info);
for (int i = 1; i < d_.size(); i++) {
string crypto_name = explode("|", d_[i])[0], color = "";
int crypto_price = atoi(explode("|", d_[i])[1].c_str()), item_id = 0, crypto_sales = crypto_price * 0.9;
for (int i = 0; i < Crypto_Update.crypto.size(); i++) {
if (Crypto_Update.crypto[i].first == crypto_name) {
if (crypto_price >= Crypto_Update.crypto[i].second) color = "`2rise``";
else color = "`4drop``";
Crypto_Update.crypto[i].second = crypto_price;
Crypto_Update.crypto_sale[i].second = crypto_sales;
Crypto_Update.crypto_sale_list += "\nadd_button_with_icon|sell_" + Crypto_Update.crypto[i].first + "|" + Crypto_Update.crypto[i].first + "|staticPurpleFrame|" + to_string(item_crypto(Crypto_Update.crypto[i].first)) + "|" + to_string(crypto_sales) + "|";
Crypto_Update.crypto_list += "\nadd_button_with_icon|buy_" + Crypto_Update.crypto[i].first + "|" + Crypto_Update.crypto[i].first + " (" + color + ")|staticYellowFrame|" + to_string(item_crypto(Crypto_Update.crypto[i].first)) + "|" + to_string(crypto_price) + "|";
}
}
}
Crypto_Update.crypto_time = time(nullptr) + 6000;
}
if (World_Stuff.last_world_menu - ms_time <= 0) {
World_Stuff.active_world_list.clear();
World_Stuff.active_world_list = "";
load_config();
for (uint8_t i = 0; i < (World_Stuff.top_active_worlds.size() > 20 ? 20 : World_Stuff.top_active_worlds.size()); i++) {
uint8_t w_cz = 0;
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != World_Stuff.top_active_worlds[i].second) continue;
w_cz++;
}
World_Stuff.active_world_list += "\nadd_floater|" + World_Stuff.top_active_worlds[i].second + "|" + to_string(w_cz) + "|0.4" + (i == 0 ? "5" : "2") + "|3529161471";
}
if (World_Stuff.active_world_list.empty()) {
vector<string> active_worlds;
for (uint8_t i = 0; i < (worlds.size() >= 18 ? 18 : worlds.size()); i++) {
World world_ = worlds[rand() % worlds.size()];
if (find(active_worlds.begin(), active_worlds.end(), world_.name) == active_worlds.end()) {
//0.5
World_Stuff.active_world_list += "\nadd_floater|" + world_.name + "|0|0.42|3529161471";
active_worlds.push_back(world_.name);
}
}
}
if (World_Stuff.active_world_list.empty())World_Stuff.active_world_list = "\nadd_floater|START|0|0.5|3529161471";
World_Stuff.top_active_worlds.clear();
World_Stuff.last_world_menu = ms_time + 150000;
}
}
if (last_rainbow_reset - ms_time <= 0) {
rainbow_color++;
if (rainbow_color > 24) rainbow_color = 0;
last_rainbow_reset = ms_time + 2000;
}
if (last_autofarm - ms_time <= 0) {
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED || currentPeer->data == NULL || pInfo(currentPeer)->world.empty()) continue;
if (pInfo(currentPeer)->cheater_settings & Gtps3::SETTINGS_0 && pInfo(currentPeer)->disable_cheater == 0) {
if (pInfo(currentPeer)->last_used_block != 0 && pInfo(currentPeer)->autofarm_x != -1) {
for (int i = 0; i < pInfo(currentPeer)->autofarm_slot; i++) {
if (i > 3 and pInfo(currentPeer)->hand != 13700) continue;
player_punch(currentPeer, pInfo(currentPeer)->last_used_block, pInfo(currentPeer)->autofarm_x + (pInfo(currentPeer)->backwards ? i * -1 : i), pInfo(currentPeer)->autofarm_y, pInfo(currentPeer)->x, pInfo(currentPeer)->y, true);
}
}
}
}
}
if (last_autofarm - ms_time <= 0) last_autofarm = ms_time + 530;
if (last_time - ms_time <= 0) {
for (int a = 0; a < World_Stuff.t_worlds.size(); a++) {
string name = World_Stuff.t_worlds[a];
vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name](const World& a) { return a.name == name; });
if (p != worlds.end()) {
World* world = &worlds[p - worlds.begin()];
world->fresh_world = true;
if (world->machines.size() == 0 && world->npc.size() == 0 && world->special_event == false) {
World_Stuff.t_worlds.erase(World_Stuff.t_worlds.begin() + a);
a--;
if (get_players_world(world->name) == 0) save_world(world->name, true);
continue;
}
if (world->special_event) {
if (world->last_special_event + 30000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
gamepacket_t p, p2;
p.Insert("OnAddNotification"), p.Insert("interface/large/special_event.rttex"), p.Insert("`2" + items[world->special_event_item].event_name + ":`` " + (items[world->special_event_item].event_total == 1 ? "`oTime's up! Nobody found it!``" : "`oTime's up! " + to_string(world->special_event_item_taken) + " of " + to_string(items[world->special_event_item].event_total) + " items found.``") + ""), p.Insert("audio/cumbia_horns.wav"), p.Insert(0);
p2.Insert("OnConsoleMessage"), p2.Insert("`2" + items[world->special_event_item].event_name + ":`` " + (items[world->special_event_item].event_total == 1 ? "`oTime's up! Nobody found it!``" : "`oTime's up! " + to_string(world->special_event_item_taken) + " of " + to_string(items[world->special_event_item].event_total) + " items found.``") + "");
for (ENetPeer* currentPeer_event = server->peers; currentPeer_event < &server->peers[server->peerCount]; ++currentPeer_event) {
if (currentPeer_event->state != ENET_PEER_STATE_CONNECTED or currentPeer_event->data == NULL or pInfo(currentPeer_event)->world != world->name) continue;
p.CreatePacket(currentPeer_event), p2.CreatePacket(currentPeer_event);
PlayerMoving data_{};
for (int i_ = 0; i_ < world->drop_new.size(); i_++) {
if (find(world->world_event_items.begin(), world->world_event_items.end(), world->drop_new[i_][0]) != world->world_event_items.end()) {
BYTE* raw1_ = PackBlockUpdate(14, 0, 0, 0, 0, 0, 0, 0, world->drop_new[i_][2], 0, 0, 0, 0, 0);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != world->name) continue;
send_raw(currentPeer, 4, raw1_, 56, ENET_PACKET_FLAG_RELIABLE);
}
delete[] raw1_;
world->drop_new.erase(world->drop_new.begin() + i_);
i_--;
}
}
}
world->world_event_items.clear();
world->last_special_event = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count(), world->special_event_item = 0, world->special_event_item_taken = 0, world->special_event = false;
}
continue;
}
/*
for (int i_ = 0; i_ < (world->npc.size() > 25 ? 25 : world->npc.size()); i_++) {
WorldNPC* npc = &world->npc[i_];
if (npc->last_ - time(nullptr) > 0 || not npc->enabled || not world->blocks[npc->x + (npc->y * 100)].enabled) continue;
int block = world->blocks[npc->x + (npc->y * 100)].fg;
npc->last_ = time(nullptr) + npc->rate_of_fire;
if (world->blocks[npc->x + (npc->y * 100)].fg == 4344 or world->blocks[npc->x + (npc->y * 100)].fg == 8020) {
npc->uid = world->npc_uid++;
BYTE* raw1_ = PackBlockUpdate(34, 0, npc->x * 32 + 16, npc->y * 32 + (block == 8020 ? 6 : 16), npc->x * 32 + 16, npc->y * 32 + (block == 8020 ? 6 : 16), (int)npc->kryptis, 0, 0, 0, npc->projectile_speed, (block == 8020 ? 15 : 8), npc->uid, 2);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != world->name) continue;
send_raw(currentPeer, 4, raw1_, 56, ENET_PACKET_FLAG_RELIABLE);
}
delete[] raw1_;
npc->started_moving = ms_time;
if (world->npc_uid > 120) world->npc_uid = 0;
}
else world->blocks[npc->x + (npc->y * 100)].enabled = false;
}*/
for (int i_ = 0; i_ < world->machines.size(); i_++) {
WorldMachines* machine = &world->machines[i_];
if (world->blocks[machine->x + (machine->y * 100)].pr <= 0 or not world->blocks[machine->x + (machine->y * 100)].enabled or machine->target_item == 0) {
if (items[world->blocks[machine->x + (machine->y * 100)].fg].blockType == BlockTypes::AUTO_BLOCK) {
world->machines.erase(world->machines.begin() + i_);
i_--;
}
continue;
}
WorldBlock* itemas = &world->blocks[machine->x + (machine->y * 100)];
int ySize = world->blocks.size() / 100, xSize = world->blocks.size() / ySize;
if (itemas->pr > 0) {
if (machine->last_ - ms_time > 0) break;
if (itemas->fg == 5958) machine->last_ = ms_time + (machine->target_item * 60000);
else machine->last_ = ms_time + 1500;
if (itemas->fg == 5958) {
if ((itemas->shelf_1 == 0 && itemas->shelf_2 == 0 && itemas->shelf_3 == 0) or itemas->enabled == false) {
for (int i_ = 0; i_ < world->machines.size(); i_++) {
if (world->machines[i_].x == machine->x and world->machines[i_].y == machine->y) {
gamepacket_t p;
p.Insert("OnSetCurrentWeather");
p.Insert(world->weather = 0);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->world == world->name) p.CreatePacket(currentPeer);
}
world->machines.erase(world->machines.begin() + i_);
break;
}
}
}
else {
if (itemas->shelf_3 == false && world->weather == 40) world->weather = 38;
if (itemas->shelf_2 == false && world->weather == 39) world->weather = 40;
if (itemas->shelf_1 == false && world->weather == 38) world->weather = 39;
if (itemas->shelf_1 && world->weather == 38) {
if (itemas->shelf_2) world->weather = 39;
else if (itemas->shelf_3) world->weather = 40;
}
else if (itemas->shelf_2 && world->weather == 39) {
if (itemas->shelf_3) world->weather = 40;
else if (itemas->shelf_1) world->weather = 38;
}
else if (itemas->shelf_3 && world->weather == 40) {
if (itemas->shelf_1) world->weather = 38;
else if (itemas->shelf_2) world->weather = 39;
}
gamepacket_t p;
p.Insert("OnSetCurrentWeather");
p.Insert(world->weather);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->world == world->name) p.CreatePacket(currentPeer);
}
}
}
else if (itemas->fg == 6952 or (itemas->fg == 6954 && itemas->build_only == false)) {
int itemas_ = (itemas->fg == 6954 ? machine->target_item - 1 : machine->target_item);
vector<WorldBlock>::iterator p = find_if(world->blocks.begin(), world->blocks.end(), [&](const WorldBlock& a) { return a.fg == itemas_ or a.bg == itemas_; });
if (p != world->blocks.end()) {
WorldBlock* block_ = &world->blocks[p - world->blocks.begin()];
int size = p - world->blocks.begin(), x_ = size % xSize, y_ = size / xSize;
if (items[itemas_].blockType == BlockTypes::BACKGROUND and block_->fg != 0) continue;
BYTE* raw1_ = PackBlockUpdate(17, 0x8, x_ * 32 + 16, y_ * 32 + 16, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0);
BYTE* raw2_ = PackBlockUpdate(36, 0x8, x_ * 32 + 16, y_ * 32 + 16, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != world->name) continue;
send_raw(currentPeer, 4, raw1_, 56, ENET_PACKET_FLAG_RELIABLE);
send_raw(currentPeer, 4, raw2_, 56, ENET_PACKET_FLAG_RELIABLE);
}
delete[] raw1_;
delete[] raw2_;
itemas->pr--;
if (itemas->pr <= 0) {
PlayerMoving data_{};
data_.packetType = 5, data_.punchX = machine->x, data_.punchY = machine->y, data_.characterState = 0x8;
BYTE* raw = packPlayerMoving(&data_, 112 + alloc_(world, itemas));
BYTE* blc = raw + 56;
form_visual(blc, *itemas, *world, NULL, false);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->world == world->name) {
send_raw(currentPeer, 4, raw, 112 + alloc_(world, itemas), ENET_PACKET_FLAG_RELIABLE);
}
}
delete[] raw, blc;
}
if (block_->hp == -1) {
block_->hp = items[itemas_].breakHits;
block_->lp = ms_time;
}
block_->hp -= 1;
if (block_->hp == 0) {
if (items[itemas_].max_gems != 0) {
int maxgems = items[itemas_].max_gems;
if (itemas_ == 120) maxgems = 50;
int c_ = rand() % (maxgems + 1);
if (c_ != 0) {
bool no_seed = false, no_gems = false, no_block = false;
if (itemas_ == 2242 or itemas_ == 2244 or itemas_ == 2246 or itemas_ == 2248 or itemas_ == 2250 or itemas_ == 542) no_seed = true, no_block = true;
else {
for (int i_ = 0; i_ < world->drop_new.size(); i_++) {
if (abs(world->drop_new[i_][4] - y_ * 32) <= 16 and abs(world->drop_new[i_][3] - x_ * 32) <= 16) {
if (world->drop_new[i_][0] == 112 and items[itemas_].rarity < 8) {
no_gems = true;
}
else {
no_seed = true, no_block = true;
}
}
}
}
int chanced = 0;
if (thedaytoday == 2) chanced = 5;
if (rand() % 100 < 8) {
WorldDrop drop_block_{};
drop_block_.id = itemas_, drop_block_.count = 1, drop_block_.x = (x_ * 32) + rand() % 17, drop_block_.y = (y_ * 32) + rand() % 17;
if (not use_mag(world, drop_block_, x_, y_) and not no_block) {
dropas_(world, drop_block_);
}
}
else if (rand() % 100 < (items[itemas_].newdropchance + chanced)) {
WorldDrop drop_seed_{};
drop_seed_.id = itemas_ + 1, drop_seed_.count = 1, drop_seed_.x = (x_ * 32) + rand() % 17, drop_seed_.y = (y_ * 32) + rand() % 17;
if (not use_mag(world, drop_seed_, x_, y_) and not no_seed) {
dropas_(world, drop_seed_);
}
}
else if (not no_gems) {
drop_rare_item(world, NULL, itemas_, x_, y_, false);
gems_(NULL, world, c_, x_ * 32, y_ * 32, itemas_);
}
}
}
reset_(block_, x_, y_, world);
PlayerMoving data_{};
data_.packetType = 5, data_.punchX = x_, data_.punchY = y_, data_.characterState = 0x8;
BYTE* raw = packPlayerMoving(&data_, 112 + alloc_(world, block_));
BYTE* blc = raw + 56;
form_visual(blc, *block_, *world, NULL, false);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->world == world->name) {
send_raw(currentPeer, 4, raw, 112 + alloc_(world, block_), ENET_PACKET_FLAG_RELIABLE);
}
}
delete[] raw, blc;
}
else {
BYTE* raw1_ = PackBlockUpdate(0x8, 0x0, x_, y_, 0, 0, 0, -1, 6, x_, y_, 0, 0, 0);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != world->name) continue;
send_raw(currentPeer, 4, raw1_, 56, ENET_PACKET_FLAG_RELIABLE);
}
delete[] raw1_;
}
}
}
else if (itemas->fg == 6950 or (itemas->fg == 6954 && itemas->build_only)) {
vector<WorldBlock>::iterator p = find_if(world->blocks.begin(), world->blocks.end(), [&](const WorldBlock& a) { return a.fg == machine->target_item; });
if (p != world->blocks.end()) {
int a_ = p - world->blocks.begin();
long long times_ = time(nullptr);
uint32_t laikas = uint32_t((times_ - world->blocks[a_].planted <= items[world->blocks[a_].fg].growTime ? times_ - world->blocks[a_].planted : items[world->blocks[a_].fg].growTime));
if (items[world->blocks[a_].fg].blockType == BlockTypes::SEED and laikas == items[world->blocks[a_].fg].growTime) {
int x_ = a_ % xSize, y_ = a_ / xSize;
WorldBlock* block_ = &world->blocks[x_ + (y_ * 100)];
int drop_count = items[block_->fg - 1].rarity == 1 ? (items[block_->fg - 1].farmable ? (rand() % 6) + 5 : (rand() % block_->fruit) + 1) : items[block_->fg - 1].farmable ? (rand() % 6) + 4 : (rand() % block_->fruit) + 1;
if (harvest_seed(world, block_, x_, y_, drop_count, -1)) {
}
else if (world->weather == 8 and rand() % 300 < 2) {
WorldDrop drop_block_{};
drop_block_.id = 3722, drop_block_.count = 1, drop_block_.x = x_ * 32 + rand() % 17, drop_block_.y = y_ * 32 + rand() % 17;
dropas_(world, drop_block_);
BYTE* raw1_ = PackBlockUpdate(0x11, 0, drop_block_.x, drop_block_.y, 0, 108, 0, 0, 0, 0, 0, 0, 0, 0);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != world->name) continue;
send_raw(currentPeer, 4, raw1_, 56, ENET_PACKET_FLAG_RELIABLE);
}
delete[] raw1_;
}
if (drop_count != 0) drop_rare_item(world, NULL, machine->target_item - 1, x_, y_, true);
BYTE* raw1_ = PackBlockUpdate(17, 0x8, x_ * 32 + 16, y_ * 32 + 16, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0);
BYTE* raw2_ = PackBlockUpdate(36, 0x8, x_ * 32 + 16, y_ * 32 + 16, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != world->name) continue;
send_raw(currentPeer, 4, raw1_, 56, ENET_PACKET_FLAG_RELIABLE);
send_raw(currentPeer, 4, raw2_, 56, ENET_PACKET_FLAG_RELIABLE);
}
delete[] raw1_;
delete[] raw2_;
itemas->pr--;
if (itemas->pr <= 0) {
PlayerMoving data_{};
data_.packetType = 5, data_.punchX = machine->x, data_.punchY = machine->y, data_.characterState = 0x8;
BYTE* raw = packPlayerMoving(&data_, 112 + alloc_(world, itemas));
BYTE* blc = raw + 56;
form_visual(blc, *itemas, *world, NULL, false);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->world == world->name) {
send_raw(currentPeer, 4, raw, 112 + alloc_(world, itemas), ENET_PACKET_FLAG_RELIABLE);
}
}
delete[] raw, blc;
}
}
}
}
}
}
}
}
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED || currentPeer->data == NULL or pInfo(currentPeer)->tankIDName.empty() or pInfo(currentPeer)->world.empty()) continue;
if (pInfo(currentPeer)->hand == 3578 || pInfo(currentPeer)->face == 3576) {
if (pInfo(currentPeer)->hand_torch + 60000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
int got = 0;
if (pInfo(currentPeer)->hand == 3578) {
if (pInfo(currentPeer)->hand_torch != 0) {
modify_inventory(currentPeer, 3578, got);
if (got - 1 >= 1) {
gamepacket_t p;
p.Insert("OnTalkBubble"), p.Insert(pInfo(currentPeer)->netID), p.Insert("`4My torch went out, but I have " + to_string(got - 1) + " more!``"), p.Insert(0), p.Insert(0), p.CreatePacket(currentPeer);
}
modify_inventory(currentPeer, 3578, got = -1);
}
}
else if (pInfo(currentPeer)->face == 3576) {
modify_inventory(currentPeer, 3306, got = -1);
}
pInfo(currentPeer)->hand_torch = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
}
}
else if (pInfo(currentPeer)->hand == 2204 or pInfo(currentPeer)->hand == 2558 and pInfo(currentPeer)->x != -1 and pInfo(currentPeer)->y != -1) {
if (pInfo(currentPeer)->random_geiger_time < 100) {
pInfo(currentPeer)->random_geiger_time++;
}
else {
pInfo(currentPeer)->random_geiger_time = 0;
pInfo(currentPeer)->geiger_x = (rand() % 100) * 32;
pInfo(currentPeer)->geiger_y = (rand() % 54) * 32;
}
int hands_ = pInfo(currentPeer)->hand;
if (not has_playmod2(pInfo(currentPeer), 10)) {
if (pInfo(currentPeer)->geiger_x == -1 and pInfo(currentPeer)->geiger_y == -1) {
pInfo(currentPeer)->geiger_x = (rand() % 100) * 32;
pInfo(currentPeer)->geiger_y = (rand() % 54) * 32;
}
int a_ = pInfo(currentPeer)->geiger_x + ((pInfo(currentPeer)->geiger_y * 100) / 32), b_ = pInfo(currentPeer)->x + ((pInfo(currentPeer)->y * 100) / 32), diff = abs(a_ - b_) / 32;
if (diff < 30) {
int t_ = 1500;
if (diff >= 6) t_ = 1350;
else if (diff < 15) t_ = 1000;
else if (diff <= 1) t_ = 2500;
if (pInfo(currentPeer)->geiger_time + t_ < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
pInfo(currentPeer)->geiger_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
PlayerMoving data_{};
data_.packetType = 17, data_.characterState = 0x8, data_.x = pInfo(currentPeer)->x + 10, data_.y = pInfo(currentPeer)->y + 16, data_.XSpeed = (diff >= 30 ? 0 : (diff >= 15 ? 1 : 2)), data_.YSpeed = 114;
BYTE* raw = packPlayerMoving(&data_);
send_raw(currentPeer, 4, raw, 56, ENET_PACKET_FLAG_RELIABLE);
delete[] raw;
if (diff <= 1) {
pInfo(currentPeer)->geiger_x = -1, pInfo(currentPeer)->geiger_y = -1;
int give_back_geiger = items[pInfo(currentPeer)->hand].geiger_give_back;
{
int c_ = -1;
modify_inventory(currentPeer, pInfo(currentPeer)->hand, c_);
int c_2 = 1;
if (modify_inventory(currentPeer, give_back_geiger, c_2) != 0) {
string name_ = pInfo(currentPeer)->world;
vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name_](const World& a) { return a.name == name_; });
if (p != worlds.end()) {
World* world_ = &worlds[p - worlds.begin()];
world_->fresh_world = true;
WorldDrop drop_block_{};
drop_block_.id = give_back_geiger, drop_block_.count = 1, drop_block_.x = pInfo(currentPeer)->x + rand() % 17, drop_block_.y = pInfo(currentPeer)->y + rand() % 17;
dropas_(world_, drop_block_);
}
}
int seconds = 1800;
if (thedaytoday == 3) seconds = 600;
pInfo(currentPeer)->hand = give_back_geiger;
update_clothes(currentPeer);
add_playmod(currentPeer, 10, seconds);
packet_(currentPeer, "action|play_sfx\nfile|audio/dialog_confirm.wav\ndelayMS|0");
}
if (pInfo(currentPeer)->lwiz_step == 13) {
if (pInfo(currentPeer)->lwiz_quest == 5 || pInfo(currentPeer)->lwiz_quest == 6 || pInfo(currentPeer)->lwiz_quest == 7 || pInfo(currentPeer)->lwiz_quest == 8) {
add_lwiz_points(currentPeer, 1);
}
}
if (pInfo(currentPeer)->grow4good_geiger < pInfo(currentPeer)->grow4good_geiger2 && pInfo(currentPeer)->grow4good_geiger != -1) daily_quest(currentPeer, false, "geiger", 1);
add_event_xp(currentPeer, 1, "geiger");
int give_times = 1;
if (pInfo(currentPeer)->gp) {
if (complete_gpass_task(currentPeer, "Geiger")) give_times++;
}
for (int i = 0; i < give_times; i++) {
int item_ = items[hands_].randomitem[rand() % items[hands_].randomitem.size()], c_ = 1;
if (item_ == 1486) if (pInfo(currentPeer)->lwiz_step == 6) add_lwiz_points(currentPeer, 1);
if (item_ == 1486 && pInfo(currentPeer)->C_QuestActive && pInfo(currentPeer)->C_QuestKind == 11 && pInfo(currentPeer)->C_QuestProgress < pInfo(currentPeer)->C_ProgressNeeded) {
pInfo(currentPeer)->C_QuestProgress += 1;
if (pInfo(currentPeer)->C_QuestProgress >= pInfo(currentPeer)->C_ProgressNeeded) {
pInfo(currentPeer)->C_QuestProgress = pInfo(currentPeer)->C_ProgressNeeded;
gamepacket_t p;
p.Insert("OnTalkBubble");
p.Insert(pInfo(currentPeer)->netID);
p.Insert("`9Ring Quest task complete! Go tell the Ringmaster!");
p.Insert(0), p.Insert(0);
p.CreatePacket(currentPeer);
}
}
/*
if (item_ == 13158) {
c_ = 5;
ubi_sold_3 += 5;
}*/
if (modify_inventory(currentPeer, item_, c_) != 0) {
string name_ = pInfo(currentPeer)->world;
vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name_](const World& a) { return a.name == name_; });
if (p != worlds.end()) {
World* world_ = &worlds[p - worlds.begin()];
world_->fresh_world = true;
WorldDrop drop_block_{};
drop_block_.id = item_, drop_block_.count = 1, drop_block_.x = pInfo(currentPeer)->x + rand() % 17, drop_block_.y = pInfo(currentPeer)->y + rand() % 17;
dropas_(world_, drop_block_);
}
}
gamepacket_t p;
p.Insert("OnTalkBubble");
p.Insert(pInfo(currentPeer)->netID);
p.Insert("I found `21 " + items[item_].name + "``!" + (hands_ == 2558 ? " But now I lost it in my basket!" : "") + "");
p.Insert(0), p.Insert(0);
p.CreatePacket(currentPeer);
gamepacket_t p2;
p2.Insert("OnConsoleMessage");
p2.Insert(get_player_nick(currentPeer) + " found `21 " + items[item_].name + "``!");
PlayerMoving data_{};
data_.packetType = 19, data_.plantingTree = 0, data_.netID = 0;
data_.punchX = item_;
data_.x = pInfo(currentPeer)->x + 10, data_.y = pInfo(currentPeer)->y + 16;
int32_t to_netid = pInfo(currentPeer)->netID;
BYTE* raw = packPlayerMoving(&data_);
raw[3] = 5;
memcpy(raw + 8, &to_netid, 4);
for (ENetPeer* currentPeer2 = server->peers; currentPeer2 < &server->peers[server->peerCount]; ++currentPeer2) {
if (currentPeer2->state != ENET_PEER_STATE_CONNECTED or currentPeer2->data == NULL) continue;
if (pInfo(currentPeer2)->world == pInfo(currentPeer)->world) {
send_raw(currentPeer2, 4, raw, 56, ENET_PACKET_FLAG_RELIABLE);
p2.CreatePacket(currentPeer2);
}
}
delete[]raw;
}
gamepacket_t p;
p.Insert("OnParticleEffect");
p.Insert(48);
p.Insert((float)pInfo(currentPeer)->x + 10, (float)pInfo(currentPeer)->y + 16);
p.CreatePacket(currentPeer);
}
}
}
}
}
if (pInfo(currentPeer)->hider == false && (pInfo(currentPeer)->rb or pInfo(currentPeer)->valentine && pInfo(currentPeer)->name_time + 250 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count())) {
if (pInfo(currentPeer)->vip == 0) pInfo(currentPeer)->rb = false;
else {
pInfo(currentPeer)->name_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
string msg2 = "", nick = fixchar4(get_player_nick(currentPeer));
if (pInfo(currentPeer)->rb) {
if (pInfo(currentPeer)->is_legend && pInfo(currentPeer)->d_name.empty()) msg2 += random_color[rainbow_color] + nick;
else {
for (int i = 0; i < nick.length(); i++) msg2 += random_color[i + rainbow_color] + nick[i];
}
}
else {
vector <string> random_letter{ "4", "p" };
if (pInfo(currentPeer)->is_legend && pInfo(currentPeer)->d_name.empty()) msg2 += "`" + random_letter[rand() % random_letter.size()] + nick;
else for (int i = 0; i < nick.length(); i++) msg2 += "`" + random_letter[rand() % random_letter.size()] + nick[i];
}
nick_update_2(currentPeer, NULL, msg2);
}
}
if (pInfo(currentPeer)->save_time + 300000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
if (pInfo(currentPeer)->save_time != 0) {
pInfo(currentPeer)->opc++;
if (pInfo(currentPeer)->hand == 10384) pInfo(currentPeer)->opc += 2;
if (pInfo(currentPeer)->gp || pInfo(currentPeer)->hand == 10384 || pInfo(currentPeer)->hair == 9542 || pInfo(currentPeer)->hair == 9984 || pInfo(currentPeer)->hair == 9920 || pInfo(currentPeer)->necklace == 9964 || pInfo(currentPeer)->necklace == 10176 || pInfo(currentPeer)->pants == 9782 || pInfo(currentPeer)->hand == 9880 || pInfo(currentPeer)->hand == 10020 || pInfo(currentPeer)->hand == 9974 || pInfo(currentPeer)->hand == 9918 || pInfo(currentPeer)->hand == 10290 || pInfo(currentPeer)->hand == 9916 || pInfo(currentPeer)->hand == 9914 || pInfo(currentPeer)->hand == 9766 || pInfo(currentPeer)->hand == 9772 || pInfo(currentPeer)->hand == 9908) pInfo(currentPeer)->opc++;
add_honors(pInfo(currentPeer)->world, pInfo(currentPeer)->world_owner);
if (pInfo(currentPeer)->grow4good_30mins < 30) daily_quest(currentPeer, false, "30mins", 10);
loop_save(currentPeer);
add_top_player(to_lower(pInfo(currentPeer)->tankIDName));
}
pInfo(currentPeer)->save_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
}
if (pInfo(currentPeer)->World_Timed - time(nullptr) == 60 && pInfo(currentPeer)->WorldTimed && pInfo(currentPeer)->tankIDName != pInfo(currentPeer)->world_owner) {
gamepacket_t p;
p.Insert("OnTalkBubble"); p.Insert(pInfo(currentPeer)->netID); p.Insert("Your access to this world will expire in less than a minute!"); p.Insert(0); p.Insert(0); p.CreatePacket(currentPeer);
}
else if (pInfo(currentPeer)->World_Timed - time(nullptr) < 0 && pInfo(currentPeer)->WorldTimed && pInfo(currentPeer)->tankIDName != pInfo(currentPeer)->world_owner) {
exit_(currentPeer);
}
if (pInfo(currentPeer)->fishing_used != 0) {
if (pInfo(currentPeer)->last_fish_catch + pInfo(currentPeer)->fish_seconds < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count() && rand() % 100 < (pInfo(currentPeer)->hand == 6258 ? 20 : pInfo(currentPeer)->hand == 3010 ? 15 : 10)) {
PlayerMoving data_{};
data_.packetType = 17, data_.netID = 34, data_.YSpeed = 34, data_.x = pInfo(currentPeer)->f_x * 32 + 16, data_.y = pInfo(currentPeer)->f_y * 32 + 16;
pInfo(currentPeer)->last_fish_catch = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
BYTE* raw = packPlayerMoving(&data_);
gamepacket_t p3(0, pInfo(currentPeer)->netID);
p3.Insert("OnPlayPositioned"), p3.Insert("audio/splash.wav");
for (ENetPeer* currentPeer_event = server->peers; currentPeer_event < &server->peers[server->peerCount]; ++currentPeer_event) {
if (currentPeer_event->state != ENET_PEER_STATE_CONNECTED or currentPeer_event->data == NULL or pInfo(currentPeer_event)->world != pInfo(currentPeer)->world) continue;
send_raw(currentPeer_event, 4, raw, 56, ENET_PACKET_FLAG_RELIABLE), p3.CreatePacket(currentPeer_event);
}
delete[] raw;
if (pInfo(currentPeer)->cheater_settings & Gtps3::SETTINGS_16 && pInfo(currentPeer)->disable_cheater == 0) {
int bait = pInfo(currentPeer)->fishing_used, fx = pInfo(currentPeer)->f_x, fy = pInfo(currentPeer)->f_y;
stop_fishing(currentPeer, false, "");
player_punch(currentPeer, bait, fx, fy, fx * 32, fy * 32);
}
}
}
if (pInfo(currentPeer)->world != "TRADE" && pInfo(currentPeer)->world != Hide_N_Seek.hidenseekworld) {
vector<pair<int, string>>::iterator p = find_if(World_Stuff.top_active_worlds.begin(), World_Stuff.top_active_worlds.end(), [&](const pair < int, string>& element) { return element.second == pInfo(currentPeer)->world; });
if (p != World_Stuff.top_active_worlds.end()) World_Stuff.top_active_worlds[p - World_Stuff.top_active_worlds.begin()].first++;
else World_Stuff.top_active_worlds.push_back(make_pair(1, pInfo(currentPeer)->world));
}
/*
if (pInfo(currentPeer)->world == "GROWGANOTH") {
if (last_growganoth_time - ms_time <= 0) {
last_growganoth_time = ms_time + 15000;
update_growganoth(currentPeer);
}
}*/
{
if (last_firehouse - ms_time <= 0) {
vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [&](const World& a) { return a.name == pInfo(currentPeer)->world; });
if (p != worlds.end()) {
World* world = &worlds[p - worlds.begin()];
world->fresh_world = true;
vector<WorldBlock>::iterator p3 = find_if(world->blocks.begin(), world->blocks.end(), [&](const WorldBlock& a) { return a.fg == 3072; });
if (p3 != world->blocks.end()) {
vector<WorldBlock>::iterator p2 = find_if(world->blocks.begin(), world->blocks.end(), [&](const WorldBlock& a) { return a.flags & 0x10000000; });
if (p2 != world->blocks.end()) {
int x_ = int(p2 - world->blocks.begin()) % 100, y_ = int(p2 - world->blocks.begin()) / 100;
apply_tile_visual(world, &world->blocks[x_ + (y_ * 100)], x_, y_, 0x10000000, true);
}
}
if (last_fire_time - ms_time <= 0) {
if (world->total_fires < 150) {
vector<WorldBlock>::iterator p2 = find_if(world->blocks.begin(), world->blocks.end(), [&](const WorldBlock& a) { return a.flags & 0x10000000 && (world->fire_try > 10 ? a.applied_fire == true : a.applied_fire == false); });
if (p2 != world->blocks.end()) {
int x_ = int(p2 - world->blocks.begin()) % 100, y_ = int(p2 - world->blocks.begin()) / 100;
vector<int> random_xy{ 1, 0, -1, 0 };
int randomx = 0, randomy = 0;
if (rand() % 2 < 1) randomx = x_ + random_xy[rand() % random_xy.size()], randomy = y_;
else randomx = x_, randomy = y_ + random_xy[rand() % random_xy.size()];
if (randomx > 0 && randomx < world->max_x && randomy > 0 && randomy < world->max_y) {
bool has_fire = world->blocks[randomx + (randomy * 100)].flags & 0x10000000, has_water = world->blocks[randomx + (randomy * 100)].flags & 0x04000000;
if (world->blocks[randomx + (randomy * 100)].fg != 0 && has_fire == false && has_water == false && items[world->blocks[randomx + (randomy * 100)].fg].blockType != BlockTypes::MAIN_DOOR && items[world->blocks[randomx + (randomy * 100)].fg].blockType != BlockTypes::BEDROCK && world->blocks[randomx + (randomy * 100)].fg != 9570) apply_tile_visual(world, &world->blocks[randomx + (randomy * 100)], randomx, randomy, 0x10000000);
else {
world->blocks[x_ + (y_ * 100)].fire_try++;
if (world->blocks[x_ + (y_ * 100)].fire_try >= 8) world->blocks[x_ + (y_ * 100)].applied_fire = true, world->blocks[x_ + (y_ * 100)].fire_try = 0;
}
}
}
else {
world->fire_try++;
if (world->fire_try > 10) world->fire_try = 0;
}
}
}
}
}
}
long long time_ = time(nullptr);
for (int i_ = 0; i_ < pInfo(currentPeer)->playmods.size(); i_++) {
if (pInfo(currentPeer)->playmods[i_].id == 12) {
if (pInfo(currentPeer)->valentine_time + 2500 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
pInfo(currentPeer)->valentine_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
for (ENetPeer* valentine = server->peers; valentine < &server->peers[server->peerCount]; ++valentine) {
if (valentine->state != ENET_PEER_STATE_CONNECTED or valentine->data == NULL) continue;
if (pInfo(valentine)->world == pInfo(currentPeer)->world and pInfo(valentine)->tankIDName == pInfo(currentPeer)->playmods[i_].user) {
if (not pInfo(valentine)->invis and not pInfo(currentPeer)->invis and pInfo(currentPeer)->x != -1 and pInfo(currentPeer)->y != -1 and pInfo(valentine)->x != -1 and pInfo(valentine)->y != -1) {
gamepacket_t p;
p.Insert("OnParticleEffect");
p.Insert(13);
p.Insert((float)pInfo(valentine)->x + 10, (float)pInfo(valentine)->y + 16);
p.Insert((float)0), p.Insert((float)pInfo(currentPeer)->netID);
bool double_send = false;
for (int i_2 = 0; i_2 < pInfo(valentine)->playmods.size(); i_2++) {
if (pInfo(valentine)->playmods[i_2].id == 12 and pInfo(valentine)->playmods[i_2].user == pInfo(currentPeer)->tankIDName) {
double_send = true;
break;
}
}
gamepacket_t p2;
p2.Insert("OnParticleEffect");
p2.Insert(13);
p2.Insert((float)pInfo(currentPeer)->x + 10, (float)pInfo(currentPeer)->y + 16);
p2.Insert((float)0), p2.Insert((float)pInfo(valentine)->netID);
for (ENetPeer* valentine_bc = server->peers; valentine_bc < &server->peers[server->peerCount]; ++valentine_bc) {
if (valentine_bc->state != ENET_PEER_STATE_CONNECTED or valentine_bc->data == NULL) continue;
if (pInfo(valentine_bc)->world == pInfo(currentPeer)->world) {
p.CreatePacket(valentine_bc);
if (double_send) p2.CreatePacket(valentine_bc);
}
}
}
break;
}
}
}
}
if (pInfo(currentPeer)->playmods[i_].time - time_ < 0) {
if (pInfo(currentPeer)->playmods[i_].id == 125) {
if (pInfo(currentPeer)->moderator == 0) {
pInfo(currentPeer)->mod = 0, pInfo(currentPeer)->tmod = 0;
if (not pInfo(currentPeer)->d_name.empty()) {
pInfo(currentPeer)->d_name = "";
nick_update(currentPeer, NULL);
}
}
}
else if (pInfo(currentPeer)->playmods[i_].id == 126) pInfo(currentPeer)->vip = 0;
else if (pInfo(currentPeer)->playmods[i_].id == 127 || pInfo(currentPeer)->playmods[i_].id == 128) exit_(currentPeer);
else if (pInfo(currentPeer)->playmods[i_].id == 136) pInfo(currentPeer)->hit_by = 0;
else if (pInfo(currentPeer)->playmods[i_].id == 143) {
if (pInfo(currentPeer)->cheater_ == 0) {
pInfo(currentPeer)->cheater_settings = 0;
pInfo(currentPeer)->chat_prefix.clear();
autofarm_status(currentPeer);
}
}
packet_(currentPeer, "action|play_sfx\nfile|audio/dialog_confirm.wav\ndelayMS|0");
gamepacket_t p;
p.Insert("OnConsoleMessage");
p.Insert(info_about_playmods[pInfo(currentPeer)->playmods[i_].id - 1][5] + " (`$" + info_about_playmods[pInfo(currentPeer)->playmods[i_].id - 1][3] + "`` mod removed)");
p.CreatePacket(currentPeer);
pInfo(currentPeer)->playmods.erase(pInfo(currentPeer)->playmods.begin() + i_);
update_clothes_value(currentPeer);
update_clothes(currentPeer);
break;
}
}
}
if (last_time - ms_time <= 0) last_time = ms_time + 1450;
if (last_firehouse - ms_time <= 0) last_firehouse = ms_time + 2000000;
if (last_fire_time - ms_time <= 0)last_fire_time = ms_time + 2000000;
}
}
}
bool isASCII(const std::string& s)
{
return !std::any_of(s.begin(), s.end(), [](char c) {
return static_cast<unsigned char>(c) > 127;
});
}
std::string get_str_between_two_str(const std::string& s,
const std::string& start_delim,
const std::string& stop_delim)
{
unsigned first_delim_pos = s.find(start_delim);
unsigned end_pos_of_first_delim = first_delim_pos + start_delim.length();
unsigned last_delim_pos = s.find(stop_delim);
return s.substr(end_pos_of_first_delim,
last_delim_pos - end_pos_of_first_delim);
}
void thesaver() {
while (true) {
Sleep(300000 * 2);
cout << "AUTO SAVING..." << endl;
trigger_save2();
}
}
int main(int argc, char* argv[]) {