Merge: Starfleet and Starmada reworks
No files matched your search
@@ -5217,6 +5217,13 @@ namespace CalamityMod.CalPlayer
|
||||
private void NOULOL()
|
||||
{
|
||||
Player.ResetEffects();
|
||||
for (int j = 0; j < 1000; j++)
|
||||
{
|
||||
if (!Main.projectile[j].active || Main.projectile[j].owner != Player.whoAmI)
|
||||
continue;
|
||||
|
||||
Player.ownedProjectileCounts[Main.projectile[j].type]++;
|
||||
}
|
||||
Player.head = -1;
|
||||
Player.body = -1;
|
||||
Player.legs = -1;
|
||||
|
||||
@@ -61,6 +61,7 @@ using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using CalamityMod.Projectiles.Melee;
|
||||
using CalamityMod.Projectiles.Pets;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
@@ -200,6 +201,17 @@ namespace CalamityMod.CalPlayer
|
||||
if (Player.ActiveItem().type != ModContent.ItemType<SaharaSlicers>())
|
||||
saharaSlicersBolts = 0;
|
||||
|
||||
if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType<Starfleet>() && (Player.ownedProjectileCounts[ModContent.ProjectileType<StarfleetHoldout>()] == 0) && !Player.dead)
|
||||
{
|
||||
int damage = (int)Player.GetTotalDamage<RangedDamageClass>().ApplyTo(Player.HeldItem.damage);
|
||||
Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType<StarfleetHoldout>(), damage, Player.HeldItem.knockBack, Player.whoAmI);
|
||||
}
|
||||
if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType<Starmada>() && (Player.ownedProjectileCounts[ModContent.ProjectileType<StarmadaHoldout>()] == 0) && !Player.dead)
|
||||
{
|
||||
int damage = (int)Player.GetTotalDamage<RangedDamageClass>().ApplyTo(Player.HeldItem.damage);
|
||||
Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType<StarmadaHoldout>(), damage, Player.HeldItem.knockBack, Player.whoAmI);
|
||||
}
|
||||
|
||||
// De-equipping Gael's Greatsword deletes all rage.
|
||||
if (Player.ActiveItem().type == ModContent.ItemType<GaelsGreatsword>())
|
||||
heldGaelsLastFrame = true;
|
||||
|
||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Graphics.Metaballs
|
||||
{
|
||||
public class StarsmokeMetaball : Metaball
|
||||
{
|
||||
public Color borderColor = Color.Purple;
|
||||
public Vector2 goalDir = Vector2.Zero;
|
||||
public Vector2 scrollDir = Vector2.Zero;
|
||||
public class StarsmokeParticle
|
||||
{
|
||||
public float Size;
|
||||
|
||||
public Vector2 Velocity;
|
||||
|
||||
public Vector2 Center;
|
||||
public Vector2 BaseSquash = Vector2.One;
|
||||
public float Rotation;
|
||||
public float ShrinkSpeed = 0;
|
||||
public int Lifetime;
|
||||
public float SquashPower = 0;
|
||||
public int time = 0;
|
||||
|
||||
public StarsmokeParticle(Vector2 center, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0)
|
||||
{
|
||||
Center = center;
|
||||
Velocity = velocity;
|
||||
Size = size;
|
||||
Rotation = Velocity.ToRotation() + MathHelper.PiOver2;
|
||||
BaseSquash = squash;
|
||||
Lifetime = lifetime;
|
||||
ShrinkSpeed = shrinkSpeed;
|
||||
SquashPower = velocitySquash;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
float sine = (float)Math.Sin(time * 0.15f * SquashPower) * 0.8f;
|
||||
Center += Velocity;
|
||||
Velocity *= 0.96f;
|
||||
Velocity += Velocity.RotatedBy(0.36f * sine * SquashPower * (Math.Sign(ShrinkSpeed))) * 0.02f;
|
||||
if ((float)time / (float)Lifetime > 0.8f)
|
||||
{
|
||||
Size *= 0.9f;
|
||||
}
|
||||
BaseSquash.X *= (1 - 0.2f * ShrinkSpeed);
|
||||
BaseSquash.Y *= (1 + 0.2f * ShrinkSpeed);
|
||||
Rotation = Velocity.ToRotation() + MathHelper.PiOver2;
|
||||
time++;
|
||||
}
|
||||
}
|
||||
public static Asset<Texture2D> LayerAsset
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public static List<StarsmokeParticle> Particles
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = new();
|
||||
|
||||
public override bool AnythingToDraw => Particles.Any();
|
||||
|
||||
public override IEnumerable<Texture2D> Layers
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return LayerAsset.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs;
|
||||
public override void Load()
|
||||
{
|
||||
if (Main.dedServ)
|
||||
return;
|
||||
|
||||
// Load the layer asset wrapper.
|
||||
LayerAsset = ModContent.Request<Texture2D>($"CalamityMod/Particles/GlowSquareParticleBig", AssetRequestMode.ImmediateLoad);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (goalDir == Vector2.Zero)
|
||||
goalDir = Vector2.One.RotatedByRandom(Math.PI);
|
||||
if ((int)(Main.GlobalTimeWrappedHourly * 50) % 5 == 0)
|
||||
{
|
||||
goalDir = goalDir.RotatedByRandom(0.13f);
|
||||
}
|
||||
scrollDir = Vector2.Lerp(scrollDir, goalDir, 0.01f);
|
||||
|
||||
float rate = Main.GlobalTimeWrappedHourly * 19;
|
||||
List<Color> colors = new List<Color>()
|
||||
{
|
||||
new Color (192, 10, 111),
|
||||
Color.Coral,
|
||||
Color.DarkOrange
|
||||
};
|
||||
|
||||
int colorIndex = (int)(rate / 2 % colors.Count);
|
||||
Color currentColor = colors[colorIndex];
|
||||
Color nextColor = colors[(colorIndex + 1) % colors.Count];
|
||||
borderColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
|
||||
|
||||
// Update all particle instances.
|
||||
// Once sufficiently small, they vanish.
|
||||
for (int i = 0; i < Particles.Count; i++)
|
||||
Particles[i].Update();
|
||||
Particles.RemoveAll(p => p.Size <= 2f);
|
||||
}
|
||||
public override Color EdgeColor => borderColor with { A = 0 } * 0.3f;
|
||||
|
||||
public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) =>
|
||||
Particles.Add(new(position, velocity, size, lifetime, squash, shrinkSpeed, velocitySquash));
|
||||
|
||||
// Make the texture scroll.
|
||||
public override Vector2 CalculateManualOffsetForLayer(int layerIndex)
|
||||
{
|
||||
return scrollDir * 0.5f;
|
||||
}
|
||||
|
||||
public override void DrawInstances()
|
||||
{
|
||||
Texture2D tex = ModContent.Request<Texture2D>("CalamityMod/Graphics/Metaballs/StarsmokeMetaball2").Value;
|
||||
|
||||
foreach (StarsmokeParticle particle in Particles)
|
||||
{
|
||||
float sine = (float)Math.Sin(particle.time * 0.2f) * 0.5f;
|
||||
float lifetimeVal = 1 - (particle.time / particle.Lifetime);
|
||||
Vector2 altSquash = new Vector2(1f + 1 * (1 + sine) * lifetimeVal, 1f + 1 * (1 - sine) * lifetimeVal);
|
||||
Vector2 squash = Vector2.Lerp(particle.BaseSquash, new Vector2(Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 2.5f)), particle.SquashPower);
|
||||
Vector2 drawPosition = particle.Center - Main.screenPosition;
|
||||
Vector2 origin = tex.Size() * 0.5f;
|
||||
Vector2 scale = Vector2.One * particle.Size / tex.Size();
|
||||
Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, particle.Rotation, origin, squash * scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/PlasmaBlast");
|
||||
Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/StarfleetStar");
|
||||
Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
|
||||
Item.rare = ModContent.RarityType<Turquoise>();
|
||||
Item.Calamity().donorItem = true;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Placeables.Ores;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using CalamityMod.Rarities;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
@@ -17,46 +18,53 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
Item.width = 76;
|
||||
Item.height = 36;
|
||||
Item.damage = 115;
|
||||
Item.damage = 2888;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.useTime = 55;
|
||||
Item.useAnimation = 55;
|
||||
Item.useTime = 70;
|
||||
Item.useAnimation = 70;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 15f;
|
||||
Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice;
|
||||
Item.rare = ModContent.RarityType<PureGreen>();
|
||||
Item.UseSound = SoundID.Item92;
|
||||
Item.channel = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ModContent.ProjectileType<PlasmaBlast>();
|
||||
Item.shoot = ModContent.ProjectileType<StarfleetStar>();
|
||||
Item.shootSpeed = 12f;
|
||||
Item.useAmmo = AmmoID.FallenStar;
|
||||
}
|
||||
|
||||
public override Vector2? HoldoutOffset()
|
||||
// Holdout projectile is spawned when holding the item, so using the item does nothing
|
||||
public override bool CanUseItem(Player player) => false;
|
||||
public override void ModifyTooltips(List<TooltipLine> list)
|
||||
{
|
||||
return new Vector2(-8, -11);
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
for (int index = 0; index < 5; ++index)
|
||||
Player Owner = Main.LocalPlayer;
|
||||
if (Owner is null)
|
||||
return;
|
||||
float rate = (Main.GlobalTimeWrappedHourly * 3);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f;
|
||||
float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f;
|
||||
Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
new Color(146, 255, 211),
|
||||
new Color(222, 225, 146),
|
||||
new Color(255, 233, 146)
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
|
||||
TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip7");
|
||||
if (line != null)
|
||||
line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f);
|
||||
}
|
||||
public override void AddRecipes()
|
||||
{
|
||||
CreateRecipe().
|
||||
AddIngredient(ItemID.SuperStarCannon).
|
||||
AddIngredient<Lumenyl>(6).
|
||||
AddIngredient<RuinousSoul>(4).
|
||||
AddIngredient<ExodiumCluster>(12).
|
||||
AddTile(TileID.MythrilAnvil).
|
||||
AddIngredient(ItemID.FallenStar, 15).
|
||||
AddIngredient<GalacticaSingularity>(3).
|
||||
AddTile(TileID.LunarCraftingStation).
|
||||
Register();
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -1,15 +1,15 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Placeables.Ores;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using CalamityMod.Rarities;
|
||||
using CalamityMod.Tiles.Furniture.CraftingStations;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
@@ -25,54 +25,50 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
Item.width = 122;
|
||||
Item.height = 50;
|
||||
Item.damage = 150;
|
||||
Item.damage = 4900;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.useAnimation = Item.useTime = 15;
|
||||
Item.useAnimation = Item.useTime = 70;
|
||||
Item.knockBack = 15f;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.UseSound = SoundID.Item92;
|
||||
Item.autoReuse = true;
|
||||
Item.noMelee = true;
|
||||
Item.shoot = ModContent.ProjectileType<PlasmaBlast>();
|
||||
Item.shootSpeed = 16f;
|
||||
Item.channel = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ModContent.ProjectileType<StarmadaStar>();
|
||||
Item.shootSpeed = 12f;
|
||||
Item.useAmmo = AmmoID.FallenStar;
|
||||
Item.rare = ModContent.RarityType<CosmicPurple>();
|
||||
Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice;
|
||||
}
|
||||
|
||||
public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent;
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
// Holdout projectile is spawned when holding the item, so using the item does nothing
|
||||
public override bool CanUseItem(Player player) => false;
|
||||
public override void ModifyTooltips(List<TooltipLine> list)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
Player Owner = Main.LocalPlayer;
|
||||
if (Owner is null)
|
||||
return;
|
||||
float rate = (Main.GlobalTimeWrappedHourly * 3);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
int starType = Utils.SelectRandom(Main.rand,
|
||||
[
|
||||
ModContent.ProjectileType<PlasmaBlast>(),
|
||||
ModContent.ProjectileType<AstralStar>(),
|
||||
ProjectileID.StarCannonStar,
|
||||
ProjectileID.Starfury
|
||||
]);
|
||||
int star = Projectile.NewProjectile(source, position + Main.rand.NextVector2Circular(21f, 21f), velocity * Main.rand.NextFloat(0.8f, 1.2f), starType, damage, knockback, player.whoAmI);
|
||||
if (star.WithinBounds(Main.maxProjectiles))
|
||||
{
|
||||
Main.projectile[star].penetrate = 1;
|
||||
Main.projectile[star].timeLeft = 300;
|
||||
Main.projectile[star].DamageType = DamageClass.Ranged;
|
||||
Main.projectile[star].netUpdate = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
new Color(164, 47, 160),
|
||||
new Color(227, 97, 72),
|
||||
new Color(193, 255, 146)
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
|
||||
TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip8");
|
||||
if (line != null)
|
||||
line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f);
|
||||
}
|
||||
public override void AddRecipes()
|
||||
{
|
||||
CreateRecipe().
|
||||
AddIngredient<Starfleet>().
|
||||
AddIngredient<StarSputter>().
|
||||
AddIngredient<CosmiliteBar>(8).
|
||||
AddIngredient<DarksunFragment>(8).
|
||||
AddIngredient<ExodiumCluster>(15).
|
||||
AddIngredient<AuricBar>(5).
|
||||
AddIngredient<ExodiumCluster>(25).
|
||||
AddTile<CosmicAnvil>().
|
||||
Register();
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
@@ -1194,15 +1194,32 @@ Spyker: {
|
||||
|
||||
Starfleet: {
|
||||
DisplayName: Starfleet
|
||||
Tooltip: Fires a spread of plasma blasts
|
||||
Tooltip:
|
||||
'''
|
||||
<left> fires a spread of starshots
|
||||
<right> fires a concussive short range starburst
|
||||
Holding down <right> disables the recoil damper
|
||||
Starshots can be accelerated by firing when the starburst goes off
|
||||
Perfect timing reduces spread and increases damage
|
||||
Imperfect timing still increases damage, but heavily increases spread
|
||||
Uses fallen stars, 50% chance to save ammo
|
||||
'Etoile, et toi'
|
||||
'''
|
||||
}
|
||||
|
||||
Starmada: {
|
||||
DisplayName: Starmada
|
||||
Tooltip:
|
||||
'''
|
||||
Fires a barrage of stars and plasma blasts
|
||||
{$CommonItemTooltip.PercentChanceToSaveAmmo}
|
||||
<left> fires a spread of starshots
|
||||
<right> fires a concussive short range starburst
|
||||
Holding down <right> disables the recoil damper
|
||||
Starshots can be accelerated by firing when the starburst goes off
|
||||
Perfect timing reduces spread, increases damage, and adds a stacking weapon power buff
|
||||
Imperfect timing still increases damage, but heavily increases spread and reduces weapon power
|
||||
The weapon power buff strengthens both starshots and the concussive starburst
|
||||
Uses fallen stars, 50% chance to save ammo
|
||||
'Et toi, et moi'
|
||||
'''
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,6 @@ PlagueTaintedDrone.DisplayName: Plague Tainted Drone
|
||||
PlanarRipperBolt.DisplayName: Planar Bolt
|
||||
PlanarRipperExplosion.DisplayName: Planar Explosion
|
||||
PlanetaryAnnihilationProj.DisplayName: Planetary Ball
|
||||
PlasmaBlast.DisplayName: Plasma Blast
|
||||
PlasmaExplosion.DisplayName: Plasma Explosion
|
||||
PolarStar.DisplayName: Star Shot
|
||||
PrecisionBolt.DisplayName: Precision Bolt
|
||||
@@ -212,6 +211,9 @@ SproutingArrowSplit.DisplayName: Sprouting Arrow
|
||||
SputterComet.DisplayName: Sputter Comet
|
||||
SputterCometBig.DisplayName: Sputter Comet
|
||||
SpykerProj.DisplayName: Spyker
|
||||
StarfleetStar.DisplayName: Starfleet Star
|
||||
StarmadaHitProj.DisplayName: Starmada
|
||||
StarmadaStar.DisplayName: Starmada Star
|
||||
StarmageddonBinaryStarCenter.DisplayName: Starmageddon Binary Star Center
|
||||
StarmageddonStar.DisplayName: Starmageddon Star
|
||||
StarmageddonStar2.DisplayName: Starmageddon Star
|
||||
|
||||
|
After Width: | Height: | Size: 9.0 KiB |
@@ -100,6 +100,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles
|
||||
/// Defaults to <see langword="true"/>.
|
||||
/// </summary>
|
||||
public bool KeepRefreshingLifetime { get; set; } = true;
|
||||
/// <summary>
|
||||
/// If the holdout should constantly set Owner.itemTime and Owner.itemAnimation as 2.
|
||||
/// </summary>
|
||||
public bool SetUsage { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The current offset length from the arm of the holdout.<br/>
|
||||
@@ -216,7 +220,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles
|
||||
Owner.ChangeDir(direction);
|
||||
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
Owner.itemTime = Owner.itemAnimation = 2;
|
||||
if (SetUsage)
|
||||
Owner.itemTime = Owner.itemAnimation = 2;
|
||||
Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation();
|
||||
|
||||
// -Pi/2 because the arms rotation starts with arms pointing down.
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class PlasmaBlast : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 10;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 10;
|
||||
Projectile.height = 10;
|
||||
Projectile.alpha = 150;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.soundDelay == 0)
|
||||
{
|
||||
Projectile.soundDelay = 20 + Main.rand.Next(40);
|
||||
SoundEngine.PlaySound(SoundID.Item9, Projectile.position);
|
||||
}
|
||||
|
||||
Projectile.localAI[0] += 1f;
|
||||
if (Projectile.localAI[0] == 12f)
|
||||
{
|
||||
Projectile.localAI[0] = 0f;
|
||||
for (int l = 0; l < 12; l++)
|
||||
{
|
||||
Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f;
|
||||
dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f);
|
||||
dustVel = dustVel.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default);
|
||||
int dust = Dust.NewDust(Projectile.Center, 0, 0, DustID.FireworkFountain_Blue, 0f, 0f, 160, default, 1f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
Main.dust[dust].position = Projectile.Center + dustVel;
|
||||
Main.dust[dust].velocity = Projectile.velocity * 0.1f;
|
||||
Main.dust[dust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dust].position) * 1.25f;
|
||||
}
|
||||
}
|
||||
|
||||
Projectile.alpha -= 15;
|
||||
int alphaControl = 150;
|
||||
if (Projectile.Center.Y >= Projectile.ai[1])
|
||||
alphaControl = 0;
|
||||
if (Projectile.alpha < alphaControl)
|
||||
Projectile.alpha = alphaControl;
|
||||
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
||||
|
||||
if (Main.rand.NextBool(16))
|
||||
{
|
||||
Vector2 extraDustVel = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default);
|
||||
int extraDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworkFountain_Blue, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f);
|
||||
Main.dust[extraDust].velocity = extraDustVel * 0.66f;
|
||||
Main.dust[extraDust].position = Projectile.Center + extraDustVel * 12f;
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(48) && !Main.dedServ)
|
||||
{
|
||||
int gore = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f);
|
||||
Main.gore[gore].velocity *= 0.66f;
|
||||
Main.gore[gore].velocity += Projectile.velocity * 0.3f;
|
||||
}
|
||||
|
||||
if (Projectile.ai[1] == 1f)
|
||||
{
|
||||
Projectile.light = 0.9f;
|
||||
if (Main.rand.NextBool(10))
|
||||
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworkFountain_Blue, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f);
|
||||
if (Main.rand.NextBool(20) && !Main.dedServ)
|
||||
Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f);
|
||||
}
|
||||
|
||||
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.1f / 255f, (255 - Projectile.alpha) * 0.7f / 255f, (255 - Projectile.alpha) * 0.15f / 255f);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<Voidfrost>(), 180);
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
if (Projectile.ai[0] == 1f)
|
||||
return;
|
||||
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<PlasmaExplosion>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 316 B |
@@ -0,0 +1,305 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ModLoader;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class StarfleetHoldout : BaseGunHoldoutProjectile
|
||||
{
|
||||
public override int AssociatedItemID => ItemType<Starfleet>();
|
||||
public override Vector2 GunTipPosition => base.GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -5;
|
||||
public override float RecoilResolveSpeed => 0.1f;
|
||||
public override float MaxOffsetLengthFromArm => 25f;
|
||||
public override float OffsetXUpwards => -12f;
|
||||
public override float BaseOffsetY => -10f;
|
||||
public override float OffsetYDownwards => 10f;
|
||||
public override float WeaponTurnSpeed => (0.6f);
|
||||
|
||||
public int time = 0;
|
||||
public int lastUseTime = 0;
|
||||
public int perfectLeniancy = 2;
|
||||
public int goodLeniancy => perfectLeniancy + 6;
|
||||
public ref float shootingCooldown => ref Projectile.ai[0];
|
||||
public ref float starburstTimer => ref Projectile.ai[1];
|
||||
public int extendedCooldown => (int)(lastUseTime * 1.2f);
|
||||
public int naildriverCooldown => (int)(lastUseTime * 1.5f);
|
||||
public int starburstPerfectTime = 23;
|
||||
public float recoilIntensity = 0;
|
||||
public int recoilTimerMax = 62;
|
||||
public Vector2 recoilDirection;
|
||||
public bool setVel = true;
|
||||
public float glowIntensity = 1;
|
||||
public Color c1 = new Color(146, 255, 211);
|
||||
public Color c2 = new Color(222, 225, 146);
|
||||
public Color c3 = new Color(255, 233, 146);
|
||||
public Color shiftColor;
|
||||
public ref float starburstCooldown => ref Projectile.ai[2];
|
||||
public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window
|
||||
public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window
|
||||
public override void KillHoldoutLogic() { }
|
||||
public override void SetDefaults()
|
||||
{
|
||||
base.SetDefaults();
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
public override void HoldoutAI()
|
||||
{
|
||||
float rate = (time * 0.05f);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
c1,
|
||||
c2,
|
||||
c3,
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
|
||||
SetUsage = false;
|
||||
bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0;
|
||||
if (lastUseTime == 0 || doingNothing)
|
||||
lastUseTime = Owner.HeldItem.useAnimation;
|
||||
if (!doingNothing)
|
||||
Owner.itemTime = Owner.itemAnimation = 5;
|
||||
|
||||
glowIntensity = MathHelper.Lerp(glowIntensity, (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax, 0, shootingCooldown, true), 5), 0.2f);
|
||||
|
||||
if ((Owner.HeldItem.type != ItemType<Starfleet>() && doingNothing) || Owner.dead)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
bool hasAmmo = Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, true);
|
||||
bool leftShootChecks = (Main.mouseLeft && !Main.mapFullscreen && !Owner.mouseInterface && shootingCooldown == 0) && hasAmmo;
|
||||
bool rightShootChecks = Owner.Calamity().mouseRight && !Main.mapFullscreen && !Owner.mouseInterface && starburstCooldown == 0 && starburstTimer == 0;
|
||||
|
||||
if (Main.mouseLeft && !hasAmmo && OffsetLengthFromArm >= 24.5f)
|
||||
{
|
||||
OffsetLengthFromArm -= 8;
|
||||
SoundStyle click = new("CalamityMod/Sounds/Item/DudFire");
|
||||
SoundEngine.PlaySound(click with { Volume = .6f, Pitch = -.2f }, Projectile.Center);
|
||||
}
|
||||
if (leftShootChecks)
|
||||
FireShotgun();
|
||||
if (rightShootChecks)
|
||||
{
|
||||
SoundStyle test = new("CalamityMod/Sounds/Item/StarfleetStarburst");
|
||||
SoundEngine.PlaySound(test with { Volume = 1f, Pitch = 0f }, Projectile.Center);
|
||||
starburstTimer++;
|
||||
}
|
||||
if (starburstTimer > 0)
|
||||
{
|
||||
// Do wind up animation
|
||||
if (starburstTimer < starburstPerfectTime / 2)
|
||||
OffsetLengthFromArm = 25 - 12 * (1 - (float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2 - 1, 0, starburstTimer, true), 5));
|
||||
else
|
||||
OffsetLengthFromArm = 13 + 20 * ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 8));
|
||||
|
||||
if (starburstTimer == starburstPerfectTime)
|
||||
FireStarburst();
|
||||
|
||||
starburstTimer++;
|
||||
if (starburstTimer > starburstPerfectTime + goodLeniancy + 1)
|
||||
starburstTimer = 0;
|
||||
}
|
||||
if (shootingCooldown > 0)
|
||||
shootingCooldown--;
|
||||
if (starburstCooldown > 0)
|
||||
starburstCooldown--;
|
||||
if (recoilIntensity > 0 && (shootingCooldown > 0 || starburstCooldown > 0))
|
||||
ManageRecoil();
|
||||
time++;
|
||||
}
|
||||
public void ManageRecoil()
|
||||
{
|
||||
float slowdown = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4);
|
||||
Vector2 movement = recoilDirection * (recoilIntensity) * slowdown;
|
||||
if (Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f)) || !Owner.Calamity().mouseRight)
|
||||
{
|
||||
recoilIntensity = 0;
|
||||
return;
|
||||
}
|
||||
if (slowdown > 0.1f)
|
||||
{
|
||||
if (setVel)
|
||||
{
|
||||
Owner.velocity = movement * 0.25f;
|
||||
setVel = false;
|
||||
}
|
||||
Projectile.Center += movement;
|
||||
Owner.Center += movement;
|
||||
}
|
||||
else
|
||||
setVel = true;
|
||||
}
|
||||
public void FireShotgun()
|
||||
{
|
||||
// 50% chance to not consume ammo
|
||||
Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, Main.rand.NextBool());
|
||||
|
||||
SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarfleetFire");
|
||||
for (int i = 0; i < (naildriver ? 2 : 1); i++)
|
||||
SoundEngine.PlaySound(shotgunFire with { Volume = (naildriver && i == 0 ? 0.3f : 0.6f), Pitch = ((naildriver && i == 0) ? 0f : 0.2f), MaxInstances = 2 }, Projectile.Center);
|
||||
// Perfects have longer cooldown
|
||||
int cooldown = (naildriver ? naildriverCooldown : lastUseTime);
|
||||
recoilTimerMax = cooldown;
|
||||
shootingCooldown = cooldown;
|
||||
recoilDirection = -Projectile.velocity;
|
||||
Owner.Calamity().GeneralScreenShakePower = (naildriver ? 9 : scattershot ? 7 : 4);
|
||||
OffsetLengthFromArm = (naildriver ? 0 : scattershot ? 7 : 15);
|
||||
|
||||
int baseShotCount = 6;
|
||||
for (int i = 0; i < baseShotCount; i++)
|
||||
{
|
||||
float randomVel = Main.rand.NextFloat(0.8f, 1f);
|
||||
float damageMult = ((naildriver || scattershot) ? 1.75f : 1f) / baseShotCount;
|
||||
float spread = (naildriver ? 0.06f : scattershot ? 0.9f : 0.25f);
|
||||
Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ModContent.ProjectileType<StarfleetStar>(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner, 0, 0, Main.rand.Next(0, 300 + 1));
|
||||
shotgun.extraUpdates = naildriver ? 9 : scattershot ? 7 : 3;
|
||||
}
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
float variance = Main.rand.NextFloat(-0.7f, 0.7f);
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(GunTipPosition, dustStyle);
|
||||
dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 3f;
|
||||
dust.velocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2);
|
||||
dust.noGravity = true;
|
||||
dust.color = GetRandomColor();
|
||||
dust.fadeIn = 4.75f;
|
||||
}
|
||||
|
||||
// You can uncomment this to check your timing
|
||||
/*if (naildriver)
|
||||
Main.NewText("naildriver: " + (starburstPerfectTime - starburstTimer), Color.DarkOrchid);
|
||||
if (scattershot)
|
||||
Main.NewText("scattershot: " + (starburstPerfectTime - starburstTimer), Color.Lime);*/
|
||||
|
||||
recoilIntensity = (naildriver ? 55f : scattershot ? 20f : 0);
|
||||
}
|
||||
public void FireStarburst()
|
||||
{
|
||||
if (Owner.Calamity().GeneralScreenShakePower < 7)
|
||||
Owner.Calamity().GeneralScreenShakePower = 7;
|
||||
recoilDirection = -Projectile.velocity;
|
||||
if (recoilIntensity < 15)
|
||||
recoilIntensity = 15;
|
||||
if (recoilTimerMax < extendedCooldown)
|
||||
recoilTimerMax = extendedCooldown;
|
||||
if (starburstCooldown < extendedCooldown)
|
||||
starburstCooldown = extendedCooldown;
|
||||
|
||||
float blastSize = 140;
|
||||
float minMultiplier = 0.1f;
|
||||
int hitsToMinMult = 6;
|
||||
Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<BasicBurst>(), (int)(Projectile.damage * 3), -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult);
|
||||
blast.timeLeft = 15;
|
||||
|
||||
for (int i = 0; i < 14; i++)
|
||||
{
|
||||
float dist = Main.rand.NextFloat(0, 3);
|
||||
Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 5, dist * 5), Projectile.velocity * Main.rand.NextFloat(4, 5) * (6 - dist * 2), "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.1f, 0.2f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: 0.3f);
|
||||
GeneralParticleHandler.SpawnParticle(forwardJet);
|
||||
}
|
||||
for (int i = 0; i < 34; i++)
|
||||
{
|
||||
float rot = Main.rand.NextFloat(0.05f, 0.35f) * (Main.rand.NextBool() ? -1 : 1);
|
||||
Vector2 startVel = Projectile.velocity.RotatedBy(rot) * Main.rand.NextFloat(8, 18) * (Main.rand.NextBool(4) ? 2f : 1);
|
||||
Particle stars = new VelChangingSpark(GunTipPosition, startVel, startVel.RotatedBy(rot * 5), "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true);
|
||||
GeneralParticleHandler.SpawnParticle(stars);
|
||||
}
|
||||
int parts = 60;
|
||||
for (int i = 0; i < parts; i++)
|
||||
{
|
||||
Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 4f;
|
||||
Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation());
|
||||
|
||||
float size = Utils.GetLerpValue(0, -4, intenededVel.X, true);
|
||||
float width = Utils.GetLerpValue(0, 4 * Math.Sign(fxVel.X), fxVel.X, true);
|
||||
Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f));
|
||||
|
||||
Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f);
|
||||
GeneralParticleHandler.SpawnParticle(aura);
|
||||
|
||||
}
|
||||
}
|
||||
public Color GetRandomColor()
|
||||
{
|
||||
Color useColor = Main.rand.Next(4) switch
|
||||
{
|
||||
0 => c1,
|
||||
1 => c2,
|
||||
_ => c3,
|
||||
};
|
||||
return useColor;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (time < 2)
|
||||
return false;
|
||||
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
|
||||
Texture2D glowTexture = Request<Texture2D>("CalamityMod/Items/Weapons/Ranged/StarfleetGlow").Value;
|
||||
Texture2D orb = Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
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;
|
||||
|
||||
float glowMult = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4);
|
||||
int draws = 18;
|
||||
float sine = (float)Math.Sin(time * 0.02f);
|
||||
float attackMult = (float)Math.Pow(Utils.GetLerpValue(0, starburstPerfectTime - 1, starburstTimer, true), 2);
|
||||
float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 55.5f / MathHelper.Pi);
|
||||
float fastSine = (float)Math.Sin(time * 0.2f);
|
||||
Color glowColor = shiftColor;
|
||||
|
||||
if (starburstTimer > 0 && starburstCooldown == 0)
|
||||
{
|
||||
for (int i = 0; i < draws; i++)
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time * 2);
|
||||
Main.EntitySpriteDraw(texture, drawPosition + drawOffset * 6 * attackMult, null, shiftColor with { A = 0 } * 0.7f * attackMult, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
}
|
||||
}
|
||||
|
||||
Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
|
||||
for (int i = 0; i < draws; i++)
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4);
|
||||
Main.EntitySpriteDraw(glowTexture, drawPosition + drawOffset, null, Color.Lerp(Color.Gray * 0.15f, glowColor with { A = 0 }, glowIntensity) * (0.1f + 0.5f * glowMult), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
}
|
||||
|
||||
if (starburstTimer > 0 && starburstCooldown == 0)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
// The shining orb at the tip
|
||||
Color orbColor = shiftColor with { A = 0 } * 0.5f;
|
||||
Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackMult * Main.rand.NextFloat(0.9f, 1.1f) * 8.5f;
|
||||
Main.EntitySpriteDraw(orb, GunTipPosition - Main.screenPosition, null, orbColor, Main.rand.NextFloat(-5, 5), orb.Size() * 0.5f, scale, SpriteEffects.None);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class StarfleetStar : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public int time = 0;
|
||||
public Color c1 = new Color(146, 255, 211);
|
||||
public Color c2 = new Color(222, 225, 146);
|
||||
public Color c3 = new Color(255, 233, 146);
|
||||
public Color shiftColor;
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 25;
|
||||
Projectile.height = 25;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.penetrate = 3;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
float rate = (Projectile.ai[2] * 0.05f);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
c1,
|
||||
c2,
|
||||
c3,
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
Projectile.ai[2]++;
|
||||
|
||||
if (time > 5 && time % 2 == 0)
|
||||
{
|
||||
Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor * 0.6f, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f);
|
||||
GeneralParticleHandler.SpawnParticle(trail);
|
||||
|
||||
if (time > 18)
|
||||
{
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle);
|
||||
dust.scale = Main.rand.NextFloat(1.2f, 1.8f);
|
||||
dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f);
|
||||
dust.noGravity = true;
|
||||
dust.color = shiftColor;
|
||||
dust.fadeIn = 5f;
|
||||
}
|
||||
}
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
time++;
|
||||
}
|
||||
public Color GetRandomColor()
|
||||
{
|
||||
Color useColor = Main.rand.Next(4) switch
|
||||
{
|
||||
0 => c1,
|
||||
1 => c2,
|
||||
_ => c3,
|
||||
};
|
||||
return useColor;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D glowTexture = Request<Texture2D>("CalamityMod/Projectiles/Rogue/LeonidStar").Value;
|
||||
Texture2D tex2 = Request<Texture2D>("CalamityMod/Particles/FadeStreak").Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
Vector2 rotationPoint = glowTexture.Size() * 0.5f;
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Vector2 offset = (MathHelper.TwoPi * i / 5).ToRotationVector2().RotatedBy(Projectile.rotation + MathHelper.Pi);
|
||||
for (int t = 0; t < 2; t++)
|
||||
Main.EntitySpriteDraw(tex2, drawPosition, null, shiftColor with { A = 0 } * 0.4f, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically);
|
||||
Main.EntitySpriteDraw(tex2, drawPosition, null, Color.White with { A = 0 } * 0.4f, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2(1.5f, 0.7f) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
float minMult = 0.1f;
|
||||
int hitsToMinMult = 2;
|
||||
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
|
||||
modifiers.SourceDamage *= damageMult;
|
||||
}
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
float variance = Main.rand.NextFloat(-0.5f, 0.5f);
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle);
|
||||
dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f;
|
||||
dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2);
|
||||
dust.noGravity = true;
|
||||
dust.color = GetRandomColor();
|
||||
dust.fadeIn = 2.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class StarmadaHitProj : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public int time = 0;
|
||||
public Color c1 = new Color(164, 47, 160);
|
||||
public Color c2 = new Color(227, 97, 72);
|
||||
public Color c3 = new Color(193, 255, 146);
|
||||
public Color shiftColor;
|
||||
public bool move = false;
|
||||
public NPC targeted;
|
||||
public Vector2 targetPos;
|
||||
public Vector2 distFromPos;
|
||||
public float squash = 1;
|
||||
public bool launched => Projectile.localAI[2] == 5 && move;
|
||||
public bool setLaunchStats = true;
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 25;
|
||||
Projectile.height = 25;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.extraUpdates = 3;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 800;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
public void FindTarget()
|
||||
{
|
||||
if (Projectile.ai[0] != -5)
|
||||
targeted = Main.npc[(int)Projectile.ai[0]];
|
||||
if (targeted == null || !targeted.CanBeChasedBy(Projectile, false) || !targeted.active)
|
||||
{
|
||||
targeted = Projectile.Center.ClosestNPCAt(800);
|
||||
Projectile.ai[0] = -5;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (time == 0)
|
||||
{
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
targetPos = Projectile.Center;
|
||||
}
|
||||
float rate = (Projectile.ai[2] * 0.05f);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
c1,
|
||||
c2,
|
||||
c3,
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
Projectile.ai[2]++;
|
||||
|
||||
float startTime = 120 + Projectile.ai[1];
|
||||
float endTime = startTime + 15 + Projectile.ai[1];
|
||||
if (launched)
|
||||
{
|
||||
if (setLaunchStats)
|
||||
{
|
||||
Projectile.extraUpdates = 12;
|
||||
Projectile.penetrate = 1;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
Projectile.localNPCImmunity[i] = 0;
|
||||
|
||||
setLaunchStats = false;
|
||||
}
|
||||
Projectile.rotation += (MathHelper.TwoPi) / (endTime / 3);
|
||||
if (time % 2 == 0)
|
||||
{
|
||||
Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/BloomCircle", false, 13, 0.11f, shiftColor * 0.6f, new Vector2(launched ? 5.5f : 0.8f, 3f), shrinkSpeed: launched ? 1f : 0.5f);
|
||||
GeneralParticleHandler.SpawnParticle(trail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (move)
|
||||
{
|
||||
squash = MathHelper.Lerp(squash, (time < endTime ? 0.15f : 1f), 0.08f);
|
||||
if (time == endTime)
|
||||
Projectile.localAI[2] = 1;
|
||||
if (time >= endTime)
|
||||
{
|
||||
if (Main.rand.NextBool(15))
|
||||
{
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle);
|
||||
dust.scale = Main.rand.NextFloat(1.2f, 1.8f);
|
||||
dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5f, 7f);
|
||||
dust.noGravity = true;
|
||||
dust.color = shiftColor;
|
||||
dust.fadeIn = 2f;
|
||||
}
|
||||
|
||||
Projectile.Center += Projectile.velocity.SafeNormalize(Vector2.UnitX) * 0.2f;
|
||||
if (time < endTime * 2f)
|
||||
Projectile.velocity *= 0.9f + (Projectile.ai[1] * 0.005f);
|
||||
|
||||
Projectile.rotation += (MathHelper.TwoPi) / (endTime / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.velocity.ToRotation() + MathHelper.PiOver2, 0.1f);
|
||||
Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/BloomCircle", false, 15, 0.3f, shiftColor, new Vector2(0.8f, 1.3f), shrinkSpeed: 0.5f);
|
||||
GeneralParticleHandler.SpawnParticle(trail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.rotation += MathHelper.TwoPi / (startTime / 3);
|
||||
|
||||
FindTarget();
|
||||
if (targeted != null)
|
||||
{
|
||||
targetPos = targeted.Center;
|
||||
}
|
||||
if (distFromPos != Vector2.Zero)
|
||||
{
|
||||
Projectile.Center = targetPos + distFromPos;
|
||||
}
|
||||
else if (targeted != null)
|
||||
distFromPos = (Projectile.Center - targeted.Center);
|
||||
|
||||
|
||||
distFromPos += -Projectile.velocity * 3.5f;
|
||||
Projectile.velocity *= 0.97f + (Projectile.ai[1] * 0.0025f);
|
||||
}
|
||||
}
|
||||
if (time == startTime && setLaunchStats)
|
||||
{
|
||||
Projectile.timeLeft = (int)(endTime * 3);
|
||||
move = true;
|
||||
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15;
|
||||
}
|
||||
|
||||
Projectile.scale = (float)Math.Pow(Math.Min(Utils.GetLerpValue(0, 40, time, true), Utils.GetLerpValue(0, 40, Projectile.timeLeft, true)), 3);
|
||||
|
||||
time++;
|
||||
}
|
||||
public override bool ShouldUpdatePosition() => move;
|
||||
public Color GetRandomColor()
|
||||
{
|
||||
Color useColor = Main.rand.Next(4) switch
|
||||
{
|
||||
0 => c1,
|
||||
1 => c2,
|
||||
_ => c3,
|
||||
};
|
||||
return useColor;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D star = Request<Texture2D>("CalamityMod/ExtraTextures/SimpleStar").Value;
|
||||
Texture2D tex = Request<Texture2D>("CalamityMod/Particles/CircularSmear").Value;
|
||||
Texture2D tex2 = Request<Texture2D>("CalamityMod/Particles/FadeStreak").Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
Vector2 rotationPoint = star.Size() * 0.5f;
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
Main.EntitySpriteDraw(tex, drawPosition, null, shiftColor with { A = 0 } * Math.Max((float)Math.Pow(squash, 5) - 0.15f, 0), Projectile.rotation * 1.6f, tex.Size() * 0.5f, Projectile.scale * Owner.gravDir * 0.39f, SpriteEffects.None);
|
||||
for (int i = 0; i < 2; i++)
|
||||
Main.EntitySpriteDraw(star, drawPosition, null, i == 0 ? Color.White with { A = 0 } * 0.3f : (shiftColor with { A = 0 } * 0.6f), Projectile.rotation, rotationPoint, new Vector2(1f * squash, 1f + (1 - squash)) * Projectile.scale * Owner.gravDir * (i == 0 ? 0.12f : 0.2f), SpriteEffects.None);
|
||||
return false;
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
|
||||
float minMult = 0.1f;
|
||||
int hitsToMinMult = 2;
|
||||
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
|
||||
modifiers.SourceDamage *= damageMult * (launched ? 2 : 1);
|
||||
}
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
if (launched)
|
||||
{
|
||||
float rot = Main.rand.NextFloat(0, MathHelper.TwoPi);
|
||||
for (int b = 1; b <= 6; b++)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle);
|
||||
dust.scale = 8 - b;
|
||||
dust.velocity = -Vector2.UnitY.RotatedBy((MathHelper.TwoPi / 5 * i) + rot) * (b * 1.75f + 2);
|
||||
dust.noGravity = true;
|
||||
dust.color = GetRandomColor();
|
||||
dust.fadeIn = 6.5f - b * 0.5f;
|
||||
}
|
||||
}
|
||||
Particle bloom = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 25, 1.2f, shiftColor, new Vector2(1, 1), true, true, 0, false, false, glowOpacity: 0.85f);
|
||||
GeneralParticleHandler.SpawnParticle(bloom);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,471 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ModLoader;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class StarmadaHoldout : BaseGunHoldoutProjectile
|
||||
{
|
||||
public override int AssociatedItemID => ItemType<Starmada>();
|
||||
public override Vector2 GunTipPosition => base.GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -5;
|
||||
public override float RecoilResolveSpeed => 0.1f;
|
||||
public override float MaxOffsetLengthFromArm => 32f;
|
||||
public override float OffsetXUpwards => -12f;
|
||||
public override float BaseOffsetY => -10f;
|
||||
public override float OffsetYDownwards => 10f;
|
||||
public override float WeaponTurnSpeed => (0.6f);
|
||||
|
||||
public int time = 0;
|
||||
public int lastUseTime = 0;
|
||||
public int perfectLeniancy = 2;
|
||||
public float frontRecoil = 0;
|
||||
public int goodLeniancy => perfectLeniancy + 6;
|
||||
public ref float shootingCooldown => ref Projectile.ai[0];
|
||||
public ref float starburstTimer => ref Projectile.ai[1];
|
||||
public int extendedCooldown => (int)(lastUseTime * 1.2f);
|
||||
public int perfectCooldown => (int)(lastUseTime * 1.5f);
|
||||
public int starburstPerfectTime = 23;
|
||||
public float recoilIntensity = 0;
|
||||
public int recoilTimerMax = 62;
|
||||
public Vector2 recoilDirection;
|
||||
public bool setVel = true;
|
||||
public float glowIntensity = 1;
|
||||
public float attackVisualMult = 0;
|
||||
public Color c1 = new Color(164, 47, 160);
|
||||
public Color c2 = new Color(227, 97, 72);
|
||||
public Color c3 = new Color(193, 255, 146);
|
||||
public Color shiftColor;
|
||||
public Vector2 gunBackPosition;
|
||||
public int gunPower = 1;
|
||||
public int lastGunPower = 1;
|
||||
public SlotId AudSlot1;
|
||||
public SlotId AudSlot2;
|
||||
public bool failedChain = false;
|
||||
public float shake = 0;
|
||||
public ref float starburstCooldown => ref Projectile.ai[2];
|
||||
public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window
|
||||
public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window
|
||||
public override void KillHoldoutLogic() { }
|
||||
public override void SetDefaults()
|
||||
{
|
||||
base.SetDefaults();
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
public override void HoldoutAI()
|
||||
{
|
||||
float rate = (time * 0.05f);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
c1,
|
||||
c2,
|
||||
c3,
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
|
||||
SetUsage = false;
|
||||
bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0;
|
||||
if (lastUseTime == 0 || doingNothing)
|
||||
lastUseTime = Owner.HeldItem.useAnimation;
|
||||
if (!doingNothing)
|
||||
Owner.itemTime = Owner.itemAnimation = 5;
|
||||
|
||||
glowIntensity = MathHelper.Lerp(glowIntensity, (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax, 0, shootingCooldown, true), 5), 0.2f);
|
||||
attackVisualMult = MathHelper.Lerp(attackVisualMult, (float)Math.Pow(Math.Min(Utils.GetLerpValue(0, starburstPerfectTime - 1, starburstTimer, true), 2) + (gunPower - 1) * 0.25f, 1) * glowIntensity, 0.2f);
|
||||
shake = MathHelper.Lerp(shake, 0, 0.05f);
|
||||
frontRecoil = MathHelper.Lerp(frontRecoil, 0, 0.11f);
|
||||
|
||||
if ((Owner.HeldItem.type != ItemType<Starmada>() && doingNothing) || Owner.dead)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
bool hasAmmo = Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, true);
|
||||
bool leftShootChecks = (Main.mouseLeft && !Main.mapFullscreen && !Owner.mouseInterface && shootingCooldown == 0) && hasAmmo;
|
||||
bool rightShootChecks = Owner.Calamity().mouseRight && !Main.mapFullscreen && !Owner.mouseInterface && starburstCooldown == 0 && starburstTimer == 0;
|
||||
|
||||
if (Main.mouseLeft && !hasAmmo && shake < 0.1f)
|
||||
{
|
||||
shake = 0.8f;
|
||||
SoundStyle click = new("CalamityMod/Sounds/Item/DudFire");
|
||||
SoundEngine.PlaySound(click with { Volume = .6f, Pitch = -.2f}, Projectile.Center);
|
||||
}
|
||||
|
||||
if (leftShootChecks)
|
||||
FireShotgun();
|
||||
if (rightShootChecks)
|
||||
{
|
||||
SoundStyle blast1 = new("CalamityMod/Sounds/Item/StarfleetStarburst");
|
||||
AudSlot1 = SoundEngine.PlaySound(blast1 with { Volume = 0.7f + gunPower * 0.1f, Pitch = 0f, MaxInstances = 8 }, Projectile.Center);
|
||||
SoundStyle blast2 = new("CalamityMod/Sounds/Item/StarfleetStarburst");
|
||||
AudSlot2 = SoundEngine.PlaySound(blast2 with { Volume = 0.5f + gunPower * 0.1f, Pitch = -0.2f + gunPower * 0.2f, MaxInstances = 8 }, Projectile.Center);
|
||||
lastGunPower = gunPower;
|
||||
starburstTimer++;
|
||||
}
|
||||
if (starburstTimer > 0)
|
||||
{
|
||||
// Do wind up animation
|
||||
if (starburstTimer < starburstPerfectTime / 2)
|
||||
{
|
||||
float up = (1 - (float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2 - 1, 0, starburstTimer, true), 2));
|
||||
OffsetLengthFromArm = 32 - 7 * up;
|
||||
frontRecoil = -25 * up;
|
||||
}
|
||||
else
|
||||
{
|
||||
float down = ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 12));
|
||||
OffsetLengthFromArm = 25 + 15 * down;
|
||||
frontRecoil = -25 + 25 * down;
|
||||
}
|
||||
|
||||
if (starburstTimer == starburstPerfectTime)
|
||||
FireStarburst();
|
||||
|
||||
starburstTimer++;
|
||||
if (starburstTimer > starburstPerfectTime + goodLeniancy + 1)
|
||||
starburstTimer = 0;
|
||||
}
|
||||
if (shootingCooldown > 0)
|
||||
{
|
||||
if (lastGunPower != gunPower)
|
||||
{
|
||||
if (SoundEngine.TryGetActiveSound(AudSlot1, out var s1) && s1.IsPlaying && failedChain)
|
||||
{
|
||||
s1.Pitch = MathHelper.Lerp(s1.Pitch, -0.7f, 0.07f);
|
||||
s1.Volume = MathHelper.Lerp(s1.Volume, 0.2f, 0.07f);
|
||||
}
|
||||
if (SoundEngine.TryGetActiveSound(AudSlot2, out var s2) && s2.IsPlaying && failedChain)
|
||||
{
|
||||
s2.Pitch = MathHelper.Lerp(s2.Pitch, -0.7f, 0.07f);
|
||||
s2.Volume = MathHelper.Lerp(s2.Volume, 0.2f, 0.07f);
|
||||
}
|
||||
}
|
||||
shootingCooldown--;
|
||||
}
|
||||
else
|
||||
failedChain = false;
|
||||
if (starburstCooldown > 0)
|
||||
starburstCooldown--;
|
||||
if (recoilIntensity > 0 && (shootingCooldown > 0 || starburstCooldown > 0))
|
||||
ManageRecoil();
|
||||
|
||||
time++;
|
||||
}
|
||||
public void ManageRecoil()
|
||||
{
|
||||
float slowdown = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4);
|
||||
Vector2 movement = recoilDirection * (recoilIntensity) * slowdown;
|
||||
if (Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f)) || !Owner.Calamity().mouseRight)
|
||||
{
|
||||
recoilIntensity = 0;
|
||||
return;
|
||||
}
|
||||
if (slowdown > 0.1f)
|
||||
{
|
||||
if (setVel)
|
||||
{
|
||||
Owner.velocity = movement * 0.25f;
|
||||
setVel = false;
|
||||
}
|
||||
Projectile.Center += movement;
|
||||
Owner.Center += movement;
|
||||
}
|
||||
else
|
||||
setVel = true;
|
||||
}
|
||||
public void FireShotgun()
|
||||
{
|
||||
// 50% chance to not consume ammo
|
||||
Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, Main.rand.NextBool());
|
||||
|
||||
|
||||
if (!naildriver && gunPower > 1)
|
||||
{
|
||||
shake = 4;
|
||||
failedChain = true;
|
||||
SoundStyle oops = new("CalamityMod/Sounds/Item/TaserLaunch");
|
||||
SoundStyle oops2 = new("CalamityMod/Sounds/Item/LightMetal");
|
||||
for (int i = 0; i < 2; i++)
|
||||
SoundEngine.PlaySound((i == 0 ? oops : oops2) with { Volume = 1f, Pitch = (i == 0 ? 0.5f : -0.3f), MaxInstances = 2 }, Projectile.Center);
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarmadaFire");
|
||||
for (int i = 0; i < (naildriver ? 2 : 1); i++)
|
||||
SoundEngine.PlaySound(shotgunFire with { Volume = (naildriver && i == 0 ? 0.3f : 0.6f), Pitch = ((naildriver && i == 0) ? -0.2f : 0f), MaxInstances = 2 }, Projectile.Center);
|
||||
|
||||
for (int b = 0; b < 24; b++)
|
||||
{
|
||||
int parts2 = 4;
|
||||
for (int i = 0; i < parts2; i++)
|
||||
{
|
||||
float power = Main.rand.NextFloat(0.2f, 1f);
|
||||
Vector2 vel = (MathHelper.TwoPi * i / parts2).ToRotationVector2().RotatedBy(Projectile.rotation) * 12f;
|
||||
float size = (0.8f + 0.35f * gunPower) * Main.rand.NextFloat(0.9f, 1.1f) * (1.1f - power);
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(gunBackPosition, dustStyle);
|
||||
dust.scale = size;
|
||||
dust.velocity = vel * power * (0.7f + gunPower * 0.2f);
|
||||
dust.noGravity = true;
|
||||
dust.color = GetRandomColor();
|
||||
dust.fadeIn = 0f;
|
||||
|
||||
if (b == 0)
|
||||
{
|
||||
Particle aura = new CustomSpark(gunBackPosition, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 20, size * 0.9f, shiftColor, new Vector2(0.65f, 1f), glowCenter: true, glowOpacity: 0.8f, glowCenterScale: 0.85f, extraRotation: Projectile.rotation + (i % 2 == 0 ? MathHelper.PiOver2 : 0), shrinkSpeed: 0.1f);
|
||||
GeneralParticleHandler.SpawnParticle(aura);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Perfects have longer cooldown
|
||||
int cooldown = (naildriver ? perfectCooldown : lastUseTime);
|
||||
recoilTimerMax = cooldown;
|
||||
shootingCooldown = cooldown;
|
||||
recoilDirection = -Projectile.velocity;
|
||||
Owner.Calamity().GeneralScreenShakePower = (naildriver ? 9 + gunPower : scattershot ? 8 : 5);
|
||||
OffsetLengthFromArm = (naildriver ? 0 : scattershot ? 7 : 15);
|
||||
frontRecoil = (naildriver ? -25 : scattershot ? -18 : -10);
|
||||
|
||||
float gunPowerMult = MathHelper.Lerp(gunPower, 1, 0.7f);
|
||||
|
||||
int baseShotCount = 7;
|
||||
for (int i = 0; i < baseShotCount + gunPower; i++)
|
||||
{
|
||||
float randomVel = Main.rand.NextFloat(0.8f, 1f);
|
||||
float damageMult = ((naildriver || scattershot) ? 1.75f : 1f) / baseShotCount;
|
||||
float spread = (i == 0 ? 0f : naildriver ? 0.06f : scattershot ? 0.9f : 0.25f) * MathHelper.Lerp(gunPower, 1, 0.75f);
|
||||
Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ModContent.ProjectileType<StarmadaStar>(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner, 0, 0, Main.rand.Next(0, 300 + 1));
|
||||
shotgun.extraUpdates = naildriver ? 9 : scattershot ? 7 : 3;
|
||||
}
|
||||
for (int i = 0; i < (int)(25 * gunPowerMult); i++)
|
||||
{
|
||||
float variance = Main.rand.NextFloat(-0.7f, 0.7f);
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(GunTipPosition, dustStyle);
|
||||
dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 3f * gunPowerMult;
|
||||
dust.velocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2) * gunPowerMult;
|
||||
dust.noGravity = true;
|
||||
dust.color = GetRandomColor();
|
||||
dust.fadeIn = 3.75f;
|
||||
}
|
||||
|
||||
// You can uncomment this to check your timing
|
||||
/*if (naildriver)
|
||||
Main.NewText("naildriver: " + (starburstPerfectTime - starburstTimer), Color.DarkOrchid);
|
||||
if (scattershot)
|
||||
Main.NewText("scattershot: " + (starburstPerfectTime - starburstTimer), Color.Lime);*/
|
||||
|
||||
if (naildriver && gunPower < 3)
|
||||
gunPower++;
|
||||
if (scattershot || (!naildriver && !scattershot))
|
||||
gunPower = 1;
|
||||
|
||||
recoilIntensity = (naildriver ? 70f : scattershot ? 25f : 0);
|
||||
setVel = true;
|
||||
}
|
||||
public void FireStarburst()
|
||||
{
|
||||
if (Owner.Calamity().GeneralScreenShakePower < 8)
|
||||
Owner.Calamity().GeneralScreenShakePower = 8;
|
||||
recoilDirection = -Projectile.velocity;
|
||||
if (recoilIntensity < 19)
|
||||
recoilIntensity = 19;
|
||||
if (recoilTimerMax < extendedCooldown)
|
||||
recoilTimerMax = extendedCooldown;
|
||||
if (starburstCooldown < extendedCooldown)
|
||||
starburstCooldown = extendedCooldown;
|
||||
setVel = true;
|
||||
|
||||
Vector2 blastCenter = GunTipPosition + Projectile.velocity * 10;
|
||||
float blastSize = 140 + 15 * lastGunPower;
|
||||
float minMultiplier = 0.1f;
|
||||
int hitsToMinMult = 8;
|
||||
int damage = (int)(Projectile.damage * (1 + lastGunPower * 0.5f));
|
||||
Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), blastCenter, Vector2.Zero, ModContent.ProjectileType<BasicBurst>(), damage, -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult);
|
||||
blast.timeLeft = 15;
|
||||
|
||||
float gunPowerMult = MathHelper.Lerp(lastGunPower, 1, 0.7f);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
float dist = Main.rand.NextFloat(1, 4);
|
||||
Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 3.5f, dist * 3.5f), Projectile.velocity * Main.rand.NextFloat(5, 6) * (8 - dist * 2) * gunPowerMult, "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.15f, 0.25f) * gunPowerMult, GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: 0.3f);
|
||||
GeneralParticleHandler.SpawnParticle(forwardJet);
|
||||
}
|
||||
for (int i = 0; i < 34; i++)
|
||||
{
|
||||
float rot = Main.rand.NextFloat(0.05f, 0.35f) * (Main.rand.NextBool() ? -1 : 1);
|
||||
Vector2 startVel = Projectile.velocity.RotatedBy(rot) * Main.rand.NextFloat(8, 18) * (Main.rand.NextBool(4) ? 2f : 1);
|
||||
Particle stars = new VelChangingSpark(GunTipPosition, startVel * gunPowerMult, startVel.RotatedBy(rot * 5) * gunPowerMult, "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f) * gunPowerMult, GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true);
|
||||
GeneralParticleHandler.SpawnParticle(stars);
|
||||
}
|
||||
if (lastGunPower == 3)
|
||||
{
|
||||
int parts2 = 45;
|
||||
for (int i = 0; i < parts2; i++)
|
||||
{
|
||||
Vector2 intenededVel = (MathHelper.TwoPi * i / parts2).ToRotationVector2() * 3f;
|
||||
Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxPlace = GunTipPosition + Projectile.velocity * 45 + fxVel.RotatedBy(Projectile.velocity.ToRotation());
|
||||
|
||||
float size = Utils.GetLerpValue(0, -3, intenededVel.X, true);
|
||||
float width = Utils.GetLerpValue(0, 3 * Math.Sign(fxVel.X), fxVel.X, true);
|
||||
Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f));
|
||||
|
||||
Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f);
|
||||
GeneralParticleHandler.SpawnParticle(aura);
|
||||
|
||||
}
|
||||
}
|
||||
if (lastGunPower >= 2)
|
||||
{
|
||||
int parts = 85;
|
||||
for (int i = 0; i < parts; i++)
|
||||
{
|
||||
Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 5f;
|
||||
Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation());
|
||||
|
||||
float size = Utils.GetLerpValue(0, -5, intenededVel.X, true);
|
||||
float width = Utils.GetLerpValue(0, 5 * Math.Sign(fxVel.X), fxVel.X, true);
|
||||
Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f));
|
||||
|
||||
Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(19 + size * 6), 0.45f + size * 0.23f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f);
|
||||
GeneralParticleHandler.SpawnParticle(aura);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int parts = 70;
|
||||
for (int i = 0; i < parts; i++)
|
||||
{
|
||||
Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 4f;
|
||||
Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation());
|
||||
Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation());
|
||||
|
||||
float size = Utils.GetLerpValue(0, -4, intenededVel.X, true);
|
||||
float width = Utils.GetLerpValue(0, 4 * Math.Sign(fxVel.X), fxVel.X, true);
|
||||
Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f));
|
||||
|
||||
Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(18 + size * 5), 0.35f + size * 0.23f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f);
|
||||
GeneralParticleHandler.SpawnParticle(aura);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public Color GetRandomColor()
|
||||
{
|
||||
Color useColor = Main.rand.Next(4) switch
|
||||
{
|
||||
0 => c1,
|
||||
1 => c2,
|
||||
_ => c3,
|
||||
};
|
||||
return useColor;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (time < 2)
|
||||
return false;
|
||||
|
||||
gunBackPosition = Projectile.Center - Projectile.velocity * 38f + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -2;
|
||||
|
||||
Texture2D orb = Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
|
||||
Texture2D shine = Request<Texture2D>("CalamityMod/Particles/FadeStreak").Value;
|
||||
|
||||
Texture2D front = Request<Texture2D>("CalamityMod/Projectiles/Ranged/StarmadaFront").Value;
|
||||
Texture2D frontGlow = Request<Texture2D>("CalamityMod/Projectiles/Ranged/StarmadaFrontGlow").Value;
|
||||
Texture2D back = Request<Texture2D>("CalamityMod/Projectiles/Ranged/StarmadaBack").Value;
|
||||
Texture2D backGlow = Request<Texture2D>("CalamityMod/Projectiles/Ranged/StarmadaBackGlow").Value;
|
||||
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition + Main.rand.NextVector2Circular(8 * shake, 8 * shake);
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
float glowMult = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4);
|
||||
int draws = 14 + 4 * gunPower;
|
||||
float sine = (float)Math.Sin(time * 0.02f);
|
||||
float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 55.5f / MathHelper.Pi);
|
||||
float fastSine = (float)Math.Sin(time * 0.2f);
|
||||
Color glowColor = Color.Lerp(Color.Gray * 0.15f, shiftColor with { A = 0 }, glowIntensity) * (0.1f * gunPower + 0.5f * glowMult);
|
||||
Vector2 frontRecoilPlace = Projectile.velocity * frontRecoil;
|
||||
|
||||
if ((starburstTimer > 0 && starburstCooldown == 0) || gunPower > 1)
|
||||
{
|
||||
for (int i = 0; i < draws; i++)
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time * 2);
|
||||
Main.EntitySpriteDraw(back, drawPosition + drawOffset * (6 + gunPower) * attackVisualMult, null, shiftColor with { A = 0 } * 0.7f * attackVisualMult, drawRotation, back.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
Main.EntitySpriteDraw(front, drawPosition + drawOffset * (6 + gunPower) * attackVisualMult + frontRecoilPlace, null, shiftColor with { A = 0 } * 0.7f * attackVisualMult, drawRotation, front.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
}
|
||||
}
|
||||
|
||||
// back
|
||||
Main.EntitySpriteDraw(back, drawPosition, null, drawColor, drawRotation, back.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
for (int i = 0; i < draws; i++) // back glow
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4) * MathHelper.Lerp(gunPower, 1, 0.75f);
|
||||
Main.EntitySpriteDraw(backGlow, drawPosition + drawOffset, null, glowColor, drawRotation, backGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
Main.EntitySpriteDraw(backGlow, drawPosition, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, backGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
}
|
||||
// front
|
||||
Main.EntitySpriteDraw(front, drawPosition + frontRecoilPlace, null, drawColor, drawRotation, front.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
for (int i = 0; i < draws; i++) // front glow
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4) * MathHelper.Lerp(gunPower, 1, 0.75f);
|
||||
Main.EntitySpriteDraw(frontGlow, drawPosition + drawOffset + frontRecoilPlace, null, glowColor, drawRotation, frontGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
Main.EntitySpriteDraw(frontGlow, drawPosition + frontRecoilPlace, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, frontGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite);
|
||||
}
|
||||
|
||||
if (starburstTimer > 0 && starburstCooldown == 0)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
// The shining orb at the tip
|
||||
Color orbColor = shiftColor with { A = 0 } * 0.5f;
|
||||
Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackVisualMult * Main.rand.NextFloat(0.9f, 1.1f) * 8.5f;
|
||||
Main.EntitySpriteDraw(orb, GunTipPosition - Main.screenPosition, null, orbColor, Main.rand.NextFloat(-5, 5), orb.Size() * 0.5f, scale, SpriteEffects.None);
|
||||
}
|
||||
}
|
||||
|
||||
Color powerColor = Color.Lerp(shiftColor, (gunPower == 1 ? c1 : gunPower == 2 ? c2 : c3), 0.7f);
|
||||
|
||||
float scaleMod = (0.15f + gunPower * 0.1f) * attackVisualMult;
|
||||
float rand = Main.rand.NextFloat(0.7f, 1f);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int y = 0; y < 2; y++)
|
||||
Main.EntitySpriteDraw(orb, gunBackPosition - Main.screenPosition, null, powerColor with { A = 0 }, y == 0 ? MathHelper.PiOver2 : 0, orb.Size() * 0.5f, new Vector2(0.5f, 1f) * scaleMod * 0.6f * rand, SpriteEffects.None);
|
||||
|
||||
Vector2 offset = (MathHelper.TwoPi * i / 4).ToRotationVector2().RotatedBy(Projectile.rotation);
|
||||
for (int t = 0; t < 3; t++)
|
||||
Main.EntitySpriteDraw(shine, gunBackPosition - Main.screenPosition, null, powerColor with { A = 0 }, offset.ToRotation(), new Vector2(shine.Width * 0.5f, 0), new Vector2((1f - t * 0.1f) * rand + gunPower * 0.05f, 0.5f + t * 0.15f) * Projectile.scale * Owner.gravDir * scaleMod, SpriteEffects.FlipVertically);
|
||||
Main.EntitySpriteDraw(shine, gunBackPosition - Main.screenPosition, null, Color.White with { A = 0 }, offset.ToRotation(), new Vector2(shine.Width * 0.5f, 0), new Vector2(0.5f, 0.75f) * Projectile.scale * Owner.gravDir * scaleMod, SpriteEffects.FlipVertically);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class StarmadaStar : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public int time = 0;
|
||||
public Color c1 = new Color(164, 47, 160);
|
||||
public Color c2 = new Color(227, 97, 72);
|
||||
public Color c3 = new Color(193, 255, 146);
|
||||
public Color shiftColor;
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 25;
|
||||
Projectile.height = 25;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.penetrate = 5;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
float rate = (Projectile.ai[2] * 0.05f);
|
||||
List<Color> eColors = new List<Color>()
|
||||
{
|
||||
c1,
|
||||
c2,
|
||||
c3,
|
||||
};
|
||||
int colorIndex = (int)(rate / 2 % eColors.Count);
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f);
|
||||
Projectile.ai[2]++;
|
||||
|
||||
if (time > 5 && time % 2 == 0)
|
||||
{
|
||||
Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f);
|
||||
GeneralParticleHandler.SpawnParticle(trail);
|
||||
|
||||
if (time > 18)
|
||||
{
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle);
|
||||
dust.scale = Main.rand.NextFloat(1.2f, 1.8f);
|
||||
dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f);
|
||||
dust.noGravity = true;
|
||||
dust.color = shiftColor;
|
||||
dust.fadeIn = 5f;
|
||||
}
|
||||
}
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
time++;
|
||||
}
|
||||
public Color GetRandomColor()
|
||||
{
|
||||
Color useColor = Main.rand.Next(4) switch
|
||||
{
|
||||
0 => c1,
|
||||
1 => c2,
|
||||
_ => c3,
|
||||
};
|
||||
return useColor;
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D tex2 = Request<Texture2D>("CalamityMod/Particles/FadeStreak").Value;
|
||||
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
|
||||
Color drawColor = Projectile.GetAlpha(lightColor);
|
||||
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
|
||||
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Vector2 offset = (MathHelper.TwoPi * i / 5).ToRotationVector2().RotatedBy(Projectile.rotation + MathHelper.Pi);
|
||||
for (int t = 0; t < 3; t++)
|
||||
Main.EntitySpriteDraw(tex2, drawPosition, null, shiftColor with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically);
|
||||
Main.EntitySpriteDraw(tex2, drawPosition, null, Color.White with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2(1.5f, 0.7f) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
float minMult = 0.1f;
|
||||
int hitsToMinMult = 4;
|
||||
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
|
||||
modifiers.SourceDamage *= damageMult;
|
||||
|
||||
if (Projectile.numHits == 0 && false)
|
||||
{
|
||||
// spawn slice projectiles
|
||||
Vector2 spawnPos = target.Center + target.Center.DirectionFrom(Owner.Center).RotatedByRandom(0.5f) * (target.height / 2 + 40);
|
||||
Vector2 vel = spawnPos.DirectionTo(target.Center);
|
||||
int damage = (int)(Projectile.damage * 0.25f);
|
||||
Projectile star = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), spawnPos, vel, ModContent.ProjectileType<StarmadaHitProj>(), damage, 0, Projectile.owner, target.whoAmI, Main.rand.Next(0, 7 + 1), Main.rand.Next(0, 300 + 1));
|
||||
}
|
||||
}
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
float variance = Main.rand.NextFloat(-0.5f, 0.5f);
|
||||
int dustStyle = DustType<SquashDust>();
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle);
|
||||
dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f;
|
||||
dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2);
|
||||
dust.noGravity = true;
|
||||
dust.color = GetRandomColor();
|
||||
dust.fadeIn = 2.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,6 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
|
||||
int type = Utils.SelectRandom(Main.rand,
|
||||
[
|
||||
ModContent.ProjectileType<PlasmaBlast>(),
|
||||
ModContent.ProjectileType<AstralStar>(),
|
||||
ProjectileID.StarCannonStar,
|
||||
ProjectileID.Starfury
|
||||
@@ -155,7 +154,7 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, predictSpeed, type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner);
|
||||
if (star.WithinBounds(Main.maxProjectiles))
|
||||
{
|
||||
if (type == ModContent.ProjectileType<PlasmaBlast>() || type == ModContent.ProjectileType<AstralStar>())
|
||||
if (type == ModContent.ProjectileType<StarfleetStar>() || type == ModContent.ProjectileType<AstralStar>())
|
||||
Main.projectile[star].ai[0] = 1f;
|
||||
|
||||
Main.projectile[star].extraUpdates = 4;
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
|
||||
int type = Utils.SelectRandom(Main.rand,
|
||||
[
|
||||
ModContent.ProjectileType<PlasmaBlast>(),
|
||||
ModContent.ProjectileType<StarfleetStar>(),
|
||||
ModContent.ProjectileType<AstralStar>(),
|
||||
ProjectileID.StarCannonStar,
|
||||
ProjectileID.Starfury
|
||||
@@ -155,7 +155,7 @@ namespace CalamityMod.Projectiles.Ranged
|
||||
int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, predictSpeed, type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner);
|
||||
if (star.WithinBounds(Main.maxProjectiles))
|
||||
{
|
||||
if (type == ModContent.ProjectileType<PlasmaBlast>() || type == ModContent.ProjectileType<AstralStar>())
|
||||
if (type == ModContent.ProjectileType<StarfleetStar>() || type == ModContent.ProjectileType<AstralStar>())
|
||||
Main.projectile[star].ai[0] = 1f;
|
||||
|
||||
Main.projectile[star].extraUpdates = 4;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
Mods: {
|
||||
CalamityMod: {
|
||||
Items: {
|
||||
TableCoralLeft: {
|
||||
DisplayName: Table Coral Left
|
||||
Tooltip: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||