m1 functionality
This commit is contained in:
1 parent
c43f122c08
commit
72231ac123
16 files changed
+397
-210
No files matched your search
@@ -298,6 +298,10 @@ namespace CalamityMod.CalPlayer
|
||||
public bool lucreciaEnergyPaused = false;
|
||||
public bool lucreciaEnergyMaxSFXPlayed = false;
|
||||
private int lucreciaParticleTimer = 0;
|
||||
public int starburstShivElementalMastery = 0;
|
||||
public int starburstShivElementalMasteryTimer = 0;
|
||||
public bool starburstShivElementalMasteryPaused = false;
|
||||
public bool starburstShivElementalMasteryMaxSFXPlayed = false;
|
||||
public float unstableCastersGauntletVis = 0;
|
||||
public int unstableCastersGauntletVisTimer = 0;
|
||||
public int PhotoAudioCooldown = 0;
|
||||
@@ -3264,6 +3268,7 @@ namespace CalamityMod.CalPlayer
|
||||
flareGunOverheat = 0;
|
||||
hellbornShots = 0;
|
||||
lucreciaEnergy = 0;
|
||||
starburstShivElementalMastery = 0;
|
||||
garandShots = 0;
|
||||
searedPanCounter = 0;
|
||||
searedPanTimer = 0;
|
||||
|
||||
@@ -431,6 +431,51 @@ namespace CalamityMod.CalPlayer
|
||||
lucreciaEnergyPaused = false;
|
||||
}
|
||||
|
||||
if (Player.HeldItem.type == ModContent.ItemType<StarburstShiv>() && starburstShivElementalMastery > 0)
|
||||
{
|
||||
if (starburstShivElementalMastery == StarburstShiv.MaxEnergy && !starburstShivElementalMasteryPaused)
|
||||
{
|
||||
starburstShivElementalMasteryPaused = true;
|
||||
starburstShivElementalMasteryTimer = 0;
|
||||
}
|
||||
|
||||
starburstShivElementalMasteryTimer++;
|
||||
|
||||
// If the mastery is at max, pause for 180 ticks
|
||||
if (starburstShivElementalMasteryPaused)
|
||||
{
|
||||
if (starburstShivElementalMasteryTimer >= 1 && !starburstShivElementalMasteryMaxSFXPlayed)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item79 with { Volume = 1.6f, Pitch = 0.4f }, Player.Center);
|
||||
starburstShivElementalMasteryMaxSFXPlayed = true;
|
||||
|
||||
}
|
||||
// If the pause is Done, resume decrementing.
|
||||
if (starburstShivElementalMasteryTimer >= 180)
|
||||
{
|
||||
starburstShivElementalMasteryPaused = false;
|
||||
starburstShivElementalMasteryTimer = 0;
|
||||
starburstShivElementalMastery--;
|
||||
}
|
||||
}
|
||||
else // Decrementing
|
||||
{
|
||||
starburstShivElementalMasteryMaxSFXPlayed = false;
|
||||
// Once every 8 ticks
|
||||
if (starburstShivElementalMasteryTimer >= 8)
|
||||
{
|
||||
starburstShivElementalMastery--;
|
||||
starburstShivElementalMasteryTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset the timer and pause state if the player isn't holding the weapon.
|
||||
starburstShivElementalMasteryTimer = 0;
|
||||
starburstShivElementalMasteryPaused = false;
|
||||
}
|
||||
|
||||
|
||||
if (Player.HeldItem.type == ModContent.ItemType<UnstableCastersGauntlet>() && unstableCastersGauntletVis < 100)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Projectiles.Melee.Shortswords;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Audio;
|
||||
using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class ElementalMastery : CooldownHandler
|
||||
{
|
||||
private float AdjustedCompletion => instance.timeLeft / (float) StarburstShiv.MaxEnergy;
|
||||
private Color TextColor => Color.AliceBlue;
|
||||
private Color TextBorderColor = Color.AntiqueWhite;
|
||||
|
||||
public static new string ID => "ElementalMastery";
|
||||
public override bool CanTickDown => false;
|
||||
public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType<StarburstShiv>();
|
||||
public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}");
|
||||
public override string Texture => $"CalamityMod/Cooldowns/{ID}";
|
||||
public override string OutlineTexture => $"CalamityMod/Cooldowns/{ID}Outline";
|
||||
public override string OverlayTexture => $"CalamityMod/Cooldowns/{ID}Overlay";
|
||||
|
||||
public override Color OutlineColor => Color.SlateGray;
|
||||
public override Color CooldownStartColor => Color.Lerp(Color.OrangeRed, Color.SlateGray, instance.Completion);
|
||||
public override Color CooldownEndColor => Color.Lerp(Color.AliceBlue, Color.SlateGray, instance.Completion);
|
||||
|
||||
public override void ApplyBarShaders(float opacity)
|
||||
{
|
||||
// Use the adjusted completion
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].Apply();
|
||||
}
|
||||
|
||||
public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
|
||||
{
|
||||
base.DrawExpanded(spriteBatch, position, opacity, scale);
|
||||
|
||||
Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f);
|
||||
DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale);
|
||||
}
|
||||
|
||||
public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
|
||||
{
|
||||
Texture2D sprite = Request<Texture2D>(Texture).Value;
|
||||
Texture2D outline = Request<Texture2D>(OutlineTexture).Value;
|
||||
Texture2D overlay = Request<Texture2D>(OverlayTexture).Value;
|
||||
|
||||
// Draw the outline
|
||||
spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f);
|
||||
|
||||
// Draw the icon
|
||||
spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
|
||||
|
||||
// Draw the small overlay
|
||||
int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion);
|
||||
Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight);
|
||||
spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
|
||||
|
||||
Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f);
|
||||
DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 312 B |
Binary file not shown.
|
After Width: | Height: | Size: 161 B |
Binary file not shown.
|
After Width: | Height: | Size: 130 B |
@@ -1,4 +1,8 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Cooldowns;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using CalamityMod.Projectiles.DraedonsArsenal;
|
||||
using CalamityMod.Projectiles.Melee;
|
||||
using CalamityMod.Projectiles.Melee.Shortswords;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -13,33 +17,53 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Weapons.Melee";
|
||||
|
||||
public static int MaxEnergy = 100;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 74;
|
||||
Item.height = 94;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.autoReuse = true;
|
||||
Item.useStyle = ItemUseStyleID.Rapier;
|
||||
Item.damage = 138;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.damage = 183;
|
||||
Item.DamageType = DamageClass.Melee;
|
||||
Item.useAnimation = Item.useTime = 13;
|
||||
Item.shoot = ModContent.ProjectileType<StarburstShivProj>();
|
||||
Item.shootSpeed = 2.4f;
|
||||
Item.knockBack = 8.5f;
|
||||
Item.UseSound = SoundID.Item1;
|
||||
Item.useAnimation = Item.useTime = 20;
|
||||
Item.shootSpeed = 10f;
|
||||
Item.knockBack = 9f;
|
||||
Item.value = CalamityGlobalItem.RarityPurpleBuyPrice;
|
||||
Item.rare = ItemRarityID.Purple;
|
||||
Item.shoot = ModContent.ProjectileType<StarburstShivHoldout>();
|
||||
|
||||
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
|
||||
Item.autoReuse = true;
|
||||
Item.channel = true;
|
||||
base.SetDefaults();
|
||||
}
|
||||
|
||||
public override bool MeleePrefix() => true;
|
||||
public override bool AltFunctionUse(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Melee/StarburstShivGlow").Value);
|
||||
|
||||
public override void HoldItem(Player player)
|
||||
{
|
||||
if (player.Calamity().cooldowns.TryGetValue(ElementalMastery.ID, out var cooldown))
|
||||
{
|
||||
cooldown.timeLeft = player.Calamity().starburstShivElementalMastery;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.AddCooldown(ElementalMastery.ID, 0);
|
||||
}
|
||||
}
|
||||
public override void AddRecipes()
|
||||
{
|
||||
CreateRecipe().
|
||||
AddIngredient(ItemID.PiercingStarlight).
|
||||
AddIngredient<Lucrecia>().
|
||||
AddIngredient(ItemID.LunarBar, 5).
|
||||
AddIngredient<LifeAlloy>(5).
|
||||
AddIngredient(ItemID.FragmentSolar, 5).
|
||||
|
||||
@@ -309,3 +309,4 @@ WulfrumScrew.DisplayName: Wulfrum Screw
|
||||
WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver
|
||||
YinYoDark.DisplayName: Dark Shard
|
||||
YinYoLight.DisplayName: Light Shard
|
||||
StarburstShivM1Hitbox.DisplayName: Lightspeed Stab
|
||||
@@ -85,3 +85,4 @@ PlagueShotBuffer.DisplayName: Plague Shot
|
||||
WaterShot.DisplayName: Water Shot
|
||||
WaterShotBuffer.DisplayName: Water Shot
|
||||
FrequencyManipulatorEnergy.DisplayName: Frequency Manipulator Energy
|
||||
StarburstShivHoldout.DisplayName: Starburst Shiv Holdout
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee.Shortswords
|
||||
{
|
||||
public class StarburstShivProj : BaseShortswordProjectile
|
||||
{
|
||||
public override LocalizedText DisplayName => CalamityUtils.GetItemName<StarburstShiv>();
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Melee/StarburstShiv";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = Projectile.height = 44;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.scale = 1f;
|
||||
Projectile.DamageType = TrueMeleeDamageClass.Instance;
|
||||
Projectile.ownerHitCheck = true;
|
||||
Projectile.timeLeft = 360;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.hide = true;
|
||||
Projectile.ownerHitCheck = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
}
|
||||
|
||||
public override Action<Projectile> EffectBeforePullback => (proj) =>
|
||||
{
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 14f, ModContent.ProjectileType<StarburstBeam>(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f);
|
||||
};
|
||||
|
||||
public override void SetVisualOffsets()
|
||||
{
|
||||
const int HalfSpriteWidth = 37;
|
||||
const int HalfSpriteHeight = 47;
|
||||
|
||||
int HalfProjWidth = Projectile.width / 2;
|
||||
int QuarterProjHeight = Projectile.height / 4;
|
||||
|
||||
DrawOriginOffsetX = 0;
|
||||
DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth);
|
||||
DrawOriginOffsetY = -(HalfSpriteHeight - QuarterProjHeight);
|
||||
}
|
||||
|
||||
public override void ExtraBehavior()
|
||||
{
|
||||
if (Main.rand.NextBool(5))
|
||||
{
|
||||
int rainbowDust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f);
|
||||
Main.dust[rainbowDust].velocity *= 0.2f;
|
||||
Main.dust[rainbowDust].noGravity = true;
|
||||
}
|
||||
}
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<ElementalMix>(), 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
public class StarburstBeam : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Melee";
|
||||
public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 20;
|
||||
Projectile.height = 20;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.penetrate = 2;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 60;
|
||||
Projectile.aiStyle = ProjAIStyleID.Beam;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f);
|
||||
Main.dust[rainbow].noGravity = true;
|
||||
Main.dust[rainbow].velocity = Vector2.Zero;
|
||||
|
||||
CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (Projectile.timeLeft > 50)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
for (int k = 0; k < 2; k++)
|
||||
{
|
||||
int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f);
|
||||
Main.dust[rainbow].noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<ElementalMix>(), 30);
|
||||
OnHitEffects(target.Center);
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
||||
{
|
||||
OnHitEffects(target.Center);
|
||||
}
|
||||
|
||||
private void OnHitEffects(Vector2 targetPos)
|
||||
{
|
||||
var source = Projectile.GetSource_FromThis();
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
if (Projectile.owner == Main.myPlayer)
|
||||
{
|
||||
CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, x > 2, 800f, 800f, 0f, 800f, 20f, ModContent.ProjectileType<StarburstSHIV>(), Projectile.damage, Projectile.knockBack, Projectile.owner, false, 50f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 741 B |
@@ -1,54 +0,0 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
public class StarburstSHIV : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Melee";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 15;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 20;
|
||||
Projectile.height = 20;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.timeLeft = 90;
|
||||
Projectile.aiStyle = ProjAIStyleID.Beam;
|
||||
Projectile.extraUpdates = 1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f);
|
||||
|
||||
int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f);
|
||||
Main.dust[rainbow].noGravity = true;
|
||||
Main.dust[rainbow].velocity = Vector2.Zero;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f);
|
||||
Main.dust[rainbow].noGravity = true;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (Projectile.timeLeft > 85)
|
||||
return false;
|
||||
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 741 B |
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Particles;
|
||||
using static Terraria.Player;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using CalamityMod.Projectiles.Melee;
|
||||
|
||||
namespace CalamityMod.Projectiles.DraedonsArsenal
|
||||
{
|
||||
public class StarburstShivHoldout : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Misc";
|
||||
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Melee/StarburstShiv";
|
||||
public ref float attackTimer => ref Projectile.ai[0];
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
// Sprite visuals
|
||||
public float scaleFx = 0.6f; // Default that looks reasonable size-wise, changes on some attacks
|
||||
|
||||
public Vector2 innateOffset = new(23f, -5f);
|
||||
public Vector2 handPos;
|
||||
|
||||
public int primaryStabfireRate => 2;
|
||||
public int time = 0;
|
||||
|
||||
public float bladeRot = 0;
|
||||
public bool pressedRight = false;
|
||||
|
||||
// Internal control
|
||||
private int stabTimer;
|
||||
|
||||
public override bool? CanDamage() => false;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 74;
|
||||
Projectile.height = 94;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.MeleeNoSpeed;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 5;
|
||||
Projectile.extraUpdates = 1;
|
||||
}
|
||||
public void Positioning(Vector2 toMouse) // Hand and holdout positioning
|
||||
{
|
||||
|
||||
Owner.ChangeDir(Math.Sign(toMouse.X));
|
||||
|
||||
// Calculate the angle for the arm holding the weapon
|
||||
float baseArmRotation = toMouse.ToRotation();
|
||||
float compositeArmRotation = baseArmRotation + bladeRot - MathHelper.PiOver2;
|
||||
|
||||
// Set the front composite arm to point towards the correct direction.
|
||||
Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, compositeArmRotation);
|
||||
Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, 0f);
|
||||
|
||||
Vector2 actualInnateOffset = innateOffset;
|
||||
if (Owner.direction == -1)
|
||||
{
|
||||
actualInnateOffset.X += 1f;
|
||||
actualInnateOffset.Y += 10f;
|
||||
|
||||
}
|
||||
|
||||
handPos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.Full, compositeArmRotation) + actualInnateOffset.RotatedBy(baseArmRotation);
|
||||
|
||||
// Set properties based on the mouse direction
|
||||
Projectile.velocity = toMouse;
|
||||
Projectile.rotation = toMouse.ToRotation() + bladeRot;
|
||||
Projectile.Center = handPos;
|
||||
|
||||
// Same for the owner
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
Owner.itemTime = Owner.itemAnimation = 2;
|
||||
|
||||
// Item rotation for the player's sprite display
|
||||
Owner.itemRotation = Projectile.rotation;
|
||||
if (Owner.direction != 1)
|
||||
{
|
||||
Owner.itemRotation -= MathHelper.Pi;
|
||||
}
|
||||
|
||||
Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation);
|
||||
}
|
||||
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.scale = 1f;
|
||||
|
||||
if (Owner.channel)
|
||||
{
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld());
|
||||
Positioning(toMouse);
|
||||
|
||||
if (Owner.altFunctionUse == 0)
|
||||
{
|
||||
UsePrimary(toMouse);
|
||||
|
||||
Vector2 currOffset = Projectile.Center + new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-1f, 7f));
|
||||
Projectile.Center = currOffset;
|
||||
}
|
||||
|
||||
else if (Owner.altFunctionUse == 2)
|
||||
{
|
||||
// Dash functionality
|
||||
}
|
||||
}
|
||||
|
||||
// -- BASIC M1 --
|
||||
private void UsePrimary(Vector2 toMouse)
|
||||
{
|
||||
stabTimer++;
|
||||
if (stabTimer % primaryStabfireRate != 0)
|
||||
return;
|
||||
|
||||
float offset = Main.rand.NextFloat(-MathHelper.ToRadians(6f), MathHelper.ToRadians(6f));
|
||||
Vector2 stabDir = toMouse.RotatedBy(offset);
|
||||
|
||||
// SoundEngine.PlaySound(SoundID.Item1 with { Volume = 0.8f, Pitch = 0.1f, MaxInstances = 6, PitchVariance = 0.1f }, Owner.Center);
|
||||
|
||||
Vector2 stabOrigin = Owner.MountedCenter;
|
||||
Vector2 stabTip = stabOrigin + stabDir * 100f;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vector2 spawnPos = stabTip + Main.rand.NextVector2Circular(18f, 12f);
|
||||
|
||||
Vector2 vel = stabDir * Main.rand.NextFloat(5f, 19f);
|
||||
Color color = Color.Lerp(Color.AliceBlue, Color.OrangeRed, Main.rand.NextFloat(1f));
|
||||
Particle spark = new GlowSparkParticle(spawnPos, vel, false, Main.rand.Next(5, 8), Main.rand.NextFloat(0.02f, 0.07f), color * 0.55f, new Vector2(0.5f, 1.3f), true, false);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
|
||||
|
||||
// Drawing randomness
|
||||
bladeRot = Main.rand.NextFloat(-0.25f, 0.5f) * Owner.direction;
|
||||
Projectile.scale *= Main.rand.NextFloat(0.88f, 1.04f);
|
||||
if (Main.rand.NextBool())
|
||||
{
|
||||
Owner.SetCompositeArmFront(true, Main.rand.NextBool() ? CompositeArmStretchAmount.ThreeQuarters : CompositeArmStretchAmount.Quarter, Owner.itemRotation - (Owner.direction == 1 ? MathHelper.PiOver2 : MathHelper.TwoPi * 0.75f) + Main.rand.NextFloat(-0.22f, 0.22f));
|
||||
}
|
||||
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center + toMouse * 20 * (float)Math.Pow(scaleFx, 4), toMouse * 25, ModContent.ProjectileType<StarburstShivM1Hitbox>(), Projectile.damage, 0, Projectile.owner);
|
||||
|
||||
}
|
||||
|
||||
// -- DASH --
|
||||
private void UseSecondary(Vector2 toMouse)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
// Un-jand the rotation that the sprite is drawn to actually point toward the mouse cursor
|
||||
float drawRotation = Projectile.rotation + MathHelper.PiOver4;
|
||||
if (Owner.direction == -1)
|
||||
{
|
||||
drawRotation += MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
||||
int frameHeight = texture.Height / Main.projFrames[Projectile.type];
|
||||
Rectangle frame = new Rectangle(0, Projectile.frame * frameHeight, texture.Width, frameHeight);
|
||||
Vector2 origin = new Vector2(texture.Width / 2f, frameHeight / 2f);
|
||||
|
||||
SpriteEffects spriteEffects = Owner.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
|
||||
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, lightColor, drawRotation, origin, Projectile.scale * scaleFx, spriteEffects, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.NPCs;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
[PierceResistExceptionAttribute(true)]
|
||||
public class StarburstShivM1Hitbox : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Melee";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 84;
|
||||
Projectile.height = 64;
|
||||
Projectile.friendly = true;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.timeLeft = 6;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 4;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld() + MathHelper.Pi.ToRotationVector2());
|
||||
|
||||
float rotation = toMouse.ToRotation();
|
||||
|
||||
Projectile.rotation = rotation;
|
||||
Projectile.velocity = toMouse * 34;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user