-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGitGudPlayer.cs
960 lines (875 loc) · 31.7 KB
/
GitGudPlayer.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
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
using AssortedCrazyThings.Base;
using AssortedCrazyThings.Base.Netcode.Packets;
using AssortedCrazyThings.Items.Gitgud;
using Microsoft.Xna.Framework;
using System;
using System.Collections;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
//GITGUD BEHAVIOR GOES HERE
/*
* In GitGudPlayer:
* Add these two in order:
* public byte bossNameGitgudCounter = 0;
* public bool bossNameGitgud = false;
*
* **IMPORTANT**: IN ORDER OF BOSS PROGRESSION, HAS TO BE THE SAME ORDER IN EVERY CONTEXT
* Add the byte to Save(), Load() and OnEnterWorld()
* Add the bool to ResetEffects() and Initialize()
*
* Add new item into Items/Gitgud/ (with the proper bool in UpdateAccessory())
*
* In GitgudData:
* Add the byte to SetCounter() in the proper order, adjust the case <number> things so it's in order properly
* Register the item and its properties in RegisterItems()
*
*/
//TODO get rid of Counter[], will not properly work in MP when players join/leave. should be stored player-only
//TODO unhardcode kingSlimeGitgudCounter etc
//TODO move into gitgud namespace
namespace AssortedCrazyThings
{
/// <summary>
/// Holds static functions and data related to the Gitgud accessories
/// </summary>
public class GitgudData
{
/// <summary>
/// Holds the data of all Gitgud Accessories, and a list of counters per player
/// </summary>
private static GitgudData[] DataList; //Left as null if disabled via config
public static LocalizedText DeleteFromInventoryText { get; private set; }
/// <summary>
/// Name for the delete message
/// </summary>
public Func<string> ItemNameFunc { set; get; }
/// <summary>
/// Boss name for tooltip
/// </summary>
public string BossName { set; get; }
/// <summary>
/// Buff immunity while boss is alive
/// </summary>
public int[] BuffTypeList { private set; get; }
/// <summary>
/// Buff name for tooltip
/// </summary>
public Func<string> BuffNameFunc { private set; get; }
/// <summary>
/// Dropped gitgud item
/// </summary>
public int ItemType { private set; get; }
/// <summary>
/// Boss type (usually only one, can be multiple for worms)
/// </summary>
public int[] BossTypeList { private set; get; }
/// <summary>
/// NPCs that deal damage during the boss fight (boss minions) (includes the boss itself by default)
/// </summary>
public int[] NPCTypeList { private set; get; }
/// <summary>
/// Projectiles that deal damage during the boss fight
/// </summary>
public int[] ProjTypeList { private set; get; }
/// <summary>
/// Threshold, after which the item drops
/// </summary>
public byte CounterMax { private set; get; }
/// <summary>
/// Percentage by which the damage gets reduced
/// </summary>
public float Reduction { private set; get; }
public Func<NPC, bool> CustomCountCondition { get; private set; }
/// <summary>
/// Invasion name, unused
/// </summary>
public string Invasion { private set; get; }
/// <summary>
/// Invasion in progress, ignore the lists for damage reduction
/// </summary>
public Func<bool> InvasionBool { private set; get; }
//255 long
/// <summary>
/// The bool that is set by the wearing accessory
/// </summary>
public BitArray Accessory { private set; get; }
/// <summary>
/// number of times player died to the boss
/// </summary>
public byte[] Counter { private set; get; }
public GitgudData(int itemType, int[] buffTypeList,
int[] bossTypeList, int[] nPCTypeList, int[] projTypeList, byte counterMax, float reduction, Func<NPC, bool> customCountCondition, string invasion, Func<bool> invasionBool)
{
ItemType = itemType;
ItemNameFunc = () => Lang.GetItemNameValue(itemType);
BuffTypeList = buffTypeList;
BuffNameFunc = () => string.Join(", ", buffTypeList.Select(b => Lang.GetBuffName(b)).ToArray());
BossTypeList = bossTypeList;
NPC npc = ContentSamples.NpcsByNetId[bossTypeList[0]];
BossName = npc.GetFullNetName().ToString();
if (bossTypeList.Length > 1)
{
for (int i = 1; i < bossTypeList.Length; i++)
{
npc = ContentSamples.NpcsByNetId[bossTypeList[i]];
string name = npc.GetFullNetName().ToString();
if (!BossName.Contains(name))
{
BossName += GitgudItem.BossNameSeparator + name;
}
}
}
if (nPCTypeList == null) nPCTypeList = new int[1];
if (projTypeList == null) projTypeList = new int[1];
NPCTypeList = AssUtils.ConcatArray(nPCTypeList, bossTypeList);
ProjTypeList = projTypeList;
CounterMax = counterMax;
Reduction = reduction;
CustomCountCondition = customCountCondition ?? ((NPC npc) => true);
Invasion = invasion;
InvasionBool = invasionBool ?? (() => false);
Array.Sort(BossTypeList);
Array.Sort(NPCTypeList);
Array.Sort(ProjTypeList);
Counter = new byte[255];
Accessory = new BitArray(255);
}
public override string ToString()
{
return ItemNameFunc();
}
public static void Add<T>(int[] buffTypeList,
int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func<NPC, bool> customCountCondition = null, string invasion = "", Func<bool> invasionBool = null) where T : ModItem
{
Add(ModContent.ItemType<T>(), buffTypeList, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool);
}
public static void Add<T>(int buffType,
int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func<NPC, bool> customCountCondition = null, string invasion = "", Func<bool> invasionBool = null) where T : ModItem
{
Add(ModContent.ItemType<T>(), buffType, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool);
}
public static void Add(int itemType, int[] buffTypeList,
int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func<NPC, bool> customCountCondition = null, string invasion = "", Func<bool> invasionBool = null)
{
if (itemType < 0 || itemType >= ItemLoader.ItemCount) throw new Exception("not a valid item type");
DataList[DataList.Length - 1] = new GitgudData(itemType, buffTypeList, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool);
Array.Resize(ref DataList, DataList.Length + 1);
}
public static void Add(int itemType, int buffType,
int[] bossTypeList, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func<NPC, bool> customCountCondition = null, string invasion = "", Func<bool> invasionBool = null)
{
if (itemType < 0 || itemType >= ItemLoader.ItemCount) throw new Exception("not a valid item type");
DataList[DataList.Length - 1] = new GitgudData(itemType, buffType == -1 ? Array.Empty<int>() : new int[] { buffType }, bossTypeList, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool);
Array.Resize(ref DataList, DataList.Length + 1);
}
public static void Add<T>(int buffType,
int bossType, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func<NPC, bool> customCountCondition = null, string invasion = "", Func<bool> invasionBool = null) where T : ModItem
{
Add(ModContent.ItemType<T>(), buffType, new int[] { bossType }, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool);
}
public static void Add(int itemType, int buffType,
int bossType, int[] nPCTypeList = null, int[] projTypeList = null, byte counterMax = 5, float reduction = 0.15f, Func<NPC, bool> customCountCondition = null, string invasion = "", Func<bool> invasionBool = null)
{
Add(itemType, buffType, new int[] { bossType }, nPCTypeList, projTypeList, counterMax, reduction, customCountCondition, invasion, invasionBool);
}
/// <summary>
/// Deletes the item from the inventory, trash slot, mouse item, and accessories
/// </summary>
public static void DeleteItemFromInventory(Player player, int index)
{
GitgudData data = DataList[index];
int itemType = data.ItemType;
string itemName = data.ItemNameFunc();
bool deleted = false;
//TODO instead of iterating, figure out solution that deletes item even in modded slots
Item[][] inventoryArray = { player.inventory, player.bank.item, player.bank2.item, player.bank3.item, player.bank4.item, player.armor }; //go though player inv
for (int y = 0; y < inventoryArray.Length; y++)
{
for (int e = 0; e < inventoryArray[y].Length; e++)
{
if (inventoryArray[y][e].type == itemType) //find gitgud item
{
inventoryArray[y][e].TurnToAir();
deleted = true;
}
}
}
//trash slot
if (player.trashItem.type == itemType)
{
player.trashItem.TurnToAir();
deleted = true;
}
//mouse item
if (Main.netMode != NetmodeID.Server && Main.myPlayer == player.whoAmI && Main.mouseItem.type == itemType)
{
Main.mouseItem.TurnToAir();
deleted = true;
}
if (deleted && Main.myPlayer == player.whoAmI)
{
Main.NewText(DeleteFromInventoryText.Format(itemName), new Color(255, 175, 0));
}
}
/// <summary>
/// Sets the counter on both the DataList and the players respective field
/// </summary>
public static void SetCounter(int whoAmI, int index, byte value, bool packet = false)
{
if (DataList == null)
{
return;
}
DataList[index].Counter[whoAmI] = value;
GitGudPlayer gPlayer = Main.player[whoAmI].GetModPlayer<GitGudPlayer>();
switch (index)
{
case 0:
gPlayer.kingSlimeGitgudCounter = value;
break;
case 1:
gPlayer.eyeOfCthulhuGitgudCounter = value;
break;
case 2:
gPlayer.brainOfCthulhuGitgudCounter = value;
break;
case 3:
gPlayer.eaterOfWorldsGitgudCounter = value;
break;
case 4:
gPlayer.queenBeeGitgudCounter = value;
break;
case 5:
gPlayer.skeletronGitgudCounter = value;
break;
case 6:
gPlayer.deerclopsGitgudCounter = value;
break;
case 7:
gPlayer.wallOfFleshGitgudCounter = value;
break;
//HARDMODE
case 8:
gPlayer.queenSlimeGitgudCounter = value;
break;
case 9:
gPlayer.destroyerGitgudCounter = value;
break;
case 10:
gPlayer.twinsGitgudCounter = value;
break;
case 11:
gPlayer.skeletronPrimeGitgudCounter = value;
break;
case 12:
gPlayer.planteraGitgudCounter = value;
break;
case 13:
gPlayer.empressOfLightGitgudCounter = value;
break;
case 14:
gPlayer.golemGitgudCounter = value;
break;
case 15:
gPlayer.dukeFishronGitgudCounter = value;
break;
case 16:
gPlayer.lunaticCultistGitgudCounter = value;
break;
case 17:
gPlayer.moonLordGitgudCounter = value;
break;
//INVASIONS
//case 17:
// gPlayer.pirateInvasionGitgudCounter = value;
// break;
default: //shouldn't get there hopefully
if (packet) AssUtils.Instance.Logger.Warn("Received unspecified GitgudReset Packet " + index);
else throw new Exception("Unspecified index in the gitgud array " + index);
break;
}
}
/// <summary>
/// Used in GitgudItem.ModifyTooltips
/// </summary>
public static bool GetDataFromItemType(int type, out GitgudData data)
{
data = null;
if (DataList != null)
{
for (int i = 0; i < DataList.Length; i++)
{
if (DataList[i].ItemType == type)
{
data = DataList[i];
}
}
}
return data != null;
}
public static void SendCounters(BinaryWriter writer, Player player)
{
if (DataList != null)
{
for (int i = 0; i < DataList.Length; i++)
{
writer.Write((byte)DataList[i].Counter[player.whoAmI]);
}
}
}
public static void RecvCounters(BinaryReader reader, Player player)
{
if (DataList != null)
{
//Length is synced on both sides
byte[] tempArray = new byte[DataList.Length];
for (int i = 0; i < DataList.Length; i++)
{
tempArray[i] = reader.ReadByte();
}
for (int i = 0; i < DataList.Length; i++)
{
SetCounter(player.whoAmI, i, tempArray[i], true);
}
}
}
/// <summary>
/// Serverside
/// </summary>
private static void SendChangeCounter(int whoAmI, int index, byte value)
{
if (DataList != null && Main.netMode == NetmodeID.Server)
{
new GitgudChangeCountersPacket(index, value).Send(to: whoAmI);
//AssUtils.Print("send changecounter from server with " + whoAmI + " " + index + " " + value);
}
}
/// <summary>
/// Called in GeneralGlobalNPC.NPCLoot. Sends all participating players a reset packet
/// </summary>
public static void Reset(NPC npc)
{
//Single and Server only
if (DataList != null)
{
for (int j = 0; j < Main.maxPlayers; j++)
{
Player player = Main.player[j];
if (player.active && npc.playerInteraction[j]) //playerInteraction is only accurate in single and server
{
for (int i = 0; i < DataList.Length; i++)
{
//resets even when all but one player is dead and boss is defeated
GitgudData data = DataList[i];
bool canReset = Array.BinarySearch(data.BossTypeList, npc.type) > -1;
if (canReset && data.CustomCountCondition(npc))
{
DeleteItemFromInventory(player, i);
//only send a packet if necessary
if (data.Counter[j] != 0)
{
//DataList[i].Counter[j] = 0;
SetCounter(j, i, 0);
SendChangeCounter(j, i, 0);
}
}
}
}
}
}
}
/// <summary>
/// Called in OnRespawn, spawns the item if the counter was overflown. Not clientside (not even sure myself at this point)
/// </summary>
public static void SpawnItem(Player player)
{
if (DataList != null)
{
for (int i = 0; i < DataList.Length; i++)
{
GitgudData data = DataList[i];
if (data.Counter[player.whoAmI] >= data.CounterMax)
{
//DataList[i].Counter[player.whoAmI] = 0;
SetCounter(player.whoAmI, i, 0);
if (!player.HasItem(data.ItemType) && !data.Accessory[player.whoAmI])
{
int spawnX = Main.spawnTileX - 1;
int spawnY = Main.spawnTileY - 1;
if (player.SpawnX != -1 && player.SpawnY != -1)
{
spawnX = player.SpawnX;
spawnY = player.SpawnY;
}
Item.NewItem(new EntitySource_WorldEvent(), new Vector2(spawnX, spawnY) * 16, data.ItemType);
}
}
}
}
}
/// <summary>
/// Called in PostUpdateEquips
/// </summary>
public static void ApplyBuffImmune(Player player)
{
if (DataList != null)
{
for (int i = 0; i < DataList.Length; i++)
{
GitgudData data = DataList[i];
if (data.Accessory[player.whoAmI] && data.BuffTypeList.Length > 0 && AssUtils.AnyNPCs(data.BossTypeList))
{
for (int j = 0; j < data.BuffTypeList.Length; j++)
{
player.buffImmune[data.BuffTypeList[j]] = true;
}
}
}
}
}
/// <summary>
/// Called in PreKill, checks what NPCs are alive, then increases the counter by 1
/// </summary>
public static void IncreaseCounters(int whoAmI)
{
if (DataList != null)
{
bool[] increasedFor = new bool[DataList.Length];
for (int k = 0; k < Main.maxNPCs; k++)
{
NPC npc = Main.npc[k];
if (npc.active && npc.playerInteraction[whoAmI]) //playerInteraction is only accurate in single and server
{
for (int i = 0; i < DataList.Length; i++)
{
GitgudData data = DataList[i];
if (!increasedFor[i] && Array.BinarySearch(data.BossTypeList, npc.type) > -1)
{
//AssUtils.Print("increased counter of " + whoAmI + " from " + DataList[i].Counter[whoAmI] + " to " + (DataList[i].Counter[whoAmI] + 1));
//DataList[i].Counter[whoAmI]++;
byte value = (byte)(data.Counter[whoAmI] + 1);
SetCounter(whoAmI, i, value);
SendChangeCounter(whoAmI, i, value);
increasedFor[i] = true;
}
}
}
}
}
}
/// <summary>
/// Called in ModifyHitByNPC
/// </summary>
public static void ReduceDamageNPC(int whoAmI, int npcType, ref Player.HurtModifiers modifiers)
{
if (DataList != null)
{
for (int i = 0; i < DataList.Length; i++)
{
GitgudData data = DataList[i];
if (data.Accessory[whoAmI])
{
//only reduce damage if accessory worn and (either an invasion is going on or a boss alive)
if (data.InvasionBool() ||
(Array.BinarySearch(data.NPCTypeList, npcType) > -1 && AssUtils.AnyNPCs(data.BossTypeList)))
{
modifiers.FinalDamage *= 1 - data.Reduction;
return;
}
}
}
}
}
/// <summary>
/// Called in ModifyHitByProjectile
/// </summary>
public static void ReduceDamageProj(int whoAmI, int projType, ref Player.HurtModifiers modifiers)
{
if (DataList != null)
{
for (int i = 0; i < DataList.Length; i++)
{
GitgudData data = DataList[i];
if (data.Accessory[whoAmI])
{
//only reduce damage if accessory worn and (either an invasion is going on or a boss alive)
if (data.InvasionBool() ||
(Array.BinarySearch(data.ProjTypeList, projType) > -1 && AssUtils.AnyNPCs(data.BossTypeList)))
{
modifiers.FinalDamage *= 1 - data.Reduction;
return;
}
}
}
}
}
/// <summary>
/// Called in PostUpdateEquips. Updates the DataList with if the accessories are worn
/// </summary>
public static void UpdateAccessories(int whoAmI, BitArray accessories)
{
if (DataList != null)
{
if (accessories.Length != DataList.Length) throw new Exception("Number of gitgud accessory bools don't match with the registered gitgud items");
for (int i = 0; i < accessories.Length; i++) //has to have the same order as DataList
{
DataList[i].Accessory[whoAmI] = accessories[i];
}
}
}
/// <summary>
/// Called in OnEnterWorld, Sets up the counters in the DataList for each accessory. Clientside
/// </summary>
public static void LoadCounters(int whoAmI, byte[] counters)
{
if (DataList != null)
{
if (counters.Length != DataList.Length) throw new Exception("Number of gitgud counters don't match with the registered gitgud counters");
for (int i = 0; i < counters.Length; i++) //has to have the same order as DataList
{
DataList[i].Counter[whoAmI] = counters[i];
}
if (Main.netMode == NetmodeID.MultiplayerClient)
{
new GitgudLoadCountersPacket(Main.player[whoAmI]).Send();
}
}
}
/// <summary>
/// Called in Mod.PostSetupContent. Basically a RegisterItems()
/// <seealso cref="RegisterItems"/>
/// </summary>
public static void Load()
{
if (!ContentConfig.Instance.BossConsolation)
{
return;
}
DataList = new GitgudData[1];
string category = $"Items.Gitgud.";
DeleteFromInventoryText ??= AssUtils.Instance.GetLocalization($"{category}DeleteFromInventory");
RegisterItems();
//since Add always increases the array size by one, it will make it so the last element is null
Array.Resize(ref DataList, DataList.Length - 1);
if (DataList.Length == 0) DataList = null;
}
/// <summary>
/// Called in Mod.Unload
/// </summary>
public static void Unload()
{
DataList = null;
}
private static bool OtherTwinDead(NPC npc)
{
if (npc.type == NPCID.Retinazer)
{
return !NPC.AnyNPCs(NPCID.Spazmatism);
}
else
{
return !NPC.AnyNPCs(NPCID.Retinazer);
}
}
/// <summary>
/// Fills the DataList with data for each accessory
/// </summary>
private static void RegisterItems()
{
Add<KingSlimeGitgud>(
-1,
NPCID.KingSlime,
nPCTypeList: new int[] { NPCID.BlueSlime },
projTypeList: new int[] { ProjectileID.SpikedSlimeSpike });
Add<EyeOfCthulhuGitgud>(
-1,
NPCID.EyeofCthulhu,
nPCTypeList: new int[] { NPCID.ServantofCthulhu });
Add<BrainOfCthulhuGitgud>(
BuffID.Slow,
NPCID.BrainofCthulhu,
nPCTypeList: new int[] { NPCID.Creeper });
Add<EaterOfWorldsGitgud>(
BuffID.Weak,
new int[] { NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, NPCID.EaterofWorldsHead },
nPCTypeList: new int[] { NPCID.VileSpit },
customCountCondition: (NPC npc) => npc.boss);
Add<QueenBeeGitgud>(
BuffID.Poisoned,
NPCID.QueenBee,
nPCTypeList: new int[] { NPCID.Bee, NPCID.BeeSmall },
projTypeList: new int[] { ProjectileID.Stinger });
Add<SkeletronGitgud>(
BuffID.Bleeding,
NPCID.SkeletronHead,
nPCTypeList: new int[] { NPCID.SkeletronHand },
projTypeList: new int[] { ProjectileID.Skull });
Add<DeerclopsGitgud>(
new int[] { BuffID.Slow, BuffID.Frozen },
new int[] { NPCID.Deerclops },
projTypeList: new int[] { ProjectileID.DeerclopsIceSpike, ProjectileID.DeerclopsRangedProjectile, ProjectileID.InsanityShadowHostile });
Add<WallOfFleshGitgud>(
-1,
NPCID.WallofFlesh,
nPCTypeList: new int[] { NPCID.WallofFleshEye },
projTypeList: new int[] { ProjectileID.EyeLaser });
//HARDMODE
Add<QueenSlimeGitgud>(
-1,
NPCID.QueenSlimeBoss,
nPCTypeList: new int[] { NPCID.QueenSlimeMinionBlue, NPCID.QueenSlimeMinionPink, NPCID.QueenSlimeMinionPurple },
projTypeList: new int[] { ProjectileID.QueenSlimeGelAttack, ProjectileID.QueenSlimeSmash, ProjectileID.QueenSlimeMinionBlueSpike, ProjectileID.QueenSlimeMinionPinkBall });
Add<DestroyerGitgud>(
-1,
NPCID.TheDestroyer,
nPCTypeList: new int[] { NPCID.TheDestroyerBody, NPCID.TheDestroyerTail, NPCID.Probe },
projTypeList: new int[] { ProjectileID.PinkLaser });
Add<TwinsGitgud>(
BuffID.CursedInferno,
new int[] { NPCID.Retinazer, NPCID.Spazmatism },
projTypeList: new int[] { ProjectileID.EyeLaser, ProjectileID.CursedFlameHostile, ProjectileID.EyeFire },
customCountCondition: OtherTwinDead);
Add<SkeletronPrimeGitgud>(
-1,
NPCID.SkeletronPrime,
nPCTypeList: new int[] { NPCID.PrimeCannon, NPCID.PrimeLaser, NPCID.PrimeSaw, NPCID.PrimeVice, },
projTypeList: new int[] { ProjectileID.DeathLaser, ProjectileID.BombSkeletronPrime, });
Add<PlanteraGitgud>(
BuffID.Poisoned,
NPCID.Plantera,
nPCTypeList: new int[] { NPCID.PlanterasHook, NPCID.PlanterasTentacle },
projTypeList: new int[] { ProjectileID.ThornBall, ProjectileID.SeedPlantera, ProjectileID.PoisonSeedPlantera });
Add<EmpressOfLightGitgud>(
-1,
NPCID.HallowBoss,
//TODO confirm 872, 873, 919, 923, 924 minus HallowBossDeathAurora (874) spawn
projTypeList: new int[] { ProjectileID.HallowBossLastingRainbow, ProjectileID.HallowBossRainbowStreak, ProjectileID.FairyQueenLance, ProjectileID.FairyQueenSunDance, ProjectileID.FairyQueenHymn, });
Add<GolemGitgud>(
BuffID.OnFire,
NPCID.Golem,
nPCTypeList: new int[] { NPCID.GolemFistLeft, NPCID.GolemFistRight, NPCID.GolemHead, NPCID.GolemHeadFree },
projTypeList: new int[] { ProjectileID.Fireball, ProjectileID.EyeBeam });
Add<DukeFishronGitgud>(
-1,
NPCID.DukeFishron,
nPCTypeList: new int[] { NPCID.DetonatingBubble, NPCID.Sharkron, NPCID.Sharkron2 },
projTypeList: new int[] { ProjectileID.Sharknado, ProjectileID.SharknadoBolt, ProjectileID.Cthulunado });
Add<LunaticCultistGitgud>(
BuffID.OnFire,
NPCID.CultistBoss,
nPCTypeList: new int[] { NPCID.AncientCultistSquidhead,/* NPCID.CultistBossClone,*/ },
projTypeList: new int[] { ProjectileID.CultistBossIceMist, ProjectileID.CultistBossLightningOrb, ProjectileID.CultistBossLightningOrbArc, ProjectileID.CultistBossFireBall, ProjectileID.CultistBossFireBallClone });
Add<MoonLordGitgud>(
-1,
new int[] { NPCID.MoonLordHead, NPCID.MoonLordCore },
nPCTypeList: new int[] { NPCID.MoonLordFreeEye,/* NPCID.MoonLordHand, NPCID.MoonLordHead, NPCID.MoonLordLeechBlob */}, //don't deal any damage
projTypeList: new int[] { ProjectileID.PhantasmalEye, ProjectileID.PhantasmalSphere, ProjectileID.PhantasmalDeathray, ProjectileID.PhantasmalBolt });
//INVASIONS
//Add<PirateInvasionGitgud>(
// "", -1,
// NPCID.PirateShip,
// reduction: 0.10f,
// invasion: "The Pirate Invasion",
// invasionBool: ()=> (Main.invasionType == InvasionID.PirateInvasion));
//Add<ClassNameOfItem>(
// <BuffName, should be "" when the other thing is -1>, <BuffID, or -1>,
// <NPCID of boss, or new int[] {NPCID1, NPCID2 etc } if multiple segments of a boss>,
// <nPCTypeList: new int[] { NPCID1, NPCID2 etc } for the minions of the boss>,
// <projTypeList: new int[] { ProjectileID1, ProjectileID2 etc } for the projectiles of the boss>);
// Last two optional (if boss is super basic, but I can't think of one)
}
}
[Content(ContentType.BossConsolation)]
public class GitGudPlayer : AssPlayerBase
{
public Func<BitArray> gitgudAccessories;
public byte kingSlimeGitgudCounter = 0;
public bool kingSlimeGitgud = false;
public byte eyeOfCthulhuGitgudCounter = 0;
public bool eyeOfCthulhuGitgud = false;
public byte brainOfCthulhuGitgudCounter = 0;
public bool brainOfCthulhuGitgud = false;
public byte eaterOfWorldsGitgudCounter = 0;
public bool eaterOfWorldsGitgud = false;
public byte queenBeeGitgudCounter = 0;
public bool queenBeeGitgud = false;
public byte skeletronGitgudCounter = 0;
public bool skeletronGitgud = false;
public byte deerclopsGitgudCounter = 0;
public bool deerclopsGitgud = false;
public byte wallOfFleshGitgudCounter = 0;
public bool wallOfFleshGitgud = false;
//HARDMODE
public byte queenSlimeGitgudCounter = 0;
public bool queenSlimeGitgud = false;
public byte destroyerGitgudCounter = 0;
public bool destroyerGitgud = false;
public byte twinsGitgudCounter = 0;
public bool twinsGitgud = false;
public byte skeletronPrimeGitgudCounter = 0;
public bool skeletronPrimeGitgud = false;
public byte planteraGitgudCounter = 0;
public bool planteraGitgud = false;
public byte empressOfLightGitgudCounter = 0;
public bool empressOfLightGitgud = false;
public byte golemGitgudCounter = 0;
public bool golemGitgud = false;
public byte dukeFishronGitgudCounter = 0;
public bool dukeFishronGitgud = false;
public byte lunaticCultistGitgudCounter = 0;
public bool lunaticCultistGitgud = false;
public byte moonLordGitgudCounter = 0;
public bool moonLordGitgud = false;
//INVASIONS
//public byte pirateInvasionGitgudCounter = 0;
//public bool pirateInvasionGitgud = false;
public override void ResetEffects()
{
kingSlimeGitgud = false;
eyeOfCthulhuGitgud = false;
brainOfCthulhuGitgud = false;
eaterOfWorldsGitgud = false;
queenBeeGitgud = false;
skeletronGitgud = false;
deerclopsGitgud = false;
wallOfFleshGitgud = false;
queenSlimeGitgud = false;
destroyerGitgud = false;
twinsGitgud = false;
skeletronPrimeGitgud = false;
planteraGitgud = false;
empressOfLightGitgud = false;
golemGitgud = false;
dukeFishronGitgud = false;
lunaticCultistGitgud = false;
moonLordGitgud = false;
//pirateInvasionGitgud = false;
}
public override void Initialize()
{
gitgudAccessories = new Func<BitArray>(() => new BitArray(new bool[]
{
kingSlimeGitgud,
eyeOfCthulhuGitgud,
brainOfCthulhuGitgud,
eaterOfWorldsGitgud,
queenBeeGitgud,
skeletronGitgud,
deerclopsGitgud,
wallOfFleshGitgud,
queenSlimeGitgud,
destroyerGitgud,
twinsGitgud,
skeletronPrimeGitgud,
planteraGitgud,
empressOfLightGitgud,
golemGitgud,
dukeFishronGitgud,
lunaticCultistGitgud,
moonLordGitgud,
//pirateInvasionGitgud,
}
));
}
//no need for syncplayer because the server handles the item drop stuff
public override void SaveData(TagCompound tag)
{
tag.Add("kingSlimeGitgudCounter", (byte)kingSlimeGitgudCounter);
tag.Add("eyeOfCthulhuGitgudCounter", (byte)eyeOfCthulhuGitgudCounter);
tag.Add("brainOfCthulhuGitgudCounter", (byte)brainOfCthulhuGitgudCounter);
tag.Add("eaterOfWorldsGitgudCounter", (byte)eaterOfWorldsGitgudCounter);
tag.Add("queenBeeGitgudCounter", (byte)queenBeeGitgudCounter);
tag.Add("skeletronGitgudCounter", (byte)skeletronGitgudCounter);
tag.Add("deerclopsGitgudCounter", (byte)deerclopsGitgudCounter);
tag.Add("wallOfFleshGitgudCounter", (byte)wallOfFleshGitgudCounter);
tag.Add("queenSlimeGitgudCounter", (byte)queenSlimeGitgudCounter);
tag.Add("destroyerGitgudCounter", (byte)destroyerGitgudCounter);
tag.Add("twinsGitgudCounter", (byte)twinsGitgudCounter);
tag.Add("skeletronPrimeGitgudCounter", (byte)skeletronPrimeGitgudCounter);
tag.Add("planteraGitgudCounter", (byte)planteraGitgudCounter);
tag.Add("empressOfLightGitgudCounter", (byte)empressOfLightGitgudCounter);
tag.Add("golemGitgudCounter", (byte)golemGitgudCounter);
tag.Add("dukeFishronGitgudCounter", (byte)dukeFishronGitgudCounter);
tag.Add("lunaticCultistGitgudCounter", (byte)lunaticCultistGitgudCounter);
tag.Add("moonLordGitgudCounter", (byte)moonLordGitgudCounter);
//tag.Add("pirateInvasionGitgudCounter", (byte)pirateInvasionGitgudCounter);
}
public override void LoadData(TagCompound tag)
{
kingSlimeGitgudCounter = tag.GetByte("kingSlimeGitgudCounter");
eyeOfCthulhuGitgudCounter = tag.GetByte("eyeOfCthulhuGitgudCounter");
brainOfCthulhuGitgudCounter = tag.GetByte("brainOfCthulhuGitgudCounter");
eaterOfWorldsGitgudCounter = tag.GetByte("eaterOfWorldsGitgudCounter");
queenBeeGitgudCounter = tag.GetByte("queenBeeGitgudCounter");
skeletronGitgudCounter = tag.GetByte("skeletronGitgudCounter");
deerclopsGitgudCounter = tag.GetByte("deerclopsGitgudCounter");
wallOfFleshGitgudCounter = tag.GetByte("wallOfFleshGitgudCounter");
queenSlimeGitgudCounter = tag.GetByte("queenSlimeGitgudCounter");
destroyerGitgudCounter = tag.GetByte("destroyerGitgudCounter");
twinsGitgudCounter = tag.GetByte("twinsGitgudCounter");
skeletronPrimeGitgudCounter = tag.GetByte("skeletronPrimeGitgudCounter");
planteraGitgudCounter = tag.GetByte("planteraGitgudCounter");
empressOfLightGitgudCounter = tag.GetByte("empressOfLightGitgudCounter");
golemGitgudCounter = tag.GetByte("golemGitgudCounter");
dukeFishronGitgudCounter = tag.GetByte("dukeFishronGitgudCounter");
lunaticCultistGitgudCounter = tag.GetByte("lunaticCultistGitgudCounter");
moonLordGitgudCounter = tag.GetByte("moonLordGitgudCounter");
//pirateInvasionGitgudCounter = tag.GetByte("pirateInvasionGitgudCounter");
}
public override void ModifyHitByNPC(NPC npc, ref Player.HurtModifiers modifiers)
{
GitgudData.ReduceDamageNPC(Player.whoAmI, npc.type, ref modifiers);
}
public override void ModifyHitByProjectile(Projectile proj, ref Player.HurtModifiers modifiers)
{
GitgudData.ReduceDamageProj(Player.whoAmI, proj.type, ref modifiers);
}
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
{
GitgudData.IncreaseCounters(Player.whoAmI);
return true;
}
public override void OnEnterWorld()
{
GitgudData.LoadCounters(Player.whoAmI, new byte[]
{
kingSlimeGitgudCounter,
eyeOfCthulhuGitgudCounter,
brainOfCthulhuGitgudCounter,
eaterOfWorldsGitgudCounter,
queenBeeGitgudCounter,
skeletronGitgudCounter,
deerclopsGitgudCounter,
wallOfFleshGitgudCounter,
queenSlimeGitgudCounter,
destroyerGitgudCounter,
twinsGitgudCounter,
skeletronPrimeGitgudCounter,
planteraGitgudCounter,
empressOfLightGitgudCounter,
golemGitgudCounter,
dukeFishronGitgudCounter,
lunaticCultistGitgudCounter,
moonLordGitgudCounter,
//pirateInvasionGitgudCounter,
});
//TODO has to send to server!
}
public override void PostUpdateEquips()
{
GitgudData.UpdateAccessories(Player.whoAmI, gitgudAccessories());
GitgudData.ApplyBuffImmune(Player);
//AssUtils.Print(GitgudData.DataList.Length);
}
public override void OnRespawn()
{
GitgudData.SpawnItem(Player);
}
}
}