This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMPlayer.cs
280 lines (263 loc) · 7.03 KB
/
MPlayer.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Tremor.Items;
using Tremor.Items.Afterlife;
using Tremor.Items.Argite;
using Tremor.Items.Berserker;
using Tremor.Items.Brass;
using Tremor.Items.Chaos;
using Tremor.Items.Crystal;
using Tremor.Items.Flesh;
using Tremor.Items.Fungus;
using Tremor.Items.Harpy;
using Tremor.Items.Invar;
using Tremor.Items.Magmonium;
using Tremor.Items.Nano;
using Tremor.Items.Nightingale;
using Tremor.Items.Orcish;
using Tremor.Items.Sandstone;
namespace Tremor
{
// Todo: transfer more to a general class
public class MPlayer : ModPlayer
{
public static MPlayer GetModPlayer(Player player)
=> player.GetModPlayer<MPlayer>();
// Buffs and debuffs
public bool fragileContiion;
// Alchemist
public float alchemicalDamage;
public float alchemicalKbAddition;
public float alchemicalKbMult;
public int alchemicalCrit;
// Undocumented
public bool pyro;
public bool nitro;
public bool spirit;
public bool enchanted;
public bool glove;
public bool core;
public bool novaAura;
public bool novaSet;
public bool novaHelmet;
public bool novaChestplate;
public override void ResetEffects()
{
// Buffs and debuffs
fragileContiion = false;
// Alchemist
alchemicalDamage = 1f;
alchemicalKbAddition = 0f;
alchemicalKbMult = 1f;
alchemicalCrit = 0;
// Undocumented
pyro = false;
nitro = false;
spirit = false;
enchanted = false;
glove = false;
core = false;
novaAura = false;
novaSet = false;
novaHelmet = false;
novaChestplate = false;
}
public override void PostUpdateMiscEffects()
{
// Reset conditions
if (fragileContiion)
player.statDefense = 0;
}
public override void OnEnterWorld(Player player)
{
// switch this bool to log
if (false)
{
// some random sheet to log armor recipes
// cuz im lazy
// poops out the wiki format for armor sets recipes
// does not support 3 hat variants, or assumes all hats use the same recipes
// (deviant hat recipes not allowed), put in 1 hat
// WorkBenches => Work Bench
// Anvils => Iron Anvil / Lead Anvil
// MythrilAnvil => Mythril Anvil / Orihalcum Anvil
var armors = new[]
{
new[]
{
mod.ItemType<InvarHat>(),
mod.ItemType<InvarBreastplate>(),
mod.ItemType<InvarGreaves>(),
},
new[]
{
mod.ItemType<HarpyHelmet>(),
mod.ItemType<HarpyChestplate>(),
mod.ItemType<HarpyLeggings>(),
},
new[]
{
mod.ItemType<ArgiteHelmet>(),
mod.ItemType<ArgiteBreastplate>(),
mod.ItemType<ArgiteGreaves>(),
},
new[]
{
mod.ItemType<NightingaleHood>(),
mod.ItemType<NightingaleChestplate>(),
mod.ItemType<NightingaleGreaves>(),
},
new[]
{
mod.ItemType<OrcishHelmet>(),
mod.ItemType<OrcishBreastplate>(),
mod.ItemType<OrcishGreaves>(),
},
new[]
{
mod.ItemType<FungusHelmet>(),
mod.ItemType<FungusBreastplate>(),
mod.ItemType<FungusGreaves>(),
},
new[]
{
mod.ItemType<FleshHelmet>(),
mod.ItemType<FleshBreastplate>(),
mod.ItemType<FleshGreaves>(),
},
new[]
{
mod.ItemType<CrystalHelmet>(),
mod.ItemType<CrystalChestplate>(),
mod.ItemType<CrystalGreaves>(),
},
new[]
{
mod.ItemType<LuxoriousHelmet>(),
mod.ItemType<LuxoriousBreastplate>(),
mod.ItemType<LuxoriousLeggings>(),
},
new[]
{
mod.ItemType<AfterlifeHood>(),
mod.ItemType<AfterlifeBreastplate>(),
mod.ItemType<AfterlifeLeggings>(),
},
new[]
{
mod.ItemType<NanoHelmet>(),
mod.ItemType<NanoBreastplate>(),
mod.ItemType<NanoGreaves>(),
},
new[]
{
mod.ItemType<MagmoniumHelmet>(),
mod.ItemType<MagmoniumBreastplate>(),
mod.ItemType<MagmoniumGreaves>(),
},
new[]
{
mod.ItemType<SandStoneHelmet>(),
mod.ItemType<SandStoneBreastplate>(),
mod.ItemType<SandStoneGreaves>(),
},
new[]
{
mod.ItemType<ChaosHelmet>(),
mod.ItemType<ChaosBreastplate>(),
mod.ItemType<ChaosGreaves>(),
},
new[]
{
mod.ItemType<BrassHelmet>(),
mod.ItemType<BrassHeadgear>(),
mod.ItemType<BrassMask>(),
},
new[]
{
mod.ItemType<BerserkerHelmet>(),
mod.ItemType<BerserkerChestplate>(),
mod.ItemType<BerserkerGreaves>(),
},
};
ErrorLogger.ClearLog();
foreach (var armor in armors)
{
Item item = new Item(); // item used for initializing
ErrorLogger.Log("==========");
ErrorLogger.Log("Combined recipe for: " + string.Join(", ", armor.Select(x =>
{
item.SetDefaults(x);
return item.Name;
})));
ErrorLogger.Log("==========");
var reqItems = new List<Item>();
var reqTiles = new List<int>();
var reqTileNames = new List<string>();
// loop pieces
foreach (int piece in armor)
{
var recipes = Main.recipe.Where(x => x.createItem.type == piece);
foreach (Recipe recipe in recipes)
{
reqItems = reqItems.Concat(recipe.requiredItem).ToList();
reqTiles = reqTiles.Concat(recipe.requiredTile).ToList();
}
}
// combine stacks
var duplicateItems = reqItems.GroupBy(x => x.type).Where(x => x.Count() > 1).Select(x => x);
var combItems = TremorUtils.DistinctBy(reqItems, x => x.type).ToList();
foreach (var grouping in duplicateItems)
{
var reqItem = combItems.FirstOrDefault(x => x.type == grouping.Key);
if (reqItem != null)
{
reqItem.stack = reqItems.Where(x => x.type == grouping.Key).Sum(x => x.stack);
}
}
reqItems = new List<Item>(combItems);
reqTiles = reqTiles.Distinct().ToList();
// get non empty entries
reqItems = reqItems.Where(x => !x.IsAir).ToList();
reqTileNames = reqTiles.Where(x => x > 0).Select(x => typeof(TileID).FindNameByConstant((ushort) x)).ToList();
int i = reqTileNames.IndexOf("Anvils");
if (i != -1)
{
reqTileNames.RemoveAt(i);
reqTileNames.Add("Iron Anvil");
reqTileNames.Add("Lead Anvil");
}
i = reqTileNames.IndexOf("WorkBenches");
if (i != -1)
{
reqTileNames.RemoveAt(i);
reqTileNames.Add("Work Bench");
}
i = reqTileNames.IndexOf("OrichalcumAnvil");
if (i != -1)
{
reqTileNames.RemoveAt(i);
reqTileNames.Add("Orichalcum Anvil");
}
i = reqTileNames.IndexOf("MythrilAnvil");
if (i != -1)
{
reqTileNames.RemoveAt(i);
reqTileNames.Add("Mythril Anvil");
reqTileNames.Add("Orichalcum Anvil");
}
// make strings, log
string items = "* " + string.Join(" + ", reqItems.Select(x => $"{x.stack} {{{{item link|{x.Name}}}}}"));
string tiles = "* Crafted at " + string.Join(" / ", reqTileNames.Select(x => $"{{{{item link|{x}}}}}"));
ErrorLogger.Log($"{items}\n{tiles}");
ErrorLogger.Log("==========\n");
}
}
}
}
}