forked from MadYeling/Fargowiltas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFargoPlayer.cs
212 lines (189 loc) · 6.52 KB
/
FargoPlayer.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
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using Fargowiltas.NPCs;
using System;
namespace Fargowiltas
{
public class FargoPlayer : ModPlayer
{
internal bool BattleCry;
private int oldSelected;
private bool isReuse = false;
internal int originalSelectedItem;
internal bool autoRevertSelectedItem = false;
public override void SetupStartInventory(IList<Item> items, bool mediumCoreDeath)
{
Item item = new Item();
item.SetDefaults(ItemType<Items.Misc.Stats>());
items.Add(item);
}
public override void ProcessTriggers(TriggersSet triggersSet)
{
if (Fargowiltas.CustomKey.JustPressed)
{
QuickUseItemAt(40);
}
if (Fargowiltas.RodKey.JustPressed)
{
AutoUseRod();
}
if (Fargowiltas.HomeKey.JustPressed)
{
AutoUseMirror();
}
}
/*private void Fargos()
{
if (player.GetModPlayer<FargowiltasSouls.FargoPlayer>().NinjaEnchant)
{
player.AddBuff(ModLoader.GetMod("FargowiltasSouls").BuffType("FirstStrike"), 60);
}
}*/
public override void PostUpdate()
{
if (autoRevertSelectedItem)
{
if (player.itemTime == 0 && player.itemAnimation == 0)
{
player.selectedItem = originalSelectedItem;
autoRevertSelectedItem = false;
}
}
}
public override void PostUpdateEquips()
{
Mod soulsMod = ModLoader.GetMod("FargowiltasSouls");
if (Fargowiltas.SwarmActive)
{
player.buffImmune[BuffID.Horrified] = true;
}
for (int i = 0; i < player.bank.item.Length; i++)
{
Item item = player.bank.item[i];
if (item.active && Array.IndexOf(Informational, item.type) > -1)
{
player.VanillaUpdateEquip(item);
}
}
}
int[] Informational = { ItemID.CopperWatch, ItemID.TinWatch, ItemID.TungstenWatch, ItemID.SilverWatch, ItemID.GoldWatch, ItemID.PlatinumWatch, ItemID.DepthMeter, ItemID.Compass, ItemID.Radar, ItemID.LifeformAnalyzer, ItemID.TallyCounter, ItemID.MetalDetector, ItemID.Stopwatch, ItemID.DPSMeter, ItemID.FishermansGuide, ItemID.Sextant, ItemID.WeatherRadio, ItemID.GPS, ItemID.REK, ItemID.GoblinTech, ItemID.FishFinder, ItemID.PDA, ItemID.CellPhone};
public override void UpdateBiomes()
{
if (FargoGlobalNPC.BossIsAlive(ref FargoGlobalNPC.eaterBoss, NPCID.EaterofWorldsHead))
{
player.ZoneCorrupt = true;
}
if (FargoGlobalNPC.BossIsAlive(ref FargoGlobalNPC.brainBoss, NPCID.BrainofCthulhu))
{
player.ZoneCrimson = true;
}
if (FargoGlobalNPC.BossIsAlive(ref FargoGlobalNPC.plantBoss, NPCID.Plantera))
{
player.ZoneJungle = true;
}
switch (Main.fountainColor)
{
case 0:
player.ZoneBeach = true;
break;
case 6:
player.ZoneDesert = true;
break;
case 3:
player.ZoneJungle = true;
break;
case 5:
player.ZoneSnow = true;
break;
case 2:
player.ZoneCorrupt = true;
break;
case 10:
player.ZoneCrimson = true;
break;
case 4:
if (Main.hardMode)
{
player.ZoneHoly = true;
}
break;
}
}
public override void CatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
{
int num15 = 150;
int num18 = num15 * 7 / power;
if (num18 < 4)
{
num18 = 4;
}
bool flag5 = false;
if (Main.rand.Next(num18) == 0)
{
flag5 = true;
}
int num21 = 10;
if (player.cratePotion)
{
num21 += 10;
}
if (Main.rand.Next(100) < num21)
{
if (flag5 && liquidType == 0 && player.ZoneSnow)
{
caughtType = mod.ItemType("IceCrate");
}
else if (flag5 && liquidType == 1 && ItemID.Sets.CanFishInLava[fishingRod.type] && player.ZoneUnderworldHeight)
{
caughtType = mod.ItemType("ShadowCrate");
}
}
}
public void AutoUseMirror()
{
for (int i = 0; i < player.inventory.Length; i++)
{
switch (player.inventory[i].type)
{
case ItemID.RecallPotion:
case ItemID.MagicMirror:
case ItemID.IceMirror:
case ItemID.CellPhone:
QuickUseItemAt(i);
break;
}
}
}
public void AutoUseRod()
{
for (int i = 0; i < player.inventory.Length; i++)
{
if (player.inventory[i].type == ItemID.RodofDiscord)
{
QuickUseItemAt(i);
break;
}
}
}
public void QuickUseItemAt(int index, bool use = true)
{
if (!autoRevertSelectedItem && player.selectedItem != index && player.inventory[index].type != 0)
{
originalSelectedItem = player.selectedItem;
autoRevertSelectedItem = true;
player.selectedItem = index;
player.controlUseItem = true;
if (use)
{
player.ItemCheck(Main.myPlayer);
}
}
}
}
}