Visual Glowup + misc. tweaks
Holdout code mostly sourced from Scorpio and the Flak line. Projectile visuals mostly sourced from Polaris Parrotfish.
This commit is contained in:
1 parent
0bfc945eef
commit
8a1fd48598
3 files changed
+228
-37
No files matched your search
@@ -1,47 +1,55 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
public class SlagfireDouser : ModItem, ILocalizedModType
|
||||
{
|
||||
public static int OriginalUseTime = 30;
|
||||
public static int TimeBetweenBursts = 4;
|
||||
public static int ProjectilesPerBurst = 4;
|
||||
|
||||
public new string LocalizationCategory => "Items.Weapons.Ranged";
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 104;
|
||||
Item.height = 34;
|
||||
Item.damage = 10;
|
||||
Item.damage = 11;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.useTime = 4;
|
||||
Item.useAnimation = 16;
|
||||
Item.useTime = 18;
|
||||
Item.useAnimation = 18;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 2f;
|
||||
Item.UseSound = SoundID.Item61; // Grenade Launcher, Chicken Cannon, etc
|
||||
Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.95f, PitchVariance = 0.1f };
|
||||
Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ModContent.ProjectileType<Slagfire>();
|
||||
Item.autoReuse = false; // Because holdout
|
||||
Item.shoot = ModContent.ProjectileType<SlagfireDouserHoldout>();
|
||||
Item.ArmorPenetration = 10;
|
||||
Item.shootSpeed = 14f;
|
||||
Item.reuseDelay = 16;
|
||||
Item.shootSpeed = 13f;
|
||||
Item.reuseDelay = 0; // Because holdout
|
||||
Item.channel = true; // Because holdout
|
||||
Item.noUseGraphic = true;
|
||||
}
|
||||
|
||||
public override Vector2? HoldoutOffset() => new Vector2(-16, 0);
|
||||
public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true;
|
||||
public override Vector2? HoldoutOffset() => new Vector2(102, 0);
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ProjectileType<SlagfireDouserHoldout>(), damage, knockback, player.whoAmI);
|
||||
|
||||
float SpeedX = velocity.X + (float)Main.rand.Next(-25, 26) * 0.04f;
|
||||
float SpeedY = velocity.Y + (float)Main.rand.Next(-25, 26) * 0.04f;
|
||||
Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI);
|
||||
|
||||
return false;
|
||||
// Seting its velocity like this is what aims to the mouse
|
||||
holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.WorldBuilding;
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class Slagfire : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 32;
|
||||
@@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
|
||||
Projectile.localAI[1]++;
|
||||
if (Projectile.localAI[1] >= 4f)
|
||||
{
|
||||
@@ -43,28 +44,51 @@ namespace CalamityMod.Projectiles.Magic
|
||||
Projectile.localAI[0] += 1f;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Color trailColor = Color.PaleVioletRed;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Vector2 positionDelta = Projectile.velocity / 3f * i;
|
||||
int spawnDelta = 14;
|
||||
int dustIdx = Dust.NewDust(new Vector2(Projectile.position.X + spawnDelta, Projectile.position.Y + spawnDelta), Projectile.width - spawnDelta * 2, Projectile.height - spawnDelta * 2, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f);
|
||||
Dust dust = Main.dust[dustIdx];
|
||||
dust.noGravity = true;
|
||||
dust.velocity *= 0.1f;
|
||||
dust.velocity += Projectile.velocity * 0.5f;
|
||||
dust.position -= positionDelta;
|
||||
Vector2 sparkPosition = Projectile.Center - (Projectile.velocity / 3f * i);
|
||||
|
||||
Vector2 sparkVelocity = -Projectile.velocity * 0.01f * Main.rand.NextFloat(0.5f, 1.5f);
|
||||
|
||||
Particle spark = new CustomSpark(
|
||||
sparkPosition,
|
||||
sparkVelocity,
|
||||
"CalamityMod/Particles/BloomLineFade",
|
||||
false,
|
||||
6,
|
||||
0.04f,
|
||||
trailColor * 0.85f,
|
||||
new Vector2(0.8f, 1), // Scaling for the end
|
||||
shrinkSpeed: 0.4f);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(8))
|
||||
{
|
||||
int spawnDelta = 16;
|
||||
int dustIdx = Dust.NewDust(new Vector2(Projectile.position.X + spawnDelta, Projectile.position.Y + spawnDelta), Projectile.width - spawnDelta * 2, Projectile.height - spawnDelta * 2, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 0.5f);
|
||||
Main.dust[dustIdx].velocity *= 0.25f;
|
||||
Main.dust[dustIdx].velocity += Projectile.velocity * 0.5f;
|
||||
Vector2 sparkPosition = Projectile.Center + Main.rand.NextVector2Circular(15, 15);
|
||||
Vector2 sparkVelocity = -Projectile.velocity * Main.rand.NextFloat(0.01f, 0.045f); // Backward velocity
|
||||
|
||||
Particle subtleSpark = new CustomSpark(
|
||||
sparkPosition,
|
||||
sparkVelocity,
|
||||
"CalamityMod/Particles/BloomLineFade",
|
||||
false,
|
||||
8,
|
||||
0.02f,
|
||||
trailColor * 0.5f,
|
||||
new Vector2(0.5f, 0.8f),
|
||||
shrinkSpeed: 0.3f);
|
||||
GeneralParticleHandler.SpawnParticle(subtleSpark);
|
||||
}
|
||||
|
||||
if (Projectile.localAI[1] >= 10f)
|
||||
Projectile.velocity.Y += 0.075f;
|
||||
}
|
||||
Projectile.velocity.Y += 0.2f;
|
||||
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target)
|
||||
{
|
||||
@@ -83,7 +107,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
if (target.type == NPCID.Guide)
|
||||
{
|
||||
|
||||
|
||||
if (target.life <= 0)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
@@ -94,12 +118,12 @@ namespace CalamityMod.Projectiles.Magic
|
||||
}
|
||||
|
||||
if (!NPC.AnyNPCs(NPCID.WallofFlesh)) // Don't spawn if Wall is already active
|
||||
{
|
||||
{
|
||||
int playerIndex = Projectile.owner;
|
||||
if (playerIndex >= 0 && Main.player[playerIndex].active)
|
||||
{
|
||||
NPC.SpawnOnPlayer(playerIndex, NPCID.WallofFlesh); // The game handles spawning logic by itself from here
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class SlagfireDouserHoldout : BaseGunHoldoutProjectile
|
||||
{
|
||||
public override int AssociatedItemID => ItemType<SlagfireDouser>();
|
||||
|
||||
private static readonly Vector2 CustomHoldoutOffset = new Vector2(25f, 0f);
|
||||
|
||||
public override Vector2 GunTipPosition // There is likely a cleaner way to do this with the base gun holdout proj
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector2 baseTip = base.GunTipPosition;
|
||||
|
||||
baseTip.X += CustomHoldoutOffset.X * Owner.direction;
|
||||
baseTip.Y += CustomHoldoutOffset.Y;
|
||||
|
||||
baseTip -= Vector2.UnitY.RotatedBy(Projectile.rotation) * 10f * Projectile.spriteDirection * Owner.gravDir;
|
||||
|
||||
return baseTip;
|
||||
}
|
||||
}
|
||||
|
||||
public override float RecoilResolveSpeed => 0.12f;
|
||||
public override float MaxOffsetLengthFromArm => 12f;
|
||||
public override float OffsetXUpwards => -25f;
|
||||
public override float OffsetXDownwards => -25f;
|
||||
public override float OffsetYUpwards => -24f;
|
||||
public override float OffsetYDownwards => 24f;
|
||||
public override float BaseOffsetY => -2f;
|
||||
public ref float ShootingTimer => ref Projectile.ai[0];
|
||||
|
||||
private const int BurstProjectiles = 4; // 4 Slagfire shots per burst
|
||||
private const int DelayBetweenShotsInBurst = 4;
|
||||
private const int BurstCooldown = 18;
|
||||
|
||||
public static int DustEffectsID { get; set; } = DustID.Ice_Red;
|
||||
public static Color EffectsColor { get; set; } = Color.MediumVioletRed;
|
||||
public static Color StaticEffectsColor { get; set; } = Color.MediumVioletRed;
|
||||
|
||||
public override void HoldoutAI()
|
||||
{
|
||||
if (!Owner.channel)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
if (ShootingTimer % (HeldItem.useAnimation + BurstProjectiles * DelayBetweenShotsInBurst + BurstCooldown) == 0 && ShootingTimer > 0)
|
||||
{
|
||||
ShootingTimer = 0;
|
||||
}
|
||||
|
||||
// Calc current shot index
|
||||
int currentShotInBurst = (int)((ShootingTimer % (HeldItem.useAnimation + BurstProjectiles * DelayBetweenShotsInBurst + BurstCooldown) - HeldItem.useAnimation) / DelayBetweenShotsInBurst);
|
||||
|
||||
if (ShootingTimer >= HeldItem.useAnimation && currentShotInBurst >= 0 && currentShotInBurst < BurstProjectiles)
|
||||
{
|
||||
if ((ShootingTimer - HeldItem.useAnimation) % DelayBetweenShotsInBurst == 0)
|
||||
{
|
||||
Shoot(HeldItem);
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
Vector2 projectileDirection = Projectile.velocity.SafeNormalize(Vector2.Zero);
|
||||
|
||||
Vector2 position = GunTipPosition - Projectile.velocity * 5; // Position near the gun tip
|
||||
Vector2 velocity = projectileDirection.RotatedByRandom(MathHelper.ToRadians(0.25f)) * Main.rand.NextFloat(0.9f, 1.9f);
|
||||
|
||||
SquishyLightParticle energy = new(position, velocity, Main.rand.NextFloat(0.18f, 0.22f), StaticEffectsColor, Main.rand.Next(3, 5 + 1), 1, 1.5f);
|
||||
GeneralParticleHandler.SpawnParticle(energy);
|
||||
|
||||
Dust dust = Dust.NewDustPerfect(position, DustEffectsID, velocity, 0, default, Main.rand.NextFloat(1.2f, 1.7f));
|
||||
dust.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
ShootingTimer++; // Once per tick
|
||||
}
|
||||
|
||||
public void Shoot(Item item)
|
||||
{
|
||||
Vector2 projectileDirection = Projectile.velocity.SafeNormalize(Vector2.Zero);
|
||||
|
||||
int damage = Owner.GetWeaponDamage(item);
|
||||
float knockback = Owner.GetWeaponKnockback(item, item.knockBack);
|
||||
int projectileType = ProjectileType<Slagfire>();
|
||||
float projectileSpeed = item.shootSpeed;
|
||||
|
||||
// Random spread
|
||||
Vector2 finalProjectileVelocity = projectileDirection.RotatedByRandom(MathHelper.ToRadians(8f)) * projectileSpeed;
|
||||
|
||||
// Slagfire
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, finalProjectileVelocity, projectileType, damage, knockback, Projectile.owner);
|
||||
|
||||
// Saves resources for dedicated servers from here
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item61, Projectile.Center);
|
||||
|
||||
// Apply recoil by decreasing the offset length from the arm
|
||||
OffsetLengthFromArm -= 3f;
|
||||
|
||||
int dustAmount = Main.rand.Next(10, 15 + 1);
|
||||
for (int i = 0; i < dustAmount; i++)
|
||||
{
|
||||
Dust shootDust = Dust.NewDustPerfect(
|
||||
GunTipPosition,
|
||||
DustEffectsID,
|
||||
projectileDirection.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 8f)); // Dust spread for visual effect
|
||||
shootDust.noGravity = true;
|
||||
shootDust.noLight = true;
|
||||
shootDust.noLightEmittence = true;
|
||||
}
|
||||
|
||||
// Pulse FX
|
||||
Particle shootPulse = new DirectionalPulseRing(
|
||||
GunTipPosition,
|
||||
Vector2.Zero, // Pulse doesn't need initial velocity
|
||||
Color.Gray * 0.7f,
|
||||
new Vector2(0.5f, 1f),
|
||||
Projectile.rotation,
|
||||
0.1f,
|
||||
0.4f,
|
||||
20);
|
||||
GeneralParticleHandler.SpawnParticle(shootPulse);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
|
||||
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
|
||||
drawPosition.X += CustomHoldoutOffset.X * Owner.direction;
|
||||
drawPosition.Y += CustomHoldoutOffset.Y;
|
||||
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
Vector2 rotationPoint = texture.Size() * 0.5f;
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user