Plasma Rifle ig

This commit is contained in:
Altixal committed 2024-08-14 22:20:08 +07:00
1 parent da8251cd0a
commit 7629dbd470
7 files changed
+174 -134

No files matched your search

+19 -27
View File
@@ -1,7 +1,6 @@
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Rarities;
using CalamityMod.Sounds;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
@@ -28,18 +27,20 @@ namespace CalamityMod.Items.Weapons.Magic
Item.width = 72;
Item.height = 20;
Item.damage = 150;
Item.mana = 40;
Item.DamageType = DamageClass.Magic;
Item.useAnimation = Item.useTime = 8;
Item.useStyle = ItemUseStyleID.Shoot;
Item.noMelee = true;
Item.mana = 40;
Item.useAnimation = Item.useTime = 40;
Item.knockBack = 4f;
Item.shoot = ModContent.ProjectileType<PlasmaRifleShot>();
Item.shootSpeed = 12f;
Item.UseSound = HeavyShotSound;
Item.useStyle = ItemUseStyleID.Shoot;
Item.autoReuse = true;
Item.noMelee = true;
Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
Item.rare = ModContent.RarityType<Turquoise>();
Item.UseSound = CommonCalamitySounds.PlasmaBlastSound;
Item.autoReuse = true;
Item.shootSpeed = 12f;
Item.shoot = ModContent.ProjectileType<PlasmaShot>();
}
public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
@@ -48,14 +49,7 @@ namespace CalamityMod.Items.Weapons.Magic
public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
Item.UseSound = FastShotSound;
}
else
{
Item.UseSound = HeavyShotSound;
}
Item.UseSound = player.altFunctionUse == 2 ? FastShotSound : HeavyShotSound;
return base.CanUseItem(player);
}
@@ -65,20 +59,18 @@ namespace CalamityMod.Items.Weapons.Magic
mult *= 0.25f;
}
public override float UseSpeedMultiplier(Player player)
{
if (player.altFunctionUse == 2)
return 1f;
return 0.2f;
}
public override float UseSpeedMultiplier(Player player) => player.altFunctionUse == 2 ? 5f : 1f;
public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => position += velocity.SafeNormalize(Vector2.UnitX) * 56f;
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
if (player.altFunctionUse == 2)
Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType<PlasmaBolt>(), damage * 2, knockback, player.whoAmI);
else
Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI);
return false;
{
Projectile.NewProjectile(source, position, velocity, type, damage * 2, knockback, player.whoAmI, 1f);
return false;
}
return true;
}
public override void AddRecipes()
@@ -630,8 +630,8 @@ PlasmaRifle: {
DisplayName: Plasma Rifle
Tooltip:
'''
Fires a plasma blast that explodes
Press <right> to rapidly fire plasma bolts
Fires an explosive plasma blast
Press <right> to rapidly fire non-explosive blasts
'''
}
@@ -157,10 +157,10 @@ PhasedGodRay.DisplayName: Phased God Ray
PhotosyntheticShard.DisplayName: Photosynthetic Shard
PhotosyntheticSolarBeam.DisplayName: Solar Beam
PlagueFang.DisplayName: Plague Fang
PlasmaBolt.DisplayName: Plasma Bolt
PlasmaRay.DisplayName: Plasma Ray
PlasmaRay2.DisplayName: Plasma Ray
PlasmaShot.DisplayName: Plasma Shot
PlasmaRifleExplosion.DisplayName: Ionizing Particle Cloud
PlasmaRifleShot.DisplayName: Concentrated Plasma Blast
PoseidonTyphoon.DisplayName: Poseidon Typhoon
PrimordialAncientExplosion.DisplayName: Primordial Ancient
PrimordialAncientProjectile.DisplayName: Primordial Ancient
-42
View File
@@ -1,42 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class PlasmaBolt : 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.penetrate = 1;
Projectile.alpha = 255;
Projectile.timeLeft = 200;
Projectile.MaxUpdates = 10;
}
public override void AI()
{
Projectile.ai[0] += 1f;
if (Projectile.ai[0] > 6f)
{
for (int d = 0; d < 5; d++)
{
Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)];
dust.velocity = Vector2.Zero;
dust.position -= Projectile.velocity / 5f * d;
dust.noGravity = true;
dust.scale = 0.65f;
dust.noLight = true;
}
}
}
}
}
+39
View File
@@ -0,0 +1,39 @@
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class PlasmaRifleExplosion : BaseMassiveExplosionProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override int Lifetime => 40;
public override bool UsesScreenshake => true;
public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 3f;
public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Chartreuse;
public override void SetDefaults()
{
Projectile.width = Projectile.height = 2;
Projectile.friendly = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.timeLeft = Lifetime;
Projectile.DamageType = DamageClass.Magic;
}
public override void PostAI() => Lighting.AddLight(Projectile.Center, Color.Chartreuse.ToVector3() * Projectile.Opacity * 0.7f);
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (Projectile.numHits > 0)
Projectile.damage = (int)(Projectile.damage * 0.9f);
if (Projectile.damage < 1)
Projectile.damage = 1;
}
}
}
+112
View File
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using CalamityMod.Projectiles.DraedonsArsenal;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class PlasmaRifleShot : ModProjectile, ILocalizedModType
{
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>();
// Meanwhile, this is for the shorter trail at the head
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 12;
ProjectileID.Sets.TrailingMode[Type] = 2;
}
public override void SetDefaults()
{
Projectile.width = Projectile.height = 12;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.MaxUpdates = 10;
Projectile.timeLeft = 30 * Projectile.MaxUpdates;
Projectile.penetrate = -1; // Effectively no pierce -- this is just to prevent sudden trail cutting
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
if (Projectile.numHits > 0)
{
Projectile.scale -= 0.02f;
Projectile.Opacity -= 0.02f;
if (Projectile.Opacity <= 0f)
Projectile.Kill();
}
else
{
if (Projectile.FinalExtraUpdate() || TrailPos.Count < 15)
TrailPos.Add(Projectile.position);
if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything
Explode();
}
}
public override bool? CanDamage() => Projectile.numHits == 0 ? null : false;
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Projectile.numHits == 0)
Explode();
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
if (Projectile.numHits == 0)
Explode();
return false;
}
public void Explode()
{
Projectile.numHits++; // Ensure this can only happen once
Projectile.timeLeft = 50;
Projectile.velocity = Vector2.Zero;
Projectile.netUpdate = true;
TrailPos.Add(Projectile.position); // Final position update
// Right click can not explode
if (Projectile.ai[0] > 0f)
return;
SoundEngine.PlaySound(AnomalysNanogunMPFBBoom.MPFBExplosion, Projectile.Center);
if (Projectile.owner == Main.myPlayer)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<PlasmaRifleExplosion>(), Projectile.damage, Projectile.knockBack, Projectile.owner, ai1: 160f);
for (int k = 0; k < 30; k++)
{
float intensity = Main.rand.NextFloat(0.1f, 1f);
Color BaseCol = Color.Lerp(Color.Lime, Color.Yellow, intensity);
Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(24f, 25f) - 20f * intensity);
MediumMistParticle cloud = new MediumMistParticle(Projectile.Center, velocity, BaseCol, Color.Chartreuse, Main.rand.NextFloat(1f, 1.6f) + 2f * intensity, 210f, Main.rand.NextFloat(0.03f, -0.03f));
GeneralParticleHandler.SpawnParticle(cloud);
}
}
internal float HeadWidthFunction(float completionRatio) => Projectile.scale * 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 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);
PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(HeadWidthFunction, HeadColorFunction, (_) => Projectile.Size * 0.5f), 12);
return false;
}
}
}
-61
View File
@@ -1,61 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class PlasmaShot : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 6;
Projectile.height = 6;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.penetrate = 1;
Projectile.alpha = 255;
Projectile.timeLeft = 600;
Projectile.MaxUpdates = 10;
}
public override void AI()
{
Projectile.ai[0] += 1f;
if (Projectile.ai[0] > 6f)
{
for (int d = 0; d < 10; d++)
{
Dust dust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)];
dust.velocity = Vector2.Zero;
dust.position -= Projectile.velocity / 5f * d;
dust.noGravity = true;
dust.noLight = true;
}
}
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
int cloudAmt = Main.rand.Next(20, 31);
if (Projectile.owner == Main.myPlayer)
{
for (int i = 0; i < cloudAmt; i++)
{
Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f);
Projectile cloud = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ProjectileID.ToxicCloud + Main.rand.Next(3), (int)(Projectile.damage * 0.3f), 1f, Projectile.owner, 0f, Main.rand.Next(-45, 1));
cloud.usesIDStaticNPCImmunity = true;
cloud.idStaticNPCHitCooldown = 10;
}
}
for (int k = 0; k < 5; k++)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TerraBlade, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
}
}
}
}