-
Notifications
You must be signed in to change notification settings - Fork 0
/
VeryUsualDay.cs
477 lines (452 loc) · 20.5 KB
/
VeryUsualDay.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features;
using Exiled.API.Features.Pickups;
using MEC;
using Newtonsoft.Json;
using PlayerRoles;
using UnityEngine;
using Player = VeryUsualDay.Handlers.Player;
using PlayerHandler = Exiled.Events.Handlers.Player;
using Random = UnityEngine.Random;
using Server = VeryUsualDay.Handlers.Server;
using ServerHandler = Exiled.Events.Handlers.Server;
namespace VeryUsualDay
{
public class VeryUsualDay : Plugin<Config>
{
public static VeryUsualDay Instance { get; private set; }
public override string Author => "JustMarfix";
public override string Name => "VeryUsualDay (FX Version)";
public override Version Version => new Version(5, 3, 0);
public bool IsEnabledInRound { get; set; }
public bool IsLunchtimeActive { get; set; }
public bool IsDboysSpawnAllowed { get; set; }
public bool IsTeslaEnabled { get; set; }
public bool Is008Leaked { get; set; }
public List<int> JoinedDboys { get; set; } = new List<int>();
public List<int> DBoysQueue { get; set; } = new List<int>();
public List<int> Shakheds { get; set; } = new List<int>();
public List<int> Zombies { get; set; } = new List<int>();
public List<RoomType> ChaosRooms { get; set; } = new List<RoomType>();
public int BuoCounter { get; set; } = 1;
public int SpawnedDboysCounter { get; set; } = 1;
public int SpawnedWorkersCounter { get; set; } = 1;
public int SpawnedScientistCounter { get; set; } = 1;
public int SpawnedSecurityCounter { get; set; } = 1;
private readonly Vector3 _armedPersonnelTowerCoords = new Vector3(-16f, 1014.5f, -32f);
private readonly Vector3 _civilianPersonnelTowerCoords = new Vector3(44.4f, 1014.5f, -51.6f);
public readonly Vector3 SpawnPosition = new Vector3(139.487f, 995.392f, -16.762f);
public static readonly Vector3 PrisonPosition = new Vector3(130.233f, 993.766f, 21.049f);
public Vector3 SupplyBoxCoords = new Vector3();
public Vector3 VaseCoords = new Vector3();
public Pickup Vase;
public readonly List<Vector3> EmfSupplyCoords = new List<Vector3>
{
new Vector3(-10.682f, 1003f, -32.115f),
new Vector3(-6.873f, 1003f, -32f)
};
public enum Codes
{
[Description("Зелёный")]
Green,
[Description("Изумрудный")]
Emerald,
[Description("Синий")]
Blue,
[Description("Оранжевый")]
Orange,
[Description("Жёлтый")]
Yellow,
[Description("Красный")]
Red
}
public enum Scps
{
Scp0082,
Scp01921,
Scp01922,
Scp035,
Scp0352,
Scp049,
Scp0762,
Scp372,
Scp682,
Scp966,
Scp999,
}
public Codes CurrentCode { get; set; } = Codes.Green;
public Dictionary<int, Scps> ScpPlayers { get; set; } = new Dictionary<int, Scps>();
private static void _registerEvents()
{
PlayerHandler.ChangingRole += Player.OnChangingRole;
PlayerHandler.PickingUpItem += Player.OnPickingUpItem;
PlayerHandler.DroppingItem += Player.OnDroppingItem;
PlayerHandler.Hurting += Player.OnHurting;
PlayerHandler.Dying += Player.OnDying;
PlayerHandler.Died += Player.OnDied;
PlayerHandler.Left += Player.OnLeft;
PlayerHandler.Shooting += Player.OnShooting;
PlayerHandler.UsingItem += Player.OnUsingItem;
PlayerHandler.TriggeringTesla += Player.OnTriggeringTesla;
PlayerHandler.Verified += Player.OnVerified;
PlayerHandler.Hurt += Player.OnHurt;
PlayerHandler.Healed += Player.OnHealed;
PlayerHandler.Handcuffing += Player.OnHandcuffing;
PlayerHandler.InteractingDoor += Player.OnInteractingDoor;
ServerHandler.WaitingForPlayers += Server.OnWaitingForPlayers;
ServerHandler.RoundStarted += Server.OnRoundStarted;
}
private static void _unregisterEvents()
{
PlayerHandler.ChangingRole -= Player.OnChangingRole;
PlayerHandler.PickingUpItem -= Player.OnPickingUpItem;
PlayerHandler.DroppingItem -= Player.OnDroppingItem;
PlayerHandler.Hurting -= Player.OnHurting;
PlayerHandler.Died -= Player.OnDied;
PlayerHandler.Left -= Player.OnLeft;
PlayerHandler.Shooting -= Player.OnShooting;
PlayerHandler.TriggeringTesla -= Player.OnTriggeringTesla;
PlayerHandler.Verified -= Player.OnVerified;
PlayerHandler.Hurt -= Player.OnHurt;
PlayerHandler.Healed -= Player.OnHealed;
PlayerHandler.Handcuffing -= Player.OnHandcuffing;
PlayerHandler.InteractingDoor -= Player.OnInteractingDoor;
ServerHandler.WaitingForPlayers -= Server.OnWaitingForPlayers;
ServerHandler.RoundStarted -= Server.OnRoundStarted;
}
public override void OnEnabled()
{
Instance = this;
if (Instance.Config.AuthToken == "")
{
Log.Error("AuthToken пуст - функционал тюрьмы и БД будет недоступен.");
}
_registerEvents();
base.OnEnabled();
}
public override void OnDisabled()
{
Instance = null;
_unregisterEvents();
base.OnDisabled();
}
public IEnumerator<float> _008_poisoning()
{
for (;;)
{
foreach (var target in Exiled.API.Features.Player.Get(player => player.Zone == ZoneType.HeavyContainment && !Instance.Config.DoNotPoisonRoles.Contains(player.Role.Type) && player.Role.Team != Team.SCPs && (player.CustomInfo is null || !player.CustomInfo.ToLower().Contains("scp"))))
{
target.EnableEffect(EffectType.Poisoned);
}
yield return Timing.WaitForSeconds(10f);
}
}
public IEnumerator<float> _joining()
{
for (;;)
{
if (CurrentCode == Codes.Green)
{
var counter = 0;
foreach (var i in DBoysQueue.ToList())
{
if (!Exiled.API.Features.Player.TryGet(i, out var dboy)) continue;
if ((dboy.CustomInfo == "Человек" || dboy.CustomInfo is null) && dboy.Role.Type == RoleTypeId.Tutorial)
{
if (JoinedDboys.Count >= 5)
{
break;
}
if (counter == 3)
{
break;
}
dboy.CustomName = $"Испытуемый - ##-{SpawnedDboysCounter}";
JoinedDboys.Add(i);
dboy.Role.Set(RoleTypeId.ClassD);
Timing.CallDelayed(1f, () =>
{
dboy.ClearInventory();
dboy.Handcuff();
dboy.Broadcast(10, "<b>Вы стали <color=#EE7600>Испытуемым</color>! Можете сотрудничать с <color=#120a8f>фондом</color> или принимать попытки <color=#ff2b2b>побега</color> при первой возможности. </b>");
});
counter += 1;
SpawnedDboysCounter += 1;
}
DBoysQueue.Remove(i);
}
switch (counter)
{
case 0:
break;
case 1:
Cassie.Message("<b><color=#FF0090>O5</color> >>> <color=#008080>Комплекс</color></b>: один испытуемый прибыл в блок D. <size=0> . . . . . . . . . . . . . . . . . . . . . .", isNoisy: false, isSubtitles: true);
break;
case 2:
Cassie.Message("<b><color=#FF0090>O5</color> >>> <color=#008080>Комплекс</color></b>: двое испытуемых прибыло в блок D<size=0> . . . . . . . . . . . . . . . . . . . . . .", isNoisy: false, isSubtitles: true);
break;
case 3:
Cassie.Message("<b><color=#FF0090>O5</color> >>> <color=#008080>Комплекс</color></b>: трое испытуемых прибыло в блок D<size=0> . . . . . . . . . . . . . . . . . . . . . .", isNoisy: false, isSubtitles: true);
break;
}
}
yield return Timing.WaitForSeconds(300f);
}
}
public IEnumerator<float> _prisonTimer()
{
for (;;)
{
foreach (var player in Exiled.API.Features.Player.List)
{
if (player.TryGetSessionVariable("isInPrison", out bool prisonState) && prisonState)
{
player.TryGetSessionVariable("prisonTime", out Int32 time);
// Log.Info($"Игроку {player.UserId} осталось находиться в тюрьме {time} секунд.");
time -= 1;
player.SessionVariables.Remove("prisonTime");
player.SessionVariables.Add("prisonTime", time);
if (time == 0)
{
PrisonController.SendToPrison(player, 0, "Выпущен из тюрьмы.");
}
}
}
yield return Timing.WaitForSeconds(1f);
}
}
public IEnumerator<float> _chaos()
{
for (;;)
{
foreach (var roomType in ChaosRooms)
{
var room = Room.Get(roomType);
foreach (var door in room.Doors.Where(p => !p.IsElevator && !p.IsGate && !p.IsKeycardDoor && !p.IsLocked).Shuffle())
{
Timing.CallDelayed(Random.Range(0f, 1.5f), () =>
{
door.IsOpen = !door.IsOpen;
});
}
foreach (var player in room.Players)
{
if (Random.Range(0, 100) < 50)
{
var score = Random.Range(0, 100);
if (score < 25)
{
player.PlayGunSound(ItemType.GunCrossvec, (byte)Random.Range(175, 256));
}
else if (score < 50)
{
player.PlayGunSound(ItemType.GunFSP9, (byte)Random.Range(175, 256));
}
else if (score < 75)
{
player.PlayGunSound(ItemType.GunE11SR, (byte)Random.Range(175, 256));
}
else
{
player.PlayGunSound(ItemType.GunShotgun, (byte)Random.Range(175, 256));
}
}
else if (Random.Range(0, 100) < 30)
{
player.PlayBeepSound();
}
else if (Random.Range(0, 100) < 30)
{
player.PlayShieldBreakSound();
}
else
{
player.EnableEffect(EffectType.Scanned, duration: 10f);
}
}
}
yield return Timing.WaitForSeconds(0.75f);
}
}
/*
public IEnumerator<float> _avel()
{
for (;;)
{
foreach (var pair in ScpPlayers.Where(p => p.Value == Scps.Scp0762))
{
try
{
if (Exiled.API.Features.Player.TryGet(pair.Key, out var avel) && avel.Health < 5000)
{
avel.Heal(50f);
}
}
catch (Exception e)
{
Log.Error(e);
}
}
yield return Timing.WaitForSeconds(7f);
}
}*/
private static async Task<string> HttpGetUser(string steamid)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Instance.Config.AuthToken);
var content = await client.GetStringAsync($"{Instance.Config.BaseApiUrl}/get_user/{steamid}");
return content;
}
}
private async void SetUserRole(Exiled.API.Features.Player player)
{
var jsonString = await HttpGetUser(player.UserId);
var json = JsonConvert.DeserializeObject<List<string>>(jsonString);
if (json.Count == 0)
{
return;
}
var splitted = json[1].Split(' ');
player.CustomInfo = new StringBuilder().Append($"\"{splitted[0]}\" ").Append(string.Join(" ", splitted.Skip(1))).ToString(); // add quotes to the name and conc. to the main string
player.CustomName = json[2];
switch (json[3])
{
case "СБ":
player.Role.Set(RoleTypeId.FacilityGuard, RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
foreach (var item in Instance.Config.SecurityItems[json[4]])
{
player.AddItem(item);
}
foreach (var ammo in Instance.Config.SecurityAmmo[json[4]])
{
player.AddAmmo(ammo, 60);
}
player.MaxHealth = Instance.Config.SecurityHealth[json[4]];
player.Health = Instance.Config.SecurityHealth[json[4]];
player.Teleport(_armedPersonnelTowerCoords);
});
break;
case "НС":
player.Role.Set(RoleTypeId.Scientist, RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
foreach (var item in Instance.Config.ScientificItems[json[4]])
{
player.AddItem(item);
}
if (Instance.Config.ScienceHealth.ContainsKey(json[4]))
{
player.MaxHealth = Instance.Config.ScienceHealth[json[4]];
player.Health = Instance.Config.ScienceHealth[json[4]];
}
player.Teleport(_civilianPersonnelTowerCoords);
});
break;
case "Рабочие":
player.Role.Set(RoleTypeId.ClassD, RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
foreach (var item in Instance.Config.WorkersItems[json[4]])
{
player.AddItem(item);
}
foreach (var pair in Instance.Config.WorkersEffects[json[4]])
{
player.EnableEffect(pair.Key);
player.ChangeEffectIntensity(pair.Key, pair.Value);
}
player.MaxHealth = Instance.Config.WorkersHealth[json[4]];
player.Health = Instance.Config.WorkersHealth[json[4]];
player.Teleport(_civilianPersonnelTowerCoords);
});
break;
case "ГОР":
player.Role.Set(Instance.Config.EmfRoles[json[4]], RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
foreach (var item in Instance.Config.EmfItems[json[4]])
{
player.AddItem(item);
}
foreach (var ammo in Instance.Config.EmfAmmo[json[4]])
{
player.AddAmmo(ammo, 60);
}
foreach (var pair in Instance.Config.EmfEffects[json[4]])
{
player.EnableEffect(pair.Key);
player.ChangeEffectIntensity(pair.Key, pair.Value);
}
player.MaxHealth = Instance.Config.EmfHealth[json[4]];
player.Health = Instance.Config.EmfHealth[json[4]];
player.Teleport(_armedPersonnelTowerCoords);
});
break;
case "ОВБ":
player.Role.Set(RoleTypeId.Tutorial, RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
player.Scale = new Vector3(1.3f, 0.8f, 1f);
foreach (var item in Instance.Config.AgencyItems[json[4]])
{
player.AddItem(item);
}
foreach (var ammo in Instance.Config.AgencyAmmo[json[4]])
{
player.AddAmmo(ammo, 60);
}
player.MaxHealth = Instance.Config.AgencyHealth;
player.Health = Instance.Config.AgencyHealth;
player.IsGodModeEnabled = false;
player.Teleport(_armedPersonnelTowerCoords);
});
break;
case "Административный персонал":
player.Role.Set(RoleTypeId.Scientist, RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
foreach (var item in Instance.Config.AdministrativeItems[json[4]])
{
player.AddItem(item);
}
player.MaxHealth = Instance.Config.AdministrativeHealth[json[4]];
player.Health = Instance.Config.AdministrativeHealth[json[4]];
player.Teleport(_civilianPersonnelTowerCoords);
});
break;
case "Испытуемые":
player.Role.Set(RoleTypeId.ClassD, RoleSpawnFlags.None);
Timing.CallDelayed(2f, () =>
{
player.ClearInventory();
player.Handcuff();
player.MaxHealth = 130f;
player.Health = 130f;
});
break;
}
}
public void RoleDistribution()
{
foreach (var player in Exiled.API.Features.Player.Get(RoleTypeId.Tutorial))
{
if ((!player.TryGetSessionVariable("isInPrison", out bool prisonState) || !prisonState) && (player.CustomInfo == "Человек" || player.CustomInfo is null))
{
SetUserRole(player);
}
}
}
}
}