-
Notifications
You must be signed in to change notification settings - Fork 69
/
Player.cs
18178 lines (18178 loc) · 593 KB
/
Player.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
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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Terraria
{
public class Player
{
public const int maxBuffs = 10;
public Vector2[] itemFlamePos = new Vector2[7];
public int itemFlameCount;
public bool outOfRange;
public bool teleporting;
public float teleportTime;
public int teleportStyle;
public bool sloping;
public bool chilled;
public bool frozen;
public bool ichor;
public int ropeCount;
public int manaRegenBonus;
public int manaRegenDelayBonus;
public int dash;
public int dashTime;
public int dashDelay;
public int gem = -1;
public int gemCount;
public byte meleeEnchant;
public byte pulleyDir;
public bool pulley;
public int pulleyFrame;
public float pulleyFrameCounter;
public bool blackBelt;
public bool sliding;
public int slideDir;
public int launcherWait;
public bool iceSkate;
public bool carpet;
public int spikedBoots;
public int carpetFrame = -1;
public float carpetFrameCounter;
public bool canCarpet;
public int carpetTime;
public int miscCounter;
public bool sandStorm;
public bool crimsonRegen;
public bool ghostHeal;
public bool sticky;
public bool slippy;
public bool slippy2;
public bool powerrun;
public bool flapSound;
public bool iceBarrier;
public bool panic;
public byte iceBarrierFrame;
public byte iceBarrierFrameCounter;
public bool shadowDodge;
public float shadowDodgeCount;
public bool palladiumRegen;
public bool onHitDodge;
public bool onHitRegen;
public bool onHitPetal;
public int petalTimer;
public int shadowDodgeTimer;
public int maxMinions = 1;
public int numMinions;
public bool pygmy;
public bool slime;
public int wingTime;
public int wings;
public int wingFrame;
public int wingFrameCounter;
public bool male = true;
public bool ghost;
public int ghostFrame;
public int ghostFrameCounter;
public int miscTimer;
public bool pvpDeath;
public bool zoneDungeon;
public bool zoneEvil;
public bool zoneHoly;
public bool zoneMeteor;
public bool zoneJungle;
public bool zoneSnow;
public bool zoneBlood;
public bool zoneCandle;
public bool boneArmor;
public bool frostArmor;
public bool honey;
public bool crystalLeaf;
public bool paladinBuff;
public bool paladinGive;
public float townNPCs;
public Vector2 position;
public Vector2 oldPosition;
public Vector2 velocity;
public Vector2 oldVelocity;
public double headFrameCounter;
public double bodyFrameCounter;
public double legFrameCounter;
public int netSkip;
public int oldSelectItem;
public bool immune;
public int immuneTime;
public int immuneAlphaDirection;
public int immuneAlpha;
public int team;
public bool hbLocked;
public static int nameLen = 20;
private float maxRegenDelay;
public string chatText = "";
public int sign = -1;
public int chatShowTime;
public int reuseDelay;
public int aggro;
public float activeNPCs;
public bool mouseInterface;
public int noThrow;
public int changeItem = -1;
public int selectedItem;
public Item[] armor = new Item[11];
public Item[] dye = new Item[3];
public int itemAnimation;
public int itemAnimationMax;
public int itemTime;
public int toolTime;
public float itemRotation;
public int itemWidth;
public int itemHeight;
public Vector2 itemLocation;
public bool poundRelease;
public float ghostFade;
public float ghostDir = 1f;
public int[] buffType = new int[10];
public int[] buffTime = new int[10];
public bool[] buffImmune = new bool[81];
public int heldProj = -1;
public int breathCD;
public int breathMax = 200;
public int breath = 200;
public int lavaCD;
public int lavaMax;
public int lavaTime;
public bool socialShadow;
public bool socialGhost;
public bool armorSteath;
public int stealthTimer;
public float stealth = 1f;
public string setBonus = "";
public Item[] inventory = new Item[59];
public Item[] bank = new Item[Chest.maxItems];
public Item[] bank2 = new Item[Chest.maxItems];
public float headRotation;
public float bodyRotation;
public float legRotation;
public Vector2 headPosition;
public Vector2 bodyPosition;
public Vector2 legPosition;
public Vector2 headVelocity;
public Vector2 bodyVelocity;
public Vector2 legVelocity;
public int nonTorch = -1;
public float gfxOffY;
public float stepSpeed = 1f;
public static bool deadForGood = false;
public bool dead;
public int respawnTimer;
public string name = "";
public int attackCD;
public int potionDelay;
public byte difficulty;
public bool wet;
public byte wetCount;
public bool lavaWet;
public bool honeyWet;
public int hitTile;
public int hitTileX;
public int hitTileY;
public int jump;
public int head = -1;
public int body = -1;
public int legs = -1;
public Rectangle headFrame;
public Rectangle bodyFrame;
public Rectangle legFrame;
public Rectangle hairFrame;
public bool controlLeft;
public bool controlRight;
public bool controlUp;
public bool controlDown;
public bool controlJump;
public bool controlUseItem;
public bool controlUseTile;
public bool controlThrow;
public bool controlInv;
public bool controlHook;
public bool controlTorch;
public bool controlMap;
public bool releaseJump;
public bool releaseUp;
public bool releaseUseItem;
public bool releaseUseTile;
public bool releaseInventory;
public bool releaseHook;
public bool releaseThrow;
public bool releaseQuickMana;
public bool releaseQuickHeal;
public bool releaseLeft;
public bool releaseRight;
public bool mapZoomIn;
public bool mapZoomOut;
public bool mapAlphaUp;
public bool mapAlphaDown;
public bool mapFullScreen;
public bool mapStyle;
public bool releaseMapFullscreen;
public bool releaseMapStyle;
public int leftTimer;
public int rightTimer;
public bool delayUseItem;
public bool active;
public int width = 20;
public int height = 42;
public int direction = 1;
public bool showItemIcon;
public bool showItemIconR;
public int showItemIcon2;
public int whoAmi;
public int runSoundDelay;
public float shadow;
public float manaCost = 1f;
public bool fireWalk;
public Vector2[] shadowPos = new Vector2[3];
public int shadowCount;
public bool channel;
public int step = -1;
public int statDefense;
public int statAttack;
public int statLifeMax = 100;
public int statLife = 100;
public int statMana;
public int statManaMax;
public int statManaMax2;
public int lifeRegen;
public int lifeRegenCount;
public int lifeRegenTime;
public int manaRegen;
public int manaRegenCount;
public int manaRegenDelay;
public bool manaRegenBuff;
public bool noKnockback;
public bool spaceGun;
public float gravDir = 1f;
public bool ammoCost80;
public bool ammoCost75;
public int stickyBreak;
public bool magicQuiver;
public bool magmaStone;
public bool lavaRose;
public bool lightOrb;
public bool fairy;
public bool bunny;
public bool turtle;
public bool eater;
public bool penguin;
public bool magicCuffs;
public bool coldDash;
public bool eyeSpring;
public bool snowman;
public bool scope;
public bool dino;
public bool skeletron;
public bool hornet;
public bool tiki;
public bool parrot;
public bool truffle;
public bool sapling;
public bool wisp;
public bool lizard;
public bool archery;
public bool poisoned;
public bool venom;
public bool blind;
public bool blackout;
public bool frostBurn;
public bool onFrostBurn;
public bool burned;
public bool suffocating;
public bool onFire;
public bool onFire2;
public bool noItems;
public bool wereWolf;
public bool wolfAcc;
public bool rulerAcc;
public bool bleed;
public bool confused;
public bool accMerman;
public bool merman;
public bool brokenArmor;
public bool silence;
public bool slow;
public bool gross;
public bool tongued;
public bool kbGlove;
public bool starCloak;
public bool longInvince;
public bool pStone;
public bool manaFlower;
public int meleeCrit = 4;
public int rangedCrit = 4;
public int magicCrit = 4;
public float meleeDamage = 1f;
public float rangedDamage = 1f;
public float bulletDamage = 1f;
public float arrowDamage = 1f;
public float rocketDamage = 1f;
public float magicDamage = 1f;
public float minionDamage = 1f;
public float minionKB;
public float meleeSpeed = 1f;
public float moveSpeed = 1f;
public float pickSpeed = 1f;
public int SpawnX = -1;
public int SpawnY = -1;
public int[] spX = new int[200];
public int[] spY = new int[200];
public string[] spN = new string[200];
public int[] spI = new int[200];
public static int tileRangeX = 5;
public static int tileRangeY = 4;
private static int tileTargetX;
private static int tileTargetY;
private static int jumpHeight = 15;
private static float jumpSpeed = 5.01f;
public bool adjWater;
public bool adjHoney;
public bool oldAdjWater;
public bool oldAdjHoney;
public bool[] adjTile = new bool[251];
public bool[] oldAdjTile = new bool[251];
private static int itemGrabRange = 38;
private static float itemGrabSpeed = 0.45f;
private static float itemGrabSpeedMax = 4f;
public Color hairColor = new Color(215, 90, 55);
public Color skinColor = new Color(255, 125, 90);
public Color eyeColor = new Color(105, 90, 75);
public Color shirtColor = new Color(175, 165, 140);
public Color underShirtColor = new Color(160, 180, 215);
public Color pantsColor = new Color(255, 230, 175);
public Color shoeColor = new Color(160, 105, 60);
public int hair;
public bool hostile;
public int accCompass;
public int accWatch;
public int accDepthMeter;
public bool discount;
public bool coins;
public bool accDivingHelm;
public bool accFlipper;
public bool doubleJump;
public bool jumpAgain;
public bool dJumpEffect;
public bool doubleJump2;
public bool jumpAgain2;
public bool dJumpEffect2;
public bool doubleJump3;
public bool jumpAgain3;
public bool dJumpEffect3;
public bool doubleJump4;
public bool jumpAgain4;
public bool dJumpEffect4;
public bool spawnMax;
public int blockRange;
public int[] grappling = new int[20];
public int grapCount;
public int rocketTime;
public int rocketTimeMax = 7;
public int rocketDelay;
public int rocketDelay2;
public bool rocketRelease;
public bool rocketFrame;
public int rocketBoots;
public bool canRocket;
public bool jumpBoost;
public bool noFallDmg;
public int swimTime;
public bool killGuide;
public bool killClothier;
public bool lavaImmune;
public bool gills;
public bool slowFall;
public bool findTreasure;
public bool invis;
public bool detectCreature;
public bool nightVision;
public bool enemySpawns;
public bool thorns;
public bool turtleArmor;
public bool turtleThorns;
public bool waterWalk;
public bool waterWalk2;
public bool gravControl;
public bool gravControl2;
public bool bee;
public int chest = -1;
public int chestX;
public int chestY;
public int talkNPC = -1;
public int fallStart;
public int slowCount;
public int potionDelayTime = Item.potionDelay;
public void HealEffect(int healAmount, bool broadcast = true)
{
CombatText.NewText(new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), new Color(100, 255, 100, 255), string.Concat(healAmount), false, false);
if (broadcast && Main.netMode == 1 && this.whoAmi == Main.myPlayer)
{
NetMessage.SendData(35, -1, -1, "", this.whoAmi, (float)healAmount, 0f, 0f, 0);
}
}
public void ManaEffect(int manaAmount)
{
CombatText.NewText(new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height), new Color(100, 100, 255, 255), string.Concat(manaAmount), false, false);
if (Main.netMode == 1 && this.whoAmi == Main.myPlayer)
{
NetMessage.SendData(43, -1, -1, "", this.whoAmi, (float)manaAmount, 0f, 0f, 0);
}
}
public static byte FindClosest(Vector2 Position, int Width, int Height)
{
byte result = 0;
for (int i = 0; i < 255; i++)
{
if (Main.player[i].active)
{
result = (byte)i;
break;
}
}
float num = -1f;
for (int j = 0; j < 255; j++)
{
if (Main.player[j].active && !Main.player[j].dead && (num == -1f || Math.Abs(Main.player[j].position.X + (float)(Main.player[j].width / 2) - Position.X + (float)(Width / 2)) + Math.Abs(Main.player[j].position.Y + (float)(Main.player[j].height / 2) - Position.Y + (float)(Height / 2)) < num))
{
num = Math.Abs(Main.player[j].position.X + (float)(Main.player[j].width / 2) - Position.X + (float)(Width / 2)) + Math.Abs(Main.player[j].position.Y + (float)(Main.player[j].height / 2) - Position.Y + (float)(Height / 2));
result = (byte)j;
}
}
return result;
}
public void checkArmor()
{
}
public void toggleInv()
{
if (this.talkNPC >= 0)
{
this.talkNPC = -1;
Main.npcChatText = "";
Main.PlaySound(11, -1, -1, 1);
return;
}
if (this.sign >= 0)
{
this.sign = -1;
Main.editSign = false;
Main.npcChatText = "";
Main.PlaySound(11, -1, -1, 1);
return;
}
if (!Main.playerInventory)
{
Recipe.FindRecipes();
Main.playerInventory = true;
Main.PlaySound(10, -1, -1, 1);
return;
}
Main.playerInventory = false;
Main.PlaySound(11, -1, -1, 1);
}
public void dropItemCheck()
{
if (!Main.playerInventory)
{
this.noThrow = 0;
}
if (this.noThrow > 0)
{
this.noThrow--;
}
if (!Main.craftGuide && Main.guideItem.type > 0)
{
int num = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, Main.guideItem.type, 1, false, 0, false);
Main.guideItem.position = Main.item[num].position;
Main.item[num] = Main.guideItem;
Main.guideItem = new Item();
if (Main.netMode == 0)
{
Main.item[num].noGrabDelay = 100;
}
Main.item[num].velocity.Y = -2f;
Main.item[num].velocity.X = (float)(4 * this.direction) + this.velocity.X;
if (Main.netMode == 1)
{
NetMessage.SendData(21, -1, -1, "", num, 0f, 0f, 0f, 0);
}
}
if (!Main.reforge && Main.reforgeItem.type > 0)
{
int num2 = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, Main.reforgeItem.type, 1, false, 0, false);
Main.reforgeItem.position = Main.item[num2].position;
Main.item[num2] = Main.reforgeItem;
Main.reforgeItem = new Item();
if (Main.netMode == 0)
{
Main.item[num2].noGrabDelay = 100;
}
Main.item[num2].velocity.Y = -2f;
Main.item[num2].velocity.X = (float)(4 * this.direction) + this.velocity.X;
if (Main.netMode == 1)
{
NetMessage.SendData(21, -1, -1, "", num2, 0f, 0f, 0f, 0);
}
}
if (Main.myPlayer == this.whoAmi)
{
this.inventory[58] = (Item)Main.mouseItem.Clone();
}
bool flag = true;
if (Main.mouseItem.type > 0 && Main.mouseItem.stack > 0)
{
Player.tileTargetX = (int)(((float)Main.mouseX + Main.screenPosition.X) / 16f);
Player.tileTargetY = (int)(((float)Main.mouseY + Main.screenPosition.Y) / 16f);
if (this.gravDir == -1f)
{
Player.tileTargetY = (int)((Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY) / 16f);
}
if (this.selectedItem != 58)
{
this.oldSelectItem = this.selectedItem;
}
this.selectedItem = 58;
flag = false;
}
if (flag && this.selectedItem == 58)
{
this.selectedItem = this.oldSelectItem;
}
if (((this.controlThrow && this.releaseThrow && this.inventory[this.selectedItem].type > 0 && !Main.chatMode) || (((Main.mouseRight && !this.mouseInterface && Main.mouseRightRelease) || !Main.playerInventory) && Main.mouseItem.type > 0 && Main.mouseItem.stack > 0)) && this.noThrow <= 0)
{
Item item = new Item();
bool flag2 = false;
if (((Main.mouseRight && !this.mouseInterface && Main.mouseRightRelease) || !Main.playerInventory) && Main.mouseItem.type > 0 && Main.mouseItem.stack > 0)
{
item = this.inventory[this.selectedItem];
this.inventory[this.selectedItem] = Main.mouseItem;
this.delayUseItem = true;
this.controlUseItem = false;
flag2 = true;
}
int num3 = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, this.inventory[this.selectedItem].type, 1, false, 0, false);
if (!flag2 && this.inventory[this.selectedItem].type == 8 && this.inventory[this.selectedItem].stack > 1)
{
this.inventory[this.selectedItem].stack--;
}
else
{
this.inventory[this.selectedItem].position = Main.item[num3].position;
Main.item[num3] = this.inventory[this.selectedItem];
this.inventory[this.selectedItem] = new Item();
}
if (Main.netMode == 0)
{
Main.item[num3].noGrabDelay = 100;
}
Main.item[num3].velocity.Y = -2f;
Main.item[num3].velocity.X = (float)(4 * this.direction) + this.velocity.X;
if (((Main.mouseRight && !this.mouseInterface) || !Main.playerInventory) && Main.mouseItem.type > 0)
{
this.inventory[this.selectedItem] = item;
Main.mouseItem = new Item();
}
else
{
this.itemAnimation = 10;
this.itemAnimationMax = 10;
}
Recipe.FindRecipes();
if (Main.netMode == 1)
{
NetMessage.SendData(21, -1, -1, "", num3, 0f, 0f, 0f, 0);
}
}
}
public void AddBuff(int type, int time, bool quiet = true)
{
if (this.buffImmune[type])
{
return;
}
if (!quiet && Main.netMode == 1)
{
bool flag = true;
for (int i = 0; i < 10; i++)
{
if (this.buffType[i] == type)
{
flag = false;
}
}
if (flag)
{
NetMessage.SendData(55, -1, -1, "", this.whoAmi, (float)type, (float)time, 0f, 0);
}
}
int num = -1;
for (int j = 0; j < 10; j++)
{
if (this.buffType[j] == type)
{
if (this.buffTime[j] < time)
{
this.buffTime[j] = time;
}
return;
}
}
if (Main.vanityPet[type] || Main.lightPet[type])
{
for (int k = 0; k < 10; k++)
{
if (Main.vanityPet[type] && Main.vanityPet[this.buffType[k]])
{
this.DelBuff(k);
}
if (Main.lightPet[type] && Main.lightPet[this.buffType[k]])
{
this.DelBuff(k);
}
}
}
while (num == -1)
{
int num2 = -1;
for (int l = 0; l < 10; l++)
{
if (!Main.debuff[this.buffType[l]])
{
num2 = l;
break;
}
}
if (num2 == -1)
{
return;
}
for (int m = num2; m < 10; m++)
{
if (this.buffType[m] == 0)
{
num = m;
break;
}
}
if (num == -1)
{
this.DelBuff(num2);
}
}
this.buffType[num] = type;
this.buffTime[num] = time;
if (Main.meleeBuff[type])
{
for (int n = 0; n < 10; n++)
{
if (n != num && Main.meleeBuff[this.buffType[n]])
{
this.DelBuff(n);
}
}
}
}
public void DelBuff(int b)
{
this.buffTime[b] = 0;
this.buffType[b] = 0;
for (int i = 0; i < 9; i++)
{
if (this.buffTime[i] == 0 || this.buffType[i] == 0)
{
for (int j = i + 1; j < 10; j++)
{
this.buffTime[j - 1] = this.buffTime[j];
this.buffType[j - 1] = this.buffType[j];
this.buffTime[j] = 0;
this.buffType[j] = 0;
}
}
}
}
public void QuickHeal()
{
if (this.noItems)
{
return;
}
if (this.statLife == this.statLifeMax || this.potionDelay > 0)
{
return;
}
for (int i = 0; i < 58; i++)
{
if (this.inventory[i].stack > 0 && this.inventory[i].type > 0 && this.inventory[i].potion && this.inventory[i].healLife > 0)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, this.inventory[i].useSound);
if (this.inventory[i].potion)
{
this.potionDelay = this.potionDelayTime;
this.AddBuff(21, this.potionDelay, true);
}
this.statLife += this.inventory[i].healLife;
this.statMana += this.inventory[i].healMana;
if (this.statLife > this.statLifeMax)
{
this.statLife = this.statLifeMax;
}
if (this.statMana > this.statManaMax2)
{
this.statMana = this.statManaMax2;
}
if (this.inventory[i].healLife > 0 && Main.myPlayer == this.whoAmi)
{
this.HealEffect(this.inventory[i].healLife, true);
}
if (this.inventory[i].healMana > 0 && Main.myPlayer == this.whoAmi)
{
this.ManaEffect(this.inventory[i].healMana);
}
this.inventory[i].stack--;
if (this.inventory[i].stack <= 0)
{
this.inventory[i].type = 0;
this.inventory[i].name = "";
}
Recipe.FindRecipes();
return;
}
}
}
public void QuickMana()
{
if (this.noItems)
{
return;
}
if (this.statMana == this.statManaMax2)
{
return;
}
for (int i = 0; i < 58; i++)
{
if (this.inventory[i].stack > 0 && this.inventory[i].type > 0 && this.inventory[i].healMana > 0 && (this.potionDelay == 0 || !this.inventory[i].potion))
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, this.inventory[i].useSound);
if (this.inventory[i].potion)
{
this.potionDelay = this.potionDelayTime;
this.AddBuff(21, this.potionDelay, true);
}
this.statLife += this.inventory[i].healLife;
this.statMana += this.inventory[i].healMana;
if (this.statLife > this.statLifeMax)
{
this.statLife = this.statLifeMax;
}
if (this.statMana > this.statManaMax2)
{
this.statMana = this.statManaMax2;
}
if (this.inventory[i].healLife > 0 && Main.myPlayer == this.whoAmi)
{
this.HealEffect(this.inventory[i].healLife, true);
}
if (this.inventory[i].healMana > 0 && Main.myPlayer == this.whoAmi)
{
this.ManaEffect(this.inventory[i].healMana);
}
this.inventory[i].stack--;
if (this.inventory[i].stack <= 0)
{
this.inventory[i].type = 0;
this.inventory[i].name = "";
}
Recipe.FindRecipes();
return;
}
}
}
public int countBuffs()
{
int num = 0;
for (int i = 0; i < 10; i++)
{
if (this.buffType[num] > 0)
{
num++;
}
}
return num;
}
public void QuickBuff()
{
if (this.noItems)
{
return;
}
int num = 0;
for (int i = 0; i < 58; i++)
{
if (this.countBuffs() == 10)
{
return;
}
if (this.inventory[i].stack > 0 && this.inventory[i].type > 0 && this.inventory[i].buffType > 0 && !this.inventory[i].summon)
{
bool flag = true;
for (int j = 0; j < 10; j++)
{
if (this.buffType[j] == this.inventory[i].buffType)
{
flag = false;
break;
}
if (Main.meleeBuff[this.inventory[i].buffType] && Main.meleeBuff[this.buffType[j]])
{
flag = false;
break;
}
}
if (Main.lightPet[this.inventory[i].buffType] || Main.vanityPet[this.inventory[i].buffType])
{
for (int k = 0; k < 10; k++)
{
if (Main.lightPet[this.buffType[k]] && Main.lightPet[this.inventory[i].buffType])
{
flag = false;
}
if (Main.vanityPet[this.buffType[k]] && Main.vanityPet[this.inventory[i].buffType])
{
flag = false;
}
}
}
if (this.inventory[i].mana > 0 && flag)
{
if (this.statMana >= (int)((float)this.inventory[i].mana * this.manaCost))
{
this.manaRegenDelay = (int)this.maxRegenDelay;
this.statMana -= (int)((float)this.inventory[i].mana * this.manaCost);
}
else
{
flag = false;
}
}
if (this.whoAmi == Main.myPlayer && this.inventory[i].type == 603 && !Main.cEd)
{
flag = false;
}
if (flag)
{
num = this.inventory[i].useSound;
int num2 = this.inventory[i].buffTime;
if (num2 == 0)
{
num2 = 3600;
}
this.AddBuff(this.inventory[i].buffType, num2, true);
if (this.inventory[i].consumable)
{
this.inventory[i].stack--;
if (this.inventory[i].stack <= 0)
{
this.inventory[i].type = 0;
this.inventory[i].name = "";
}
}
}
}
}
if (num > 0)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, num);
Recipe.FindRecipes();
}
}
public void StatusNPC(int type, int i)
{
if (this.meleeEnchant > 0)
{
if (this.meleeEnchant == 1)
{
Main.npc[i].AddBuff(70, 60 * Main.rand.Next(5, 10), false);
}
if (this.meleeEnchant == 2)
{
Main.npc[i].AddBuff(39, 60 * Main.rand.Next(3, 7), false);
}
if (this.meleeEnchant == 3)
{
Main.npc[i].AddBuff(24, 60 * Main.rand.Next(3, 7), false);
}
if (this.meleeEnchant == 5)
{
Main.npc[i].AddBuff(69, 60 * Main.rand.Next(10, 20), false);
}
if (this.meleeEnchant == 6)
{
Main.npc[i].AddBuff(31, 60 * Main.rand.Next(1, 4), false);
}
if (this.meleeEnchant == 8)
{
Main.npc[i].AddBuff(20, 60 * Main.rand.Next(5, 10), false);
}
if (this.meleeEnchant == 4)
{
Main.npc[i].AddBuff(69, 120, false);
}
}
if (this.frostBurn)
{
Main.npc[i].AddBuff(44, 60 * Main.rand.Next(5, 15), false);
}
if (this.magmaStone)
{
if (Main.rand.Next(7) == 0)
{
Main.npc[i].AddBuff(24, 360, false);
}
else
{
if (Main.rand.Next(3) == 0)
{
Main.npc[i].AddBuff(24, 120, false);
}
else
{
Main.npc[i].AddBuff(24, 60, false);
}
}
}
if (type == 121)
{
if (Main.rand.Next(2) == 0)
{
Main.npc[i].AddBuff(24, 180, false);
return;
}
}
else
{
if (type == 122)
{
if (Main.rand.Next(10) == 0)
{
Main.npc[i].AddBuff(24, 180, false);
return;
}
}
else
{
if (type == 190)
{
if (Main.rand.Next(4) == 0)
{
Main.npc[i].AddBuff(20, 420, false);
return;
}
}
else
{
if (type == 217)
{
if (Main.rand.Next(5) == 0)
{
Main.npc[i].AddBuff(24, 180, false);
return;
}
}
else
{
if (type == 1123 && Main.rand.Next(10) != 0)
{
Main.npc[i].AddBuff(31, 120, false);
}
}
}
}
}