From 8653134f6450cd81bf00a270b5a7a010f477aea2 Mon Sep 17 00:00:00 2001 From: Merkalto Date: Mon, 25 Jul 2022 17:39:37 -0500 Subject: [PATCH] Galileo Gladius support --- Items/Weapons/Melee/CosmicShiv.cs | 3 +- Items/Weapons/Melee/GalileoGladius.cs | 61 ++----------- .../Melee/Shortswords/ElementalShivProj.cs | 4 +- .../Melee/Shortswords/GalileoGladiusProj.cs | 91 +++++++++++++++++++ 4 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 Projectiles/Melee/Shortswords/GalileoGladiusProj.cs diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index e31cb9e1d3..266e6bd601 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -21,7 +21,6 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.useStyle = ItemUseStyleID.Rapier; - Item.useTurn = false; Item.useAnimation = 18; Item.useTime = 18; Item.width = 44; @@ -32,8 +31,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.DamageType = DamageClass.Melee; Item.knockBack = 9f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; + Item.noUseGraphic = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 2.4f; diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index 425554b466..987dc6c126 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -1,9 +1,6 @@ -using Terraria.DataStructures; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Melee.Shortswords; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -23,8 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; - Item.useTurn = false; + Item.useStyle = ItemUseStyleID.Rapier; Item.useAnimation = 10; Item.useTime = 10; Item.width = 44; @@ -33,62 +29,19 @@ namespace CalamityMod.Items.Weapons.Melee Item.DamageType = DamageClass.Melee; Item.knockBack = 10f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.noUseGraphic = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2.4f; Item.value = CalamityGlobalItem.Rarity13BuyPrice; Item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - int moonDamage = (int)(damage * 0.3333f); - Projectile.NewProjectile(source, position.X, position.Y, Item.shootSpeed * player.direction, 0f, type, moonDamage, knockback, player.whoAmI, 0f, 0f); - return false; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(5)) - { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, (Main.rand.NextBool(2) ? 20 : 176), (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(player); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(player); - } - - private void SpawnMeteor(Player player) - { - if (player.whoAmI == Main.myPlayer) - { - var source = player.GetSource_ItemUse(Item); - if (player.Calamity().galileoCooldown <= 0) - { - int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; - CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); - player.Calamity().galileoCooldown = 15; - } - } - } - public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.Gladius). //This may be too rare for this recipe, we'll see I guess. - Merkalto + AddIngredient(ItemID.Gladius). AddIngredient(8). AddIngredient(5). AddIngredient(15). diff --git a/Projectiles/Melee/Shortswords/ElementalShivProj.cs b/Projectiles/Melee/Shortswords/ElementalShivProj.cs index d01aa66994..a073e02efb 100644 --- a/Projectiles/Melee/Shortswords/ElementalShivProj.cs +++ b/Projectiles/Melee/Shortswords/ElementalShivProj.cs @@ -1,4 +1,4 @@ -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework; @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords public override void SetStaticDefaults() { - DisplayName.SetDefault("Elemental Shiv"); + DisplayName.SetDefault("Elemental Shiv"); // TODO: Make this one function like PiercingStarlight } public override void SetDefaults() diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs new file mode 100644 index 0000000000..0e72981f08 --- /dev/null +++ b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs @@ -0,0 +1,91 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using System; + +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class GalileoGladiusProj : BaseShortswordProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/GalileoGladius"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Galileo Gladius"); // TODO: Make it function like Gladius, not like PiercingStarlight. + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(24); + 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; + } + + public override Action EffectBeforePullback => (proj) => + { + int moonDamage = (int)(Projectile.damage * 0.3333f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 10f, ModContent.ProjectileType(), moonDamage, Projectile.knockBack, Projectile.owner, 0f, 0f); + }; + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 42 / 2; + const int HalfSpriteHeight = 46 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(5)) + { + int num250 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (Main.rand.NextBool(2) ? 20 : 176), (float)(Main.player[Projectile.owner].direction * 2), 0f, 150, default, 1.3f); + Main.dust[num250].velocity *= 0.2f; + Main.dust[num250].noGravity = true; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + SpawnMeteor(Main.player[Projectile.owner]); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + SpawnMeteor(Main.player[Projectile.owner]); + } + + private void SpawnMeteor(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + var source = player.GetSource_FromThis(); + if (player.Calamity().galileoCooldown <= 0) + { + int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; + CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); + player.Calamity().galileoCooldown = 15; + } + } + } + } +}