This commit is contained in:
Doze-Zoze committed 2026-07-20 19:38:54 -05:00
commit f897ae00a5
151 files changed
+2289 -978

No files matched your search

@@ -200,7 +200,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles
/// <summary>
/// Internal timer for the projectile's swing animation
/// </summary>
internal int swingTimer = 0;
public int swingTimer = 0;
public static Asset<Texture2D> TrailTexture;
@@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles
List<float> oldProjectileRot = new List<float> { };
List<Vector2> oldProjectilePos = new List<Vector2> { };
internal int ExistsTime = 20;
public int ExistsTime = 20;
public bool inStartup => timer < StartupTime;
public bool inCooldown => timer > CooldownStartFrame;
-3
View File
@@ -161,9 +161,6 @@ namespace CalamityMod.Projectiles.Boss
if (Projectile.owner == Main.myPlayer)
{
int totalProjectiles = !ProvUtils.StandardAI() ? 8 : 6;
if (Main.getGoodWorld)
totalProjectiles *= 2;
float radians = MathHelper.TwoPi / totalProjectiles;
int type = ModContent.ProjectileType<HolyBlastFrags>();
float velocity = 5f;
+158 -219
View File
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Dusts;
using CalamityMod.Effects;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs.Providence;
using CalamityMod.Particles;
using CalamityMod.Systems.Graphic;
using CalamityMod.Utilities.Daybreak;
using CalamityMod.Utilities.Daybreak.Buffers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Newtonsoft.Json.Serialization;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
@@ -20,14 +20,29 @@ namespace CalamityMod.Projectiles.Boss
{
public class HolyBurnOrb : ModProjectile, ILocalizedModType
{
private static Asset<Texture2D> TrailNoiseTexture;
private static Asset<Texture2D> TrailDistortionTexture;
private static Asset<Texture2D> GlowOrbTexture;
bool started = false;
public new string LocalizationCategory => "Projectiles.Boss";
public override string Texture => "CalamityMod/Projectiles/StarProj";
public override void Load()
{
if (!Main.dedServ)
{
TrailNoiseTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise");
TrailDistortionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2");
GlowOrbTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/GlowOrbParticle");
}
}
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 32;
ProjectileID.Sets.TrailingMode[Type] = 2;
ProjectileID.Sets.TrailCacheLength[Type] = 12;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
@@ -66,7 +81,7 @@ namespace CalamityMod.Projectiles.Boss
Projectile.timeLeft = 160;
}
if (Main.getGoodWorld)
if (!ProvUtils.StandardAI())
{
if (Projectile.velocity.Length() < 12f && Projectile.ai[1] == 0f)
{
@@ -74,8 +89,8 @@ namespace CalamityMod.Projectiles.Boss
}
else
{
Projectile.ai[1] += 0.05f;
Projectile.velocity *= MathHelper.Lerp(0.95f, 1.05f, (float)Math.Abs(Math.Sin(Projectile.ai[1])));
Projectile.ai[1] += 0.075f;
Projectile.velocity *= MathHelper.Lerp(0.95f, 1.05f, MathF.Abs(MathF.Sin(Projectile.ai[1])));
}
}
else if (Projectile.velocity.Length() < 16f)
@@ -87,59 +102,6 @@ namespace CalamityMod.Projectiles.Boss
Projectile.position -= (Projectile.velocity / Projectile.MaxUpdates) * (Projectile.MaxUpdates - 1);
}
public override bool PreDraw(ref Color lightColor)
{
//drawn by the HolyBurnOrbDrawer system
return false;
}
public float FireWidthFunction(float completion, Vector2 pos)
{
float width;
float maxBodyWidth = 32f * Projectile.scale;
float curveRatio = 0.2f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
// Crop the tip of the trail into a conic shape.
if (completion < curveRatio)
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
// Pulse inwards and outwards over time.
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireColorFunction(float completion, Vector2 pos)
{
Color mainColor = ProvUtils.GetProjectileColor(255) * 1.3f;
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity;
}
public float FireCoreWidthFunction(float completion, Vector2 pos)
{
float width;
float maxBodyWidth = Projectile.scale * 24;
float curveRatio = 0.25f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
if (completion < curveRatio)
width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireCoreColorFunction(float completion, Vector2 pos)
{
Color mainColor = ProvUtils.GetProjectileColor(255);
Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion);
return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity;
}
public override void OnKill(int timeLeft)
{
@@ -173,191 +135,168 @@ namespace CalamityMod.Projectiles.Boss
ProvUtils.ApplyDebuffs(target, 120);
}
}
public class HolyBurnOrbDrawer : ModSystem
{
public override void Load()
public float FireWidthFunction(float completion)
{
On_Main.DrawProjectiles += DrawAll;
float width;
float maxBodyWidth = 36f * Projectile.scale;
float curveRatio = 0.2f;
// Crop the tip of the trail into a conic shape.
if (completion < curveRatio)
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
// Pulse inwards and outwards over time.
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 12f) * 0.5f + 0.5f;
float additionalPulseWidth = MathHelper.Lerp(0f, 6f, pulseInterpolant);
return (width + additionalPulseWidth);
}
private void DrawAll(On_Main.orig_DrawProjectiles orig, Main self)
public Color FireColorFunction(float completion)
{
orig(self);
var device = Main.instance.GraphicsDevice;
List<Projectile> burnToDraw = [];
List<Projectile> healToDraw = [];
foreach (var item in Main.ActiveProjectiles)
{
if (item.type == ModContent.ProjectileType<HolyBurnOrb>())
burnToDraw.Add(item);
if (item.type == ModContent.ProjectileType<HolyLight>())
healToDraw.Add(item);
}
if ((healToDraw.Count() + burnToDraw.Count()) < 1)
return;
using (Main.spriteBatch.Scope())
{
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
//Burn trails
using (ProvUtils.PrimaryLease.Scope(clearColor: Color.Transparent))
{
foreach (var item in burnToDraw)
DrawBurnOrbTrail(item);
}
Main.spriteBatch.Draw(ProvUtils.PrimaryLease.Target, Vector2.Zero, null, Color.White * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
//Heal trail
using (ProvUtils.SecondaryLease.Scope(clearColor: Color.Transparent))
{
foreach (var item in healToDraw)
DrawHealOrbTrail(item);
}
Main.spriteBatch.Draw(ProvUtils.SecondaryLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
//Main orb
foreach (var item in burnToDraw)
DrawBurnOrb(item);
foreach (var item in healToDraw)
DrawHealOrb(item);
//Additive orb
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
foreach (var item in burnToDraw)
DrawBurnOrbAdditive(item);
foreach (var item in healToDraw)
DrawHealOrbAdditive(item);
Main.spriteBatch.End();
}
Color mainColor = Color.Lerp(ProvUtils.GetProjectileColor(255, true) * 2f, ProvUtils.GetProjectileColor(255), 0.75f);
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity;
}
void DrawBurnOrbTrail(Projectile Projectile)
public void DrawTrail()
{
if (Projectile.ModProjectile is HolyBurnOrb M)
Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f);
Vector2 basePosition = Projectile.Center - Main.screenPosition;
Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40);
if (screenBounds.Contains(basePosition.ToPoint()))
{
var tex = GeneralParticleHandler.GetTexture(GeneralParticleHandler.particleIDsByTypes[typeof(BloomParticle)]);
var len = Math.Min(Projectile.oldPos.Length, 32);
for (var i = 0; i < len; i++)
List<Vector3> path = [];
for (var i = 0; i < Projectile.oldPos.Length; i++)
{
Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Color color = M.FireColorFunction(i / (float)len, Projectile.oldPos[i]);
var color2 = ProvUtils.GetProjectileColor(255, true);
float width = M.FireWidthFunction(i / (float)len, Projectile.oldPos[i]);
Main.spriteBatch.Draw(tex, drawPos, null, (color2 with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width, SpriteEffects.None, 0f);
Main.spriteBatch.Draw(tex, drawPos, null, (color with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width * 0.25f, SpriteEffects.None, 0f);
Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition;
path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f));
}
if (path.Count > 2 && Projectile.ai[0] > 6)
{
Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value;
shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
shader.Parameters["glowPower"].SetValue(1.48f);
Main.graphics.GraphicsDevice.Textures[0] = TrailNoiseTexture.Value;
Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
Main.graphics.GraphicsDevice.Textures[1] = TrailDistortionTexture.Value;
Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection);
using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => FireWidthFunction(progress), progress => FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true);
shaderScope.Draw(trailMesh.View);
}
}
}
void DrawBurnOrb(Projectile Projectile)
public override bool PreDraw(ref Color lightColor)
{
float lerpMult = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f)));
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Color baseColor = ProvUtils.GetProjectileColor(255, true) * 4;
Color baseColor2 = ProvUtils.GetProjectileColor(255);
baseColor.A = 0;
baseColor *= lerpMult;
baseColor2 *= lerpMult;
Vector2 origin = texture.Size() / 2f;
Vector2 scale = new Vector2(0.5f, 1f) * ((lerpMult - 1) * 0.5f + 1f);
SpriteEffects spriteEffects = SpriteEffects.None;
if (Projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Projectile.rotation += MathHelper.ToRadians(lerpMult * 2f);
float upRight = MathHelper.PiOver4;
float up = MathHelper.PiOver2;
float upLeft = 3f * MathHelper.PiOver4;
float left = MathHelper.Pi;
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upLeft + Projectile.rotation, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upRight - Projectile.rotation, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upLeft + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upRight - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, up + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, left - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, up + Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, left - Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0);
// Trail drawn by the HolyBurnOrbDrawer system.
DrawBurnOrb();
DrawBurnOrbAdditive();
return false;
}
void DrawBurnOrbAdditive(Projectile Projectile)
private void DrawBurnOrb()
{
var texture = ModContent.Request<Texture2D>("CalamityMod/Particles/GlowOrbParticle").Value;
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, ProvUtils.GetProjectileColor(255), 0, texture.Size() * 0.5f, 1f, 0, 0f);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White, 0, texture.Size() * 0.5f, 0.5f, 0, 0f);
}
void DrawHealOrbTrail(Projectile Projectile)
{
if (Projectile.ModProjectile is HolyLight M)
{
var tex = GeneralParticleHandler.GetTexture(GeneralParticleHandler.particleIDsByTypes[typeof(BloomParticle)]);
var len = Math.Min(Projectile.oldPos.Length, 32);
for (var i = 0; i < len; i++)
{
Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Color color = M.FireCoreColorFunction(i / (float)len, Projectile.oldPos[i]);
var color2 = new Color(0, 25, 0);
float width = M.FireWidthFunction(i / (float)len, Projectile.oldPos[i]);
Main.spriteBatch.Draw(tex, drawPos, null, (color2 with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width, SpriteEffects.None, 0f);
Main.spriteBatch.Draw(tex, drawPos, null, (color with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width * 0.25f, SpriteEffects.None, 0f);
}
}
}
void DrawHealOrb(Projectile Projectile)
{
float vel = Projectile.velocity.Length() / 8;
Projectile.localAI[1] += vel;
float lerpMult = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f)));
Texture2D drawTexture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
Color brightGreen = new Color(54, 209, 54, 0);
Vector2 projDirection = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Vector2 halfTextureSize = drawTexture.Size() / 2f;
Color halfBrightGreen = brightGreen * 0.5f;
float timeLeftColorScale = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f)));
Projectile.rotation += MathHelper.ToRadians(timeLeftColorScale * 2f);
Vector2 timeLeftDrawEffect = new Vector2(0.5f, 1f) * timeLeftColorScale;
Vector2 timeLeftDrawEffect2 = new Vector2(0.5f, 1f) * timeLeftColorScale;
brightGreen *= timeLeftColorScale;
halfBrightGreen *= timeLeftColorScale;
Vector2 position3 = projDirection + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * 0;
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Color baseColor = ProvUtils.GetProjectileColor(255, true) * 4;
Color baseColor2 = ProvUtils.GetProjectileColor(255);
baseColor.A = 0;
baseColor *= lerpMult;
baseColor2 *= lerpMult;
Vector2 origin = texture.Size() * 0.5f;
Vector2 scale = new Vector2(0.5f, 1f) * ((lerpMult - 1) * 0.5f + 1f);
SpriteEffects spriteEffects = SpriteEffects.None;
if (Projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0);
Projectile.rotation += MathHelper.ToRadians(lerpMult * 2f);
Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0);
float upRight = MathHelper.PiOver4;
float up = MathHelper.PiOver2;
float upLeft = 3f * MathHelper.PiOver4;
float left = MathHelper.Pi;
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upLeft + Projectile.rotation, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upRight - Projectile.rotation, origin, scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upLeft + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upRight - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, up + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor, left - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, up + Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0);
Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, left - Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0);
}
void DrawHealOrbAdditive(Projectile Projectile)
private void DrawBurnOrbAdditive()
{
var texture = ModContent.Request<Texture2D>("CalamityMod/Particles/GlowOrbParticle").Value;
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54), 0, texture.Size() * 0.5f, 1f, 0, 0f);
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White, 0, texture.Size() * 0.5f, 0.5f, 0, 0f);
Main.EntitySpriteDraw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, ProvUtils.GetProjectileColor(255) with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 1f, 0, 0f);
Main.EntitySpriteDraw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 0.5f, 0, 0f);
}
}
public class HolyBurnOrbDrawer : ModSystem
{
public static RenderTargetLease TrailPixelationLease { get; private set; }
private List<Projectile> HolyBurnOrbs = [];
private List<Projectile> HolyLights = [];
public override void Load()
{
GeneralDrawLayerSystem.OnBeforeProjectiles += DrawOrbTrails;
if (!Main.dedServ)
{
Main.QueueMainThreadAction(() => TrailPixelationLease = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)));
}
}
public override void PostUpdateProjectiles()
{
foreach (var item in Main.ActiveProjectiles)
{
if (item.type == ModContent.ProjectileType<HolyBurnOrb>() && !HolyBurnOrbs.Contains(item))
HolyBurnOrbs.Add(item);
if (item.type == ModContent.ProjectileType<HolyLight>() && !HolyLights.Contains(item))
HolyLights.Add(item);
}
HolyBurnOrbs.RemoveAll(p => !p.active || p.timeLeft <= 1);
HolyLights.RemoveAll(p => !p.active || p.timeLeft <= 1);
}
private void DrawOrbTrails()
{
if ((HolyBurnOrbs.Count + HolyLights.Count) > 0)
{
using (Main.spriteBatch.Scope())
{
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
using (TrailPixelationLease.Scope(clearColor: Color.Transparent))
{
foreach (var item in HolyBurnOrbs)
item.ModProjectile<HolyBurnOrb>().DrawTrail();
foreach (var item in HolyLights)
item.ModProjectile<HolyLight>().DrawTrail();
}
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
// Redraw at double scale to pixelate the trails.
Main.spriteBatch.Draw(TrailPixelationLease.Target, Vector2.Zero, null, Color.White with { A = 0 }, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
Main.spriteBatch.End();
}
}
}
}
}
+4 -4
View File
@@ -90,12 +90,12 @@ namespace CalamityMod.Projectiles.Boss
if (Projectile.owner == Main.myPlayer)
{
Vector2 velocity = new Vector2(0.01f, 0f);
if (Main.getGoodWorld)
if (!ProvUtils.StandardAI())
velocity *= Main.rand.NextFloat(1f, 2f);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<HolyFire2>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f);
if (Main.getGoodWorld)
if (!ProvUtils.StandardAI())
velocity *= Main.rand.NextFloat(1f, 2f);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -velocity, ModContent.ProjectileType<HolyFire2>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f);
@@ -106,12 +106,12 @@ namespace CalamityMod.Projectiles.Boss
if (Projectile.owner == Main.myPlayer)
{
Vector2 velocity = new Vector2(0.05f, 0f);
if (Main.getGoodWorld)
if (!ProvUtils.StandardAI())
velocity *= Main.rand.NextFloat(1f, 2f);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<HolyFire2>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f);
if (Main.getGoodWorld)
if (!ProvUtils.StandardAI())
velocity *= Main.rand.NextFloat(1f, 2f);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -velocity, ModContent.ProjectileType<HolyFire2>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f);
+127 -60
View File
@@ -1,13 +1,13 @@
using System;
using System.Linq;
using System.Collections.Generic;
using CalamityMod.Dusts;
using CalamityMod.Effects;
using CalamityMod.Enums;
using CalamityMod.NPCs.Providence;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using CalamityMod.Utilities.Daybreak;
using CalamityMod.Utilities.Daybreak.Buffers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
@@ -18,13 +18,29 @@ namespace CalamityMod.Projectiles.Boss
{
public class HolyLight : ModProjectile, ILocalizedModType
{
private static Asset<Texture2D> TrailNoiseTexture;
private static Asset<Texture2D> TrailDistortionTexture;
private static Asset<Texture2D> GlowOrbTexture;
public new string LocalizationCategory => "Projectiles.Boss";
public override string Texture => "CalamityMod/Projectiles/StarProj";
public override void Load()
{
if (!Main.dedServ)
{
TrailNoiseTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak");
TrailDistortionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise");
GlowOrbTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/GlowOrbParticle");
}
}
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 32;
ProjectileID.Sets.TrailingMode[Type] = 2;
ProjectileID.Sets.TrailCacheLength[Type] = 16;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
Projectile.localAI[1] = Main.rand.NextFloat(30f);
@@ -85,60 +101,6 @@ namespace CalamityMod.Projectiles.Boss
}
}
public override bool PreDraw(ref Color lightColor)
{
//drawn by the HolyBurnOrbDrawer system
return false;
}
public float FireWidthFunction(float completion, Vector2 pos)
{
float width;
float maxBodyWidth = 32f * Projectile.scale;
float curveRatio = 0.2f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
// Crop the tip of the trail into a conic shape.
if (completion < curveRatio)
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
// Pulse inwards and outwards over time.
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireColorFunction(float completion, Vector2 pos)
{
Color mainColor = new Color(54, 209, 54) * 1.3f;
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity;
}
public float FireCoreWidthFunction(float completion, Vector2 pos)
{
float width;
float maxBodyWidth = Projectile.scale * 24;
float curveRatio = 0.25f;
var positions = Projectile.oldPos.ToList();
positions.RemoveAll(x => x == Vector2.Zero);
if (completion < curveRatio)
width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
}
public Color FireCoreColorFunction(float completion, Vector2 pos)
{
Color mainColor = new Color(54, 209, 54);
Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion);
return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity;
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item14 with { Pitch = -0.3f, Volume = 0.7f }, Projectile.Center);
@@ -162,5 +124,110 @@ namespace CalamityMod.Projectiles.Boss
dust.noLightEmittence = true;
}
}
public float FireWidthFunction(float completion)
{
float width;
float maxBodyWidth = 56f * Projectile.scale;
float curveRatio = 0.2f;
// Crop the tip of the trail into a conic shape.
if (completion < curveRatio)
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
else
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
// Pulse inwards and outwards over time.
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
return (width + additionalPulseWidth);
}
public Color FireColorFunction(float completion)
{
Color mainColor = new Color(54, 209, 54) * 1.3f;
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity;
}
public void DrawTrail()
{
Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f);
Vector2 basePosition = Projectile.Center - Main.screenPosition;
Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40);
if (screenBounds.Contains(basePosition.ToPoint()))
{
List<Vector3> path = [];
for (var i = 0; i < Projectile.oldPos.Length; i++)
{
Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition;
path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f));
}
if (path.Count > 2 && Projectile.ai[0] > 6)
{
Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value;
shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly);
shader.Parameters["glowPower"].SetValue(1.48f);
Main.graphics.GraphicsDevice.Textures[0] = TrailNoiseTexture.Value;
Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
Main.graphics.GraphicsDevice.Textures[1] = TrailDistortionTexture.Value;
Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap;
using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection);
using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => FireWidthFunction(progress), progress => FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true);
shaderScope.Draw(trailMesh.View);
}
}
}
public override bool PreDraw(ref Color lightColor)
{
// Trail drawn by the HolyBurnOrbDrawer system.
DrawHealOrb();
DrawHealOrbAdditive();
return false;
}
private void DrawHealOrb()
{
float vel = Projectile.velocity.Length() / 8;
Projectile.localAI[1] += vel;
Texture2D drawTexture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
Color brightGreen = new Color(54, 209, 54, 0);
Vector2 projDirection = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
Vector2 halfTextureSize = drawTexture.Size() / 2f;
Color halfBrightGreen = brightGreen * 0.5f;
float timeLeftColorScale = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f)));
Projectile.rotation += MathHelper.ToRadians(timeLeftColorScale * 2f);
Vector2 timeLeftDrawEffect = new Vector2(0.5f, 1f) * timeLeftColorScale;
Vector2 timeLeftDrawEffect2 = new Vector2(0.5f, 1f) * timeLeftColorScale;
brightGreen *= timeLeftColorScale;
halfBrightGreen *= timeLeftColorScale;
Vector2 position3 = projDirection + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * 0;
SpriteEffects spriteEffects = SpriteEffects.None;
if (Projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3 + Vector2.UnitX * 60f, null, halfBrightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3 + Vector2.UnitX * 60f, null, halfBrightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitX * 60f, null, brightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitX * 60f, null, brightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitY * 60f, null, halfBrightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0);
Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitY * 60f, null, halfBrightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0);
}
private void DrawHealOrbAdditive()
{
Main.spriteBatch.Draw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54) with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 1f, 0, 0f);
Main.spriteBatch.Draw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 0.5f, 0, 0f);
}
}
}
+1 -1
View File
@@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Boss
{
Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f) + additionalBlobVelocity;
velocity.Y = -Math.Abs(velocity.Y);
if (Main.getGoodWorld)
if (!ProvUtils.StandardAI())
velocity *= 2f;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<MoltenBlob>(), BlobDamage, 0f, Projectile.owner);
+104
View File
@@ -0,0 +1,104 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Metaballs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class CalamitousDartFriendly : ModProjectile, ILocalizedModType
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public new string LocalizationCategory => "Projectiles.Magic";
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 4;
ProjectileID.Sets.TrailCacheLength[Type] = 2;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 40;
Projectile.height = 40;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.tileCollide = false;
Projectile.penetrate = 3;
Projectile.timeLeft = 300;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 20;
}
public override void AI()
{
if (Projectile.extraUpdates == 0)
{
Projectile.extraUpdates = 1;
Projectile.velocity *= 0.5f;
}
Projectile.frameCounter++;
if (Projectile.frameCounter >= 10)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
Projectile.frame = 0;
Lighting.AddLight(Projectile.Center, 0.9f * Projectile.Opacity, 0f, 0f);
if (Projectile.timeLeft < 51)
Projectile.Opacity -= 0.02f;
if (Projectile.velocity.X < 0f)
{
Projectile.spriteDirection = -1;
Projectile.rotation = (float)Math.Atan2(-Projectile.velocity.Y, -Projectile.velocity.X);
}
else
{
Projectile.spriteDirection = 1;
Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X);
}
Projectile.rotation = Projectile.velocity.ToRotation();
Projectile.spriteDirection = 1;
var dir = Projectile.rotation.ToRotationVector2();
if (Projectile.spriteDirection == -1)
dir = dir.RotatedBy(MathHelper.Pi);
var spot = Vector2.Lerp(Projectile.Center + dir.RotatedBy(MathHelper.PiOver2) * 26, Projectile.Center + dir.RotatedBy(-MathHelper.PiOver2) * 26, Main.rand.NextFloat());
for (var i = 0; i < 1; i++)
{
var p = CalamitasMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * 2, Vector2.Zero, 40);
p.rotation = Projectile.rotation + MathHelper.PiOver2;
p.TextureToUse = ModContent.Request<Texture2D>("CalamityMod/Particles/PointParticle").Value;
p.SizeScaling = 0.65f;
p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2Circular(3, 3), 24f);
p.SizeScaling = 0.8f;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
public override bool PreDraw(ref Color lightColor)
{
return false;
}
public override void OnKill(int timeLeft)
{
for (int dust = 0; dust <= 5; dust++)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f);
}
}
}
}
@@ -0,0 +1,94 @@
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.NPCs.CalClone;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class CalamitousExplosionFriendly : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 130;
Projectile.height = 130;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 120;
Projectile.DamageType = DamageClass.Magic;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 20;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Projectile.localAI[0]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Projectile.localAI[0] = reader.ReadSingle();
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.75f, 0f, 0f);
if (Projectile.localAI[0] == 0f)
{
SoundEngine.PlaySound(CalamitasClone.CalamitousExplosionSound, Projectile.Center);
Projectile.localAI[0] += 1f;
}
bool xflag = false;
bool yflag = false;
if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0])
{
xflag = true;
}
if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0])
{
xflag = true;
}
if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1])
{
yflag = true;
}
if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1])
{
yflag = true;
}
if (xflag && yflag)
{
Projectile.Kill();
}
float projTimer = 25f;
if (Projectile.ai[0] > 180f)
{
projTimer -= (Projectile.ai[0] - 180f) / 2f;
}
if (projTimer <= 0f)
{
projTimer = 0f;
Projectile.Kill();
}
projTimer *= 0.7f;
Projectile.ai[0] += 4f;
var p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(4, 4), 32f);
p.SizeScaling = 0.96f;
p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(3, 3), 40f);
p.SizeScaling = 0.96f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
}
}
@@ -1,18 +1,17 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.NPCs.BrimstoneElemental;
using CalamityMod.Graphics.Metaballs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class BrimstoneHellfireballFriendly : ModProjectile, ILocalizedModType
public class CalamitousFireballFriendly : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/Boss/BrimstoneHellfireball";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 6;
@@ -22,19 +21,20 @@ namespace CalamityMod.Projectiles.Magic
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.width = 48;
Projectile.height = 48;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.timeLeft = 300;
Projectile.penetrate = 1;
Projectile.MaxUpdates = 2;
Projectile.tileCollide = false;
Projectile.DamageType = DamageClass.Magic;
Projectile.penetrate = 1;
Projectile.timeLeft = 300;
Projectile.alpha = 255;
}
public override void AI()
{
//Animation
// Animation
Projectile.frameCounter++;
if (Projectile.frameCounter > 9)
{
@@ -42,52 +42,50 @@ namespace CalamityMod.Projectiles.Magic
Projectile.frameCounter = 0;
}
if (Projectile.frame >= 6)
{
Projectile.frame = 0;
}
//Fade in
// Fade in
if (Projectile.alpha > 5)
Projectile.alpha -= 15;
if (Projectile.alpha < 5)
Projectile.alpha = 5;
//Rotation
// Rotation
Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt();
Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90) * Projectile.direction;
Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90f) * Projectile.direction;
int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 170, default, 1.1f);
Main.dust[brimDust].noGravity = true;
Main.dust[brimDust].velocity *= 0.5f;
Main.dust[brimDust].velocity += Projectile.velocity * 0.1f;
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f);
if (Projectile.velocity.Length() < 16f)
Projectile.velocity *= 1.01f;
if (Projectile.localAI[0] == 0f)
Lighting.AddLight(Projectile.Center, 0.5f, 0f, 0f);
var brimDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(32, 32), (int)CalamityDusts.Brimstone, null, 170, default, 1.1f);
brimDust.noGravity = true;
brimDust.velocity *= 0.5f;
brimDust.velocity += Projectile.velocity * 0.1f;
for (var i = 0; i < 1; i++)
{
SoundEngine.PlaySound(BrimstoneElemental.HellfireballSound, Projectile.Center);
Projectile.localAI[0] += 1f;
CalamitasMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, Main.rand.NextVector2Circular(2, 2), 64f);
}
}
// Speed up as time goes on
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * (Projectile.velocity.Length() + 0.25f);
public override Color? GetAlpha(Color lightColor)
{
return new Color(250, 50, 50, Projectile.alpha);
}
public override void OnKill(int timeLeft)
{
if (Projectile.owner == Main.myPlayer)
{
int fire = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<HellfireExplosionFriendly>(), (int)(Projectile.damage * 0.66f), Projectile.knockBack, Projectile.owner);
}
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<CalamitousExplosionFriendly>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 240);
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
return false;
}
}
@@ -1,77 +0,0 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class HellfireExplosionFriendly : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 130;
Projectile.height = 130;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 120;
Projectile.DamageType = DamageClass.Magic;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 20;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.9f, 0f, 0f);
if (Projectile.localAI[0] == 0f)
{
SoundEngine.PlaySound(SoundID.Item20, Projectile.Center);
Projectile.localAI[0] += 1f;
}
float projTimer = 25f;
if (Projectile.ai[0] > 180f)
{
projTimer -= (Projectile.ai[0] - 180f) / 2f;
}
if (projTimer <= 0f)
{
projTimer = 0f;
Projectile.Kill();
}
projTimer *= 0.7f;
Projectile.ai[0] += 4f;
int timerCounter = 0;
while ((float)timerCounter < projTimer)
{
float rando1 = (float)Main.rand.Next(-10, 11);
float rando2 = (float)Main.rand.Next(-10, 11);
float rando3 = (float)Main.rand.Next(3, 9);
float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2));
randoAdjuster = rando3 / randoAdjuster;
rando1 *= randoAdjuster;
rando2 *= randoAdjuster;
int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f);
Dust dust = Main.dust[brimDust];
dust.noGravity = true;
dust.position.X = Projectile.Center.X;
dust.position.Y = Projectile.Center.Y;
dust.position.X += (float)Main.rand.Next(-10, 11);
dust.position.Y += (float)Main.rand.Next(-10, 11);
dust.velocity.X = rando1;
dust.velocity.Y = rando2;
timerCounter++;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 240);
}
}
}
-1
View File
@@ -69,7 +69,6 @@ namespace CalamityMod.Projectiles.Melee
}
else if (homeTracker == 1)
{
int inc;
Projectile.rotation -= MathHelper.Pi / 30f;
Vector2 projCenter = Projectile.Center;
float homingRange = 150f;
+99
View File
@@ -0,0 +1,99 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Metaballs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class OblivionBolt : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/Boss/BurningBolt";
public int time = 0;
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 4;
ProjectileID.Sets.TrailCacheLength[Type] = 2;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 18;
Projectile.height = 44;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
Projectile.ArmorPenetration = 20;
Projectile.penetrate = 3;
Projectile.timeLeft = 690;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
Projectile.noEnchantmentVisuals = true;
}
public override void AI()
{
if (Projectile.velocity.Length() < Projectile.ai[2])
{
Projectile.velocity *= 1.01f;
if (Projectile.velocity.Length() > Projectile.ai[2])
{
Projectile.velocity.Normalize();
Projectile.velocity *= Projectile.ai[2];
}
}
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
Projectile.frameCounter++;
if (Projectile.frameCounter > 4)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
Projectile.frame = 0;
if (Projectile.timeLeft < 60)
Projectile.Opacity = MathHelper.Clamp(Projectile.timeLeft / 60f, 0f, 1f);
if (Projectile.ai[0] == 2f)
{
if (Projectile.timeLeft > 570)
{
int player = Player.FindClosest(Projectile.Center, 1, 1);
Vector2 vector = Main.player[player].Center - Projectile.Center;
float scaleFactor = Projectile.velocity.Length();
vector.Normalize();
vector *= scaleFactor;
Projectile.velocity = (Projectile.velocity * 15f + vector) / 16f;
Projectile.velocity.Normalize();
Projectile.velocity *= scaleFactor;
}
}
Lighting.AddLight(Projectile.Center, 0.75f * Projectile.Opacity, 0f, 0f);
time++;
var p = SeekersMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * Projectile.MaxUpdates, Vector2.Zero, Terraria.GameContent.TextureAssets.Projectile[Type].Width() * Projectile.scale);
p.rotation = Projectile.rotation;
p.CurrentFrame = Projectile.frame;
p.MaxFrames = Main.projFrames[Type];
p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
p.SizeScaling = 0f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
public override bool PreDraw(ref Color lightColor)
{
return false;
}
}
}
+49
View File
@@ -0,0 +1,49 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Metaballs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class OblivionFire : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public ref float Time => ref Projectile.ai[0];
public override void SetStaticDefaults()
{
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 8;
Projectile.height = 8;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.timeLeft = 240;
Projectile.MaxUpdates = 4;
Projectile.tileCollide = false;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
Projectile.noEnchantmentVisuals = true;
}
public override void AI()
{
Time++;
if (Time >= 100f)
CalamityUtils.HomeInOnNPC(Projectile, false, 300, 2.5f, 20f, true);
CalamitasMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, Main.rand.NextVector2Circular(2, 2), 16f);
}
public override bool? CanDamage() => Time >= 45f;
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
}
}
@@ -6,7 +6,6 @@ using CalamityMod.Utilities.Daybreak;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
@@ -50,7 +49,6 @@ namespace CalamityMod.Projectiles.Melee
var StarScale = 0.2f;
Projectile.scale = 0.75f*MathF.Min(MathF.Pow((lifetime- Projectile.timeLeft)/ 20f,2f), 1f);
Projectile.Opacity = MathF.Min(Projectile.timeLeft / 20f, 1f);
Vector2 ada = default;
void SpawnStar(Vector2 offset, float intensity, int flashOffset = 0, int flashMod = 60)
{
offset += new Vector2(5, 49.25f); //this centers the constellation
+333 -6
View File
@@ -1,8 +1,15 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Cooldowns;
using CalamityMod.Dusts;
using CalamityMod.Enums;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
@@ -13,6 +20,19 @@ namespace CalamityMod.Projectiles.Melee.Yoyos
{
public override LocalizedText DisplayName => CalamityUtils.GetItemName<Oblivion>();
public const int MaxUpdates = 2;
//How many hits the yoyo has gotten. Starts at 1 to avoid a dividing by zero error
public int hitCounter = 1;
//20 hits to maximum
public int hitCountMax = 21;
public int time = 0;
//Used for visual intensity rising as the yoyo gets more hits
public float power = 0;
public float powerMax = 1;
//The grace period after the yoyo reaches max power to avoid insta-shattering
public int graceTimer = 0;
public bool shatter = false;
//Yoyo bag behavior
public bool cloneYoyo = false;
public override void SetStaticDefaults()
{
@@ -33,21 +53,328 @@ namespace CalamityMod.Projectiles.Melee.Yoyos
Projectile.penetrate = -1;
Projectile.MaxUpdates = MaxUpdates;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10 * MaxUpdates;
Projectile.localNPCHitCooldown = 15 * MaxUpdates;
}
public override void AI()
{
CalamityUtils.MagnetSphereHitscan(Projectile, 300f, 9f, 48f, 5, ModContent.ProjectileType<SeethingDischargeBrimstoneBarrage>(), 0.5, damageType: Projectile.DamageType);
if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks
var player = Main.player[Projectile.owner];
//Using yoyo glove or yoyo bag makes yoyos run out of air time 2-4x faster (randomized) when the second yoyo is out
//Therefore, we set the flight to infinite, but manually set it to recall after 15 seconds and update it across both yoyos
if (time >= 1800)
{
if (!cloneYoyo)
{
for (int i = 0; i < Main.maxProjectiles; i++)
{
Projectile p = Main.projectile[i];
if (p.active && p.type == Type && p.owner == Projectile.owner)
{
if (p.ModProjectile is OblivionYoyo oblivion)
{
oblivion.Projectile.ai[0] = -1f;
}
}
}
}
}
// Determine if the yoyo is a yoyo bag/yoyo glove clone
if (!cloneYoyo)
{
int MainYoyo = -1;
for (int x = 0; x < Main.maxProjectiles; x++)
{
Projectile proj = Main.projectile[x];
if (proj.active && proj.type == Type && proj.owner == Projectile.owner)
{
MainYoyo = x;
break;
}
}
if (Projectile.whoAmI != MainYoyo)
cloneYoyo = true;
//Yoyo behavior. Nothing will trigger on yoyos from yoyo bag
//Fireball spawning. Fire rate increases with how many hits the yoyo has gotten
if (time % (120 / hitCounter) == 0 && !shatter && Projectile.owner == Main.myPlayer)
{
float randRot = Main.rand.NextFloat(0, MathHelper.TwoPi);
Vector2 spawnVel = randRot.ToRotationVector2() * 2f;
Projectile flames = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, spawnVel, ModContent.ProjectileType<OblivionFire>(), (int)(Projectile.damage * 0.85f), Projectile.knockBack, Projectile.owner);
}
if (graceTimer > 0)
graceTimer--;
if (shatter)
{
//Constantly keep the yoyo out, even if the player lets go of the mouse
Projectile.ai[0] = 0f;
Projectile.Center = player.Calamity().mouseWorld;
//Charge up visuals
power += 0.01f;
float fade = Utils.GetLerpValue(powerMax + 2, 0, power);
float numberOfDusts = 2f;
float rotFactor = 360f / numberOfDusts;
for (int i = 0; i < numberOfDusts; i++)
{
float rot = MathHelper.ToRadians(i * rotFactor);
Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 250f, 0.04f);
velOffset *= Main.rand.NextFloat(25, 45) * fade;
Particle energy = new GlowOrbParticle(Projectile.Center + velOffset * 2.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, false, (int)(14 - (5 * fade)), Main.rand.NextFloat(1.1f, 1.25f) - 0.5f * fade, Main.rand.NextBool() ? Color.Red : Color.MediumVioletRed);
GeneralParticleHandler.SpawnParticle(energy);
Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, DustID.FireworksRGB, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.6f, 0.8f));
dust.noGravity = true;
dust.color = Color.DarkRed;
}
if (time == 240)
{
#region Visuals and Sounds
Player Owner = Main.player[Projectile.owner];
for (int i = 0; i < 2; i++)
{
Particle centerVoid = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), (2.2f + i * 0.5f), 0f, 80, false);
GeneralParticleHandler.SpawnParticle(centerVoid);
}
for (int i = 0; i < 2; i++)
{
Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f, 3f, 25, true);
GeneralParticleHandler.SpawnParticle(blastRing);
Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumVioletRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 1.5f, 25, true);
GeneralParticleHandler.SpawnParticle(blastRing2);
}
Particle backBlast1 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumVioletRed, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 2.56f * 1.3f, 18);
GeneralParticleHandler.SpawnParticle(backBlast1, false, GeneralDrawLayer.AfterEverything);
Particle backBlast2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumVioletRed, "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.3f, 30);
GeneralParticleHandler.SpawnParticle(backBlast2, false, GeneralDrawLayer.AfterEverything);
Particle backBlast3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed * 0.55f, "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.3f * 1.35f, 30);
GeneralParticleHandler.SpawnParticle(backBlast3, false, GeneralDrawLayer.AfterEverything);
Particle ring1 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/FlameExplosion2", new Vector2(0.01f, 0.085f), MathHelper.PiOver2, -4f, 4f, 30);
GeneralParticleHandler.SpawnParticle(ring1);
Particle ring2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/FlameExplosion", new Vector2(0.02f, 0.07f), 0f, -4f, 4f, 25);
GeneralParticleHandler.SpawnParticle(ring2);
Particle ring3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/FlameExplosion", new Vector2(0.02f, 0.07f), MathHelper.PiOver4, -4f, 4f, 25);
GeneralParticleHandler.SpawnParticle(ring3);
Particle ring4 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/FlameExplosion", new Vector2(0.02f, 0.07f), -MathHelper.PiOver4, -4f, 4f, 25);
GeneralParticleHandler.SpawnParticle(ring4);
for (int i = 0; i < 19; i++)
{
int dustStyle = ModContent.DustType<VoidDustInverted>();
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle);
dust.scale = Main.rand.NextFloat(1.4f, 2.2f);
dust.velocity = new Vector2(21, 21).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1f);
dust.noGravity = true;
dust.color = Color.MediumVioletRed;
}
for (int i = 0; i < (25); i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB);
dust.noGravity = false;
dust.velocity = new Vector2(18, 18).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f);
dust.scale = Main.rand.NextFloat(0.8f, 1.2f);
dust.color = Color.DarkRed;
}
Owner.SetScreenshake(6f);
SoundStyle boom = new("CalamityMod/Sounds/Custom/CalamitasClone/BulletHellEnd");
SoundEngine.PlaySound(boom with { Volume = 1.5f }, Projectile.Center);
#endregion
if (Projectile.owner == Main.myPlayer)
{
float blastSize = 240;
float minMultiplier = 0.25f;
int hitsToMinMult = 3;
int debuff1 = ModContent.BuffType<BrimstoneFlames>();
int debufftime = 180;
//I promise this is balanced
Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<BasicBurst>(), (int)(Projectile.damage * 50f), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
blast.localAI[0] = debuff1;
blast.localAI[1] = debufftime;
blast.timeLeft = 2;
blast.DamageType = Projectile.DamageType;
blast.CritChance = 100;
}
//Set cooldown
player.Calamity().oblivionCooldown = 300;
int duration = CalamityUtils.SecondsToFrames(5);
player.AddCooldown(OblivionCooldown.ID, duration, true);
//We manually kill the projectile to skip the retracting, to make it look like the yoyo is destroyed
//This needs to happen for both the main and secondary yoyo
for (int i = 0; i < Main.maxProjectiles; i++)
{
Projectile p = Main.projectile[i];
if (p.active && p.type == Type && p.owner == Projectile.owner)
{
p.Kill();
}
}
}
}
}
//If the player gets more than 200 blocks away, kill the yoyo
if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f)
Projectile.Kill();
time++;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 240);
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
//Only applies to the main yoyo
if (!cloneYoyo)
{
hitCounter++;
if (!shatter)
{
power += 0.05f;
SoundStyle onHit = new("CalamityMod/Sounds/Item/TearsOfHeavenUse");
SoundEngine.PlaySound(onHit, Projectile.Center);
if (power > powerMax)
{
power = powerMax;
}
}
if (hitCounter == hitCountMax)
{
//Refresh duration on both yoyos
for (int i = 0; i < Main.maxProjectiles; i++)
{
Projectile p = Main.projectile[i];
if (p.active && p.type == Type && p.owner == Projectile.owner)
{
if (p.ModProjectile is OblivionYoyo oblivion)
{
oblivion.time = 0;
}
}
}
//Start a 1.5 second grace period where the yoyo cannot damage enemies. This is to avoid instant shattering after reaching max power
graceTimer = 90;
//Small burst and a ring of darts
if (Projectile.owner == Main.myPlayer)
{
int totalProjectiles = 18;
float radians = MathHelper.TwoPi / totalProjectiles;
float velocity = 8f;
Vector2 spinningPoint = new Vector2(0f, -velocity);
for (int k = 0; k < totalProjectiles; k++)
{
Vector2 velocity2 = spinningPoint.RotatedBy(radians * k);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, ModContent.ProjectileType<OblivionBolt>(), Projectile.damage, 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f);
}
float blastSize = 120;
float minMultiplier = 0.25f;
int hitsToMinMult = -1;
int debuff1 = ModContent.BuffType<BrimstoneFlames>();
int debufftime = 180;
Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<BasicBurst>(), (int)(Projectile.damage * 5f), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
blast.localAI[0] = debuff1;
blast.localAI[1] = debufftime;
blast.timeLeft = 2;
blast.DamageType = Projectile.DamageType;
}
#region Visuals and Sounds
SoundStyle boom = new("CalamityMod/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit", 4);
SoundEngine.PlaySound(boom with { Volume = 1.5f }, Projectile.Center);
SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Volume = 1f, Pitch = -0.5f }, Projectile.Center);
SoundEngine.PlaySound(SoundID.Item74 with { Volume = 0.7f, Pitch = 1f }, Projectile.Center);
for (int i = 0; i < 5; i++)
{
Particle explosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.Red, Color.MediumVioletRed, Utils.GetLerpValue(0, 5, i, true)), "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.12f + 0.005f * i, (int)(20 - i * 1.5f));
GeneralParticleHandler.SpawnParticle(explosion);
}
for (int i = 0; i < 3; i++)
{
Particle explosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.DarkRed, Color.DarkOrchid, Utils.GetLerpValue(0, 3, i, true)), "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.12f + 0.01f * i, (int)(20 - i * 2f));
GeneralParticleHandler.SpawnParticle(explosion);
}
Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed, "CalamityMod/Particles/BloomCircle", Vector2.One, 0f, 0.2f, 2f, 24);
GeneralParticleHandler.SpawnParticle(outerGlow);
Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/BloomCircle", Vector2.One, 0f, 0.1f, 1f, 24);
GeneralParticleHandler.SpawnParticle(innerGlow);
#endregion
}
//If the yoyo hits while at maximum, reset the duration of both yoyos and trigger shattering
if (hitCounter > hitCountMax && !shatter)
{
Player Owner = Main.player[Projectile.owner];
SoundEngine.PlaySound(SoundID.DD2_EtherianPortalDryadTouch with { Volume = 4f }, Projectile.Center);
Owner.SetScreenshake(3f);
shatter = true;
for (int i = 0; i < Main.maxProjectiles; i++)
{
Projectile p = Main.projectile[i];
if (p.active && p.type == Type && p.owner == Projectile.owner)
{
if (p.ModProjectile is OblivionYoyo oblivion)
{
oblivion.time = 0;
}
}
}
}
}
}
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
//During the grace period after reaching max power, the yoyo cannot hit enemies for 1.5s to avoid unfair shattering
public override bool? CanDamage() => graceTimer == 0;
//Avoids instantly spawning a fireball
public override void OnSpawn(IEntitySource source)
{
time = 1;
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
Texture2D bloomTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
Texture2D shineTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/HalfStar").Value;
float randSize = Main.rand.NextFloat(0.9f, 1.1f);
float rotationAngle = MathHelper.PiOver4;
Vector2 drawPos = Projectile.Center - Main.screenPosition;
//Only applies to the main yoyo
if (!cloneYoyo)
{
//Red backglow, scales in size with power
Main.EntitySpriteDraw(bloomTexture, drawPos, null, Color.Red with { A = 0 }, Projectile.rotation, bloomTexture.Size() * 0.5f, 0.3f * randSize * power, SpriteEffects.None, 0);
Main.EntitySpriteDraw(bloomTexture, drawPos, null, Color.MediumVioletRed with { A = 0 } * 0.65f, Projectile.rotation, bloomTexture.Size() * 0.5f, 0.2f * randSize * power, SpriteEffects.None, 0);
//X, scales in size with power
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.Red with { A = 0 }, rotationAngle, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 2.75f * randSize * power, SpriteEffects.None, 0);
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.Purple with { A = 0 } * 0.65f, rotationAngle, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 2.25f * randSize * power, SpriteEffects.None, 0);
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.Red with { A = 0 }, rotationAngle + MathHelper.PiOver2, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 2.75f * randSize * power, SpriteEffects.None, 0);
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.Purple with { A = 0 } * 0.65f, rotationAngle + MathHelper.PiOver2, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 2.25f * randSize * power, SpriteEffects.None, 0);
//Yoyo drawing
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
//Red cross, doesn't scale in size unless shattering
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.DarkRed with { A = 0 }, 0, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 1.35f * randSize * (shatter ? power : 1f), SpriteEffects.None, 0);
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.Purple with { A = 0 } * 0.65f, 0, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 1.35f * randSize * (shatter ? power : 1f), SpriteEffects.None, 0);
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.DarkRed with { A = 0 }, MathHelper.PiOver2, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 1.35f * randSize * (shatter ? power : 1f), SpriteEffects.None, 0);
Main.EntitySpriteDraw(shineTexture, drawPos, null, Color.Purple with { A = 0 } * 0.65f, MathHelper.PiOver2, shineTexture.Size() * 0.5f, new Vector2(0.4f, 1f) * 1.35f * randSize * (shatter ? power : 1f), SpriteEffects.None, 0);
//Black backglow, scales in size with power
for (int i = 0; i < 2; i++)
{
Particle backglow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.25f * (power * 2), 0f, 10, false);
GeneralParticleHandler.SpawnParticle(backglow);
backglow.DrawLayer = Enums.GeneralDrawLayer.BeforeProjectiles;
backglow.DrawLayer = Enums.GeneralDrawLayer.BeforeNPCs;
}
}
else
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
return false;
}
}
-15
View File
@@ -1,20 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.DataStructures;
using CalamityMod.Dusts;
using CalamityMod.Effects;
using CalamityMod.Enums;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs;
using CalamityMod.Packets.Entities;
using CalamityMod.Particles;
using CalamityMod.Utilities.Daybreak;
using CalamityMod.Utilities.Daybreak.Buffers;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -22,7 +16,6 @@ using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.WorldBuilding;
namespace CalamityMod.Projectiles.Ranged
{
@@ -153,15 +146,7 @@ namespace CalamityMod.Projectiles.Ranged
}
private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos)
{
float width;
float maxBodyWidth = Projectile.scale * MaxLaserWidth * (1 + MathF.Pow(Utils.GetLerpValue(450, 500, VoidragonHoldout.ModProjectile<VoidragonHoldout>().beamTimer, true), 3.5f) * 4);
float shrinkRatio = 0.018f;
//if (completionRatio < shrinkRatio)
// width = MathF.Sin(completionRatio / shrinkRatio * MathHelper.PiOver2) * maxBodyWidth + shrinkRatio;
//else
// width = Utils.Remap(completionRatio, shrinkRatio, 1f, maxBodyWidth, 0f);
return maxBodyWidth * Utils.GetLerpValue(0f, 0.05f, completionRatio, true) * Utils.GetLerpValue(LaserLength, LaserLength - 0.1f, completionRatio, true);
}
+16 -62
View File
@@ -1,6 +1,7 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Ranged
public override string Texture => "CalamityMod/Projectiles/FireProj";
public static int Lifetime => 60;
public static int Fadetime => 50;
public ref float Time => ref Projectile.ai[0];
public int MistType = -1;
@@ -29,13 +29,13 @@ namespace CalamityMod.Projectiles.Ranged
Projectile.MaxUpdates = 3;
Projectile.timeLeft = Lifetime;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.idStaticNPCHitCooldown = 6;
Projectile.idStaticNPCHitCooldown = 5;
}
public override void AI()
{
Time++;
if (Time < Fadetime && Main.rand.NextBool(6))
if (Main.rand.NextBool(6))
{
Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f);
float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true);
@@ -47,13 +47,21 @@ namespace CalamityMod.Projectiles.Ranged
}
cinder.noGravity = true;
cinder.scale *= cinderSize * 1.2f;
cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f);
cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Lifetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Lifetime * 0.1f, 0.1f, 1f);
}
if (MistType == -1)
MistType = Main.rand.Next(3);
Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f);
if (Projectile.timeLeft > Lifetime - 8)
return;
float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time);
float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f);
var p = CataclysmMetaball.SpawnParticle(Projectile.Center, Vector2.Zero, Terraria.GameContent.TextureAssets.Projectile[Type].Width() * fireSize);
p.rotation = Main.rand.NextFloat(MathHelper.TwoPi);
p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
p.SizeScaling = 0.6f;
}
// Keeping the flames in place when hitting a block
@@ -69,11 +77,7 @@ namespace CalamityMod.Projectiles.Ranged
// Expanding hitbox
public override void ModifyDamageHitbox(ref Rectangle hitbox)
{
int size = (int)Utils.Remap(Time, 0f, Fadetime, 10f, 40f);
// Shrinks again after fading
if (Time > Fadetime)
size = (int)Utils.Remap(Time, Fadetime, Lifetime, 40f, 0f);
int size = (int)Utils.Remap(Time, 0f, Lifetime, 10f, 40f);
hitbox.Inflate(size, size);
}
@@ -87,68 +91,18 @@ namespace CalamityMod.Projectiles.Ranged
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 1200);
// Gas up the enemy
int smokeCount = 3 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f);
int smokeCount = 4 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f);
for (int i = 0; i < smokeCount; i++)
{
bool Smoketype = Main.rand.NextBool();
Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f);
Vector2 smokeVel = Vector2.UnitY * (Smoketype ? Main.rand.NextFloat(-0.8f, -2f) : Main.rand.NextFloat(-1.2f, -0.2f)) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f);
Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Smoketype ? Main.rand.NextFloat(0.4f, 0.75f) : Main.rand.NextFloat(1.5f, 2f), 220 - Main.rand.Next(50), 0.1f);
Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-2.4f, -0.8f) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f);
Particle smoke = new MediumMistParticle(smokePos, smokeVel, Color.MediumVioletRed, Color.Purple, Main.rand.NextFloat(1f, 2f), 245 - Main.rand.Next(50), 0.1f);
GeneralParticleHandler.SpawnParticle(smoke);
}
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D fire = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
Texture2D mist = ModContent.Request<Texture2D>("CalamityMod/Particles/MediumMist").Value;
// The conga line of colors to sift through
Color color1 = new Color(255, 110, 100, 200);
Color color2 = new Color(255, 50, 50, 70);
Color color3 = new Color(255, 100, 100, 100);
Color color4 = new Color(200, 35, 30, 100);
float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f);
float vOffset = Math.Min(Time, 20f);
float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time);
float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f);
if (timeRatio >= 1f)
return false;
for (float j = 1f; j >= 0f; j -= length)
{
// Color
Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) :
((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) :
((timeRatio < 0.35f) ? color2 :
((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) :
((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) :
Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio)))))));
fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true);
Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f);
// Positions and rotations
Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j;
float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length;
float trailRot = MathHelper.PiOver4 - mainRot;
// Draw one backtrail
Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f;
Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None);
// Draw the main fire
Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None);
// Draw the masking smoke
if (MistType > 2 || MistType < 0)
return false;
Main.spriteBatch.SetBlendState(BlendState.Additive);
Rectangle frame = mist.Frame(1, 3, 0, MistType);
Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None);
Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None);
Main.spriteBatch.SetBlendState(BlendState.AlphaBlend);
}
return false;
}
}
-2
View File
@@ -12,8 +12,6 @@ namespace CalamityMod.Projectiles.Rogue
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Projectiles/Boss/SignusScythe";
private int originalDamage;
public override void SetStaticDefaults()
{
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
@@ -20,8 +20,6 @@ namespace CalamityMod.Projectiles.Rogue
public override int StartupTime { get; set; }
public override int CooldownTime { get; set; }
bool isChannelable = false;
int explodeTimer = 0;
public override void Defaults()
+6 -3
View File
@@ -14,16 +14,19 @@ namespace CalamityMod.Projectiles.Summon
public override void SetDefaults()
{
Projectile.width = Projectile.height = 4;
Projectile.width = Projectile.height = 6;
Projectile.light = 0.5f;
Projectile.alpha = 0;
Projectile.extraUpdates = 4;
Projectile.scale = 1.18f;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.aiStyle = ProjAIStyleID.Arrow;
Projectile.timeLeft = 600;
Projectile.tileCollide = false;
Projectile.MaxUpdates = 6;
Projectile.penetrate = 5;
Projectile.timeLeft = 60 * Projectile.MaxUpdates;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
AIType = ProjectileID.BulletHighVelocity;
Projectile.DamageType = DamageClass.Summon;
}
+1 -1
View File
@@ -255,7 +255,7 @@ namespace CalamityMod.Projectiles.Summon
//Increment attack cooldown
if (Projectile.ai[1] > 0f)
{
Projectile.ai[1]++;
Projectile.ai[1] += Main.rand.NextFloat(0.5f, 2f);
}
//Set the minion to be ready for attack
if (Projectile.ai[1] > 60f)
+17 -8
View File
@@ -1,5 +1,5 @@
using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using CalamityMod.Graphics.Metaballs;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,6 +8,7 @@ namespace CalamityMod.Projectiles.Summon
public class BrimstoneLaserSummon : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
@@ -17,8 +18,6 @@ namespace CalamityMod.Projectiles.Summon
public override void SetDefaults()
{
Projectile.width = Projectile.height = 10;
Projectile.aiStyle = ProjAIStyleID.Arrow;
AIType = ProjectileID.CursedBullet;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.alpha = 120;
@@ -29,13 +28,23 @@ namespace CalamityMod.Projectiles.Summon
public override void AI()
{
Lighting.AddLight(Projectile.Center, Projectile.Opacity * 0.5f, Projectile.Opacity * 0.05f, Projectile.Opacity * 0.05f);
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
CalamityUtils.HomeInOnNPC(Projectile, false, 300, 5.5f, 10f, true);
if (Projectile.Calamity().HomingTarget < 0)
{
Projectile.velocity.Y += 0.025f;
}
CalamitasMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, Main.rand.NextVector2Circular(2, 2), 16f);
if (Projectile.velocity.Y > 16f)
{
Projectile.velocity.Y = 16f;
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 120);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 120);
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
public override Color? GetAlpha(Color lightColor) => new Color(250, 50, 50, Projectile.alpha);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 300);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

