From b89a0a01093594faa1f5a285bb4100b3c8f39a48 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Sat, 18 Feb 2023 23:19:35 -0800 Subject: [PATCH] reverted sprite swap, added glow to aura --- Buffs/Summon/SarosPossessionBuff.cs | 2 +- Items/Weapons/Summon/SarosPossession.cs | 2 +- Projectiles/Summon/SarosAura.cs | 139 ++++++++++++++++++++++++ Projectiles/Summon/SarosAura.png | Bin 0 -> 6729 bytes Projectiles/Summon/SarosDisk.cs | 83 -------------- Projectiles/Summon/SarosDisk.png | Bin 1630 -> 0 bytes Projectiles/Summon/SarosMicrosun.cs | 119 ++++++-------------- 7 files changed, 173 insertions(+), 172 deletions(-) create mode 100644 Projectiles/Summon/SarosAura.cs create mode 100644 Projectiles/Summon/SarosAura.png delete mode 100644 Projectiles/Summon/SarosDisk.cs delete mode 100644 Projectiles/Summon/SarosDisk.png diff --git a/Buffs/Summon/SarosPossessionBuff.cs b/Buffs/Summon/SarosPossessionBuff.cs index 5b9b63bf9c..432e037367 100644 --- a/Buffs/Summon/SarosPossessionBuff.cs +++ b/Buffs/Summon/SarosPossessionBuff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Buffs.Summon public override void Update(Player player, ref int buffIndex) { CalamityPlayer modPlayer = player.Calamity(); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) modPlayer.saros = true; if (!modPlayer.saros) { diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index ad0a18bb02..d2d5a9e31d 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.knockBack = 4f; Item.mana = 10; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.width = Item.height = 56; Item.useTime = Item.useAnimation = 10; diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs new file mode 100644 index 0000000000..232c7c8d93 --- /dev/null +++ b/Projectiles/Summon/SarosAura.cs @@ -0,0 +1,139 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SarosAura : ModProjectile + { + public Player Owner => Main.player[Projectile.owner]; + + public CalamityPlayer moddedOwner => Owner.Calamity(); + + public ref float GeneralTimer => ref Projectile.ai[0]; + + public bool CheckForSpawning = false; + + public static readonly SoundStyle SarosDiskThrow = new SoundStyle("CalamityMod/Sounds/Item/SarosDiskThrow", 3) { Volume = 0.4f, PitchVariance = 1 }; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Saros Aura"); + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.minionSlots = 8f; + Projectile.penetrate = -1; + + Projectile.width = Projectile.height = 132; + + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.minion = true; + } + + public override void AI() + { + NPC potentialTarget = Projectile.Center.MinionHoming(5000f, Owner); + + CheckMinionExistince(); // Ensure that the projectile using this AI is the correct projectile and that the owner has the appropriate buffs. + SpawnEffect(); // Makes a dust spawn effect where the minion spawns. + + // Attack nearby targets. + if (potentialTarget != null && Main.myPlayer == Projectile.owner) + AttackTarget(potentialTarget); + + // Stay near the target and spin around. + Projectile.Center = Owner.Center - Vector2.UnitY * 16f; + // The projectile spins right at a constant speed. + Projectile.rotation += MathHelper.ToRadians(1.5f); + + // Emit some light. + Lighting.AddLight(Projectile.Center, Vector3.One * 1.2f); + + // A timer for the AI. + GeneralTimer++; + } + + #region Methods + + public void CheckMinionExistince() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + moddedOwner.saros = false; + if (moddedOwner.saros) + Projectile.timeLeft = 2; + } + } + + public void SpawnEffect() + { + if (CheckForSpawning == false) + { + int dustAmount = 360; + for (int d = 0; d < dustAmount; d++) + { + float angle = MathHelper.TwoPi / dustAmount * d; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(20f, 30f); + + Dust spawnDust = Dust.NewDustPerfect(Owner.Center - Vector2.UnitY * 60f, (int)CalamityDusts.ProfanedFire, velocity); + spawnDust.noGravity = true; + spawnDust.color = Color.Lerp(Color.White, Color.Yellow, 0.25f); + spawnDust.scale = velocity.Length() * 0.25f; + spawnDust.velocity *= 0.7f; + } + } + CheckForSpawning = true; + } + + public void AttackTarget(NPC target) + { + if (GeneralTimer % 50f == 49f) + { + for (int i = -1; i < 2; i++) + { + float angle = (target.Center - Projectile.Center).ToRotation() + (MathHelper.PiOver2 * i) + Main.rand.NextFloat(MathHelper.PiOver4, -MathHelper.PiOver4); + Vector2 velocity = angle.ToRotationVector2() * 30f; + + int fire = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + if (Main.projectile.IndexInRange(fire)) + Main.projectile[fire].originalDamage = Projectile.originalDamage; + + Projectile.netUpdate = true; + } + } + + if (GeneralTimer % 100f == 99f) + { + float angle = (target.Center - Projectile.Center).ToRotation() + Main.rand.NextFloat(MathHelper.PiOver2, -MathHelper.PiOver2); + Vector2 velocity = angle.ToRotationVector2() * 25f; + SoundEngine.PlaySound(SarosDiskThrow, Projectile.Center); + + int disk = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); + if (Main.projectile.IndexInRange(disk)) + Main.projectile[disk].originalDamage = Projectile.originalDamage * 2; + + Projectile.netUpdate = true; + } + } + + public override bool? CanDamage() => false; + + #endregion + } +} diff --git a/Projectiles/Summon/SarosAura.png b/Projectiles/Summon/SarosAura.png new file mode 100644 index 0000000000000000000000000000000000000000..1706469c4f7d00b8d6f70b8e8136dd5af9cded0a GIT binary patch literal 6729 zcmYj$c|26_`~DGGGTE|?tl6cEL6*rDl5Ex3_ie1%vhR_74Vh*VlI&ZCDP-RnS+b0! zP)HcOnTG5?d_RBup4aP~=lpSA=iJYIU-xxi&;2Ak($lR5U5cE74_elmcqryS@5+Z5 z=TtR*_MG2T4H4YS)im5_F5gv{KP12Vzu}R#U`W5v!ax~s)xAQ;e_*`bAVK@Hocnq2 zdW)1!5eqHaCjzIEG$9BqGr5a}A3kdnx>s4IW$n!r8y}koydTEXhC~{CYmR<9wyBhZy2ed3;Y8_nW_13s zeOiZCD=0r%^}g3A{R_8%cLbaME1g}yMrf0EvT6~v;V0+Fo|Es!oy@s>cg4TM)V>=U zEex$3dov3Vi4M^MpTGj6haLU5884|YPbaHV^n%4CISSQ^?Ah~WF`d95+V&|KFStXm zM@Hb;oMW=y)?)n|kCJ5{b%Xq;jIno!cVDso0(W$FXlL>v&ukQxivIr7A>KD!F{!{J zbx-PE6OMgHegG7CGF2erTX)qQ_paHF(;XIl6aKfkkEy@|0ll0@su`fpfkuI=JK6p4 z#=wYwfuNKZ=P|?=c&>-I;)LVA9_MWw82jHxFHex_^iKwjsVo+ZI=bDKuE0+q zy=4x`<*36rus@Qa(FYp8bFX>$znGnNNOGA52ss=ze4;wM7i?WV*tT64CITAW#m?cs z;+-=5f^is*m;zUx@jK&3HEqnVL^sWm|ABtm{)_>4Oo*i-C^!Gyr7><3xVBWv`DKO* zeIs=bN9Tal`a)gFh5EBD0{@`(_L2%aZhNGE$aAKOObDI7p)Q09WgB1+QyZ`Bqo@*B z?Rj_HUZJf_nCK|;7ul=+FT5zw)c?vb12^mDAcOX9>@1W#;7*$8%_Wz*H}lGe*@M=a zzZbkqK#a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&Ao_TM+L>CM0&oJD^+tR>)rI&N*x9T%3dYs>y=nin$I-gFJTGqeQsWEVg znTbWy-CUO2WsqHayO@(QpBMm1*Spr)#5~{S{_~>OygGoPk8Ao+cUv^{l$mlWnS6h5q;T8Ax=JT5^rgX-Cj&tgobwXV27U*ZKGc&pe;BH1yP~?%72BKY@GLP5=M^ literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/SarosDisk.cs b/Projectiles/Summon/SarosDisk.cs deleted file mode 100644 index b8eb5ee7f8..0000000000 --- a/Projectiles/Summon/SarosDisk.cs +++ /dev/null @@ -1,83 +0,0 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class SarosDisk : ModProjectile - { - public Player Owner => Main.player[Projectile.owner]; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Saros Disk"); - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 8; - ProjectileID.Sets.MinionShot[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.timeLeft = 600; - - Projectile.width = Projectile.height = 66; - - Projectile.DamageType = DamageClass.Summon; - Projectile.netImportant = true; - Projectile.tileCollide = false; - Projectile.friendly = true; - Projectile.minion = true; - Projectile.ignoreWater = true; - } - - public override void AI() - { - // Tries to detect a target on a certain distance. - NPC target = Projectile.Center.MinionHoming(5000f, Owner); - - // Rotates to the left if the projectile's heading to the left and viceversa. - Projectile.rotation += (Projectile.velocity.X > 0f) ? MathHelper.ToRadians(20f) : -MathHelper.ToRadians(20f); - - // If there's a target, go towards the target. - if (target != null) - { - Projectile.velocity = Vector2.Lerp(Projectile.velocity, (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * 35f, 0.1f); - Projectile.netUpdate = true; - } - } - - public override void Kill(int timeLeft) - { - int dustAmount = 180; - for (int d = 0; d < dustAmount; d++) - { - float angle = MathHelper.TwoPi / dustAmount * d; - Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(20f, 30f); - - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.ProfanedFire, velocity); - spawnDust.noGravity = true; - spawnDust.color = Color.Lerp(Color.White, Color.Yellow, 0.25f); - spawnDust.scale = velocity.Length() * 0.25f; - spawnDust.velocity *= 0.5f; - } - } - - public override bool PreDraw(ref Color lightColor) // Makes the afterimages of the disk. - { - Texture2D texture = ModContent.Request(Texture).Value; - Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Vector2 origin = frame.Size() * 0.5f; - SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - Color afterimageDrawColor = Color.DarkOrange with { A = 25 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); - Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; - Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation, origin, Projectile.scale, direction, 0); - } - return true; - } - } -} diff --git a/Projectiles/Summon/SarosDisk.png b/Projectiles/Summon/SarosDisk.png deleted file mode 100644 index 9a3de1b6ea5a978d5b345e966155ff95df9fa4b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1630 zcmV-k2BGPx*7)eAyRCt{2n_X`dWfaGML#YJ` zBJsvAVTc#Tm}m%k;e|$0X%uWRSSYZ(Rkqpf3y?BioO5R9nVsqGG}Ptd`QOaW%kwh( z{Gb1G&U4NLbO_-;pU98-xe$QSasUv#`b9_jv#leoK8M)ev6goh@QhGw#*UB?>>dgL`o^9DP``Ss zt&tl!eMEkkkAX5{>F*GraQa99F!%KzS@k&W^o{Kcq(3sIg(r9IelGpqVCS=!Qp=eZ^%b`T0A0m?0G5=A!@By^ ze*RVZ_vCJ__wtNTw9SZUL{t-u31$cI<2N!lrw+^9T&~IW`xUD~?pJQe+4y97LzNq; zT2p@a6*=owuT?c>=mXad=^NW8)m+V7%~IhRp~$TfwmO(5L`-PR`B1MvgYL!ZGiDt* zF2~Vv;_X;}mKv*>@aFzZ~!7w=;~maaO2K8&=}dpikuIWx~xdxoU6GoGA8FX!UKDy zKKg}G(Q1<2zg$}38KG!<)!4Cr4*(+{y(1THi`p|c<2+|}f~^jw2}veo?Ht)om}!RX zXf57Z4*|M%59lgVa|@OyMdKWbw!xv8KDTm3uiXAmH$`yPXb#f~VxSaTUso{)DL zZn7gB%hLNAEzmY2lF!Dx&vaj7NiN&mj`lu*; z?f4q4yg286G*Y^=G*DUqoc#!SS}n$`{fNbB*K1wt9|2nLN5tTFs5XNgpS=Jur%d;$h@P_9vE%jl;bW!(=x?nr+;BNUzc5;zfS_1}g+C+Hj_RuUPz8kO!8 cJR=nU0lYMP=TZy$ivR!s07*qoM6N<$f_a7?-T(jq diff --git a/Projectiles/Summon/SarosMicrosun.cs b/Projectiles/Summon/SarosMicrosun.cs index 9a42e089c7..da6e0d17be 100644 --- a/Projectiles/Summon/SarosMicrosun.cs +++ b/Projectiles/Summon/SarosMicrosun.cs @@ -1,9 +1,7 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -13,14 +11,6 @@ namespace CalamityMod.Projectiles.Summon { public Player Owner => Main.player[Projectile.owner]; - public CalamityPlayer moddedOwner => Owner.Calamity(); - - public ref float GeneralTimer => ref Projectile.ai[0]; - - public bool CheckForSpawning = false; - - public static readonly SoundStyle SarosDiskThrow = new SoundStyle("CalamityMod/Sounds/Item/SarosDiskThrow", 3) { Volume = 0.4f, PitchVariance = 1 }; - public override void SetStaticDefaults() { DisplayName.SetDefault("Saros Microsun"); @@ -31,54 +21,33 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - Projectile.minionSlots = 8f; - Projectile.penetrate = -1; + Projectile.timeLeft = 600; Projectile.width = Projectile.height = 62; Projectile.DamageType = DamageClass.Summon; Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; Projectile.tileCollide = false; + Projectile.friendly = true; Projectile.minion = true; + Projectile.ignoreWater = true; } public override void AI() { - NPC potentialTarget = Projectile.Center.MinionHoming(5000f, Owner); + // Tries to detect a target on a certain distance. + NPC target = Projectile.Center.MinionHoming(5000f, Owner); - CheckMinionExistince(); // Ensure that the projectile using this AI is the correct projectile and that the owner has the appropriate buffs. - SpawnEffect(); // Makes a dust spawn effect where the minion spawns. DoAnimation(); // Does the animation of the minion. - // Attack nearby targets. - if (potentialTarget != null && Main.myPlayer == Projectile.owner) - AttackTarget(potentialTarget); - - // Stay near the target and spin around. - Projectile.Center = Owner.Center - Vector2.UnitY * 60f; - // The projectile spins in the direction of the player and spins faster the faster the player is. + // Rotates to the left if the projectile's heading to the left and viceversa. Projectile.rotation += MathHelper.ToRadians(1f + (Owner.velocity.X * 0.04f)) * Owner.direction; - // Emit some light. - Lighting.AddLight(Projectile.Center, Vector3.One * 1.2f); - - // A timer for the AI. - GeneralTimer++; - } - - #region Methods - - public void CheckMinionExistince() - { - Owner.AddBuff(ModContent.BuffType(), 3600); - if (Projectile.type == ModContent.ProjectileType()) + // If there's a target, go towards the target. + if (target != null) { - if (Owner.dead) - moddedOwner.saros = false; - if (moddedOwner.saros) - Projectile.timeLeft = 2; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * 35f, 0.1f); + Projectile.netUpdate = true; } } @@ -88,59 +57,35 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = Projectile.frameCounter / 6 % Main.projFrames[Projectile.type]; } - public void SpawnEffect() + public override bool PreDraw(ref Color lightColor) // Makes the afterimages of the disk. { - if (CheckForSpawning == false) + Texture2D texture = ModContent.Request(Texture).Value; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + for (int i = 0; i < Projectile.oldPos.Length; i++) { - int dustAmount = 360; - for (int d = 0; d < dustAmount; d++) - { - float angle = MathHelper.TwoPi / dustAmount * d; - Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(20f, 30f); - - Dust spawnDust = Dust.NewDustPerfect(Owner.Center - Vector2.UnitY * 60f, (int)CalamityDusts.ProfanedFire, velocity); - spawnDust.noGravity = true; - spawnDust.color = Color.Lerp(Color.White, Color.Yellow, 0.25f); - spawnDust.scale = velocity.Length() * 0.25f; - spawnDust.velocity *= 0.7f; - } + Color afterimageDrawColor = Color.DarkOrange with { A = 25 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation, origin, Projectile.scale, direction, 0); } - CheckForSpawning = true; + return true; } - public void AttackTarget(NPC target) + public override void Kill(int timeLeft) { - if (GeneralTimer % 50f == 49f) + int dustAmount = 180; + for (int d = 0; d < dustAmount; d++) { - for (int i = -1; i < 2; i++) - { - float angle = (target.Center - Projectile.Center).ToRotation() + (MathHelper.PiOver2 * i) + Main.rand.NextFloat(MathHelper.PiOver4, -MathHelper.PiOver4); - Vector2 velocity = angle.ToRotationVector2() * 30f; + float angle = MathHelper.TwoPi / dustAmount * d; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(20f, 30f); - int fire = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - if (Main.projectile.IndexInRange(fire)) - Main.projectile[fire].originalDamage = Projectile.originalDamage; - - Projectile.netUpdate = true; - } - } - - if (GeneralTimer % 100f == 99f) - { - float angle = (target.Center - Projectile.Center).ToRotation() + Main.rand.NextFloat(MathHelper.PiOver2, -MathHelper.PiOver2); - Vector2 velocity = angle.ToRotationVector2() * 25f; - SoundEngine.PlaySound(SarosDiskThrow, Projectile.Center); - - int disk = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); - if (Main.projectile.IndexInRange(disk)) - Main.projectile[disk].originalDamage = Projectile.originalDamage * 2; - - Projectile.netUpdate = true; + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.ProfanedFire, velocity); + spawnDust.noGravity = true; + spawnDust.color = Color.Lerp(Color.White, Color.Yellow, 0.25f); + spawnDust.scale = velocity.Length() * 0.25f; + spawnDust.velocity *= 0.5f; } } - - public override bool? CanDamage() => false; - - #endregion } }