Added the Astral Beacon

Note: This will use a schematic, much like the arsenal structures, but a building is still required and the schematic handling code is not on the master branch yet.
This commit is contained in:
DominicKarma42 committed 2020-06-23 01:22:16 -05:00
1 parent 9eeed6e0ce
commit 7e755128be
12 files changed
+370 -72

No files matched your search

-1
View File
@@ -109,7 +109,6 @@ namespace CalamityMod
// Boss Spawners
public static int ghostKillCount = 0;
public static int sharkKillCount = 0;
public static int astralKillCount = 0;
// Textures & Shaders
public static Texture2D heartOriginal2;
+22
View File
@@ -0,0 +1,22 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Items.Materials
{
public class TitanHeart : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Titan Heart");
}
public override void SetDefaults()
{
item.width = 10;
item.height = 10;
item.maxStack = 999;
item.value = Item.sellPrice(silver: 5);
item.rare = 4;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

+1 -19
View File
@@ -1,8 +1,6 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Items.Potions;
using CalamityMod.NPCs.AstrumDeus;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -14,7 +12,7 @@ namespace CalamityMod.Items.SummonItems
{
DisplayName.SetDefault("Starcore");
Tooltip.SetDefault("May the stars guide your way\n" +
"Summons Astrum Deus\n" +
"Summons Astrum Deus at the Astral Beacon\n" +
"Not consumable");
}
@@ -29,22 +27,6 @@ namespace CalamityMod.Items.SummonItems
item.consumable = false;
}
public override bool CanUseItem(Player player)
{
return !Main.dayTime && player.Calamity().ZoneAstral && !NPC.AnyNPCs(ModContent.NPCType<AstrumDeusHeadSpectral>());
}
public override bool UseItem(Player player)
{
Main.PlaySound(SoundID.Roar, player.position, 0);
if (Main.netMode != NetmodeID.MultiplayerClient)
NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType<AstrumDeusHeadSpectral>());
else
NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType<AstrumDeusHeadSpectral>());
return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
+2 -2
View File
@@ -95,8 +95,8 @@ namespace CalamityMod.Localization
new [] { "AureusBossText2", "A faint ethereal click can be heard from the dungeon." },
new [] { "AstralBossText", "The seal of the stars has been broken! You can now mine Astral Ore." },
new [] { "DeusText", "A star-spawned horror tunnels through the astral infection." },
new [] { "DeusText2", "The astral infection trembles..." },
new [] { "DeusText3", "The god of the stars draws near..." },
new [] { "DeusAltarRejectText", "The god of the stars rejects your offering. You must unleash the power of the lunar Cultist to perform the ritual." },
new [] { "DeusAltarRejectNightText", "The god of the stars rejects your offering. The ritual can only be performed at night." },
new [] { "CalamitasBossText", "You underestimate my power..." },
new [] { "CalamitasBossText2", "The brothers have been reborn!" },
+1
View File
@@ -635,6 +635,7 @@ namespace CalamityMod.NPCs.Astral
int minStardust = Main.expertMode ? 7 : 6;
int maxStardust = Main.expertMode ? 9 : 8;
DropHelper.DropItem(npc, ModContent.ItemType<Stardust>(), minStardust, maxStardust);
DropHelper.DropItemChance(npc, ModContent.ItemType<TitanHeart>(), 2, 1, 2);
DropHelper.DropItemCondition(npc, ModContent.ItemType<TitanArm>(), CalamityWorld.downedAstrageldon, 7, 1, 1);
//not guarantee to prevent inventory spam
}
-49
View File
@@ -1296,55 +1296,6 @@ namespace CalamityMod.NPCs
}
}
}
if (NPC.downedAncientCultist && !CalamityWorld.downedStarGod && npc.type == ModContent.NPCType<Atlas>() && !NPC.AnyNPCs(ModContent.NPCType<AstrumDeusHeadSpectral>()))
{
CalamityMod.astralKillCount++;
if (CalamityMod.astralKillCount == 1)
{
string key = "Mods.CalamityMod.DeusText2";
Color messageColor = Color.Gold;
if (Main.netMode == NetmodeID.SinglePlayer)
{
Main.NewText(Language.GetTextValue(key), messageColor);
}
else if (Main.netMode == NetmodeID.Server)
{
NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor);
}
}
else if (CalamityMod.astralKillCount == 2)
{
string key = "Mods.CalamityMod.DeusText3";
Color messageColor = Color.Gold;
if (Main.netMode == NetmodeID.SinglePlayer)
{
Main.NewText(Language.GetTextValue(key), messageColor);
}
else if (Main.netMode == NetmodeID.Server)
{
NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor);
}
}
if (CalamityMod.astralKillCount >= 3 && Main.netMode != NetmodeID.MultiplayerClient)
{
int lastPlayer = npc.lastInteraction;
if (!Main.player[lastPlayer].active || Main.player[lastPlayer].dead)
{
lastPlayer = npc.FindClosestPlayer();
}
if (lastPlayer >= 0)
{
CalamityWorld.ChangeTime(false);
NPC.SpawnOnPlayer(lastPlayer, ModContent.NPCType<AstrumDeusHeadSpectral>());
CalamityMod.astralKillCount = 0;
}
}
}
}
#endregion
+186
View File
@@ -0,0 +1,186 @@
using CalamityMod.Dusts;
using CalamityMod.NPCs.AstrumDeus;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class DeusRitualDrama : ModProjectile
{
public float Time
{
get => projectile.ai[0];
set => projectile.ai[0] = value;
}
public const int TotalSinePeriods = 6;
public const int PulseTime = 45;
public const int TotalRitualTime = 420;
public const float MaxUpwardRise = 540f;
public static readonly Point PulseSize = new Point(300, 300);
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Deus Ritual Drama");
}
public override void SetDefaults()
{
projectile.width = projectile.height = 2;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.timeLeft = TotalRitualTime;
}
public override void AI()
{
Time++;
if (Time == TotalRitualTime - PulseTime)
{
int idx = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y - (int)MaxUpwardRise, ModContent.NPCType<AstrumDeusHeadSpectral>(), 1);
if (idx != -1)
{
if (Main.netMode == NetmodeID.SinglePlayer)
{
Main.NewText(Language.GetTextValue("Announcement.HasAwoken", Main.npc[idx].TypeName), new Color(175, 75, 255));
return;
}
if (Main.netMode == NetmodeID.Server)
{
NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[]
{
Main.npc[idx].GetTypeNetName()
}), new Color(175, 75, 255));
return;
}
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, idx);
}
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
float upwardnessRatio = Utils.InverseLerp(60f, TotalRitualTime, Time, true);
float upwardness = MathHelper.Lerp(0f, MaxUpwardRise, upwardnessRatio);
if (Time >= TotalRitualTime - PulseTime)
{
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
float pulseCompletionRatio = Utils.InverseLerp(TotalRitualTime - PulseTime, TotalRitualTime, Time, true);
Vector2 scale = projectile.scale * (3f + pulseCompletionRatio * 5f) * new Vector2(1.5f, 1f);
DrawData drawData = new DrawData(ModContent.GetTexture("Terraria/Misc/Perlin"),
projectile.Center - Main.screenPosition + PulseSize.ToVector2() * scale * 0.5f - Vector2.UnitY * upwardness,
new Rectangle(0, 0, PulseSize.X, PulseSize.Y),
new Color(new Vector4(1f - (float)Math.Sqrt(pulseCompletionRatio))) * 0.66f,
projectile.rotation,
PulseSize.ToVector2(),
scale,
SpriteEffects.None, 0);
Color pulseColor = Color.Lerp(Color.Cyan * 1.5f, Color.OrangeRed, MathHelper.Clamp(pulseCompletionRatio * 1.5f, 0f, 1f));
GameShaders.Misc["ForceField"].UseColor(pulseColor);
GameShaders.Misc["ForceField"].Apply(drawData);
drawData.Draw(spriteBatch);
return false;
}
float outwardnessRatio = Utils.InverseLerp(60f, 220f, Time, true);
if (Time > 250f)
outwardnessRatio = 1f - Utils.InverseLerp(250f, TotalRitualTime - PulseTime, Time, true);
float outwardness = MathHelper.Lerp(0f, 140f, outwardnessRatio);
Vector2 offset = new Vector2((float)Math.Sin(Time / (TotalRitualTime - PulseTime) * MathHelper.TwoPi * TotalSinePeriods) * outwardness, -upwardness);
// If the stars "collide", generate some small explosion dust.
if (!Main.dedServ && Math.Abs(offset.X) < 6f && Time > 60f)
{
for (int i = 0; i < 20; i++)
{
Dust dust = Dust.NewDustPerfect(projectile.Center + Vector2.UnitY * offset.Y, 261);
dust.color = Utils.SelectRandom(Main.rand, Color.Cyan, Color.OrangeRed);
dust.scale = 1.15f;
dust.velocity = Main.rand.NextVector2CircularEdge(3f, 3f) * Main.rand.NextFloat(0.7f, 1.4f);
dust.noGravity = true;
float angle = MathHelper.TwoPi * i / 20f;
dust = Dust.NewDustPerfect(projectile.Center + Vector2.UnitY * offset.Y, 261);
dust.color = Utils.SelectRandom(Main.rand, Color.Cyan, Color.OrangeRed);
dust.scale = 1.15f;
dust.velocity = angle.ToRotationVector2() * 7f;
dust.noGravity = true;
}
}
DrawStars(spriteBatch, offset);
return false;
}
public void DrawStars(SpriteBatch spriteBatch, Vector2 offset)
{
Texture2D starTexture = ModContent.GetTexture(Texture);
for (int i = 0; i < 6; i++)
{
float angle = MathHelper.TwoPi * i / 6f + Time / 15f;
Vector2 angularOffset = angle.ToRotationVector2() * 4f;
spriteBatch.Draw(starTexture,
projectile.Center + angularOffset + offset - Main.screenPosition,
null,
Color.Cyan * 0.5f,
0f,
starTexture.Size() * 0.5f,
0.6f,
SpriteEffects.None,
0f);
spriteBatch.Draw(starTexture,
projectile.Center + angularOffset + offset * new Vector2(-1f, 1f) - Main.screenPosition,
null,
Color.OrangeRed * 0.5f,
0f,
starTexture.Size() * 0.5f,
0.6f,
SpriteEffects.None,
0f);
}
spriteBatch.Draw(starTexture,
projectile.Center + offset - Main.screenPosition,
null,
Color.Cyan * 1.4f,
0f,
starTexture.Size() * 0.5f,
0.6f,
SpriteEffects.None,
0f);
spriteBatch.Draw(starTexture,
projectile.Center + offset * new Vector2(-1f, 1f) - Main.screenPosition,
null,
Color.OrangeRed * 1.1f,
0f,
starTexture.Size() * 0.5f,
0.6f,
SpriteEffects.None,
0f);
// Generate dust at the star position. This gives them a trail effect.
if (!Main.dedServ)
{
Dust dust2 = Dust.NewDustPerfect(projectile.Center + offset, 261);
dust2.color = Color.Cyan;
dust2.scale = 1.15f;
dust2.velocity = Vector2.Zero;
dust2.noGravity = true;
dust2 = Dust.NewDustPerfect(projectile.Center + offset * new Vector2(-1f, 1f), 261);
dust2.color = Color.OrangeRed;
dust2.scale = 1.15f;
dust2.velocity = Vector2.Zero;
dust2.noGravity = true;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

+103
View File
@@ -0,0 +1,103 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.SummonItems;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.Projectiles.Boss;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace CalamityMod.Tiles.Astral
{
public class AstralBeacon : ModTile
{
public const int Width = 5;
public const int Height = 4;
public static readonly Color FailColor = new Color(237, 93, 83);
public override void SetDefaults()
{
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileSpelunker[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style5x4);
TileObjectData.addTile(Type);
ModTranslation name = CreateMapEntryName();
name.SetDefault("Astral Beacon");
AddMapEntry(new Color(128, 128, 158), name);
disableSmartCursor = true;
}
public override bool CanExplode(int i, int j) => false;
public override bool CanKillTile(int i, int j, ref bool blockDamaged) => false;
public override bool NewRightClick(int i, int j)
{
Tile tile = Main.tile[i, j];
int left = i - tile.frameX / 18;
int top = j - tile.frameY / 18;
if (!Main.LocalPlayer.HasItem(ModContent.ItemType<TitanHeart>()) &&
!Main.LocalPlayer.HasItem(ModContent.ItemType<Starcore>()))
return true;
if (NPC.AnyNPCs(ModContent.NPCType<AstrumDeusHeadSpectral>()))
return true;
if (CalamityUtils.CountProjectiles(ModContent.ProjectileType<DeusRitualDrama>()) > 0)
return true;
bool usingStarcore = Main.LocalPlayer.HasItem(ModContent.ItemType<Starcore>());
if (!NPC.downedAncientCultist)
{
string localizationKey = "Mods.CalamityMod.DeusAltarRejectText";
if (Main.netMode == NetmodeID.SinglePlayer)
Main.NewText(Language.GetTextValue(localizationKey), FailColor);
else if (Main.netMode == NetmodeID.Server)
NetMessage.BroadcastChatMessage(NetworkText.FromKey(localizationKey), FailColor);
return true;
}
if (Main.dayTime)
{
string localizationKey = "Mods.CalamityMod.DeusAltarRejectNightText";
if (Main.netMode == NetmodeID.SinglePlayer)
Main.NewText(Language.GetTextValue(localizationKey), FailColor);
else if (Main.netMode == NetmodeID.Server)
NetMessage.BroadcastChatMessage(NetworkText.FromKey(localizationKey), FailColor);
return false;
}
Vector2 ritualSpawnPosition = new Vector2(left + Width / 2, top).ToWorldCoordinates();
ritualSpawnPosition += new Vector2(0f, -24f);
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), ritualSpawnPosition);
Projectile.NewProjectile(ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType<DeusRitualDrama>(), 0, 0f, Main.myPlayer);
if (!usingStarcore)
Main.LocalPlayer.ConsumeItem(ModContent.ItemType<TitanHeart>(), true);
return true;
}
public override void MouseOver(int i, int j)
{
Main.LocalPlayer.showItemIcon2 = ModContent.ItemType<TitanHeart>();
if (Main.LocalPlayer.HasItem(ModContent.ItemType<Starcore>()))
Main.LocalPlayer.showItemIcon2 = ModContent.ItemType<Starcore>();
Main.LocalPlayer.noThrow = 2;
Main.LocalPlayer.showItemIcon = true;
}
public override void MouseOverFar(int i, int j)
{
Main.LocalPlayer.showItemIcon2 = ModContent.ItemType<TitanHeart>();
if (Main.LocalPlayer.HasItem(ModContent.ItemType<Starcore>()))
Main.LocalPlayer.showItemIcon2 = ModContent.ItemType<Starcore>();
Main.LocalPlayer.noThrow = 2;
Main.LocalPlayer.showItemIcon = true;
}
}
}
+13 -1
View File
@@ -525,5 +525,17 @@ namespace CalamityMod.Tiles
return new int[0];
}
}
public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged)
{
// Prevent tiles below an astral beacon from being destroyed.
if (CalamityUtils.ParanoidTileRetrieval(i, j - 1).active() &&
CalamityUtils.ParanoidTileRetrieval(i, j).type !=
CalamityUtils.ParanoidTileRetrieval(i, j - 1).type &&
CalamityUtils.ParanoidTileRetrieval(i, j - 1).type == ModContent.TileType<AstralBeacon>())
{
return false;
}
return base.CanKillTile(i, j, type, ref blockDamaged);
}
}
}
+42
View File
@@ -1598,15 +1598,57 @@ namespace CalamityMod.World
}
}
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
NetMessage.SendTileSquare(-1, i, j, 40, TileChangeType.None);
if (CanAstralBiomeSpawn())
{
DoAstralConversion(new Point(i, j));
GenerateAstralBeacon(i, j - 120);
}
}
return true;
}
public static void GenerateAstralBeacon(int roughX, int startY)
{
int x = roughX + WorldGen.genRand.Next(24, 72 + 1) * WorldGen.genRand.NextBool(2).ToDirectionInt();
int radius = WorldGen.genRand.Next(10, 13 + 1);
int y = startY;
while (!CalamityUtils.ParanoidTileRetrieval(x, y).active() ||
CalamityUtils.ParanoidTileRetrieval(x, y).type == TileID.Trees ||
CalamityUtils.ParanoidTileRetrieval(x, y).type == TileID.Cactus)
{
y++;
}
// Shove the meteor a bit into the ground.
y += radius / 2;
// Generate a base slime-shaped structure of astral stone.
WorldUtils.Gen(new Point(x, y), new Shapes.Slime(radius), Actions.Chain(new GenAction[]
{
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<AstralStone>())
}));
// And give it some astral ore to signify that it's an actual meteor.
for (int i = 0; i < 3; i++)
{
int x2 = x + WorldGen.genRand.Next(-2, 2 + 1);
int y2 = y + WorldGen.genRand.Next(-3, 3 + 1);
WorldUtils.Gen(new Point(x2, y2), new Shapes.Circle(WorldGen.genRand.Next(2, 4 + 1)), Actions.Chain(new GenAction[]
{
new Actions.ClearTile(),
new Actions.PlaceTile((ushort)ModContent.TileType<AstralOre>())
}));
}
// TODO - Use a schematic to generate the beacon when this code and the arsenal structure code are both on the master branch.
// Delete these comments once this is finished.
WorldGen.PlaceTile(x - AstralBeacon.Width / 2, y - radius - 1, ModContent.TileType<AstralBeacon>());
}
public static void DoAstralConversion(object obj)
{
//Pre-calculate all variables necessary for elliptical area checking