From 5259a83003c1a9ae9569cc4a7c5bee45ea523ba4 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 18 Jun 2021 13:36:13 -0500 Subject: [PATCH] Start of Exhumed Mechworm --- Buffs/Summon/SepulcherMinionBuff.cs | 36 ++ Buffs/Summon/SepulcherMinionBuff.png | Bin 0 -> 704 bytes CalPlayer/CalamityPlayer.cs | 2 + Items/Weapons/Summon/StaffoftheMechworm2.cs | 48 ++ Items/Weapons/Summon/StaffoftheMechworm2.png | Bin 0 -> 1405 bytes Projectiles/Summon/BrimstoneDartMinion.cs | 58 ++ Projectiles/Summon/SepulcherArm.png | Bin 0 -> 769 bytes Projectiles/Summon/SepulcherForeArm.png | Bin 0 -> 625 bytes Projectiles/Summon/SepulcherHand.png | Bin 0 -> 839 bytes Projectiles/Summon/SepulcherMinion.cs | 519 ++++++++++++++++++ Projectiles/Summon/SepulcherMinionBody.png | Bin 0 -> 1924 bytes Projectiles/Summon/SepulcherMinionBodyAlt.png | Bin 0 -> 2059 bytes Projectiles/Summon/SepulcherMinionHead.png | Bin 0 -> 1768 bytes Projectiles/Summon/SepulcherMinionTail.png | Bin 0 -> 1033 bytes 14 files changed, 663 insertions(+) create mode 100644 Buffs/Summon/SepulcherMinionBuff.cs create mode 100644 Buffs/Summon/SepulcherMinionBuff.png create mode 100644 Items/Weapons/Summon/StaffoftheMechworm2.cs create mode 100644 Items/Weapons/Summon/StaffoftheMechworm2.png create mode 100644 Projectiles/Summon/BrimstoneDartMinion.cs create mode 100644 Projectiles/Summon/SepulcherArm.png create mode 100644 Projectiles/Summon/SepulcherForeArm.png create mode 100644 Projectiles/Summon/SepulcherHand.png create mode 100644 Projectiles/Summon/SepulcherMinion.cs create mode 100644 Projectiles/Summon/SepulcherMinionBody.png create mode 100644 Projectiles/Summon/SepulcherMinionBodyAlt.png create mode 100644 Projectiles/Summon/SepulcherMinionHead.png create mode 100644 Projectiles/Summon/SepulcherMinionTail.png diff --git a/Buffs/Summon/SepulcherMinionBuff.cs b/Buffs/Summon/SepulcherMinionBuff.cs new file mode 100644 index 0000000000..34910472ba --- /dev/null +++ b/Buffs/Summon/SepulcherMinionBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class SepulcherMinionBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Sepulcher"); + Description.SetDefault("It is not benevolent"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.sepulcher = true; + + if (!modPlayer.sepulcher) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/SepulcherMinionBuff.png b/Buffs/Summon/SepulcherMinionBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..5eeae4fa2bc9a0ad21703d163c051442a004eecb GIT binary patch literal 704 zcmV;x0zdtUP)!3UH8HitVDQT+AopN{_JjsInTV(lRS`bG`|9#CMhc|#)E z*%=35TWG!FuP4s}5RB{rU^e$$@n;g()b;rE7XV%jrvSLa1I5=|0VfBV8zO)kK~rpv zGEBre0Vwug1mJ4a;xCMS1z<_)zQx-LCbPrJe{c()2sP zRc>EwKj7BAxvppWfRh9AhLh2L09qdRC_{<7HDu3-6-yOAPCEc^^Y&ib3Ya+6dJcfT zf>)=ZL@s+N)gcOH+N{0rdXrOrnKmnjw#+puKUqf<^xQOb6fm>ioQ48XD4)5j?uWaM z18yI1XNvVZlhsursJQ|Q`hW@ZWMoEQLKHMRs|nBa0Y`ydM{WS_l#`rTxAh!G~zo0_nA|K%$H6pi)0qky2&Jb%)(7k~i@0Qfr$*WcPM&LrS=LOBtcRZ(*Ve1W-aCT_vx^(PM#$I0000 PendingProjectilesToRespawn = new List(); // Due to the way vanilla summons work, the buff must be applied manually for it to properly register, since @@ -1986,6 +1987,7 @@ namespace CalamityMod.CalPlayer plaguebringerPatronSummon = false; howlTrio = false; mountedScanner = false; + sepulcher = false; abyssalDivingSuitPrevious = abyssalDivingSuit; abyssalDivingSuit = abyssalDivingSuitHide = abyssalDivingSuitForce = abyssalDivingSuitPower = false; diff --git a/Items/Weapons/Summon/StaffoftheMechworm2.cs b/Items/Weapons/Summon/StaffoftheMechworm2.cs new file mode 100644 index 0000000000..1fb6faa386 --- /dev/null +++ b/Items/Weapons/Summon/StaffoftheMechworm2.cs @@ -0,0 +1,48 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class StaffoftheMechworm2 : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Staff of the Mechworm (But Exhumed!)"); + Tooltip.SetDefault("Summons a sepulcher to fight for you\n" + + "While the sepulcher is active brimstone hearts will begin to appear and orbit you\n" + + "The sepulcher will attempt to attack you more and more frequently depending on how many hearts are present\n" + + "The sepulcher takes up 4 minion slots"); + } + + public override void SetDefaults() + { + item.damage = 666; + item.mana = 15; + item.width = 58; + item.height = 58; + item.useTime = item.useAnimation = 12; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 2f; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.DD2_BetsySummon; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(Main.MouseWorld, -Vector2.UnitY * 5f, type, damage, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Summon/StaffoftheMechworm2.png b/Items/Weapons/Summon/StaffoftheMechworm2.png new file mode 100644 index 0000000000000000000000000000000000000000..ffcc7066c041095c029a4ac8652a4ae994d0611d GIT binary patch literal 1405 zcmV-@1%mpCP)@W;98YG}@S@Niel3wi+Q17LDM7R7G&XAc(X^sRex$9|fU`mKH^5 zDku~eT>2sY^EYrlXnO+~x{B!4?ncJZyvxW1$40D;extDzN zZ|7W#B}PNp-2hlO8g z?Qveg7@}dN`U2u1|G}d2Y5*>r8?phm?|2`8%C_6D`Tfx!&j9ej&Nl$4sak|OlPy7x*@8B+%8A8wD?*Pazt+K!v5=F)t63!Nln*sQG?K1!be^>xu z_s9?c$1ctR(7B-rfTq*x`x1M^u;8V$0L+AXA7h9{+8Pqovn=yj09pB~Y=GP9>H&E2 z)P4Xquh;;VcnXL#MWOdJ;n)%Cl4UMp4ADp%L%il3LhFlL0jSti;yS*qs|;|= z=n9-r$5Dnn@!sbEY~A^4%=1c@EEq#H(#DVoTwQ2c?OhhYk$rn?fL4?#54Nud;9bT6 zIJ$QPfKn~{NH!9r=kdZAqLDU+$V^mz(-AXJWrh|*4tD;E$Lqa`Dj35R4%j zNi#&RL?x@NEGz_Ic5>VXsJiEA00tkf1)%sRRcE}gUd=UP%uHk6gO>sEFotNP!VuSQ zKC4jG4fj8;>IJDl_r7%yfYQ|}yU6@P>Wc_suHxS)#t@B^)gk)2NW~_#k3%X@sXT{| ztIx}1YeuVR7aL=UM$!z?dlfO`saGBVoL-~n@BsjFi_0v4*-4dUWahb8vBC>uh(^K< zk?fLRQVPKAWi=bs*IuP}=?-NPzc%Yk7RC^bgw-KpMrCsY0HeKquDQm~->X;=qpomW zn=vHCEP4#_GUM6Z?*Q<{HuYLiu|}nwx%yV9*M&gLU41gY$h}$Z>zEo- zD{JX$hF}cQ@Qfi|JBWpxmH8Gxz*44&8G275bw;|IAs9n6qGE{GQwLtpo5=BG%{&v0 zF+?NEkjAQ30PKHfVrCDC5whQNN81(vatewqfI0uPI?+PFbzWmgh7!&);Z^w1Q;hPg znjm}1D?>9-eJ9S`)TCsgjEWgL#t@Bg4Dnip7c*q9mi}JQ*IJDsON4L?sVb-gV0fw@ z@P58k_G}5VLq~SzTsSwBfXhrC#t;qb`Ib)ssL!4SAUC_j250YhWBW^hcSWl2=F8OB zAs9n6eC6580XR9IYXfvPsP0zwjtde~!mIG1Cy "CalamityMod/Projectiles/Boss/BrimstoneBarrage"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimfire"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 18; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.timeLeft = 300; + projectile.penetrate = 1; + projectile.minion = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.alpha = 255; + } + + public override void AI() + { + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; + projectile.Opacity = Utils.InverseLerp(300f, 285f, projectile.timeLeft, true) * Utils.InverseLerp(0f, 15f, projectile.timeLeft, true); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (projectile.velocity.Length() < 35f) + projectile.velocity *= 1.036f; + + Lighting.AddLight(projectile.Center, 0.75f, 0f, 0f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 600); + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Summon/SepulcherArm.png b/Projectiles/Summon/SepulcherArm.png new file mode 100644 index 0000000000000000000000000000000000000000..b45111f2065293ffdd8a1711e4dfab68e0bd55bf GIT binary patch literal 769 zcmV+c1OEJpP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0+vZcK~z{r)t5m} z6G0TmcccsLRw`I1K@+V9kZQc3LzPg>#wAGm<{F2u7_FWesDHOQw+1jKND; z9eFjA%OV@Lcy{ZI!Mm@ngSmPSUDq~vIKlPv*z;UOuXuhHLF=ej7-m#DTJ1vP6wwK~ z68SuR3jdXhSJ=%sCoW!LH}o%PvLxeC^uHK9`bD2Y`ai1% zPX&)oj1D9aow$TW`Cpm~^0yzo0i$$#G6*_9mP_XEWxShvq~-g{6*ha0h=2ICH!o)~ zxj!xZTirN8-rlv5iLJdd@<=+NXZO{naOuHyk%gT zis(pXW%B-;Ixp%Hlq>9eLF%97KAF((;qr~!m=HUqBC_0BQFlt7W`|Omt9&Oda;+}< zW@0d5;+OOGNz3t|H^lLZ?_+)(bWPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0tQJ$K~z{r?U%hy z0znjocM(=Z0TEFV6Qd1@78V){U%y?WAn^y#6?TDj?^&+G z$OaN;sQ8k@-I>JU?423BSJwoVlhe&7&7qH_L<$2Y9t_}binRvDyH{t30enh8k3^!) zM~`I4K#T>0aI`(2!I(KMS%|u0!`b=!JI2x+1=8V&Msgts&Wmk9G|`Ebm;t#?98z;y zZjP|(*6chcn7xNv#Eoe$N73;#;;LRm+_}9+bV07<<)|5d$h{Syg^>s(a^l1x=CfXd z)HxD)EWJU@#_zLnU_t|9JU93zGU-kqy7ygMh) zQOjNH=!i+j5{O56@BEAo4Z%^NEcveeam27QcEa!uK3i2aj(iv5b0Xq5uf!3(Gv2!w zKI?Uek>|)X%NpswsNXda@mD~k|BmQ{i>JJmL5{jJSg1SwTd3RlVFt}D+VglO8s_^+I=d8b~!BNsSH1s5^kZ)Vt0 z*6=!j1M?8k1Px&0ZBwbR9J=8m_2V3F&M{xPMS0?v?!|DQYujxcu^Txn3$Mg;2ZIU_yi1eV(P?# z5S5@q3!+3(C`ps%^^%yud6L*UUm78h`=9Qf^Z9%~KQFcw9zEXJw(j$*1pqp|ww|?b z-ngj%s+SiUV866!y%*_`0ywUp1MvC068pWBZy^6$E4~M{C<36A$!LI1uMNP1JNs6< zuiuX}z>B;0WBWNcJr;s0X&~VfiS!77la3+r^5IkKd9z-&p1b;SQD15x;S*^Mhp~1c zA$qpG3&5w}zbyM< z)d!IVD5ldUZaiedCnD;OMpm@=B)(F1?DF18r=3`H!Y5Kpr-5mP6WFUs1~wfoj5uOHb2-+VLGxiuVwMPx2&goLa!MDnMu-F==_DFx8ilT55( zO2Cbxt!x$unTSa8gX;s&OD38=Hu}K4Pt1@2AeS*` z+$B85%EaLkachg*XH@(F$E1pmcY4*>R#RP{Q$@+7#g&W#XpQ%*qDaRs<|itq7j7C8 z6%-L`@>_#QF0H)ruN4dt?^$2LQ!QtzwR=jSz#kQh6bzB&&(J)i{#L;d`2*$yEw2+b Ri?9Fy002ovPDHLkV1hBPfvW%j literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/SepulcherMinion.cs b/Projectiles/Summon/SepulcherMinion.cs new file mode 100644 index 0000000000..50abfd7e2c --- /dev/null +++ b/Projectiles/Summon/SepulcherMinion.cs @@ -0,0 +1,519 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SepulcherMinion : ModProjectile + { + public struct SepulcherSegment + { + public Vector2 CurrentPosition; + public float Rotation; + public SepulcherSegment(Vector2 position, float rotation) + { + CurrentPosition = position; + Rotation = rotation; + } + } + + public class SepulcherArm + { + public class SepulcherArmLimb + { + public Vector2 Center; + public float Rotation; + + public SepulcherArmLimb(Vector2 center, float rotation) + { + Center = center; + Rotation = rotation; + } + + public void SendData(BinaryWriter writer) + { + writer.WritePackedVector2(Center); + writer.Write(Rotation); + } + + public static SepulcherArmLimb ReceiveData(BinaryReader reader) => new SepulcherArmLimb(reader.ReadPackedVector2(), reader.ReadSingle()); + } + + public SepulcherArmLimb[] Limbs = new SepulcherArmLimb[2]; + public byte SegmentIndexToAttachTo; + public Vector2 Center; + public float Rotation; + public bool ReelingBack = false; + public bool Direction; + public SepulcherArm(Vector2 center, byte segmentIndexToAttachTo, float rotation, bool reelingBack, bool direction) + { + Center = center; + SegmentIndexToAttachTo = segmentIndexToAttachTo; + Rotation = rotation; + ReelingBack = reelingBack; + Direction = direction; + Limbs = new SepulcherArmLimb[2] + { + new SepulcherArmLimb(center, rotation), + new SepulcherArmLimb(center, rotation) + }; + } + } + + public enum AIState + { + HoverNearOwner, + AttackEnemy_Charge, + AttackEnemy_ReleaseDartBurst, + AttackOwner + } + + public int IdleTimer; + public int AttackTimer; + public int PlayerAttackCountdown; + public SepulcherSegment[] Segments = new SepulcherSegment[24]; + public List Arms = new List(); + public Player Owner => Main.player[projectile.owner]; + public AIState CurrentAIState + { + get => (AIState)(int)projectile.ai[0]; + set + { + // Don't do anything unless the caller is the owner of this projectile- changes will be synced to other clients in MP. + if (Main.myPlayer != projectile.owner) + return; + + projectile.ai[0] = (int)value; + projectile.netUpdate = true; + } + } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sepulcher"); + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.netImportant = true; + projectile.penetrate = -1; + projectile.minionSlots = 4f; + projectile.timeLeft = 90000; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.minion = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4; + projectile.scale = 1.35f; + projectile.hide = true; + } + + #region Syncing + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(IdleTimer); + writer.Write(PlayerAttackCountdown); + writer.Write(Arms.Count); + for (int i = 0; i < Arms.Count; i++) + { + writer.WritePackedVector2(Arms[i].Center); + writer.Write(Arms[i].SegmentIndexToAttachTo); + writer.Write(Arms[i].Rotation); + writer.Write(Arms[i].ReelingBack); + writer.Write(Arms[i].Direction); + Arms[0].Limbs[0].SendData(writer); + Arms[0].Limbs[1].SendData(writer); + } + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + IdleTimer = reader.ReadInt32(); + PlayerAttackCountdown = reader.ReadInt32(); + Arms.Clear(); + for (int i = 0; i < reader.ReadInt32(); i++) + { + Arms.Add(new SepulcherArm(reader.ReadPackedVector2(), reader.ReadByte(), reader.ReadSingle(), reader.ReadBoolean(), reader.ReadBoolean())); + Arms.Last().Limbs[0] = SepulcherArm.SepulcherArmLimb.ReceiveData(reader); + Arms.Last().Limbs[1] = SepulcherArm.SepulcherArmLimb.ReceiveData(reader); + } + } + #endregion + + #region AI + public override void AI() + { + Initialize(); + HandleBuffs(); + HandleFlexibleDamage(); + UpdateSegments(); + + // Fade in rapidly. + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.2f, 0f, 1f); + + NPC potentialTarget = AttemptToFindTarget(1450f); + + // Enter the attack state if a valid enemy is found and go back to hovering otherwise. + // This will be overriden if attacking the owner. + if (CurrentAIState != AIState.AttackEnemy_ReleaseDartBurst && CurrentAIState != AIState.AttackEnemy_Charge) + { + if (potentialTarget != null) + CurrentAIState = AIState.AttackEnemy_ReleaseDartBurst; + } + else if (potentialTarget is null) + { + CurrentAIState = AIState.HoverNearOwner; + AttackTimer = 0; + } + + // Reset the AI to player attack mode if the countdown is going on. + if (PlayerAttackCountdown > 0) + { + if (CurrentAIState != AIState.AttackOwner) + CurrentAIState = AIState.AttackOwner; + + PlayerAttackCountdown--; + + // If it's finished, go back to idle owner hover movement. + if (PlayerAttackCountdown <= 0) + CurrentAIState = AIState.HoverNearOwner; + } + + switch (CurrentAIState) + { + case AIState.HoverNearOwner: + HoverNearOwner(); + break; + case AIState.AttackEnemy_ReleaseDartBurst: + AttackEnemyWithDarts(potentialTarget); + AttackTimer++; + break; + case AIState.AttackEnemy_Charge: + AttackEnemyByCharging(potentialTarget); + AttackTimer++; + break; + } + + // Check if ready to enrage every so often. + IdleTimer++; + if (IdleTimer % 600 == 599) + { + float chanceToBecomeAngry = 0f; + if (Main.rand.NextFloat() < chanceToBecomeAngry) + { + PlayerAttackCountdown = 300; + projectile.netUpdate = true; + } + } + } + + public void Initialize() + { + if (projectile.localAI[0] != 0f) + return; + + for (int i = 0; i < Segments.Length; i++) + Segments[i].CurrentPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.UnitY) * i * 0.2f; + + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.localAI[0] = 1f; + if (Main.myPlayer == projectile.owner) + { + float rotationalOffset = 0f; + for (byte i = 3; i < Segments.Length - 2; i += 2) + { + Arms.Add(new SepulcherArm(Segments[i].CurrentPosition, i, rotationalOffset, false, false)); + rotationalOffset = MathHelper.WrapAngle(rotationalOffset + MathHelper.Pi / 6f); + + Arms.Add(new SepulcherArm(Segments[i].CurrentPosition, i, rotationalOffset + MathHelper.Pi, false, true)); + rotationalOffset = MathHelper.WrapAngle(rotationalOffset + MathHelper.Pi / 6f); + } + projectile.netUpdate = true; + } + } + + public void HandleBuffs() + { + // Maintain or remove the Mechworm buff from the owner. + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Owner.dead) + Owner.Calamity().sepulcher = false; + if (Owner.Calamity().sepulcher) + projectile.timeLeft = 2; + } + + public void HandleFlexibleDamage() + { + // Adjust the damage of this projectile if the owner's current minion damage factor has changed for any reason. + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); + projectile.damage = trueDamage; + } + } + + public void UpdateSegments() + { + float aheadRotation = projectile.rotation; + Vector2 aheadPosition = projectile.Center; + + // Connect all segments to each-other and calculate their rotations. + for (int i = 0; i < Segments.Length; i++) + { + Vector2 offsetToDestination = aheadPosition - Segments[i].CurrentPosition; + // This variant of segment attachment incorporates rotation. + // Given the fact that all segments will execute this code is succession, the + // result across the entire worm will exponentially decay over each segment, + // allowing for smooth rotations. This code is what the stardust dragon uses for its segmenting. + if (aheadRotation != Segments[i].Rotation) + { + float angleOffset = MathHelper.WrapAngle(aheadRotation - Segments[i].Rotation.AngleLerp(aheadRotation, 0.08f)); + offsetToDestination = offsetToDestination.RotatedBy(angleOffset * 0.08f); + } + + Segments[i].Rotation = (aheadPosition - Segments[i].CurrentPosition).ToRotation() + MathHelper.PiOver2; + Segments[i].CurrentPosition = aheadPosition - offsetToDestination.SafeNormalize(Vector2.Zero) * 60f; + + // Adjust the ahead positions before interating further. + aheadPosition = Segments[i].CurrentPosition; + aheadRotation = Segments[i].Rotation; + } + + // Adjust the arms. + for (int i = 0; i < Arms.Count; i++) + { + SepulcherSegment segmentToAttachTo = Segments[Arms[i].SegmentIndexToAttachTo]; + Vector2 idealMovePosition = segmentToAttachTo.CurrentPosition; + float sideFactor = MathHelper.Lerp(200f, 18f, Utils.InverseLerp(-0.51f, -0.06f, Arms[i].Rotation, true)); + float aheadFactor = MathHelper.Lerp(284f, 680f, Utils.InverseLerp(-0.51f, -0.06f, Arms[i].Rotation, true)); + int direction = Arms[i].Direction.ToDirectionInt(); + idealMovePosition += (segmentToAttachTo.Rotation + Arms[i].Rotation * direction - MathHelper.PiOver2).ToRotationVector2() * projectile.scale * aheadFactor; + idealMovePosition += (segmentToAttachTo.Rotation + Arms[i].Rotation * direction - MathHelper.PiOver2 + MathHelper.PiOver2 * direction).ToRotationVector2() * projectile.scale * sideFactor; + Arms[i].Center = idealMovePosition; + + Vector2 offsetFromSegment = Vector2.Zero; + + offsetFromSegment += new Vector2(direction * 60f, 55f).RotatedBy(segmentToAttachTo.Rotation - (MathHelper.PiOver2 - Arms[i].Rotation * 1.7f - 0.77f) * direction).SafeNormalize(Vector2.UnitY) * 82f; + Arms[i].Limbs[0].Center = segmentToAttachTo.CurrentPosition + offsetFromSegment; + Arms[i].Limbs[0].Rotation = offsetFromSegment.ToRotation(); + + Arms[i].Limbs[1].Rotation = (Arms[i].Center - Arms[i].Limbs[0].Center).ToRotation(); + Arms[i].Limbs[1].Center = Arms[i].Limbs[0].Center + offsetFromSegment * 0.5f + (Arms[i].Center - Arms[i].Limbs[0].Center).SafeNormalize(Vector2.UnitY) * 84f; + + float rotationalVelocityFactor = Utils.InverseLerp(0f, 6f, projectile.velocity.Length(), true); + if (CurrentAIState == AIState.AttackEnemy_Charge) + rotationalVelocityFactor *= 0.85f; + + if (Arms[i].ReelingBack) + { + Arms[i].Rotation -= rotationalVelocityFactor * 0.066f; + if (Arms[i].Rotation < -0.55f) + Arms[i].ReelingBack = false; + } + else + { + Arms[i].Rotation += rotationalVelocityFactor * 0.029f; + if (Arms[i].Rotation > 0.77f) + Arms[i].ReelingBack = true; + } + } + } + + public void HoverNearOwner() + { + // Teleport to the owner if it's very far away. + if (!projectile.WithinRange(Owner.Center, 3200f)) + { + projectile.Center = Owner.Center; + projectile.velocity = Main.rand.NextVector2CircularEdge(4f, 4f); + projectile.netUpdate = true; + } + + // Attempt to move towards the owner. + if (!projectile.WithinRange(Owner.Center, 540f)) + { + Vector2 destination = Owner.Center + (IdleTimer / 31f).ToRotationVector2() * 240f; + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 18f, 0.03f); + + float updatedDirectionRotation = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(destination), 0.04f); + projectile.velocity = updatedDirectionRotation.ToRotationVector2() * projectile.velocity.Length(); + } + else if (projectile.velocity.Length() < 16f) + projectile.velocity *= 1.03f; + + // Determine the head rotation. + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + public void AttackEnemyWithDarts(NPC target) + { + Vector2 destination = target.Center + ((AttackTimer / 20f).ToRotationVector2() * 320f); + + // Step towards the ideal velocity with an acceleration of 1 pixel/second^2. + projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(destination) * 24f, 1f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // Release a burst of darts from all segments at the target. + if (Main.myPlayer == projectile.owner && AttackTimer % 60 > 60 - Segments.Length) + { + int segmentToFireFrom = 60 - AttackTimer % 60; + Vector2 spawnPosition = Segments[segmentToFireFrom].CurrentPosition; + Vector2 shootVelocity = (target.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * 8f; + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack, projectile.owner); + } + + if (Main.myPlayer == projectile.owner && AttackTimer > 430) + { + CurrentAIState = AIState.AttackEnemy_Charge; + AttackTimer = 0; + } + } + + public void AttackEnemyByCharging(NPC target) + { + if (!projectile.WithinRange(target.Center, 350f)) + { + Vector2 destination = target.Center + (AttackTimer / 25f).ToRotationVector2() * MathHelper.Min(target.width * 0.35f, 150f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 34f, 0.05f); + + float updatedDirectionRotation = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(destination), 0.07f); + projectile.velocity = updatedDirectionRotation.ToRotationVector2() * projectile.velocity.Length(); + } + else if (projectile.velocity.Length() < 21f) + projectile.velocity *= 1.035f; + + // Determine the head rotation. + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Main.myPlayer == projectile.owner && AttackTimer > 280) + { + CurrentAIState = AIState.AttackEnemy_ReleaseDartBurst; + AttackTimer = 0; + } + } + + public NPC AttemptToFindTarget(float searchDistance) + { + NPC closestTarget = null; + + if (Owner.HasMinionAttackTargetNPC) + { + NPC targetedNPC = Main.npc[Owner.MinionAttackTargetNPC]; + if (targetedNPC.WithinRange(projectile.Center, searchDistance) && targetedNPC.CanBeChasedBy()) + return targetedNPC; + } + + float distance = searchDistance * searchDistance; + for (int index = 0; index < Main.maxNPCs; index++) + { + if (Main.npc[index].CanBeChasedBy()) + { + float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); + + if (Main.npc[index].WithinRange(projectile.Center, distance + extraDistance)) + { + distance = Main.npc[index].DistanceSQ(projectile.Center); + closestTarget = Main.npc[index]; + } + } + } + + return closestTarget; + } + + #endregion + + #region Drawing + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D headTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionHead"); + Texture2D bodyTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionBody"); + Texture2D bodyTexture2 = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionBodyAlt"); + Texture2D tailTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionTail"); + Texture2D armTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherArm"); + Texture2D foreArmTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherForeArm"); + Texture2D handTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherHand"); + + Vector2 drawPosition; + + // Draw arms. + for (int i = 0; i < Arms.Count; i++) + { + Vector2 forearmDrawPosition = Arms[i].Limbs[0].Center - Main.screenPosition; + Color drawColor = Lighting.GetColor((int)(Arms[i].Limbs[0].Center.X / 16), (int)(Arms[i].Limbs[0].Center.Y / 16)); + spriteBatch.Draw(foreArmTexture, forearmDrawPosition, null, drawColor, Arms[i].Limbs[0].Rotation + MathHelper.PiOver2, foreArmTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + + Vector2 armDrawPosition = Arms[i].Limbs[1].Center - Main.screenPosition; + drawColor = Lighting.GetColor((int)(Arms[i].Limbs[1].Center.X / 16), (int)(Arms[i].Limbs[1].Center.Y / 16)); + spriteBatch.Draw(armTexture, armDrawPosition, null, drawColor, Arms[i].Limbs[1].Rotation + MathHelper.PiOver2, armTexture.Size() * new Vector2(0.5f, 0f), projectile.scale, SpriteEffects.FlipVertically, 0f); + + Vector2 handDrawPosition = armDrawPosition; + SpriteEffects handDirection = Arms[i].Direction ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(handTexture, handDrawPosition, null, drawColor, Arms[i].Limbs[1].Rotation - MathHelper.PiOver2, handTexture.Size() * new Vector2(0.5f, 0f), projectile.scale, handDirection, 0f); + } + + for (int i = 0; i < Segments.Length; i++) + { + Texture2D textureToUse = i % 2 == 1 ? bodyTexture2 : bodyTexture; + + // Use the tail texture for the last segment. + if (i == Segments.Length - 1) + textureToUse = tailTexture; + + drawPosition = Segments[i].CurrentPosition - Main.screenPosition; + lightColor = Lighting.GetColor((int)(drawPosition.X + Main.screenPosition.X) / 16, (int)(drawPosition.Y + Main.screenPosition.Y) / 16); + spriteBatch.Draw(textureToUse, drawPosition, null, projectile.GetAlpha(lightColor), Segments[i].Rotation, textureToUse.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + + drawPosition = projectile.Center - Main.screenPosition; + lightColor = Lighting.GetColor((int)(drawPosition.X + Main.screenPosition.X) / 16, (int)(drawPosition.Y + Main.screenPosition.Y) / 16); + spriteBatch.Draw(headTexture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, headTexture.Size() * 0.5f, projectile.scale * 1.25f, SpriteEffects.None, 0f); + return false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // If default collision is possible return true immediately. + if (projHitbox.Intersects(targetHitbox)) + return true; + + // Check based on segments. + for (int i = 0; i < Segments.Length; i++) + { + if (Utils.CenteredRectangle(Segments[i].CurrentPosition, Vector2.One * 52f).Intersects(targetHitbox)) + return true; + } + + // And finally arm hands. + for (int i = 0; i < Arms.Count; i++) + { + if (Utils.CenteredRectangle(Arms[i].Center, Vector2.One * 32f).Intersects(targetHitbox)) + return true; + } + + return false; + } + + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsBehindProjectiles.Add(index); + } + + #endregion + } +} diff --git a/Projectiles/Summon/SepulcherMinionBody.png b/Projectiles/Summon/SepulcherMinionBody.png new file mode 100644 index 0000000000000000000000000000000000000000..5e8b75333ef4e7beb6b6b9b19646e550aa3167ea GIT binary patch literal 1924 zcmeAS@N?(olHy`uVBq!ia0vp^And`x3}WpM3IS4##X;^)4C~IxyaaMs(j9#r85lP9 zbN@+XWnf@t2=EDU1&VWV@yhe*YYU6pXiIA=D0s6AyC`aes_10!@)jD~xQTcK8ak#2 zXtXFxwip?$F>&oH*8kz@xo@KR|L*MfhwA_T`wcW?6pV(zPz(VvHU=?ZK4B;c@(cby zvH?TzcXm}^9C8+TL>4nJa0`PlBg3pY62QWO(bL5-B*OjZjJMlnD+su9OKhz>GV9Xs zfB99fzZtkDUy2uh7pcv4=8PYk+tEKiYE~CcE?!wYp*SMwdFv|$&W94_l9%3Y+7=mC zpQ@|E_*yFYvH+7#%Q|kyi08A^j+IW0=dxPCc4=qjvA^Hd1T=CsEmnEG>)dD2C~nU~ zXVsdF-Gbt;E&FNrWEYp(mrXYgHN4)HYABMvOoR1bu&2soe~o}9>w~jn&F?h2m zb+OPr%b+!rPSlBWK3vABE~C=jWN~|js&7kDwnC(WqTwu#6dm!2$9%*NKAPgLReEN@ zQ=h~ON|B<1obz)Ru$U(3F1g*^aY%yAJJ{8w`=3EVs9-I-knqye?gC8Txo)ZQi2d9U zBR1W^b)r|p7K?J()`i@CkDjR=Jnoiq^m0&r<^CxTyC*JjJMngzLe(#UCHhy~Pu%9s zU-U}B^yH4qVm2&t|D%NZt|cWaSZ6-=*VYg4RB8V8v1-M?nrW)VN}X_L(>>)-zl7(JOFzqT zt`wQnefsz3ZUc|sleX=>pZw=X$H%(-=txfc-~EffPw-M~{B+%^PT}FD@0D7&zCG7t zY_-W_+hN(ou$E;KBg3~D6I#w3?ay{gsC09>;GwDF?4ICu%Jb{lthZ zl|IetSDpKmJ3l6U|MUF0#ivc}=geoViSlsKSnn0CvOeJY`ctbqRc3q%daj^4*Gm7( d(-Y^sfUdH*Z)fe*L!Zjms-vPvgtKn^&p#JMjF$XFp9it|wx za3l$5#zshICjMeIy|gc4Z`_L-oQV;yj)8ZozW8Q75%+oF!miWIp%B?Y*)v0+)>Y-i4{ef;~YM0#Q*+N2^ZacoZYm{aLu#}&&S(tPGiV!T=*mW$fA%N5j)PwYDDx&2Iz4Axf!7% zaCo!M5=o}M&n=w^Eldv?I_y6OC$T=2+hFxVwQ=>UqCkNepKWpq{M?lS5_287nYNjA zU(aD!et6dFwbOT=bJS1gl_}Z3e~(R@qUbdzgFcJ8y>WUzrfYts7N;&;$dd@Q;jKW8xlXWOtaM7=*xU)nZe1Om3^lj+xKixT6W>E2(l^stwe$m1`X-p_xqJn@q_z_@ja*6DT38cUBboi*}Sp1fhx z4K3@OY3JCN9&1}-zEUHFQ-(crbxFjs4~p)W*86rdi8aQZ&7Z=h{oO+$?q1|Jvuexh zrTd+adbP72PrneZ)4JR4kK@V>QyA;lJUX1)J@@(g{|!H<1|>44-~7q*ttM{vzsQ#x jgrv94`oA!C!}s6*CRcXX1@2ds0u`;Eu6{1-oD!M<7#!iq literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/SepulcherMinionHead.png b/Projectiles/Summon/SepulcherMinionHead.png new file mode 100644 index 0000000000000000000000000000000000000000..ce918150f1e3334acb2269f120379bbaccd2d7c1 GIT binary patch literal 1768 zcmVP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ9427O6HK~#8N?VMX| z6jdC?*&?@Uf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