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
/
Tremor.cs
360 lines (313 loc) · 16.4 KB
/
Tremor.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.UI;
using Tremor.Invasion;
using Tremor.NPCs.Bosses.NovaPillar;
using Tremor.ZombieEvent;
namespace Tremor
{
public class Tremor : Mod
{
internal static Tremor instance;
public Tremor()
{
Properties = new ModProperties
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public static void Log(object message)
{
ErrorLogger.Log($"[Tremor][{DateTime.Now:yyyy-MM-dd hh:mm:ss}] {message}");
}
public static void Log(string format, params object[] args)
{
ErrorLogger.Log($"[Tremor][{DateTime.Now:yyyy-MM-dd hh:mm:ss}] {string.Format(format, args)}");
}
public override void AddRecipeGroups()
{
RecipeGroup group = new RecipeGroup(() => Language.GetTextValue("LegacyMisc.37") + " " + Lang.GetItemNameValue(ItemType("AmethystStaff")), ItemType("AmethystStaff"), ItemType("DiamondStaff"), ItemType("RubyStaff"), ItemType("TopazStaff"), ItemType("SapphireStaff"), ItemType("AmberStaff"), ItemType("EmeraldStaff"));
RecipeGroup.RegisterGroup("Tremor:GemStaves", group);
}
public override void UpdateMusic(ref int music)
{
if (Main.myPlayer != -1 && !Main.gameMenu)
{
int[] noOverride =
{
MusicID.Boss1, MusicID.Boss2, MusicID.Boss3, MusicID.Boss4, MusicID.Boss5,
MusicID.LunarBoss, MusicID.PumpkinMoon, MusicID.TheTowers, MusicID.FrostMoon, MusicID.GoblinInvasion,
MusicID.Eclipse, MusicID.MartianMadness, MusicID.PirateInvasion,
GetSoundSlot(SoundType.Music, "Sounds/Music/CyberKing"),
GetSoundSlot(SoundType.Music, "Sounds/Music/Boss6"),
GetSoundSlot(SoundType.Music, "Sounds/Music/Trinity"),
GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeRain"),
GetSoundSlot(SoundType.Music, "Sounds/Music/EvilCorn"),
GetSoundSlot(SoundType.Music, "Sounds/Music/TikiTotem"),
GetSoundSlot(SoundType.Music, "Sounds/Music/CogLord"),
GetSoundSlot(SoundType.Music, "Sounds/Music/NightOfUndead"),
GetSoundSlot(SoundType.Music, "Sounds/Music/CyberWrath")
};
int m = music;
bool playMusic =
!noOverride.Any(song => song == m)
|| !Main.npc.Any(npc => npc.boss);
Player player = Main.LocalPlayer;
if (player.active && player.GetModPlayer<TremorPlayer>(this).ZoneGranite && playMusic)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Granite");
}
if (ZWorld.ZInvasion && playMusic)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/NightOfUndead");
}
if (InvasionWorld.CyberWrath)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/CyberWrath");
}
if (player.active && NPC.AnyNPCs(NPCType("CogLord")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/CogLord");
}
if (player.active && NPC.AnyNPCs(50))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Boss6");
}
if (player.active && (NPC.AnyNPCs(NPCType("TikiTotem")) || NPC.AnyNPCs(NPCType("HappySoul")) || NPC.AnyNPCs(NPCType("AngerSoul")) || NPC.AnyNPCs(NPCType("IndifferenceSoul"))))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/TikiTotem");
}
if (player.active && NPC.AnyNPCs(NPCType("EvilCorn")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/EvilCorn");
}
if (player.active && Main.invasionType == 2)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Boss6");
}
if (player.active && Main.slimeRain && !NPC.AnyNPCs(50) && !Main.eclipse && playMusic)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeRain");
}
if (player.active && NPC.AnyNPCs(NPCType("SoulofTruth")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Trinity");
}
if (player.active && NPC.AnyNPCs(NPCType("SoulofTrust")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Trinity");
}
if (player.active && NPC.AnyNPCs(NPCType("SoulofHope")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Trinity");
}
if (player.active && NPC.AnyNPCs(NPCType("FrostKing")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Boss6");
}
if (player.active && NPC.AnyNPCs(NPCType("CyberKing")))
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/CyberKing");
}
if (Main.cloudAlpha > 0f &&
player.position.Y <
Main.worldSurface * 16.0 + Main.screenHeight / 2 && player.ZoneSnow && playMusic)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Snow2");
}
if (player.active && player.GetModPlayer<TremorPlayer>(this).ZoneIce && !Main.gameMenu && playMusic)
{
music = GetSoundSlot(SoundType.Music, "Sounds/Music/Snow2");
}
}
}
public override void PostSetupContent()
{
Mod bossChecklist = ModLoader.GetMod("BossChecklist");
if (bossChecklist != null)
{
//SlimeKing = 1f;
//EyeOfCthulhu = 2f;
//EaterOfWorlds = 3f;
//QueenBee = 4f;
//Skeletron = 5f;
//WallOfFlesh = 6f;
//TheTwins = 7f;
//TheDestroyer = 8f;
//SkeletronPrime = 9f;
//Plantera = 10f;
//Golem = 11f;
//DukeFishron = 12f;
//LunaticCultist = 13f;
//Moonlord = 14f;
bossChecklist.Call("AddBossWithInfo", "Rukh", 2.7f, (Func<bool>)(() => TremorWorld.Boss.Rukh.IsDowned()), "Use a [i:" + ItemType("DesertCrown") + "]");// in Desert
bossChecklist.Call("AddBossWithInfo", "Tiki Totem", 3.3f, (Func<bool>)(() => TremorWorld.Boss.TikiTotem.IsDowned()), "Use a [i:" + ItemType("MysteriousDrum") + "]");//in Jungle at night after beating Eye of Cthulhu
bossChecklist.Call("AddBossWithInfo", "Evil Corn", 3.4f, (Func<bool>)(() => TremorWorld.Boss.EvilCorn.IsDowned()), "Use a [i:" + ItemType("CursedPopcorn") + "]");// at night
bossChecklist.Call("AddBossWithInfo", "Storm Jellyfish", 3.5f, (Func<bool>)(() => TremorWorld.Boss.StormJellyfish.IsDowned()), "Use a [i:" + ItemType("StormJelly") + "]");
bossChecklist.Call("AddBossWithInfo", "Ancient Dragon", 3.6f, (Func<bool>)(() => TremorWorld.Boss.AncientDragon.IsDowned()), "Use a [i:" + ItemType("RustyLantern") + "]");//in Ruins after pressing with RMB on Ruin Altar and getting Ruin Powers buff
bossChecklist.Call("AddBossWithInfo", "Fungus Beetle", 5.6f, (Func<bool>)(() => TremorWorld.Boss.FungusBeetle.IsDowned()), "Use a [i:" + ItemType("MushroomCrystal") + "]");
bossChecklist.Call("AddBossWithInfo", "Heater of Worlds", 5.5f, (Func<bool>)(() => TremorWorld.Boss.HeaterofWorlds.IsDowned()), "Use a [i:" + ItemType("MoltenHeart") + "]");// in Underworld
bossChecklist.Call("AddBossWithInfo", "Alchemaster", 6.5f, (Func<bool>)(() => TremorWorld.Boss.Alchemaster.IsDowned()), "Use a [i:" + ItemType("AncientMosaic") + "]");// at night
bossChecklist.Call("AddBossWithInfo", "Motherboard (Destroyer alt)", 8.01f, (Func<bool>)(() => TremorWorld.Boss.Motherboard.IsDowned()), "Use a [i:" + ItemType("MechanicalBrain") + "]");//at night
bossChecklist.Call("AddBossWithInfo", "Pixie Queen", 9.6f, (Func<bool>)(() => TremorWorld.Boss.PixieQueen.IsDowned()), "Use a [i:" + ItemType("PixieinaJar") + "]");// in Hallow at night
bossChecklist.Call("AddBossWithInfo", "Wall of Shadows", 10.7f, (Func<bool>)(() => TremorWorld.Boss.WallOfShadow.IsDowned()), "Use a [i:" + ItemType("ShadowRelic") + "]");//into lava in Underworld after beating Plantera and having the Dryad alive
bossChecklist.Call("AddBossWithInfo", "Frost King", 10.6f, (Func<bool>)(() => TremorWorld.Boss.FrostKing.IsDowned()), "Use a [i:" + ItemType("FrostCrown") + "]");//in Snow
bossChecklist.Call("AddBossWithInfo", "Cog Lord", 11.4f, (Func<bool>)(() => TremorWorld.Boss.CogLord.IsDowned()), "Use a [i:" + ItemType("ArtifactEngine") + "]");//at night
bossChecklist.Call("AddBossWithInfo", "Mothership and Cyber King", 11.5f, (Func<bool>)(() => TremorWorld.Boss.CyberKing.IsDowned()), "Use a [i:" + ItemType("AdvancedCircuit") + "], Cyber King spawns after defeating the Mothership");//Cyber King spawns after defeating the Mothership
bossChecklist.Call("AddBossWithInfo", "Nova Pillar", 13.5f, (Func<bool>)(() => TremorWorld.Boss.NovaPillar.IsDowned()), "Kill the Lunatic Cultist outside the dungeon");
bossChecklist.Call("AddBossWithInfo", "The Dark Emperor", 14.4f, (Func<bool>)(() => TremorWorld.Boss.DarkEmperor.IsDowned()), "Use a [i:" + ItemType("EmperorCrown") + "]");
bossChecklist.Call("AddBossWithInfo", "Brutallisk", 14.5f, (Func<bool>)(() => TremorWorld.Boss.Brutallisk.IsDowned()), "Use a [i:" + ItemType("RoyalEgg") + "]");// in Desert
bossChecklist.Call("AddBossWithInfo", "Space Whale", 14.6f, (Func<bool>)(() => TremorWorld.Boss.SpaceWhale.IsDowned()), "Use a [i:" + ItemType("CosmicKrill") + "]");
bossChecklist.Call("AddBossWithInfo", "The Trinity", 14.7f, (Func<bool>)(() => TremorWorld.Boss.Trinity.IsDowned()), "Use a [i:" + ItemType("StoneofKnowledge") + "]");//at night
bossChecklist.Call("AddBossWithInfo", "Andas", 14.8f, (Func<bool>)(() => TremorWorld.Boss.Andas.IsDowned()), "Use a [i:" + ItemType("InfernoSkull") + "]");//at Underworld
}
}
public override void Unload()
{
instance = null;
if (!Main.dedServ)
{
TremorGlowMask.Unload();
Main.itemTexture[3601] = Main.instance.OurLoad<Texture2D>(string.Concat(new object[] { "Images", Path.DirectorySeparatorChar, "Item_3601" }));
for (int i = 1; i < 206; i++)
{
Main.buffTexture[i] = Main.instance.OurLoad<Texture2D>(string.Concat(new object[] { "Images", Path.DirectorySeparatorChar, "Buff_" + i }));
}
}
}
public override void Load()
{
instance = this;
Filters.Scene["Tremor:Invasion"] = new Filter(new InvasionData("FilterMiniTower").UseColor(0.2f, 0.4f, 0.5f).UseOpacity(0.9f), EffectPriority.VeryHigh);
SkyManager.Instance["Tremor:Invasion"] = new ZombieSky();
Filters.Scene["Tremor:Zombie"] = new Filter(new ZombieScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.6f), EffectPriority.VeryHigh);
SkyManager.Instance["Tremor:Zombie"] = new ZombieSky();
Filters.Scene["Tremor:Ice"] = new Filter(new ZombieScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.8f, 1.0f).UseOpacity(0.6f), EffectPriority.VeryHigh);
SkyManager.Instance["Tremor:Ice"] = new ZombieSky();
Filters.Scene["Tremor:CogLord"] = new Filter(new ZombieScreenShaderData("FilterMiniTower").UseColor(0.9f, 0.5f, 0.2f).UseOpacity(0.6f), EffectPriority.VeryHigh);
SkyManager.Instance["Tremor:CogLord"] = new ZombieSky();
// Init
NPCDrops.Init();
TremorWorld.Init();
if (!Main.dedServ)
{
string[,] musicBoxes =
{
{ "CogLord", "CogLordMusicBox", "CogLordMusicBox" },
{ "SlimeRain", "SlimeRainMusicBox", "SlimeRainMusicBox" },
{ "Boss6", "Boss6MusicBox", "Boss6MusicBox" },
{ "Trinity", "TrinityMusicBox", "TrinityMusicBox" },
{ "TikiTotem", "TikiTotemMusicBox", "TikiTotemMusicBox" },
{ "EvilCorn", "EvilCornMusicBox", "EvilCornMusicBox" },
{ "CyberKing", "CyberKingMusicBox", "CyberKingMusicBox" },
{ "Snow2", "BlizzardMusicBox", "BlizzardMusicBox" },
{ "CyberWrath", "ParadoxCohortMusicBox", "ParadoxCohortMusicBoxTile" },
{ "NightOfUndead", "DeathHordeMusicBox", "DeathHordeMusicBoxTile" },
{ "Granite", "GraniteMusicBox", "GraniteMusicBox" },
};
for (int i = 0; i < musicBoxes.GetUpperBound(0) + 1; i++)
{
AddMusicBox(GetSoundSlot(SoundType.Music, $"Sounds/Music/{musicBoxes[i, 0]}"), ItemType(musicBoxes[i, 1]), TileType(musicBoxes[i, 2]));
}
GameShaders.Armor.BindShader(ItemType("NovaDye"), new ArmorShaderData(Main.PixelShaderRef, "ArmorSolar")).UseColor(0.8f, 0.7f, 0.3f).UseSecondaryColor(0.8f, 0.7f, 0.3f);
NovaSky.PlanetTexture = GetTexture("NPCs/Bosses/NovaPillar/NovaPlanet");
Filters.Scene["Tremor:Nova"] = new Filter(new NovaData("FilterMiniTower").UseColor(0.8f, 0.7f, 0.3f).UseOpacity(0.82f), EffectPriority.VeryHigh);
SkyManager.Instance["Tremor:Nova"] = new NovaSky();
// Replace celestial sigil?
Main.itemTexture[3601] = GetTexture($"Resprites/{(ModLoader.GetLoadedMods().Contains("Elerium") ? "CelestialSigil2" : "CelestialSigil")}");
// Replace vanilla buff sprites with resprites
for (int i = 1; i < 206; i++)
{
Main.buffTexture[i] = GetTexture($"Resprites/Buff_{i}");
}
}
}
public override void AddRecipes()
{
// Recipe wrapper
RecipeUtils.AddRecipes(this);
RecipeUtils.AdaptToNovaRecipes(this);
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
if (InvasionWorld.CyberWrath)
{
int index = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));
LegacyGameInterfaceLayer orionProgress = new LegacyGameInterfaceLayer("Tremor: Invasion2",
delegate
{
DrawOrionEvent(Main.spriteBatch);
return true;
},
InterfaceScaleType.UI);
layers.Insert(index, orionProgress);
}
}
public void DrawOrionEvent(SpriteBatch spriteBatch)
{
if (InvasionWorld.CyberWrath && !Main.gameMenu)
{
float scaleMultiplier = 0.5f + 1 * 0.5f;
float alpha = 0.5f;
Texture2D progressBg = Main.colorBarTexture;
Texture2D progressColor = Main.colorBarTexture;
Texture2D orionIcon = Tremor.instance.GetTexture("Invasion/InvasionIcon");
const string orionDescription = "Paradox Cohort";
Color descColor = new Color(39, 86, 134);
Color waveColor = new Color(255, 241, 51);
Color barrierColor = new Color(255, 241, 51);
try
{
//draw the background for the waves counter
const int offsetX = 20;
const int offsetY = 20;
int width = (int)(200f * scaleMultiplier);
int height = (int)(46f * scaleMultiplier);
Rectangle waveBackground = Utils.CenteredRectangle(new Vector2(Main.screenWidth - offsetX - 100f, Main.screenHeight - offsetY - 23f), new Vector2(width, height));
Utils.DrawInvBG(spriteBatch, waveBackground, new Color(63, 65, 151, 255) * 0.785f);
//draw wave text
string waveText = "Cleared " + InvasionWorld.CyberWrathPoints1 + "%";
Utils.DrawBorderString(spriteBatch, waveText, new Vector2(waveBackground.X + waveBackground.Width / 2, waveBackground.Y), Color.White, scaleMultiplier, 0.5f, -0.1f);
//draw the progress bar
if (InvasionWorld.CyberWrathPoints1 == 0)
{
}
Rectangle waveProgressBar = Utils.CenteredRectangle(new Vector2(waveBackground.X + waveBackground.Width * 0.5f, waveBackground.Y + waveBackground.Height * 0.75f), new Vector2(progressColor.Width, progressColor.Height));
Rectangle waveProgressAmount = new Rectangle(0, 0, (int)(progressColor.Width * 0.01f * MathHelper.Clamp(InvasionWorld.CyberWrathPoints1, 0f, 100f)), progressColor.Height);
Vector2 offset = new Vector2((waveProgressBar.Width - (int)(waveProgressBar.Width * scaleMultiplier)) * 0.5f, (waveProgressBar.Height - (int)(waveProgressBar.Height * scaleMultiplier)) * 0.5f);
spriteBatch.Draw(progressBg, waveProgressBar.Location.ToVector2() + offset, null, Color.White * alpha, 0f, new Vector2(0f), scaleMultiplier, SpriteEffects.None, 0f);
spriteBatch.Draw(progressBg, waveProgressBar.Location.ToVector2() + offset, waveProgressAmount, waveColor, 0f, new Vector2(0f), scaleMultiplier, SpriteEffects.None, 0f);
//draw the icon with the event description
//draw the background
const int internalOffset = 6;
Vector2 descSize = new Vector2(154, 40) * scaleMultiplier;
Rectangle barrierBackground = Utils.CenteredRectangle(new Vector2(Main.screenWidth - offsetX - 100f, Main.screenHeight - offsetY - 19f), new Vector2(width, height));
Rectangle descBackground = Utils.CenteredRectangle(new Vector2(barrierBackground.X + barrierBackground.Width * 0.5f, barrierBackground.Y - internalOffset - descSize.Y * 0.5f), descSize);
Utils.DrawInvBG(spriteBatch, descBackground, descColor * alpha);
//draw the icon
int descOffset = (descBackground.Height - (int)(32f * scaleMultiplier)) / 2;
Rectangle icon = new Rectangle(descBackground.X + descOffset, descBackground.Y + descOffset, (int)(32 * scaleMultiplier), (int)(32 * scaleMultiplier));
spriteBatch.Draw(orionIcon, icon, Color.White);
//draw text
Utils.DrawBorderString(spriteBatch, orionDescription, new Vector2(barrierBackground.X + barrierBackground.Width * 0.5f, barrierBackground.Y - internalOffset - descSize.Y * 0.5f), Color.White, 0.80f, 0.3f, 0.4f);
}
catch (Exception e)
{
ErrorLogger.Log(e.ToString());
}
}
}
}
}