From 30bef1da1bd2d6cdf50893b1907b910bba47c545 Mon Sep 17 00:00:00 2001 From: DominicKarma42 <51094361+DominicKarma@users.noreply.github.com> Date: Sat, 18 Apr 2020 17:07:03 -0500 Subject: [PATCH] Artifact of Resilience --- Buffs/Cooldowns/ResilienceCooldown.cs | 19 + Buffs/Cooldowns/ResilienceCooldown.png | Bin 0 -> 517 bytes Items/Weapons/Typeless/RelicOfResilience.cs | 95 +++++ Items/Weapons/Typeless/RelicOfResilience.png | Bin 0 -> 787 bytes .../ProfanedGuardianBoss2.cs | 6 + .../Damageable/ArtifactOfResilienceBulwark.cs | 63 ++++ .../ArtifactOfResilienceBulwark.png | Bin 0 -> 2350 bytes .../Damageable/DamageableProjectile.cs | 350 ++++++++++++++++++ .../Typeless/ArtifactOfResilienceShard1.png | Bin 0 -> 629 bytes .../Typeless/ArtifactOfResilienceShard2.png | Bin 0 -> 621 bytes .../Typeless/ArtifactOfResilienceShard3.png | Bin 0 -> 558 bytes .../Typeless/ArtifactOfResilienceShard4.png | Bin 0 -> 648 bytes .../Typeless/ArtifactOfResilienceShard5.png | Bin 0 -> 538 bytes .../Typeless/ArtifactOfResilienceShard6.png | Bin 0 -> 386 bytes .../Typeless/ArtifactOfResilienceShards.cs | 237 ++++++++++++ 15 files changed, 770 insertions(+) create mode 100644 Buffs/Cooldowns/ResilienceCooldown.cs create mode 100644 Buffs/Cooldowns/ResilienceCooldown.png create mode 100644 Items/Weapons/Typeless/RelicOfResilience.cs create mode 100644 Items/Weapons/Typeless/RelicOfResilience.png create mode 100644 Projectiles/Damageable/ArtifactOfResilienceBulwark.cs create mode 100644 Projectiles/Damageable/ArtifactOfResilienceBulwark.png create mode 100644 Projectiles/Damageable/DamageableProjectile.cs create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShard1.png create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShard2.png create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShard3.png create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShard4.png create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShard5.png create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShard6.png create mode 100644 Projectiles/Typeless/ArtifactOfResilienceShards.cs diff --git a/Buffs/Cooldowns/ResilienceCooldown.cs b/Buffs/Cooldowns/ResilienceCooldown.cs new file mode 100644 index 0000000000..66a4975223 --- /dev/null +++ b/Buffs/Cooldowns/ResilienceCooldown.cs @@ -0,0 +1,19 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Cooldowns +{ + public class ResilienceCooldown : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Resilience Cooldown"); + Description.SetDefault("You cannot re-summon a relic of resilience"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + canBeCleared = false; + } + } +} diff --git a/Buffs/Cooldowns/ResilienceCooldown.png b/Buffs/Cooldowns/ResilienceCooldown.png new file mode 100644 index 0000000000000000000000000000000000000000..abb0b76b86b83bcc2f067bc1f485f22bad1a3f22 GIT binary patch literal 517 zcmV+g0{Z=lP)Px$zez+vR9J=OmoZC1aTLXWPqLt;Feh<|Fam=n1;>hp2pXa<;2M2_ni?B}B53jh z6mC)w+HVy63@M&8 zBfGmAuz+V)>$Hz{bZO0J->9U|i?A;CB+Pr6z$+ ztyFtuzH(6YIquA-+ShU|FmU5^5rEwKHPAgtcgt6R0}O6!F+&j4XvV4fivL!`>*3~V&%&p0-e!a00000NkvXX Hu0mjfSM=(` literal 0 HcmV?d00001 diff --git a/Items/Weapons/Typeless/RelicOfResilience.cs b/Items/Weapons/Typeless/RelicOfResilience.cs new file mode 100644 index 0000000000..31f8cb212b --- /dev/null +++ b/Items/Weapons/Typeless/RelicOfResilience.cs @@ -0,0 +1,95 @@ +using CalamityMod.Buffs.Cooldowns; +using CalamityMod.Projectiles.Damageable; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Typeless +{ + public class RelicOfResilience : ModItem + { + public const int CooldownSeconds = 5; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Relic of Resilience"); + Tooltip.SetDefault("Summons a bulwark at the mouse position\n" + + "The bulwark takes damage from enemies and all projectiles.\n" + + "On death, the bulwark explodes into a burst of shards\n" + + "After a bit of time, the shards come together to reform the original bulwark.\n" + + $"This reformation can only happen {ArtifactOfResilienceBulwark.MaxReformations} times.\n" + + "You gain a small cooldown when summoning a new bulwark.\n" + + "If a bulwark or shard already exists, using this item will relocate them"); + } + + public override void SetDefaults() + { + item.width = 40; + item.height = 34; + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.useAnimation = item.useTime = 28; + item.useStyle = ItemUseStyleID.HoldingUp; + item.UseSound = SoundID.Item45; + item.autoReuse = true; + item.noMelee = true; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 0f; + } + public override bool CanUseItem(Player player) => !player.HasBuff(ModContent.BuffType()); + public override bool UseItem(Player player) + { + return true; + } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + player.AddBuff(ModContent.BuffType(), CooldownSeconds * 60); + if (player.ownedProjectileCounts[item.shoot] > 0 || + player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].type == item.shoot) + { + Main.projectile[i].Center = Main.MouseWorld; + Main.projectile[i].netUpdate = true; + } + else + { + if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard1) + { + ((ArtifactOfResilienceShard1)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; + } + if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard2) + { + ((ArtifactOfResilienceShard2)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; + } + if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard3) + { + ((ArtifactOfResilienceShard3)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; + } + if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard4) + { + ((ArtifactOfResilienceShard4)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; + } + if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard5) + { + ((ArtifactOfResilienceShard5)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; + } + if (Main.projectile[i].modProjectile is ArtifactOfResilienceShard6) + { + ((ArtifactOfResilienceShard6)Main.projectile[i].modProjectile).StartingPosition = Main.MouseWorld; + } + } + } + } + else + { + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); + } + return false; + } + } +} diff --git a/Items/Weapons/Typeless/RelicOfResilience.png b/Items/Weapons/Typeless/RelicOfResilience.png new file mode 100644 index 0000000000000000000000000000000000000000..87d1ba1e64b34f0a26c812bb1a99e35694434f85 GIT binary patch literal 787 zcmV+u1MK{XP)Px%%}GQ-R9J=Gm`hI+Q5c4wDU?Df6uGEeRU|HmMiyv{Y}B}LrzCD&xOCype_{L$ z#<(@9KY%DP!5Ae5?+GfGT0kt9LR;z0jEnJedQN936-+w3o5{J%H)o!CzwgY9!5-^e zTUcrLcOC>Fmn)bqrx*Z_re_@oeS5dG|D)R72GEIhceDbq5MMI^W|n>caQpfd0Q!f! z0JwMe@s8r}AA&k5kxpzOz6O*Mb5k~-SK_}|-B8B&55XcS*;tO)%;X{fk*6;KIMJhy z$2XG_&v3d})f04Fb+HC}dI1RJv(~YYHR0ch>3Z_!JpiW9X8=T#X#kcoIl#*Vh1~J3 z0|0zoTvxoezOoF!NMAPqu~o~9mrkFoXaUnPi}*xzL0OY$2$p2A8@XH8h5`6AmjEC# zwp`JLgp^KNJSqeOK8smreI4KhfeFOKuvBt*((w@9yxRZq~6I@r+?0wA79DOugo5;FeuOP4Yp zYOyN*vF0`ap1qy|Y%l5_(=~eWtkS;oAOgVQ<|c2{!M|@a`i|nJP(uKK)K=Efi;~SE zA?c?3&tGl3Ht!HDry{}%IlWE>e7~%i8S4%FyZz1KsNR8I<@|g;V*nKL1;7IYcl~EU z?!2*~&HzYnS?%@Bq)btsQmx+)KvTHYEIwbVK`LQAA-~@v9;}$4)J54*WDl2}2<@9f z*I@f0is#kTT7XlDoTFE(p5TtNSR~mT4%P#(@iU{}xdHGo_N}6LZmN2MzX5Lx8MpV$ RMXmq<002ovPDHLkV1hq?VB`P* literal 0 HcmV?d00001 diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index c3a52b7001..c2c4f1e7c5 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Typeless; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -285,6 +286,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians return true; } + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + } + public override void BossLoot(ref string name, ref int potionType) { name = "A Profaned Guardian"; diff --git a/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs b/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs new file mode 100644 index 0000000000..341ecdcff2 --- /dev/null +++ b/Projectiles/Damageable/ArtifactOfResilienceBulwark.cs @@ -0,0 +1,63 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +namespace CalamityMod.Projectiles.Damageable +{ + public class ArtifactOfResilienceBulwark : DamageableProjectile + { + public int Reformations = 0; + public const int MaxReformations = 3; + public override int LifeMax => 30000; + public override int MaxDamageImmunityFrames => 5; + public override DamageSourceType DamageSources => DamageSourceType.FriendlyProjectiles | DamageSourceType.HostileProjectiles | DamageSourceType.HostileNPCs; + public override LegacySoundStyle HitSound => SoundID.NPCHit3; + public override LegacySoundStyle DeathSound => SoundID.NPCDeath14; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact of Resilience"); + } + + public override void SafeSetDefaults() + { + projectile.width = projectile.height = 76; + projectile.friendly = true; + projectile.penetrate = 20; + } + + public override void SafeAI() + { + projectile.rotation += MathHelper.ToRadians(8f); + Vector2 spawnPosition = projectile.Center + Utils.NextVector2Circular(Main.rand, projectile.width, projectile.height) / 2f; + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(spawnPosition, (int)CalamityDusts.ProfanedFire); + dust.velocity = projectile.DirectionFrom(spawnPosition); + dust.scale = Main.rand.NextFloat(1.1f, 1.5f); + dust.noGravity = true; + } + } + public override void HitEffectProjectile(int damage, Projectile target) + { + target.Kill(); + } + public override void DamageKillEffect() + { + Utils.PoofOfSmoke(projectile.Center); + } + public override void Kill(int timeLeft) + { + for (int i = 1; i <= 6; i++) + { + if (Main.myPlayer == projectile.owner) + { + float angle = MathHelper.TwoPi / 6f * (i - 1); + Projectile shard = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, mod.ProjectileType("ArtifactOfResilienceShard" + i.ToString()), projectile.damage, projectile.knockBack, projectile.owner); + shard.ai[0] = angle; + shard.frameCounter = projectile.frameCounter + 1; // FrameCounter is a stored value for the amount of times the bulwark has reformed. + } + } + } + } +} diff --git a/Projectiles/Damageable/ArtifactOfResilienceBulwark.png b/Projectiles/Damageable/ArtifactOfResilienceBulwark.png new file mode 100644 index 0000000000000000000000000000000000000000..97f00c91bdb5f8191ecbfd7804faa82be9797644 GIT binary patch literal 2350 zcmV+}3DNe6P)Px-=t)FDRCt{2oLg)aRTPH*DZOzhEv0~53KRvA00AqaTw=s%q9HMo;Dhl+qQPMF z!53pNMvReX6N$t`=mRl6NFth$7#pD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9NmAnl^Y^dM``38F5-Z1s<&tIy(`rmzH4`MOq{z%9r|;XvG9-y)(fiG-GvtsY zirERqa|n;$_Q_fR**H#WUR`u%R@$l~yG@LORhZ!n$CUIcj8FK) z`J`QAE=d}*6sZbR=~q^svLb$ZJ(4qb`h)-g&Ro0^xsqgJmC4LrzujY4osd50o?Y@4CM45S&Zv^j;gvtAt?RftSr;YVv$wHJNY~eIhOK`ls+p=XcJHd#! zVut;W%Q2@sj(M?X>K9x4Gm(Di<=*^sCjekvg~@B(>M=ch>e5B)xLMzaKX7R`rC3BHJkW_@W!f%24_?m`mQWeOXv?In&}t7{m4>bv zXOf{+?^NC~BaBwD(pP#xc|9q4eXSZv`#VUMuRttN&Wx+eYmm6Oa{)4gOKIf9&CP2h zQ}X_}&HL2q%A`DD38fO28a2xDmbGExlSFA_N%oxdN^!j^XNBTQ%hhYy2uiM0Az7L1 zO8EEp-MeSC^MoZ-4q?(;@(UxZigDFZxx{wNH^~|4YiCWyl-1ac;kMRZO4=%3&sBBA zxJ#1d*BU*bGIjd$NxD|q%as*cZ7Ag;P>aNw9iik*HNQeYQb?F)yQCMS&ElKHIyt}Q zdxR8dgi-vxuEyk_S~@yoeF;U&5>Tw{<99418S+ai@_QF@rdrNwX_DS>m|}e~#S@lL z&PYG=#KW~VToFO9N$(=7ueHdTbyp-p#&gn!v36troCV>(_NqG9Of@CfLCP#dTzSG0 zD)zT`BHrx)$gV5o>MyNURvV*9n33!dBPIv9~g0+ Uy#E+ICIA2c07*qoM6N<$g6vIr761SM literal 0 HcmV?d00001 diff --git a/Projectiles/Damageable/DamageableProjectile.cs b/Projectiles/Damageable/DamageableProjectile.cs new file mode 100644 index 0000000000..55c4a7b67f --- /dev/null +++ b/Projectiles/Damageable/DamageableProjectile.cs @@ -0,0 +1,350 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Damageable +{ + [Flags] + public enum DamageSourceType + { + HostileProjectiles = 1 << 1, + FriendlyProjectiles = 1 << 2, // Does NOT include itself. + HostileNPCs = 1 << 3 + } + public abstract class DamageableProjectile : ModProjectile + { + #region General Fields + /// + /// Current life of the projectile. + /// + public int Life; + /// + /// Total damage immunity frames. This projectile cannot be hit if this is greater than 0. Descends to 0 every frame. + /// + public int DamageImmunityFrames; + #endregion + + #region Overridable Fields/Properties + + /// + /// Total life of the projectile. + /// + public abstract int LifeMax + { + get; + } + + /// + /// The sound the projectile makes on hit. + /// + public abstract LegacySoundStyle HitSound + { + get; + } + + /// + /// The sound the projectile makes on death. + /// + public abstract LegacySoundStyle DeathSound + { + get; + } + + /// + /// The various possibile damage sources for the projectile. + /// + public abstract DamageSourceType DamageSources + { + get; + } + + /// + /// A boolean which determines if the HP bar should be drawn at all. + /// + public virtual bool DrawHPBar + { + get; + set; + } = true; + + /// + /// A boolean which determines if the HP bar should be drawn if is equal to + /// + public virtual bool DrawHPBarAtFullHealth + { + get; + set; + } = false; + + /// + /// How many damage immunity frames this projectile should recieve on hit. + /// + public virtual int MaxDamageImmunityFrames + { + get; + set; + } = 10; + + /// + /// List of all enemies this projectile should ignore when checking if it's colliding with an enemy (assuming this is possible). + /// + public virtual List NPCsToIgnore + { + get; + set; + } = new List(); + + /// + /// List of all projectiles this projectile should ignore when checking if it's colliding with a projectile (assuming this is possible). + /// + public virtual List ProjectilesToIgnore + { + get; + set; + } = new List(); + #endregion + + #region Virtual Methods + Sealed Counterparts + + /// + /// Copy of with integrations for this custom type. + /// + public virtual void SafeSetDefaults() + { + } + public sealed override void SetDefaults() + { + SafeSetDefaults(); + Life = LifeMax; + } + public sealed override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + DrawHealthBar(); + MouseOverText(); + SafePostDraw(spriteBatch, lightColor); + } + + /// + /// Copy of with integrations for this custom type. + /// + public virtual void SafePostDraw(SpriteBatch spriteBatch, Color lightColor) + { + } + public sealed override void AI() + { + SafeAI(); + if (DamageImmunityFrames > 0) + { + DamageImmunityFrames--; + return; + } + bool wasHit = NPCCollisionCheck(); + if (!wasHit) + { + wasHit = ProjectileCollisionCheck(); + } + if (wasHit && Life > 0) + { + if (HitSound != null) + { + Main.PlaySound(HitSound, projectile.Center); + } + } + else if (Life <= 0) + { + if (DeathSound != null) + { + Main.PlaySound(DeathSound, projectile.Center); + } + DamageKillEffect(); + projectile.Kill(); + } + } + public virtual bool NPCCollisionCheck() + { + Player player = Main.player[projectile.owner]; + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && !Main.npc[i].friendly && Main.npc[i].damage > 0 && DamageSources.HasFlag(DamageSourceType.HostileNPCs)) + { + if (Main.npc[i].Hitbox.Intersects(projectile.Hitbox) && !NPCsToIgnore.Contains(Main.npc[i].type)) + { + int damage = Main.DamageVar(Main.npc[i].damage); + int bannerBuffId = Item.NPCtoBanner(Main.npc[i].BannerID()); + if (bannerBuffId > 0 && player.NPCBannerBuff[bannerBuffId]) + { + if (Main.expertMode) + { + damage = (int)(damage * ItemID.Sets.BannerStrength[Item.BannerToItem(bannerBuffId)].ExpertDamageReceived); + } + else + { + damage = (int)(damage * ItemID.Sets.BannerStrength[Item.BannerToItem(bannerBuffId)].NormalDamageReceived); + } + } + CombatText.NewText(new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height), CombatText.DamagedFriendly, damage); + Life -= damage; + HitEffectNPC(damage, Main.npc[i]); + DamageImmunityFrames = MaxDamageImmunityFrames; + NetUpdate(true); + return true; + } + } + } + return false; + } + public virtual bool ProjectileCollisionCheck() + { + for (int i = 0; i < Main.projectile.Length; i++) + { + bool canBeHit = (Main.projectile[i].friendly && DamageSources.HasFlag(DamageSourceType.FriendlyProjectiles) || + Main.projectile[i].hostile && DamageSources.HasFlag(DamageSourceType.HostileProjectiles)) && + i != projectile.whoAmI; + if (Main.projectile[i].active && canBeHit && Main.projectile[i].damage > 0) + { + if (Main.projectile[i].Colliding(Main.projectile[i].Hitbox, projectile.Hitbox)) + { + int damage = Main.DamageVar(Main.projectile[i].damage) * 2; + damage = Main.expertMode ? (int)(damage * Main.expertDamage) : damage; + CombatText.NewText(new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height), CombatText.DamagedFriendly, damage); + Life -= damage; + HitEffectProjectile(damage, Main.projectile[i]); + DamageImmunityFrames = MaxDamageImmunityFrames; + if (projectile.usesIDStaticNPCImmunity) + DamageImmunityFrames = projectile.idStaticNPCHitCooldown; + if (projectile.usesLocalNPCImmunity) + DamageImmunityFrames = projectile.localNPCHitCooldown; + NetUpdate(true); + return true; + } + } + } + return false; + } + public virtual void DamageKillEffect() + { + } + /// + /// Copy of with integrations for this custom type. + /// + public virtual void SafeAI() + { + } + public sealed override void SendExtraAI(BinaryWriter writer) + { + SafeSendExtraAI(writer); + writer.Write(Life); + writer.Write(DamageImmunityFrames); + } + public sealed override void ReceiveExtraAI(BinaryReader reader) + { + SafeReceiveExtraAI(reader); + Life = reader.ReadInt32(); + DamageImmunityFrames = reader.ReadInt32(); + } + + /// + /// Copy of with integrations for this custom type. + /// The writer used to hold data which will be sent to the server. + /// + public virtual void SafeSendExtraAI(BinaryWriter writer) + { + } + + /// + /// Copy of with integrations for this custom type. + /// The reader used to obtain data which will be sent to the server. + /// + public virtual void SafeReceiveExtraAI(BinaryReader reader) + { + } + + /// + /// Syncs data from this npc to the server, and then to all clients. + /// + /// Whether net spam should be ignored and a net update should be forced. + /// The condition required for a forceful sync. Defaults to: Main.netMode != NetmodeID.MultiplayerClient + public virtual void NetUpdate(bool force = false, Func forceCondition = null) + { + if (forceCondition == null) + forceCondition = () => Main.netMode != NetmodeID.MultiplayerClient; + if (force) + { + if (forceCondition()) + { + NetMessage.SendData(MessageID.SyncProjectile, number: projectile.whoAmI); + } + } + else + projectile.netUpdate = true; + } + /// + /// Does things when the projectile is hit. + /// + /// The damage taken by the projectile. + /// The projectile which hit the target. + public virtual void HitEffectProjectile(int damage, Projectile target) + { + } + /// + /// Does things when the projectile is hit. + /// + /// The damage taken by the projectile. + /// The npc which hit the target. + public virtual void HitEffectNPC(int damage, NPC target) + { + } + #endregion + + #region Misc Functions + /// + /// Creates text, much akin to NPCs, when a mouse is over the projectile's hitbox. + /// + public void MouseOverText() + { + if (!Main.mouseText) + { + Rectangle mouseRectangle = new Rectangle((int)(Main.mouseX + Main.screenPosition.X), (int)(Main.mouseY + Main.screenPosition.Y), 1, 1); + if (Main.player[Main.myPlayer].gravDir == -1f) + { + mouseRectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY; + } + if (projectile.Hitbox.Intersects(mouseRectangle)) + { + if (LifeMax > 1) + { + string lifeDataText = string.Concat(new object[] + { + projectile.Name, + ": ", + Life, + "/", + LifeMax + }); + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix); + Main.instance.MouseTextHackZoom(lifeDataText); + } + } + } + } + /// + /// Draws a health bar below the projectile. + /// + public void DrawHealthBar() + { + if (Life == LifeMax && !DrawHPBarAtFullHealth) + return; + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix); + Main.instance.DrawHealthBar(projectile.Bottom.X, projectile.Bottom.Y, Life, LifeMax, 1f, 1f); + } + #endregion + } +} diff --git a/Projectiles/Typeless/ArtifactOfResilienceShard1.png b/Projectiles/Typeless/ArtifactOfResilienceShard1.png new file mode 100644 index 0000000000000000000000000000000000000000..120152d7bc99d1b61df89d49a8b3fd269e59d40b GIT binary patch literal 629 zcmV-*0*d{KP)Px%FG)l}R9J=On9nXlK^Vo)RMS$?guC&l!G;Zq6$@6pfk*IU9>E*1V!=wnh7C=N zO-U+Rw~4Z-qn+bU=a!_&a5nc&@62uU%bD|iQv-))MswD9x;Oy);I=l8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ArtifactOfResilienceShard3.png b/Projectiles/Typeless/ArtifactOfResilienceShard3.png new file mode 100644 index 0000000000000000000000000000000000000000..d78a648d633c6d5a05f70a90e97c0c53d9320b52 GIT binary patch literal 558 zcmV+}0@3}6P)Px$=t)FDR9J=Gn6Xa6P!xv00ue2VgG?&X!RVrin~RgafzRe^n7BIWm&;Ld9e}rw z&#BKV%{!34R`lB&JQAC=rA)u4PEY-2A`=Xe%DgvvBpUUV+`~^evg< z6R|qp-^-luG}ZukXubk){robO%>N^znTv#E&qW54vBe`I|EQKmWA6_Jnf7L@ojEFd zED=f1(Q}JOMCuO)8UILqV(9WYjKyk@FUZh!-1P3~0vE?sfx6$;fXm zZ|{JVOfW>;>N{(d)ePk$o-DaB#|1(pA_CG_Ow5!ek{3H7VEb#`5)6^bgsd1QN5Cgx zl@}}4aTOcYQYkzinMlCO{3R zZ6ze~oYTtI5KH9z>IU$A!|r#2AyUzZG(uHFPj=?=4aJPj4(l7<&Mz1uZmp@;VgOp5 z?hxQ`V;%VE6J8CG6cfwUg$UriKOzw9PA_*oLgKt4lBcmX>BM&h|1}_&NIf3;N~_zO wN=8{BsjAxjPjQJz9vLf}6;j@}GbtD%-+QS8>}b+nY5)KL07*qoM6N<$f??Px%LPD3%0p(fn}knK@iyAvyDHCNph8vyK%_fN~$ zANFq*06#{*0oeI-RQtZxydQMg6#x66%=Eh*07jF;#K@bM&y)M#e*6SLuf13RjHjs~ z84G9V+Pp82nO6_)1Mqloul7E*Z)|NRCi~q^@-H>tkYcCZn)PLRaspJ%tUek5@b1HA z(yrsT;V&RDRzMRC**a4)a|*Ds)Tw>Wnz88m#@2RnJ)9x84&~~MXJ*j9ot%4y-hciA zz|VujG0IMs-9CM|%LQJ$riY4=9^tN@gsI&2WY)F;vQ`+6ruYEL3-dvMh&8 zE0)3;I*TEhDa~hqs)?K#p`I)2>~k`0iEBt`rf26f-q`f@`!KmrS!C&J#fTRJ!p4w&PVJU(h6=Cli1pVmfNHD=8#7+dJyd_X3kwYy%Y?EhH?I-aOwO1! zGdVs6nqbJQ%-$H5Ghy33GjZ2tUj6a#DzQDcbtq>>#4|LW9@W+#4;vGn8KG5$UDG#a z_v0+fylk>#PtJ%(&Wwm_NNDU5c9md_l-5Px$)Ja4^R7i=UEKAIU#0FVj-02-}U#~A7XJbiqI zcCO^+0r2}h@W16*9YU7RW&n7ozIFf>$H$y;#rnImmPIIvoNz=pSY!v=8vvYL--Ird z^nGW(MH+t%0WZ>Qc_Rzr8R2xnMf!uA@n#C$wB?N!Koyo&33e z-xo@i4nQghJm__8^e)|+n*w_G+gKbSXu}+@DgwnT8?6=q>14u#ZWdZ^Y9)*{PA5+Eg#AugC+C+y zmsqYAsns4|mgN;k^__v$hMV^K6el&4q!PkH zsRDG}Uu(wo#kV^2DQ-GF0l;(ZEwr{ei>-6&@DOVCtL>nFRl`dt(zTVpre?eC5X)Cc cvN|@xFGE4oe_8$rAOHXW07*qoM6N<$fPx$JV``BR5*>jmAy`cKomyLfLU~n7OyXvKzA zo81Bf$R>aVTyZ8uEgZjUxbty2b7$tFXtcB11EBA^0Hj4x(IL-q6hK~h(szq-gNS^u gr=Y#DrmPWv0OP1?k_L<}0ssI207*qoM6N<$g4_hAyZ`_I literal 0 HcmV?d00001 diff --git a/Projectiles/Typeless/ArtifactOfResilienceShards.cs b/Projectiles/Typeless/ArtifactOfResilienceShards.cs new file mode 100644 index 0000000000..c638022950 --- /dev/null +++ b/Projectiles/Typeless/ArtifactOfResilienceShards.cs @@ -0,0 +1,237 @@ +using CalamityMod.Dusts; +using CalamityMod.Projectiles.Damageable; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class ArtifactOfResilienceShard1 : ModProjectile + { + public int Timer = 0; + public Vector2 StartingPosition; + public const int MaxTimeLeft = 360; + public const int FallTime = 240; + public const float OutwardMovementTime = 85f; + public const float InwardReturnMovementTime = 100f; + public const float MaxRadius = 240f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact Shard"); + Main.projFrames[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = MaxTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } + public static void ArtifactOfResilienceShardAI(Projectile projectile, ref Vector2 StartingPosition, ref int Timer) + { + // Spinning + if (projectile.localAI[1] == 0f) + { + if (projectile.localAI[0] == 0f) + { + StartingPosition = projectile.Center; + projectile.localAI[0] = 1f; + } + Timer++; + if (Timer < OutwardMovementTime) + { + projectile.ai[1] = MathHelper.Lerp(0f, MaxRadius, Timer / OutwardMovementTime); + } + if (Timer > MaxTimeLeft - InwardReturnMovementTime) + { + projectile.ai[1] = MathHelper.Lerp(0f, MaxRadius, (Timer - MaxTimeLeft) / -InwardReturnMovementTime); + } + projectile.ai[0] += MathHelper.Pi / (projectile.ai[1] / MathHelper.Pi + 1); + projectile.Center = StartingPosition + projectile.ai[0].ToRotationVector2() * projectile.ai[1]; + projectile.rotation = projectile.ai[0]; + if (projectile.timeLeft == 1) + { + for (int i = 0; i < 50; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.ProfanedFire); + dust.velocity = Utils.NextVector2Circular(Main.rand, 36f, 36f); + dust.scale = Main.rand.NextFloat(1.9f, 2.45f); + dust.noGravity = true; + } + projectile.timeLeft = FallTime; + projectile.tileCollide = true; + projectile.velocity = Utils.NextVector2Circular(Main.rand, 18f, 9f); + projectile.localAI[1] = 1; + } + } + // Falling + else + { + if (projectile.frameCounter <= ArtifactOfResilienceBulwark.MaxReformations) + { + // Reform + if (projectile.modProjectile is ArtifactOfResilienceShard1 && Main.myPlayer == projectile.owner) + { + Projectile reformedBulwark = Projectile.NewProjectileDirect(projectile.Center, + Vector2.Zero, + ModContent.ProjectileType(), + projectile.damage, + projectile.knockBack, + projectile.owner); + reformedBulwark.frameCounter = projectile.frameCounter; // Incremented on death, not reformation. + } + projectile.Kill(); + return; + } + if (projectile.velocity.Y < 12f) + { + projectile.velocity.Y += 0.25f; + } + projectile.velocity.X *= 0.95f; + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.timeLeft < 60f) + { + projectile.alpha = 255 - (int)MathHelper.Lerp(0, 255, projectile.timeLeft / 60f); + } + } + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void AI() => ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer); + } + public class ArtifactOfResilienceShard2 : ModProjectile + { + public int Timer = 0; + public Vector2 StartingPosition; + public const float MaxRadius = 660f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact Shard"); + Main.projFrames[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 40; + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer); + } + public class ArtifactOfResilienceShard3 : ModProjectile + { + public int Timer = 0; + public Vector2 StartingPosition; + public const float MaxRadius = 660f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact Shard"); + Main.projFrames[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 40; + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer); + } + public class ArtifactOfResilienceShard4 : ModProjectile + { + public int Timer = 0; + public Vector2 StartingPosition; + public const float MaxRadius = 660f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact Shard"); + Main.projFrames[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 40; + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer); + } + public class ArtifactOfResilienceShard5 : ModProjectile + { + public int Timer = 0; + public Vector2 StartingPosition; + public const float MaxRadius = 660f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact Shard"); + Main.projFrames[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 40; + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer); + } + public class ArtifactOfResilienceShard6 : ModProjectile + { + public int Timer = 0; + public Vector2 StartingPosition; + public const float MaxRadius = 660f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Artifact Shard"); + Main.projFrames[projectile.type] = 1; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = ArtifactOfResilienceShard1.MaxTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 40; + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override void AI() => ArtifactOfResilienceShard1.ArtifactOfResilienceShardAI(projectile, ref StartingPosition, ref Timer); + } +}