-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCalRemix.cs
More file actions
260 lines (244 loc) · 12.8 KB
/
CalRemix.cs
File metadata and controls
260 lines (244 loc) · 12.8 KB
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
using CalamityMod;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Materials;
using CalamityMod.NPCs.CalClone;
using CalamityMod.NPCs.CeaselessVoid;
using CalamityMod.NPCs.Crabulon;
using CalamityMod.NPCs.ExoMechs;
using CalamityMod.NPCs.Leviathan;
using CalamityMod.NPCs.OldDuke;
using CalamityMod.NPCs.PlaguebringerGoliath;
using CalRemix.Content.Buffs;
using CalRemix.Content.Items.Accessories;
using CalRemix.Content.Items.Weapons;
using CalRemix.Content.Items.ZAccessories;
using CalRemix.Content.NPCs;
using CalRemix.Content.NPCs.Bosses.Acideye;
using CalRemix.Content.NPCs.Bosses.Carcinogen;
using CalRemix.Content.NPCs.Bosses.Hydrogen;
using CalRemix.Content.NPCs.Bosses.Hypnos;
using CalRemix.Content.NPCs.Bosses.Ionogen;
using CalRemix.Content.NPCs.Bosses.Origen;
using CalRemix.Content.NPCs.Bosses.Oxygen;
using CalRemix.Content.NPCs.Bosses.Pathogen;
using CalRemix.Content.NPCs.Bosses.Phytogen;
using CalRemix.Content.NPCs.Bosses.Poly;
using CalRemix.Content.NPCs.Bosses.Pyrogen;
using CalRemix.Content.NPCs.Bosses.Wulfwyrm;
using CalRemix.Content.NPCs.Minibosses;
using CalRemix.Content.NPCs.PandemicPanic;
using CalRemix.Core.OutboundCompatibility;
using CalRemix.Core.World;
using CalRemix.UI;
using CalRemix.UI.Anomaly109;
using CalRemix.UI.Title;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Terraria;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using CalRemix.Content.Items.Weapons;
using CalRemix.Content.Buffs;
namespace CalRemix
{
public class CalRemix : Mod
{
internal static Mod CalMod = ModLoader.GetMod("CalamityMod");
internal static Mod CalMusic = ModLoader.GetMod("CalamityModMusic");
public static CalRemix instance;
public static List<int> oreList = new List<int>
{
TileID.Copper,
TileID.Tin,
TileID.Iron,
TileID.Lead,
TileID.Silver,
TileID.Tungsten,
TileID.Gold,
TileID.Platinum
};
// Defer mod call handling to the extraneous mod call manager.
public override object Call(params object[] args) => ModCallManager.Call(args);
public override void HandlePacket(BinaryReader reader, int whoAmI) => CalRemixPacketManager.HandlePacket(reader, whoAmI);
public override void Load()
{
instance = this;
PlagueGlobalNPC.PlagueHelper = new PlagueJungleHelper();
}
public override void Unload()
{
instance = null;
PlagueGlobalNPC.PlagueHelper = null;
}
public override void PostSetupContent()
{
// Calamity Calls
Mod cal = CalMod;
cal.Call("DeclareMiniboss", NPCType<LifeSlime>());
cal.Call("DeclareMiniboss", NPCType<Clamitas>());
cal.Call("DeclareMiniboss", NPCType<OnyxKinsman>());
cal.Call("DeclareMiniboss", NPCType<CyberDraedon>());
cal.Call("DeclareMiniboss", NPCType<PlagueEmperor>());
cal.Call("DeclareMiniboss", NPCType<YggdrasilEnt>());
cal.Call("DeclareMiniboss", NPCType<KingMinnowsPrime>());
cal.Call("DeclareMiniboss", NPCType<Dendritiator>());
cal.Call("MakeItemExhumable", ItemType<YharimsGift>(), ItemType<YharimsCurse>());
cal.Call("DeclareOneToManyRelationshipForHealthBar", NPCType<Hypnos>(), NPCType<HypnosPlug>());
cal.Call("DeclareOneToManyRelationshipForHealthBar", NPCType<Phytogen>(), NPCType<PineappleFrond>());
//cal.Call("DeclareOneToManyRelationshipForHealthBar", NPCType<DerellectBoss>(), NPCType<SignalDrone>());
//cal.Call("DeclareOneToManyRelationshipForHealthBar", NPCType<DerellectBoss>(), NPCType<DerellectPlug>());
AddEnchantments(cal);
if (!ModLoader.HasMod("InfernumMode") && !ModLoader.HasMod("FargowiltasCrossmod"))
LoadBossRushEntries(cal);
RefreshBestiary();
for (int i = 0; i < ItemLoader.ItemCount; i++)
{
if (ItemLoader.GetItem(i) is null)
continue;
ModItem item = ItemLoader.GetItem(i);
if (item.Type == ItemType<WulfrumMetalScrap>())
continue;
if (!CalRemixAddon.Names.Contains(item.Mod.Name) || Main.itemAnimations[item.Type] != null || item is DebuffStone || item is BouncyRogue || item is StickyRogue || item is AutoloadedLegendPortraitItem || item is LegendMemorialItem || item is LegendPromoItem)
continue;
CalRemixAddon.Items.Add(item);
}
// Menu
if (GetInstance<CalRemixConfig>().forcedMenu)
{
try
{
CalRemixConfig config = GetInstance<CalRemixConfig>();
if (typeof(MenuLoader).GetField("LastSelectedModMenu", BindingFlags.Static | BindingFlags.NonPublic) is null)
return;
ModMenu menu = ((Main.rand.NextBool(4) && config.randomMenu) || config.useSecondMenu) ? CalRemixMenu2.Instance : CalRemixMenu.Instance;
if (menu is null)
return;
MenuStuff(menu);
}
catch (Exception e)
{
Console.WriteLine("\n\n\n\n\n\n\n\n\n\n");
Console.WriteLine("CalRemixMenu");
Console.WriteLine(e.ToString());
Console.WriteLine("\n\n\n\n\n\n\n\n\n\n");
}
}
// all for the eight seconds its all worth it
cal.Call("RegisterDebuff", "CalRemix/Content/Buffs/Bleeding", (NPC npc) => npc.HasBuff(BuffID.Bleeding));
cal.Call("RegisterDebuff", "CalRemix/Content/Buffs/RealityBearerForClopsBuff", (NPC npc) => npc.HasBuff<RealityBearerForClopsBuff>());
CalRemixPlayer.LoadDyeStats();
}
private static void MenuStuff(ModMenu menu)
{
if (menu.FullName is null)
return;
typeof(MenuLoader).GetField("LastSelectedModMenu", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, menu.FullName);
if ((ModMenu)typeof(MenuLoader).GetField("switchToMenu", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) is null || menu is null)
return;
if (((ModMenu)typeof(MenuLoader).GetField("switchToMenu", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)).FullName is null || menu.FullName is null)
return;
}
internal void AddEnchantments(Mod cal)
{
LocalizedText defiant = Language.GetOrRegister($"Mods.{nameof(CalRemix)}.Enchantments.Defiant.Name");
LocalizedText defiantDesc = Language.GetOrRegister($"Mods.{nameof(CalRemix)}.Enchantments.Defiant.Description");
cal.Call("CreateEnchantment", defiant, defiantDesc, 150, new Predicate<Item>(DefiantEnchantable), "CalRemix/Assets/ExtraTextures/Enchantments/EnchantmentRuneDefiant", delegate (Player player)
{
player.GetModPlayer<CalRemixPlayer>().earthEnchant = true;
});
LocalizedText fallacious = Language.GetOrRegister($"Mods.{nameof(CalRemix)}.Enchantments.Fallacious.Name");
LocalizedText fallaciousDesc = Language.GetOrRegister($"Mods.{nameof(CalRemix)}.Enchantments.Fallacious.Description");
cal.Call("CreateEnchantment", fallacious, fallaciousDesc, 156, new Predicate<Item>(FallaciousEnchantable), "CalRemix/Assets/ExtraTextures/Enchantments/EnchantmentRuneFallacious", delegate (Player player)
{
player.GetModPlayer<CalRemixPlayer>().amongusEnchant = true;
});
}
internal static bool DefiantEnchantable(Item item)
{
return item.IsEnchantable() && item.damage > 0;
}
internal static bool FallaciousEnchantable(Item item)
{
return item.IsEnchantable() && item.damage > 0 && !item.CountsAsClass<SummonDamageClass>() && !item.IsWhip();
}
internal static void LoadBossRushEntries(Mod cal)
{
List<(int, int, Action<int>, int, bool, float, int[], int[])> brEntries = (List<(int, int, Action<int>, int, bool, float, int[], int[])>)cal.Call("GetBossRushEntries");
AddToBossRush(ref brEntries, NPCID.KingSlime, NPCType<WulfwyrmHead>(), [NPCType<WulfwyrmBody>(), NPCType<WulfwyrmTail>()]);
AddToBossRush(ref brEntries, NPCID.KingSlime, NPCType<Origen>(), [NPCType<OrigenCore>()], [NPCType<OrigenCore>()]);
AddToBossRush(ref brEntries, NPCType<Crabulon>(), NPCType<AcidEye>(), [NPCType<MutatedEye>()], needsNight: true);
AddToBossRush(ref brEntries, NPCID.Deerclops, NPCType<Carcinogen>(), [NPCType<CarcinogenShield>()]);
AddToBossRush(ref brEntries, NPCType<CalamitasClone>(), NPCType<Ionogen>(), [NPCType<IonogenShield>()]);
AddToBossRush(ref brEntries, NPCID.Plantera, NPCType<Oxygen>(), [NPCType<OxygenShield>()]);
AddToBossRush(ref brEntries, NPCType<Anahita>(), NPCType<Polyphemalus>(), [NPCType<Astigmageddon>(), NPCType<Exotrexia>(), NPCType<Conjunctivirus>(), NPCType<Cataractacomb>()], [NPCType<Astigmageddon>(), NPCType<Exotrexia>(), NPCType<Conjunctivirus>(), NPCType<Cataractacomb>()], true);
AddToBossRush(ref brEntries, NPCID.Golem, NPCType<Phytogen>(), [NPCType<PhytogenShield>(), NPCType<PineappleFrond>()]);
AddToBossRush(ref brEntries, NPCType<PlaguebringerGoliath>(), NPCType<Hydrogen>(), [NPCType<HydrogenShield>()]);
AddToBossRush(ref brEntries, NPCID.CultistBoss, NPCType<Pathogen>(), [NPCType<PathogenShield>()]);
AddToBossRush(ref brEntries, NPCType<CeaselessVoid>(), NPCType<Pyrogen>(), [NPCType<PyrogenShield>()]);
AddToBossRush(ref brEntries, NPCType<Draedon>(), NPCType<Hypnos>(), [NPCType<AergiaNeuron>(), NPCType<HypnosPlug>()]);
//AddToBossRush(ref brEntries, NPCType<SupremeCalamitas>(), NPCType<Losbaf>(), [NPCType<Losbaf>()]);
foreach (var entry in brEntries)
{
if (entry.Item1 == NPCType<OldDuke>())
{
brEntries.Remove(entry);
break;
}
}
cal.Call("SetBossRushEntries", brEntries);
}
/// <summary>
///
/// </summary>
/// <param name="brEntries">Just pass in the boss rush list, cmon you can do it!</param>
/// <param name="beforeBossType">The boss that is fought directly after the boss you want to insert</param>
/// <param name="NPCType">The boss you want to insert</param>
/// <param name="extraNPCs">Minions/parts of the boss</param>
/// <param name="needsNight">Sets time to night if true</param>
public static void AddToBossRush(ref List<(int, int, Action<int>, int, bool, float, int[], int[])> brEntries, int beforeBossType, int NPCType, int[] extraNPCs, int[] needsDead = default, bool needsNight = false, Action<int> customAction = default)
{
int bossidx = -1;
for (int i = 0; i < brEntries.Count; i++)
{
if (brEntries[i].Item1 == beforeBossType)
{
bossidx = i;
break;
}
}
if (bossidx == -1)
return;
int[] headID = [NPCType];
if (needsDead != default)
{
headID = needsDead;
}
Action<int> pr2 = delegate (int npc)
{
CalRemixHelper.SpawnNPCOnPlayer(CalamityMod.Events.BossRushEvent.ClosestPlayerToWorldCenter, NPCType);
};
if (customAction != default)
{
pr2 = customAction;
}
brEntries.Insert(bossidx, (NPCType, -1, pr2, 45, needsNight, 0f, extraNPCs, headID));
}
public static void RefreshBestiary()
{
ContentSamples.RebuildBestiarySortingIDsByBestiaryDatabaseContents(Main.BestiaryDB);
ItemDropDatabase itemDropDatabase = new ItemDropDatabase();
itemDropDatabase.Populate();
Main.ItemDropsDB = itemDropDatabase;
Main.BestiaryDB.Merge(Main.ItemDropsDB);
if (!Main.dedServ)
{
Main.BestiaryUI = new Terraria.GameContent.UI.States.UIBestiaryTest(Main.BestiaryDB);
}
}
}
}