little work on this again

This commit is contained in:
Altixal committed 2024-08-23 20:33:21 +07:00
1 parent 7629dbd470
commit 0f09378767
7 files changed
+138 -149

No files matched your search

+9 -7
View File
@@ -15,20 +15,22 @@ namespace CalamityMod.Items.Weapons.Magic
{
Item.width = 220;
Item.height = 60;
Item.damage = 132;
Item.mana = 50;
Item.damage = 400;
Item.DamageType = DamageClass.Magic;
Item.mana = 50;
Item.useTime = Item.useAnimation = 80; // 42 frames of firing animation
Item.knockBack = 2f;
Item.shoot = ModContent.ProjectileType<ThunderstormHoldout>();
Item.shootSpeed = 16f;
Item.useStyle = ItemUseStyleID.Shoot;
Item.autoReuse = true;
Item.channel = true;
Item.noMelee = true;
Item.noUseGraphic = true;
Item.channel = true;
Item.knockBack = 2f;
Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
Item.rare = ModContent.RarityType<Turquoise>();
Item.autoReuse = true;
Item.shootSpeed = 6f;
Item.shoot = ModContent.ProjectileType<ThunderstormHoldout>();
}
// Cancels out the mana used to summon the holdout
@@ -630,7 +630,7 @@ PlasmaRifle: {
DisplayName: Plasma Rifle
Tooltip:
'''
Fires an explosive plasma blast
Fires an explosive plasma blast with pinpoint accuracy
Press <right> to rapidly fire non-explosive blasts
'''
}
@@ -220,7 +220,6 @@ TacticiansTrumpCardProj.DisplayName: Trump Beam
TearsofHeavenProjectile.DisplayName: Tears of Heaven
Teslabeam.DisplayName: Teslabeam
ThunderstormShot.DisplayName: Thunderous Shot
ThunderstormShotSplit.DisplayName: Thunderous Shot
TradewindsProjectile.DisplayName: Tradewinds Feather
TridentIcicle.DisplayName: Trident Icicle
UberBubble.DisplayName: Bubble
+9 -5
View File
@@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Magic
// Meanwhile, this is for the shorter trail at the head
public override void SetStaticDefaults()
{
ProjectileID.Sets.DrawScreenCheckFluff[Type] = 5000;
ProjectileID.Sets.TrailCacheLength[Type] = 12;
ProjectileID.Sets.TrailingMode[Type] = 2;
}
@@ -49,7 +50,7 @@ namespace CalamityMod.Projectiles.Magic
else
{
if (Projectile.FinalExtraUpdate() || TrailPos.Count < 15)
TrailPos.Add(Projectile.position);
TrailPos.Add(Projectile.Center);
if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything
Explode();
@@ -77,7 +78,7 @@ namespace CalamityMod.Projectiles.Magic
Projectile.timeLeft = 50;
Projectile.velocity = Vector2.Zero;
Projectile.netUpdate = true;
TrailPos.Add(Projectile.position); // Final position update
TrailPos.Add(Projectile.Center); // Final position update
// Right click can not explode
if (Projectile.ai[0] > 0f)
@@ -97,14 +98,17 @@ namespace CalamityMod.Projectiles.Magic
}
}
internal float HeadWidthFunction(float completionRatio) => Projectile.scale * 4f * Utils.GetLerpValue(0.5f, 0.25f, MathF.Abs(0.5f - completionRatio), true);
internal float HeadWidthFunction(float completionRatio) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f) * Utils.GetLerpValue(0.5f, 0.25f, MathF.Abs(0.5f - completionRatio), true);
internal Color HeadColorFunction(float completionRatio) => Color.LightSlateGray * Projectile.Opacity;
internal float TrailWidthFunction(float completionRatio) => Projectile.scale * 4f;
internal float TrailWidthFunction(float completionRatio) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f);
internal Color TrailColorFunction(float completionRatio) => Color.Lerp(Color.Chartreuse, Color.SlateGray, Utils.Remap(Projectile.Opacity, 0.5f, 1f, 0f, 0.8f)) * Projectile.Opacity * 0.3f;
public override bool PreDraw(ref Color lightColor)
{
PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction, (_) => Projectile.Size * 0.5f), 30);
if (TrailPos == null)
return false;
PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction), 30);
PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(HeadWidthFunction, HeadColorFunction, (_) => Projectile.Size * 0.5f), 12);
return false;
}
+29 -1
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Particles;
using CalamityMod.Projectiles.BaseProjectiles;
using CalamityMod.Sounds;
using Microsoft.Xna.Framework;
@@ -31,6 +32,16 @@ namespace CalamityMod.Projectiles.Magic
public override void SetStaticDefaults() => Main.projFrames[Projectile.type] = 15;
public override void SetDefaults()
{
base.SetDefaults();
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.DamageType = DamageClass.Magic;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
}
public override void KillHoldoutLogic()
{
// Only times out if at the final frame (post-firing resting time)
@@ -86,7 +97,19 @@ namespace CalamityMod.Projectiles.Magic
{
FlashTimer = 4f;
SoundEngine.PlaySound(CommonCalamitySounds.PlasmaBlastSound, GunTipPosition);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed, ModContent.ProjectileType<ThunderstormShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
// Start from slightly behind the tip
Vector2 offsetPos = GunTipPosition - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 18f;
Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), offsetPos, velocity, ModContent.ProjectileType<ThunderstormShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
for (int i = 0; i < 8; i++)
{
float scale = Main.rand.NextFloat(0.6f, 1.25f);
Vector2 randVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(8f, 12f);
Particle point = new PointParticle(offsetPos, randVelocity, false, 15, scale, new Color(51, 197, 255));
GeneralParticleHandler.SpawnParticle(point);
}
}
}
// The firing animation
@@ -101,6 +124,11 @@ namespace CalamityMod.Projectiles.Magic
}
}
// Muzzle flash can deal damage
public override bool? CanDamage() => FlashTimer > 0f;
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(GunTipPosition + Vector2.UnitX.RotatedBy(Projectile.rotation) * MuzzleFlash.Width() * 0.4f, 64f, targetHitbox);
public override bool PreDraw(ref Color lightColor)
{
Texture2D texture = TextureAssets.Projectile[Type].Value;
+90 -52
View File
@@ -1,6 +1,12 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Projectiles.DraedonsArsenal;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
@@ -10,72 +16,104 @@ namespace CalamityMod.Projectiles.Magic
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
// Due to how far/fast this thing moves, it'd require way too many points for a smooth long trail using oldPos
public List<Vector2> TrailPos = new List<Vector2>();
public const int TrailLength = 50;
public override void SetStaticDefaults() => ProjectileID.Sets.DrawScreenCheckFluff[Type] = 5000;
public override void SetDefaults()
{
Projectile.width = 6;
Projectile.height = 6;
Projectile.width = Projectile.height = 18;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.penetrate = 1;
Projectile.alpha = 255;
Projectile.timeLeft = 600;
Projectile.MaxUpdates = 30;
Projectile.MaxUpdates = 15;
Projectile.timeLeft = 24 * Projectile.MaxUpdates;
Projectile.penetrate = -1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Projectile.ai[0] += 1f;
if (Projectile.ai[0] > 9f)
Projectile.rotation = Projectile.velocity.ToRotation();
if (Projectile.numHits > 0)
{
for (int i = 0; i < 5; i++)
Projectile.scale -= 0.01f;
Projectile.Opacity -= 0.01f;
if (Projectile.Opacity <= 0f)
Projectile.Kill();
}
else
{
// Update a bit more frequently than the update count for better point distribution
if (Projectile.FinalExtraUpdate() || Projectile.numUpdates % 3 == 2 || TrailPos == null)
{
Dust greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)];
greenDust.velocity = Vector2.Zero;
greenDust.position -= Projectile.velocity / 5f * (float)i;
greenDust.noGravity = true;
greenDust.noLight = true;
Dust lightningDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Vortex, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)];
lightningDust.velocity = Vector2.Zero;
lightningDust.position -= Projectile.velocity / 5f * (float)i;
lightningDust.noGravity = true;
lightningDust.noLight = true;
// Initialize 15 points immediately
if (TrailPos == null)
{
TrailPos = new List<Vector2>(15);
for (int i = 0; i < 15; ++i)
TrailPos.Add(Projectile.Center);
}
// Add some random value for the natural lightning look
Vector2 randOffset = (Vector2.UnitY * Main.rand.NextFloat(-24f, 24f)).RotatedBy(Projectile.rotation);
TrailPos.Insert(0, Projectile.Center + randOffset);
while (TrailPos.Count > TrailLength)
TrailPos.RemoveAt(TrailPos.Count - 1);
}
if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything
Decay();
}
}
public override void OnKill(int timeLeft)
public override bool? CanDamage() => Projectile.numHits == 0 ? null : false;
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
var source = Projectile.GetSource_FromThis();
SoundEngine.PlaySound(SoundID.Item125, Projectile.Center);
for (int n = 0; n < 5; n++)
{
CalamityUtils.ProjectileRain(source, Projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType<ThunderstormShotSplit>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
}
Projectile.ExpandHitboxBy(36);
int dustAmt = 36;
for (int j = 0; j < dustAmt; j++)
{
Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 1f; //0.75
dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center;
Vector2 dustDirection = dustRotate - Projectile.Center;
int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.Vortex, dustDirection.X, dustDirection.Y, 100, default, 1.2f);
Main.dust[killDust].noGravity = true;
Main.dust[killDust].noLight = true;
Main.dust[killDust].velocity = dustDirection;
}
for (int j = 0; j < dustAmt; j++)
{
Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f;
dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center;
Vector2 dustDirection = dustRotate - Projectile.Center;
int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.TerraBlade, dustDirection.X, dustDirection.Y, 100, default, 1.2f);
Main.dust[killDust].noGravity = true;
Main.dust[killDust].noLight = true;
Main.dust[killDust].velocity = dustDirection;
}
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.Damage();
if (Projectile.numHits == 0)
Decay();
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
if (Projectile.numHits == 0)
Decay();
return false;
}
public void Decay()
{
Projectile.numHits++; // Ensure this can only happen once
Projectile.timeLeft = 100;
Projectile.velocity = Vector2.Zero;
Projectile.netUpdate = true;
// Final position update
TrailPos.Insert(0, Projectile.Center);
while (TrailPos.Count > TrailLength)
TrailPos.RemoveAt(TrailPos.Count - 1);
SoundEngine.PlaySound(AnomalysNanogunMPFBBoom.MPFBExplosion, Projectile.Center);
}
internal float TrailWidthFunction(float completionRatio) => Projectile.scale * 12f * Utils.GetLerpValue(0.5f, 0.4f, MathF.Abs(0.5f - completionRatio), true);
internal Color TrailColorFunction(float completionRatio) => Color.Lerp(new Color(51, 197, 255), new Color(143, 51, 255), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 20f)) * Projectile.Opacity;
public override bool PreDraw(ref Color lightColor)
{
if (TrailPos == null)
return false;
GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin");
GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply();
PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction, smoothen: false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), TrailLength);
return false;
}
}
}
@@ -1,82 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class ThunderstormShotSplit : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 4;
Projectile.height = 4;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.tileCollide = false;
Projectile.penetrate = 1;
Projectile.alpha = 255;
Projectile.timeLeft = 600;
Projectile.MaxUpdates = 20;
}
public override void AI()
{
if (Projectile.timeLeft < 420)
{
Projectile.tileCollide = true;
}
Projectile.ai[0] += 1f;
if (Projectile.ai[0] > 6f)
{
for (int i = 0; i < 5; i++)
{
Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.5f)];
dust.velocity = Vector2.Zero;
dust.position -= Projectile.velocity / 5f * (float)i;
dust.noGravity = true;
dust.noLight = true;
Dust dust2 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Vortex, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.5f)];
dust2.velocity = Vector2.Zero;
dust2.position -= Projectile.velocity / 5f * (float)i;
dust2.noGravity = true;
dust2.noLight = true;
}
}
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item125, Projectile.Center);
Projectile.position = Projectile.Center;
Projectile.width = Projectile.height = 16;
Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2);
int dustAmt = 36;
for (int j = 0; j < dustAmt; j++)
{
Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; //0.75
dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center;
Vector2 dustDirection = dustRotate - Projectile.Center;
int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.Vortex, dustDirection.X, dustDirection.Y, 100, default, 0.6f);
Main.dust[killDust].noGravity = true;
Main.dust[killDust].noLight = true;
Main.dust[killDust].velocity = dustDirection;
}
for (int j = 0; j < dustAmt; j++)
{
Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f;
dustRotate = dustRotate.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center;
Vector2 dustDirection = dustRotate - Projectile.Center;
int killDust = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.TerraBlade, dustDirection.X, dustDirection.Y, 100, default, 0.6f);
Main.dust[killDust].noGravity = true;
Main.dust[killDust].noLight = true;
Main.dust[killDust].velocity = dustDirection;
}
Projectile.Damage();
}
}
}