Hyperius Bullets
splits into 3 colorful shards that whirl and spin past the target you hit to hit enemies behind them
This commit is contained in:
1 parent
1eddfa8145
commit
9cbd124f3e
7 files changed
+218
-84
No files matched your search
@@ -18,7 +18,7 @@ namespace CalamityMod.Items.Ammo
|
||||
{
|
||||
Item.width = 24;
|
||||
Item.height = 30;
|
||||
Item.damage = 18;
|
||||
Item.damage = 19;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.maxStack = 9999;
|
||||
Item.consumable = true;
|
||||
@@ -26,7 +26,7 @@ namespace CalamityMod.Items.Ammo
|
||||
Item.value = Item.sellPrice(copper: 16);
|
||||
Item.rare = ItemRarityID.Cyan;
|
||||
Item.shoot = ModContent.ProjectileType<HyperiusBulletProj>();
|
||||
Item.shootSpeed = 16f;
|
||||
Item.shootSpeed = 5f;
|
||||
Item.ammo = AmmoID.Bullet;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ HyperiusBullet: {
|
||||
DisplayName: Hyperius Bullet
|
||||
Tooltip:
|
||||
'''
|
||||
Your enemies might have a bad time
|
||||
Spawns additional bullets on enemy hits
|
||||
Powerful multicolor bullets
|
||||
Bullets split into swirling lights on impact
|
||||
'''
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class GlowOrbParticle : Particle
|
||||
{
|
||||
public Color InitialColor;
|
||||
public bool AffectedByGravity;
|
||||
public bool UseAltVisual = true;
|
||||
public float fadeOut = 1;
|
||||
public bool imporant;
|
||||
public override bool SetLifetime => true;
|
||||
public override bool UseCustomDraw => true;
|
||||
public override bool UseAdditiveBlend => UseAltVisual;
|
||||
public override bool Important => imporant;
|
||||
|
||||
public override string Texture => "CalamityMod/Particles/GlowOrbParticle";
|
||||
|
||||
public GlowOrbParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool AddativeBlend = true, bool needed = false)
|
||||
{
|
||||
Position = relativePosition;
|
||||
Velocity = velocity;
|
||||
AffectedByGravity = affectedByGravity;
|
||||
Scale = scale;
|
||||
Lifetime = lifetime;
|
||||
Color = InitialColor = color;
|
||||
UseAltVisual = AddativeBlend;
|
||||
imporant = needed;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
fadeOut -= 0.1f;
|
||||
Scale *= 0.93f;
|
||||
Color = Color.Lerp(InitialColor, InitialColor * 0.2f, (float)Math.Pow(LifetimeCompletion, 3D));
|
||||
Velocity *= 0.95f;
|
||||
if (Velocity.Length() < 12f && AffectedByGravity)
|
||||
{
|
||||
Velocity.X *= 0.94f;
|
||||
Velocity.Y += 0.25f;
|
||||
}
|
||||
Rotation = Velocity.ToRotation() + MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 scale = new Vector2(1f, 1f) * Scale;
|
||||
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
||||
|
||||
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
|
||||
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.White * fadeOut, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.5f, 0.5f), 0, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -1,7 +1,12 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using CalamityMod.Dusts;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using System;
|
||||
using CalamityMod.Particles;
|
||||
using Terraria.Audio;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
@@ -9,55 +14,79 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
private Color currentColor = Color.Black;
|
||||
|
||||
public float dustAngle = 0f;
|
||||
public bool growing = false;
|
||||
public bool dustWave = false;
|
||||
public float variance;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6;
|
||||
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
||||
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 4;
|
||||
Projectile.height = 4;
|
||||
Projectile.width = 6;
|
||||
Projectile.height = 6;
|
||||
Projectile.aiStyle = ProjAIStyleID.Arrow;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.extraUpdates = 3;
|
||||
Projectile.timeLeft = 1200;
|
||||
Projectile.extraUpdates = 10;
|
||||
AIType = ProjectileID.Bullet;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player Owner = Main.player[Projectile.owner];
|
||||
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
|
||||
|
||||
variance = Main.rand.NextFloat(0.3f, 1.7f);
|
||||
if (currentColor == Color.Black)
|
||||
{
|
||||
int startPoint = Main.rand.Next(6);
|
||||
Projectile.localAI[0] = startPoint;
|
||||
currentColor = GetStartingColor(startPoint);
|
||||
dustWave = Main.rand.NextBool();
|
||||
Projectile.scale = 1.5f;
|
||||
Projectile.velocity *= 0.3f;
|
||||
switch (Main.rand.Next(0, 4 +1))
|
||||
{
|
||||
case 4: // Yellow shot
|
||||
currentColor = Color.Yellow * 0.65f;
|
||||
break;
|
||||
case 3: // Magenta shot
|
||||
currentColor = Color.Magenta * 0.65f;
|
||||
break;
|
||||
case 2: // Red shot
|
||||
currentColor = Color.Red * 0.65f;
|
||||
break;
|
||||
case 1: // Blue shot
|
||||
currentColor = Color.Cyan * 0.65f;
|
||||
break;
|
||||
default: // Green shot
|
||||
currentColor = Color.Lime * 0.65f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Visuals(Projectile, ref currentColor);
|
||||
}
|
||||
|
||||
internal static void Visuals(Projectile projectile, ref Color c)
|
||||
{
|
||||
CalamityUtils.IterateDisco(ref c, ref projectile.localAI[0], 15);
|
||||
Vector3 compositeColor = 0.1f * Color.White.ToVector3() + 0.05f * c.ToVector3();
|
||||
Lighting.AddLight(projectile.Center, compositeColor);
|
||||
}
|
||||
|
||||
internal static Color GetStartingColor(int startPoint = 0)
|
||||
{
|
||||
switch (startPoint)
|
||||
if (dustAngle <= -0.5f)
|
||||
{
|
||||
default: return new Color(1f, 0f, 0f, 0f); // Color.Red
|
||||
case 1: return new Color(1f, 1f, 0f, 0f); // Color.Yellow
|
||||
case 2: return new Color(0f, 1f, 0f, 0f); // Color.Green
|
||||
case 3: return new Color(0f, 1f, 1f, 0f); // Color.Turquoise
|
||||
case 4: return new Color(0f, 0f, 1f, 0f); // Color.Blue
|
||||
case 5: return new Color(1f, 0f, 1f, 0f); // Color.Violet
|
||||
growing = true;
|
||||
}
|
||||
if (dustAngle >= 0.5f)
|
||||
{
|
||||
growing = false;
|
||||
}
|
||||
dustAngle += (growing ? 0.07f * variance : -0.07f * variance);
|
||||
|
||||
Projectile.localAI[0] += 1f;
|
||||
if (Projectile.localAI[0] > 12f && targetDist < 1400f)
|
||||
{
|
||||
GlowOrbParticle orb = new GlowOrbParticle((Projectile.Center + Projectile.velocity.RotatedBy((dustWave ? 1 : -1) * dustAngle) * 4.5f) - Projectile.velocity * 5, Vector2.Zero, false, 5, 0.55f + MathF.Abs(dustAngle * 0.5f), currentColor, true, true);
|
||||
GeneralParticleHandler.SpawnParticle(orb);
|
||||
|
||||
PointParticle spark = new PointParticle(Projectile.Center + Projectile.velocity * 3.5f, Projectile.velocity, false, 2, 0.6f, currentColor);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +98,24 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor);
|
||||
if (Projectile.localAI[0] > 25f)
|
||||
{
|
||||
CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
for (int b = 0; b < 3; b++)
|
||||
{
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -oldVelocity.RotatedByRandom(0.5f) * 0.7f, ModContent.ProjectileType<HyperiusSplit>(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
OnHitEffects(target.Center);
|
||||
@@ -87,24 +130,23 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
var source = Projectile.GetSource_FromThis();
|
||||
CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType<HyperiusSplit>(), (int)(Projectile.damage * 0.6), 1f, Projectile.owner, true);
|
||||
for (int b = 0; b < 3; b++)
|
||||
{
|
||||
Vector2 velocity = Projectile.velocity.RotatedByRandom(0.5f);
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType<HyperiusSplit>(), (int)(Projectile.damage * 0.1), Projectile.knockBack * 2f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
const int killDust = 3;
|
||||
int[] dustTypes = new int[] { 60, 61, 59 };
|
||||
for (int i = 0; i < killDust; ++i)
|
||||
for (int b = 0; b < 9; b++)
|
||||
{
|
||||
int dustType = dustTypes[Main.rand.Next(3)];
|
||||
float scale = Main.rand.NextFloat(0.4f, 0.9f);
|
||||
float velScale = Main.rand.NextFloat(3f, 5.5f);
|
||||
int dustID = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType);
|
||||
Main.dust[dustID].noGravity = true;
|
||||
Main.dust[dustID].scale = scale;
|
||||
Main.dust[dustID].velocity *= velScale;
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, 66, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f));
|
||||
dust.noGravity = true;
|
||||
dust.scale = Main.rand.NextFloat(0.7f, 1.4f);
|
||||
dust.color = currentColor;
|
||||
dust.fadeIn = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 2.8 KiB |
@@ -1,7 +1,13 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Particles;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
@@ -10,67 +16,95 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/Ranged/HyperiusBulletProj";
|
||||
private Color currentColor = Color.Black;
|
||||
|
||||
private int rotDirection = 1;
|
||||
private float rotIntensity;
|
||||
private bool rotPhase2 = false;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6;
|
||||
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 8;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
// Intentionally large bullet hitbox to make Hyperius swarm more forgiving with hits
|
||||
Projectile.width = 8;
|
||||
Projectile.height = 8;
|
||||
Projectile.width = 12;
|
||||
Projectile.height = 12;
|
||||
Projectile.aiStyle = ProjAIStyleID.Arrow;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 360;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.penetrate = 2;
|
||||
Projectile.timeLeft = 500;
|
||||
Projectile.extraUpdates = 8;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 10 * Projectile.extraUpdates;
|
||||
Projectile.alpha = 255;
|
||||
Projectile.ignoreWater = true;
|
||||
|
||||
AIType = ProjectileID.Bullet;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player Owner = Main.player[Projectile.owner];
|
||||
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
|
||||
|
||||
Projectile.localAI[0]++;
|
||||
if (currentColor == Color.Black)
|
||||
{
|
||||
int startPoint = Main.rand.Next(6);
|
||||
Projectile.localAI[0] = startPoint;
|
||||
currentColor = HyperiusBulletProj.GetStartingColor(startPoint);
|
||||
Projectile.alpha = 255;
|
||||
rotDirection = Main.rand.NextBool() ? 1 : -1;
|
||||
rotIntensity = Main.rand.NextFloat(0.5f, 1.5f);
|
||||
Projectile.timeLeft = Main.rand.Next(250, 300 + 1);
|
||||
switch (Projectile.ai[2])
|
||||
{
|
||||
case 4: // Yellow shot
|
||||
currentColor = Color.Yellow * 0.65f;
|
||||
break;
|
||||
case 3: // Magenta shot
|
||||
currentColor = Color.Magenta * 0.65f;
|
||||
break;
|
||||
case 2: // Red shot
|
||||
currentColor = Color.Red * 0.65f;
|
||||
break;
|
||||
case 1: // Blue shot
|
||||
currentColor = Color.Cyan * 0.65f;
|
||||
break;
|
||||
default: // Green shot
|
||||
currentColor = Color.Lime * 0.65f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetDist < 1400f)
|
||||
{
|
||||
GlowOrbParticle orb = new GlowOrbParticle(Projectile.Center - Projectile.velocity, -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.9f), false, 3, 0.55f, currentColor, true, true);
|
||||
GeneralParticleHandler.SpawnParticle(orb);
|
||||
}
|
||||
HyperiusBulletProj.Visuals(Projectile, ref currentColor);
|
||||
}
|
||||
|
||||
// This projectile is always fullbright.
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return currentColor;
|
||||
}
|
||||
if (Projectile.timeLeft == 180)
|
||||
rotPhase2 = true;
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (Projectile.timeLeft == 360)
|
||||
return false;
|
||||
CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor);
|
||||
return false;
|
||||
if (rotPhase2)
|
||||
{
|
||||
rotIntensity *= 1.001f;
|
||||
Projectile.velocity *= 0.997f;
|
||||
Projectile.velocity = Projectile.velocity.RotatedBy(-0.025f * rotIntensity * rotDirection);
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.velocity = Projectile.velocity.RotatedBy(0.015f * rotIntensity * rotDirection);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
const int killDust = 3;
|
||||
int[] dustTypes = new int[] { 60, 61, 59 };
|
||||
for (int i = 0; i < killDust; ++i)
|
||||
for (int b = 0; b < 3; b++)
|
||||
{
|
||||
int dustType = dustTypes[Main.rand.Next(3)];
|
||||
float scale = Main.rand.NextFloat(0.4f, 0.9f);
|
||||
float velScale = Main.rand.NextFloat(3f, 5.5f);
|
||||
int dustID = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType);
|
||||
Main.dust[dustID].noGravity = true;
|
||||
Main.dust[dustID].scale = scale;
|
||||
Main.dust[dustID].velocity *= velScale;
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, 66, new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f));
|
||||
dust.noGravity = true;
|
||||
dust.scale = Main.rand.NextFloat(0.5f, 1.1f);
|
||||
dust.color = currentColor;
|
||||
dust.fadeIn = 0;
|
||||
}
|
||||
}
|
||||
public override bool? CanDamage() => Projectile.localAI[0] < 20 ? false : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user