+8 -12
View File
@@ -48,27 +48,23 @@ namespace CalamityMod.Projectiles.Summon
public static int GetDust(float type)
{
if (type >= 4f && Main.rand.NextBool(5))
if (type >= 3f && Main.rand.NextBool(5))
return DustID.IchorTorch;
if (type >= 3f && Main.rand.NextBool(4))
return DustID.VenomStaff;
if (type >= 2f && Main.rand.NextBool(3))
if (type >= 2f && Main.rand.NextBool(5))
return DustID.CursedTorch;
return DustID.Torch;
return Main.rand.NextBool(4) ? DustID.VenomStaff : DustID.Torch;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(BuffID.OnFire3, 60);
target.AddBuff(BuffID.OnFire3, 300);
target.AddBuff(BuffID.Venom, 300);
if (MinionCount >= 2f)
target.AddBuff(BuffID.CursedInferno, 60);
target.AddBuff(BuffID.CursedInferno, 300);
if (MinionCount >= 3f)
target.AddBuff(BuffID.Venom, 60);
target.AddBuff(BuffID.Ichor, 300);
if (MinionCount >= 4f)
{
target.AddBuff(BuffID.Ichor, 60);
target.AddBuff(ModContent.BuffType<MarkedforDeath>(), 60);
}
target.AddBuff(ModContent.BuffType<MarkedforDeath>(), 300);
}
}
}
+1 -1
View File
@@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Summon
homeInVector.Normalize();
if (targetDist > 200f)
{
float velocity = 6f;
float velocity = 10f;
Projectile.velocity = (Projectile.velocity * 40f + homeInVector * velocity) / 41f;
}
else
@@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Summon
public const float SegmentDistance = 20;
public static int FadeoutTime = 20;
public static int ElectrifyTimer = 180;
public static float ZapDamageMultiplier = 0.5f;
public static float ZapDamageMultiplier = 1f;
//Sounds
public static readonly SoundStyle ZapSound = SoundID.Item94 with { Volume = SoundID.Item94.Volume * 0.5f };
+29 -10
View File
@@ -33,7 +33,6 @@ namespace CalamityMod.Projectiles.Summon
}
private Action _currentState;
private ref float DashTimer => ref Projectile.ai[0];
private ref float SwingTimer => ref Projectile.ai[1];
@@ -62,14 +61,21 @@ namespace CalamityMod.Projectiles.Summon
Projectile.width = Projectile.height = 32;
}
public override bool? CanDamage() => SwingTimer >= SwingWait && SwingTimer <= SwingWait + SwingTime ? base.CanDamage() : false;
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
float damageMult = MathHelper.Clamp(Utils.GetLerpValue(3, 0, Projectile.numHits), 0.25f, 1);
modifiers.SourceDamage *= damageMult;
}
#region AI
public override void MinionAI()
{
if (!HasSpawned)
{
IFrames = -1;
TrailCacheLength = 4;
DashTimer = Main.rand.Next(30);
Projectile.velocity = Projectile.DirectionFrom(Owner.Center);
CurrentState = GoToOwnerState;
HasSpawned = true;
@@ -157,7 +163,7 @@ namespace CalamityMod.Projectiles.Summon
if (SwingTimer == SwingWait + SwingTime * 0.5f && Main.myPlayer == Projectile.owner)
{
Vector2 spawnPosition = SwingCenter + predictiveDirection.SafeNormalize(-Vector2.UnitY) * 40f;
Projectile.NewProjectileDirect(
Projectile.NewProjectile(
Projectile.GetSource_FromThis(),
spawnPosition,
predictiveDirection,
@@ -166,14 +172,30 @@ namespace CalamityMod.Projectiles.Summon
Projectile.knockBack,
Projectile.owner);
}
if (DashTimer >= DashCooldown)
if ((SwingTimer == SwingWait && SwingDirection == 1) || (SwingTimer == SwingWait + SwingTime && SwingDirection == -1))
{
Vector2 dashVelocity = CalamityUtils.CalculatePredictiveAimToTarget(SwingCenter, Target, DashSpeed);
Projectile.ResetLocalNPCHitImmunity();
Projectile.numHits = 0;
}
if (Vector2.Distance(SwingCenter, Target.Center) > 48f + MathF.Min(Target.width, Target.height) * 0.8f)
{
Vector2 dashVelocity = CalamityUtils.CalculatePredictiveAimToTarget(SwingCenter, Target, ChaseSpeed);
if (!float.IsNaN(dashVelocity.X) && !float.IsNaN(dashVelocity.Y))
Projectile.velocity = dashVelocity;
DashTimer = 0f;
}
else if (Vector2.Distance(SwingCenter, Target.Center) < 40f + MathF.Min(Target.width, Target.height) * 0.5f)
{
Vector2 dashVelocity = CalamityUtils.CalculatePredictiveAimToTarget(SwingCenter, Target, RecoilSpeed);
if (!float.IsNaN(dashVelocity.X) && !float.IsNaN(dashVelocity.Y))
Projectile.velocity = dashVelocity;
}
else
Projectile.velocity *= 0.5f;
// Cancel out choppy movement
if (Projectile.velocity.Length() < 1f)
Projectile.velocity *= 0f;
SwingTimer += 1f * SwingDirection;
if (SwingTimer == 0f || SwingTimer == SwingWait + SwingTime + SwingWait)
@@ -183,9 +205,6 @@ namespace CalamityMod.Projectiles.Summon
else
HasStartedSwinging = true;
}
if (Projectile.DistanceSQ(Target.Center) > 320f * 320f)
DashTimer += Main.rand.NextBool((int)DashCooldown) ? 2 : 1;
}
private void OnStateChange(Action newState)
+24 -22
View File
@@ -24,12 +24,15 @@ namespace CalamityMod.Projectiles.Summon
Projectile.timeLeft = 200;
Projectile.coldDamage = true;
Projectile.DamageType = DamageClass.Summon;
Projectile.penetrate = -1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 5f)
Projectile.localAI[0]++;
if (Projectile.localAI[0] > 2f && Projectile.ai[0] == 0f)
{
for (int i = 0; i < 6; i++)
{
@@ -43,33 +46,32 @@ namespace CalamityMod.Projectiles.Summon
}
}
}
public override void OnKill(int timeLeft)
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
Projectile.position = Projectile.Center;
Projectile.width = Projectile.height = 70;
Projectile.position -= Projectile.Size * 0.5f;
Projectile.maxPenetrate = -1;
Projectile.penetrate = -1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.damage /= 3;
Projectile.Damage();
int flowerPetalCount = Main.rand.Next(3, 5 + 1);
float thetaDelta = Projectile.velocity.ToRotation();
float weaveDistanceMin = 2f;
float weaveDistanceOutwardMax = 3f;
float weaveDistanceInner = 0.5f;
for (float theta = 0f; theta < MathHelper.TwoPi; theta += 0.05f)
if (Projectile.ai[0] == 0f)
{
Vector2 velocity = theta.ToRotationVector2() *
Projectile.ai[0]++;
Projectile.ExpandHitboxBy(128);
Projectile.Damage();
int flowerPetalCount = Main.rand.Next(3, 5 + 1);
float thetaDelta = Projectile.velocity.ToRotation();
float weaveDistanceMin = 2f;
float weaveDistanceOutwardMax = 3f;
float weaveDistanceInner = 0.5f;
for (float theta = 0f; theta < MathHelper.TwoPi; theta += 0.05f)
{
Vector2 velocity = theta.ToRotationVector2() *
(weaveDistanceMin +
// The 0.5 in here is to prevent the petal from looping back into itself. With a 0.5 addition, it is perfect, coming back to (0,0)
// instead of weaving backwards.
(float)(Math.Sin(thetaDelta + theta * flowerPetalCount) + 0.5f + weaveDistanceInner) *
weaveDistanceOutwardMax);
Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.MushroomSpray, velocity);
dust.noGravity = true;
dust.scale = 1.35f;
Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.MushroomSpray, velocity);
dust.noGravity = true;
dust.scale = 1.35f;
}
Projectile.Kill();
}
}
}
+2 -2
View File
@@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon
Projectile.frame = 9;
Projectile.localAI[1]++;
if (Projectile.localAI[1] > 2)
if (Projectile.localAI[1] > 3)
{
Projectile.localAI[1] = 0;
@@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Summon
if (Projectile.ai[1] < 300f)
Projectile.ai[1]++;
float delay = 60f - Projectile.ai[1] / 60f * 10f;
float delay = 60f - Projectile.ai[1] / 60f * 9f;
if (Projectile.localAI[0] > delay)
{
Projectile.localAI[0] = 0f;
+10 -12
View File
@@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Summon
Projectile.penetrate = -1;
Projectile.MaxUpdates = 2;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 10;
Projectile.localNPCHitCooldown = -1;
Projectile.netImportant = true;
Projectile.timeLeft = 90000;
Projectile.DamageType = DamageClass.Summon;
@@ -122,13 +122,13 @@ namespace CalamityMod.Projectiles.Summon
public void AttackTarget(NPC target)
{
int reelBackTime = 32;
int homeDelay = 27;
int reelBackTime = 30;
int homeDelay = 15;
int attackTime = 150;
int attackCycleInterval = reelBackTime + attackTime;
// Teleport to the enemy if it's far away.
if (!Projectile.WithinRange(target.Center, 1200f))
if (!Projectile.WithinRange(target.Center, 960f))
{
Vector2 teleportDestination = target.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(250f, 300f);
DoTeleport(teleportDestination);
@@ -145,11 +145,11 @@ namespace CalamityMod.Projectiles.Summon
Projectile.frame = (int)Math.Round(MathHelper.Lerp(6f, 11f, AttackTimer / reelBackTime));
// Reel back and look at the target.
float hoverOffset = MathHelper.Lerp(200f, 480f, AttackTimer / reelBackTime);
float hoverOffset = MathHelper.Lerp(160f, 320f, AttackTimer / reelBackTime);
hoverOffset += MathHelper.Lerp(-10f, 75f, Projectile.identity % 9f / 1f);
float spin = MathHelper.Lerp(-0.27f, 0.27f, Projectile.identity / 7f % 1f);
Vector2 hoverDestination = target.Center - target.SafeDirectionTo(target.Center, Vector2.UnitY).RotatedBy(spin) * hoverOffset;
Vector2 idealVelocity = Projectile.SafeDirectionTo(hoverDestination) * MathHelper.Min(25f, Projectile.Distance(hoverDestination));
Vector2 idealVelocity = Projectile.SafeDirectionTo(hoverDestination) * MathHelper.Min(12f, Projectile.Distance(hoverDestination));
Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.02f);
Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.03f).MoveTowards(idealVelocity, 0.5f);
@@ -164,6 +164,8 @@ namespace CalamityMod.Projectiles.Summon
}
else if (DelayUntilNextPunch <= 0)
{
Projectile.ResetLocalNPCHitImmunity();
// Home towards the target briefly after the initial charge.
if (AttackTimer >= reelBackTime + homeDelay)
Projectile.velocity = Projectile.SuperhomeTowardsTarget(target, 34f, 24f);
@@ -203,14 +205,10 @@ namespace CalamityMod.Projectiles.Summon
Projectile.netUpdate = true;
}
public override bool MinionContactDamage() => true;
public override bool MinionContactDamage() => DelayUntilNextPunch <= 0 && AttackTimer > 0f;
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
// Rebound on collision.
if (DelayUntilNextPunch > 0 || AttackTimer <= 0f)
return;
// Create some cool particles to go with the hit.
Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Hitbox.ClosestPointInRect(Projectile.Center), 0.5f);
for (int i = 0; i < 7; i++)
@@ -235,7 +233,7 @@ namespace CalamityMod.Projectiles.Summon
SoundEngine.PlaySound(SoundID.Item74 with { Pitch = -0.36f }, Projectile.Center);
DelayUntilNextPunch = WarloksMoonFist.PunchCooldownTime - 10;
Projectile.velocity = Projectile.SafeDirectionTo(target.Center, -Vector2.UnitY).RotatedBy(0.16f) * Projectile.velocity.Length() * -0.45f;
Projectile.velocity = Projectile.SafeDirectionTo(target.Center, -Vector2.UnitY).RotatedBy(0.16f) * Projectile.velocity.Length() * -0.3f;
Projectile.netUpdate = true;
}
@@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon
dust_splash += 1;
}
int split = 0;
int shardAmt = Main.rand.Next(1, 5);
int shardAmt = Main.rand.Next(2, 4);
while (split < shardAmt)
{
//Calculate the velocity of the projectile
+5 -5
View File
@@ -52,22 +52,22 @@ namespace CalamityMod.Projectiles.Summon
Projectile.ai[0] -= 1f;
return;
}
Projectile.ai[1] += Main.rand.Next(1, 3);
Projectile.ai[1]++;
NPC potentialTarget = Projectile.Center.MinionHoming(800f, player, false);
NPC potentialTarget = Projectile.Center.MinionHoming(400f, player, false);
if (Projectile.owner == Main.myPlayer && potentialTarget != null)
{
if (Projectile.ai[1] > 40f)
if (Projectile.ai[1] > 75f)
{
Vector2 spawnPosition = new Vector2(Projectile.oldPosition.X + (Projectile.width / 2), Projectile.oldPosition.Y + (Projectile.height / 2));
float shootSpeed = 16f;
float gravity = -PolypLauncherProjectile.Gravity;
float distance = Vector2.Distance(spawnPosition, potentialTarget.Center);
float angle = 0.25f * (float)Math.Asin(MathHelper.Clamp(gravity * distance * 1.5f / (float)Math.Pow(shootSpeed, 2), -1f, 1f));
float angle = 0.25f * MathF.Asin(MathHelper.Clamp(gravity * distance * 1.5f / MathF.Pow(shootSpeed, 2f), -1f, 1f));
Vector2 velocity = new Vector2(0f, -shootSpeed).RotatedBy(angle).RotatedByRandom(0.1f);
Vector2 velocity = new Vector2(0f, -shootSpeed).RotatedBy(angle).RotatedByRandom(0.05f);
velocity.X *= (potentialTarget.Center.X - Projectile.Center.X < 0).ToDirectionInt();
Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPosition, velocity, ModContent.ProjectileType<PolypLauncherProjectile>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
+1 -1
View File
@@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Summon
}
Projectile.Opacity = 1f - (float)Math.Pow(LifetimeCompletion, 1.56);
Projectile.scale = MathHelper.Lerp(0.5f, 7f, LifetimeCompletion);
Projectile.scale = MathHelper.Lerp(0.5f, 5f, LifetimeCompletion);
Projectile.rotation += Projectile.localAI[0] * 0.012f;
}
+2 -2
View File
@@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Summon
Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Type];
// Hover in place.
Projectile.velocity = -Vector2.UnitY * (float)Math.Sin(MathHelper.TwoPi * Projectile.timeLeft / 96f) * 3f;
Projectile.velocity = -Vector2.UnitY * MathF.Sin(MathHelper.TwoPi * Projectile.timeLeft / 96f) * 3f;
// Look at nearby enemies.
NPC potentialTarget = Projectile.Center.MinionHoming(1000f, Owner);
@@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Summon
Projectile.spriteDirection = (Projectile.Center.X < potentialTarget.Center.X).ToDirectionInt();
// Release pulses of irradiated energy.
if (Projectile.timeLeft % RustyBeaconPrototype.PulseReleaseRate == RustyBeaconPrototype.PulseReleaseRate / 2)
if (Projectile.timeLeft % RustyBeaconPrototype.PulseReleaseRate == 1)
{
SoundEngine.PlaySound(SoundID.DD2_WitherBeastAuraPulse with { Volume = 1.6f }, Projectile.Center);
+3 -5
View File
@@ -21,18 +21,15 @@ namespace CalamityMod.Projectiles.Summon
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 7;
Projectile.minionSlots = 0f;
Projectile.extraUpdates = 1;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;
Projectile.tileCollide = false;
Projectile.timeLeft *= 5;
Projectile.minion = true;
Projectile.DamageType = DamageClass.Summon;
}
public override bool? CanDamage() => false;
public override void AI()
{
Player player = Main.player[Projectile.owner];
@@ -50,6 +47,7 @@ namespace CalamityMod.Projectiles.Summon
return;
}
Projectile.timeLeft = 2;
NPC target = Projectile.Center.MinionHoming(SkeletalDragonMother.DistanceToCheck * 0.666f, player);
if (target != null)
+1 -1
View File
@@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Summon
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 6;
Projectile.localNPCHitCooldown = 20;
Projectile.minionSlots = 6f;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;