From abcac387cf6f2cecda5fbdfcc4b8fd3fe0d1d023 Mon Sep 17 00:00:00 2001 From: AquaSG Date: Sat, 26 Aug 2023 00:50:55 -0400 Subject: [PATCH] wip galeforce --- Items/Weapons/Ranged/Galeforce.cs | 48 ++++-- Items/Weapons/Ranged/Galeforce.png | Bin 807 -> 909 bytes .../Mods.CalamityMod.Projectiles.Magic.hjson | 3 +- .../Mods.CalamityMod.Projectiles.Ranged.hjson | 4 +- Projectiles/Ranged/GaleforceArrow.cs | 94 ++++++++++++ Projectiles/Ranged/GaleforceArrow.png | Bin 0 -> 409 bytes Projectiles/Ranged/GaleforceHoldout.cs | 140 ++++++++++++++++++ 7 files changed, 276 insertions(+), 13 deletions(-) create mode 100644 Projectiles/Ranged/GaleforceArrow.cs create mode 100644 Projectiles/Ranged/GaleforceArrow.png create mode 100644 Projectiles/Ranged/GaleforceHoldout.cs diff --git a/Items/Weapons/Ranged/Galeforce.cs b/Items/Weapons/Ranged/Galeforce.cs index e0d786cc07..b22449b137 100644 --- a/Items/Weapons/Ranged/Galeforce.cs +++ b/Items/Weapons/Ranged/Galeforce.cs @@ -5,6 +5,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Magic; +using System.Linq; namespace CalamityMod.Items.Weapons.Ranged { @@ -15,31 +17,55 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 8; Item.DamageType = DamageClass.Ranged; - Item.width = 32; - Item.height = 52; + Item.width = 38; + Item.height = 68; Item.useTime = 20; Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; + Item.channel = true; Item.knockBack = 3f; Item.value = CalamityGlobalItem.Rarity3BuyPrice; Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item5; + Item.UseSound = SoundID.Item17; Item.autoReuse = true; - Item.shoot = ProjectileID.WoodenArrowFriendly; + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; - Item.useAmmo = AmmoID.Arrow; + //Item.useAmmo = AmmoID.Arrow; Item.Calamity().canFirePointBlankShots = true; } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + public override void HoldItem(Player player) { - for (int i = -8; i <= 8; i += 8) + player.Calamity().mouseWorldListener = true; + } + + public override bool CanUseItem(Player player) + { + return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType()); + } + + public override void UseItemFrame(Player player) + { + //Calculate the dirction in which the players arms should be pointing at. + Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX); + float armPointingDirection = (playerToCursor.ToRotation()); + + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.Calamity().mouseWorld.X > player.Center.X) { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType(), damage / 4, 0f, player.whoAmI); + player.ChangeDir(1); } - return true; + else + { + player.ChangeDir(-1); + } + + CalamityUtils.CleanHoldStyle(player, player.compositeFrontArm.rotation + MathHelper.PiOver2, player.GetFrontHandPosition(player.compositeFrontArm.stretch, player.compositeFrontArm.rotation).Floor(), new Vector2(38, 68), new Vector2(-9, 0)); } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Galeforce.png b/Items/Weapons/Ranged/Galeforce.png index 9bf40b407ac10e793f53804c081109bc82f54f4a..46b9f76adf7a956d596a638789068e3b59060532 100644 GIT binary patch literal 909 zcmV;819JR{P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ9410qR8K~!i%?V4Rk zQ(+v3RlKO^ODVF&($YxFU3gKN5LSj0gGv&GEECBH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H*n;djY}Dzxdz($zs?G#{iFHu_9%yb8bP$w7*JYlur%V&07)CXCMGDV zVxV0A=-*)4B^DAgLq9~&+a<8LzjmDgt+js!B?LAuWrdck=LUIQv--*#irOWxTwtyy zgHn>J8vRBoM<(wWX(cNxBw(Pr`4v|2!C$hH+a7_Hw77GPG>UkxhsY2qS;=jWptrb; za}%M}Fr+U$dGh=r+KMMPjlkkq+cfMy@@N38Ut_yq55w^6=@IIez<_U@6G@2RHD+x;0+O2YA2K?&_Ri{6qr5+&2=zy&_^YQZW@7=2e95fdfye+ zbA#0(TAGmD;cs*iqQDH=1=dF$ksf+u@gHwNd?v&%3Z}oJ#W8wq3gg52xGu5h2(SS^b_`+%MXaLs@X{t!WLVZnNA=>3+Hx1ON*oRE)6o#Pw4 "Projectiles.Ranged"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; + ProjectileID.Sets.TrailingMode[Projectile.type] = 1; + } + + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.arrow = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 300; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + return true; + } + + public override void AI() + { + Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - MathHelper.ToRadians(90); + + Vector2 destination = Projectile.Center; + bool locatedTarget = false; + + // Find a target. + for (int i = 0; i < Main.maxNPCs; i++) + { + float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + if (!Main.npc[i].CanBeChasedBy(Projectile, false) || !Projectile.WithinRange(Main.npc[i].Center, 340f + extraDistance)) + continue; + + Vector2 coneHomeCheck = (Main.npc[i].Center - Projectile.Center).SafeNormalize(Vector2.Zero) + Projectile.velocity.SafeNormalize(Vector2.Zero); + if (Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && (Math.Abs(coneHomeCheck.X) > 1.15f || Math.Abs(coneHomeCheck.Y) > 1.15f)) + { + destination = Main.npc[i].Center; + locatedTarget = true; + break; + } + } + + if (locatedTarget) + { + // Home in on the target. + Vector2 homeDirection = (destination - Projectile.Center).SafeNormalize(Vector2.UnitY); + Projectile.velocity = (Projectile.velocity * 12f + homeDirection * 20f) / (12f + 1f); + } + + if (Projectile.velocity.Length() < 20f) + { + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 20f; + } + } + + public override void Kill(int timeLeft) + { + + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2); + return false; + } + } +} diff --git a/Projectiles/Ranged/GaleforceArrow.png b/Projectiles/Ranged/GaleforceArrow.png new file mode 100644 index 0000000000000000000000000000000000000000..194f06ee01260f5bbbc70ae2dd4e60d8e6ed2032 GIT binary patch literal 409 zcmV;K0cQS*P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0WL{IK~zXfwUwc& zgg_LA-HT74!JyS(vxwPeun7ji#}W)?o82rvfWd4K(JlykcmC_yFuTLD=5n&kKna)!4egDpMmM`l+r+>|jb}7pe53($S=Xnk1g&ojKPYq)fxe)=_mwrz03FyL+5!n>|R&-Fxt zlKFF_BtkmzrE%YP$TUreY94iogl*f92=$4dP~SLB6C^@i;<7Bzx~>q_Jkp8J_wR9L zct_JTMXl?9pXzZO@T#idkGZdX9l}O-*U)|Q4t0s1=RrXbKveTwPjnmy8ioNPsHSy7 zI#GD%@c)YcyK{)X?;#P=i9*<{H19jq&-e++Mos$#RAzzD;BRkt00000NkvXXu0mjf D`$e>^ literal 0 HcmV?d00001 diff --git a/Projectiles/Ranged/GaleforceHoldout.cs b/Projectiles/Ranged/GaleforceHoldout.cs new file mode 100644 index 0000000000..433e2840a7 --- /dev/null +++ b/Projectiles/Ranged/GaleforceHoldout.cs @@ -0,0 +1,140 @@ +using System; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Effects; +using Terraria.Graphics.Shaders; + + +namespace CalamityMod.Projectiles.Ranged +{ + //Holdout, but invisible. It may as well be named "GaleforceHandler" + public class GaleforceHoldout : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static float MaxCharge = 50; + public static int ShotProjectiles = 5; + + public ref float Charge => ref Projectile.ai[0]; + public float ChargeProgress => MathHelper.Clamp(Charge, 0, MaxCharge) / MaxCharge; + public float FullChargeProgress => MathHelper.Clamp(Charge, 0, MaxCharge * 1.5f) / (MaxCharge * 1.5f); + public float Spread => MathHelper.PiOver2 * (1 - (float)Math.Pow(ChargeProgress, 1.5) * 0.95f); + + public Player Owner => Main.player[Projectile.owner]; + + + + public override void SetDefaults() + { + Projectile.width = 38; + Projectile.height = 68; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public override bool? CanDamage() + { + return false; + } + + public override bool ShouldUpdatePosition() + { + return false; + } + + public override void AI() + { + if (Owner.channel) + { + Projectile.timeLeft = 2; + Owner.itemTime = 25; + Owner.itemAnimation = 25; + Owner.heldProj = Projectile.whoAmI; + } + + float pointingRotation = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation(); + Projectile.Center = Owner.MountedCenter + pointingRotation.ToRotationVector2() * 40f; + + if (Projectile.soundDelay <= 0) + { + //SoundEngine.PlaySound(CoralSpout.ChargeSound with { Pitch = 0.5f * ChargeProgress}, Owner.MountedCenter); + Projectile.soundDelay = 10; + } + + Charge++; + } + + public override bool PreDraw(ref Color lightColor) + { + float angle = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation(); + + Effect effect = Filters.Scene["CalamityMod:SpreadTelegraph"].GetShader().Shader; + effect.Parameters["centerOpacity"].SetValue(0.7f); + effect.Parameters["mainOpacity"].SetValue((float)Math.Sqrt(ChargeProgress)); + effect.Parameters["halfSpreadAngle"].SetValue(Spread / 2f); + effect.Parameters["edgeColor"].SetValue(Color.Lerp(Color.LightGray, Color.Coral, 0).ToVector3()); + effect.Parameters["centerColor"].SetValue(Color.Lerp(Color.Gray, Color.Coral, 0).ToVector3()); + effect.Parameters["edgeBlendLength"].SetValue(0.07f); + effect.Parameters["edgeBlendStrength"].SetValue(8f); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + + Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.White, angle, new Vector2(texture.Width / 2f, texture.Height/2f), 700f, 0, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + float mainAngle = (Projectile.Center - Owner.MountedCenter).ToRotation(); + Texture2D arrowTexture = ModContent.Request("CalamityMod/Projectiles/Ranged/GaleforceArrow").Value; + + for (int i = 0; i < ShotProjectiles; i++) + { + float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / ((float)ShotProjectiles - 1)); + float direction = mainAngle + angleOffset; + Vector2 displacement = (direction + MathHelper.Pi / 12f).ToRotationVector2(); + Main.EntitySpriteDraw(arrowTexture, Owner.MountedCenter - Main.screenPosition + (displacement * 26f), null, Color.White, direction - MathHelper.Pi/2, new Vector2(texture.Width / 2f, texture.Height / 2f), 1f, 0, 0); + + } + + return false; + } + + public override void Kill(int timeLeft) + { + float mainAngle = (Projectile.Center - Owner.MountedCenter).ToRotation(); + + SoundEngine.PlaySound(SoundID.Item5 with { Volume = SoundID.Item167.Volume * 0.4f + 0.2f * ChargeProgress }, Owner.MountedCenter); + + for (int i = 0; i < ShotProjectiles; i++) + { + float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / ((float)ShotProjectiles - 1)); + Vector2 direction = (mainAngle + angleOffset).ToRotationVector2(); + + int realDamage = Projectile.damage; + + if (Owner.whoAmI == Main.myPlayer) + { + float speed = 20f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter + direction * 30f, direction * speed, ModContent.ProjectileType(), realDamage, Projectile.knockBack, Owner.whoAmI, ChargeProgress); + } + + Color pulseColor = Main.rand.NextBool() ? Color.Gray : Color.LightGray; + Particle pulse = new DirectionalPulseRing(Owner.MountedCenter + direction * 44f, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), direction.ToRotation(), 0.04f, 0.2f, 30); + GeneralParticleHandler.SpawnParticle(pulse); + } + + } + } +}