From 287f14adb092c8ca5e4fe0994a2354191ffef72d Mon Sep 17 00:00:00 2001 From: Amber Sienna Date: Sat, 14 Mar 2020 17:57:22 +0000 Subject: [PATCH 1/2] Armoured Digger drop tweaks --- NPCs/NormalNPCs/ArmoredDiggerHead.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index bf3bb9f585..675d768def 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -411,17 +411,21 @@ namespace CalamityMod.NPCs.NormalNPCs } } + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } + public override void NPCLoot() { - if (Main.rand.NextBool(40)) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType()); - } - if (Main.rand.NextBool(3)) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType()); - } - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType(), Main.rand.Next(2, 5)); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 40); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); + DropHelper.DropItem(npc, ModContent.ItemType(), Main.rand.Next(2, 5)); } } } From d9a46614bc52bd4128b10b9bb3476495e1858dfc Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 14 Mar 2020 17:33:43 -0400 Subject: [PATCH 2/2] added vile feeder summon --- Buffs/Summon/VileFeederBuff.cs | 36 ++ Buffs/Summon/VileFeederBuff.png | Bin 0 -> 708 bytes CalPlayer/CalamityPlayer.cs | 12 +- Items/Weapons/Summon/VileFeeder.cs | 89 ++++ Items/Weapons/Summon/VileFeeder.png | Bin 0 -> 733 bytes ModSupport/WeakReferenceSupport.cs | 8 +- Projectiles/Summon/FrostBlossom.cs | 6 +- Projectiles/Summon/PlantSummon.cs | 2 +- Projectiles/Summon/Shellfish.cs | 8 +- Projectiles/Summon/VileFeederProjectile.cs | 189 +++++++++ Projectiles/Summon/VileFeederProjectile.png | Bin 0 -> 866 bytes Projectiles/Summon/VileFeederSummon.cs | 444 ++++++++++++++++++++ Projectiles/Summon/VileFeederSummon.png | Bin 0 -> 1331 bytes Utilities/CalamityUtils.cs | 4 +- 14 files changed, 782 insertions(+), 16 deletions(-) create mode 100644 Buffs/Summon/VileFeederBuff.cs create mode 100644 Buffs/Summon/VileFeederBuff.png create mode 100644 Items/Weapons/Summon/VileFeeder.cs create mode 100644 Items/Weapons/Summon/VileFeeder.png create mode 100644 Projectiles/Summon/VileFeederProjectile.cs create mode 100644 Projectiles/Summon/VileFeederProjectile.png create mode 100644 Projectiles/Summon/VileFeederSummon.cs create mode 100644 Projectiles/Summon/VileFeederSummon.png diff --git a/Buffs/Summon/VileFeederBuff.cs b/Buffs/Summon/VileFeederBuff.cs new file mode 100644 index 0000000000..0d85710b64 --- /dev/null +++ b/Buffs/Summon/VileFeederBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class VileFeederBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Vile Feeder"); + Description.SetDefault("The baby eater of souls will protect you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.vileFeeder = true; + } + if (!modPlayer.vileFeeder) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/VileFeederBuff.png b/Buffs/Summon/VileFeederBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9fe1374b9181be9d634b0b32326e57f40fd050 GIT binary patch literal 708 zcmV;#0z3VQP)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;(K){{a7>y{D4^00I(8L_t(o!_}9+OIuMC$3GFFU?dic zC?=p%rBn$LhYJ3hJGm%!Q3+_576-u&(m$YsLWiP@6+|=Y;^g3@jVPj0LMe@i7E~;y zg_g!iu)}*tIfp#V6t3Up<-T+8dG~zIy(jmEqIDGjoPGauO%WBXs|W#<6!W9`6auaR z`i5HpXo{Dq4u_db0FKk%GZwDR>*zFh4nRX^SzbTZ-^$`=oFGstKkSTCQ-`YER?`AN z_)%$IM=?AyJ8NJ3r}uvFO_S$nFG&0 zoASoDKabus0#-Mx+%JI1(Jp0Az8e5w>%)fb?<=Sxx=TQ6wP^pst8B9GJ7@%8r1vdw zyWeGPNdH3R9)X>;GZmR=Z*LcXg^!Y4u+A z_ohj;MBd!?0)VBtiGn8J4grzmDz%*TBlaqut?^RfWX%XM$$6yVq4H-5yGP*bH}Bt0 zDpzlRm2at1L`2e0PClu0R*|t4Q2alA5_Xh;mEP7uf5^MR-IAbt(f|Me q5_CmabVXQ6MmkS&X=QG7VRUJ4ZU8ZaSnTfr0000(); + item.shootSpeed = 10f; + item.summon = 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) + { + if (player.altFunctionUse != 2) + { + int i = Main.myPlayer; + float num72 = item.shootSpeed; + float knockback = knockBack; + knockback = player.GetWeaponKnockback(item, knockback); + player.itemTime = item.useTime; + Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; + float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + if (player.gravDir == -1f) + { + num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + } + float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + { + num78 = (float)player.direction; + num79 = 0f; + num80 = num72; + } + else + { + num80 = num72 / num80; + } + num78 *= num80; + num79 *= num80; + vector2.X = (float)Main.mouseX + Main.screenPosition.X; + vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(num78, num79); + spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); + Projectile.NewProjectile(vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); + } + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.DemoniteBar, 5); + recipe.AddIngredient(ItemID.ShadowScale, 9); + recipe.AddIngredient(ItemID.Ebonwood, 20); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/VileFeeder.png b/Items/Weapons/Summon/VileFeeder.png new file mode 100644 index 0000000000000000000000000000000000000000..b4a7f8446bdf87408ddbbb7d5cc488c73c4b93b8 GIT binary patch literal 733 zcmV<30wVp1P)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;(K){{a7>y{D4^00JvXL_t(o!{ygaNK{c62H@w0gjj0E z;D|*g27wBJL6jum1`*fMC^HJt)ZSKhz1HJsK(4Q?=VSM^L@E_2)11_*HIiTXV$!AXrRp z==LRWb#O3N|M=d=9L!k&XHFad?OnZ#6?wteZzoX6g2`!3%C*;bFN&Q9Ljz~Qr&o8u zh5lpU#_%2R>cw!ueJWRQNn+D_{oE~Z>U6$`g51S{!g9-{>;?b$O|qm1bI^DANNoMh zL+V2mVf8AH1CMu-G}!%7#YhS zlR+>k)|{@5U}AEv;J#%qxa>Lj^X^br52j{ka?ste4?G-w30l+XyxinuzP`v^qnKEj z+R71Jsa&eAK3ZIlNi26aDJGW8#uE&`d|P!LnEpPyD!H}J#t|&mb6rgx;6-LMtd~SC zr2GX}I;~qb*F^AjA%Bnk*K#3cFIW|(H7S=&spUe-Uof0=VOm4ag(Ro8)G2$xXlG+8 z_HQFOts$lEy^yjO`~lEF=Ss0&6Wss+01|XXSad~LNk%$Pa%p95bYXO9Z*BlFgjnqF P00000NkvXXu0mjfsx3$U literal 0 HcmV?d00001 diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 4cd4712d76..aeedb9d39e 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -721,16 +721,22 @@ namespace CalamityMod sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); - sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), ProjectileType()); diff --git a/Projectiles/Summon/FrostBlossom.cs b/Projectiles/Summon/FrostBlossom.cs index 31f008ba48..8d815e3b4d 100644 --- a/Projectiles/Summon/FrostBlossom.cs +++ b/Projectiles/Summon/FrostBlossom.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon projectile.Opacity = 1f - (float)Math.Sin(projectile.ai[1] / 45f) * 0.075f - 0.075f; // Range of 1f to 0.85f if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = (player.allDamage + player.minionDamage - 1f); + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; for (int i = 0; i < 36; i++) { @@ -74,11 +74,11 @@ namespace CalamityMod.Projectiles.Summon } projectile.localAI[0] += 1f; } - if ((player.allDamage + player.minionDamage - 1f) != projectile.Calamity().spawnedPlayerMinionDamageValue) + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * - (player.allDamage + player.minionDamage - 1f)); + player.MinionDamage()); projectile.damage = trueDamage; } if (projectile.owner == Main.myPlayer) diff --git a/Projectiles/Summon/PlantSummon.cs b/Projectiles/Summon/PlantSummon.cs index eb17437f33..a71ad05891 100644 --- a/Projectiles/Summon/PlantSummon.cs +++ b/Projectiles/Summon/PlantSummon.cs @@ -342,7 +342,7 @@ namespace CalamityMod.Projectiles.Summon } else { - for (int num645 = 0; num645 < 200; num645++) + for (int num645 = 0; num645 < Main.maxNPCs; num645++) { NPC nPC2 = Main.npc[num645]; if (nPC2.CanBeChasedBy(projectile, false)) diff --git a/Projectiles/Summon/Shellfish.cs b/Projectiles/Summon/Shellfish.cs index 1f086bf8ff..ddf263d607 100644 --- a/Projectiles/Summon/Shellfish.cs +++ b/Projectiles/Summon/Shellfish.cs @@ -87,12 +87,12 @@ namespace CalamityMod.Projectiles.Summon if (projectile.ai[0] == 0f) { //lineColor == 1 means it is spawned from Mollusk Armor rather than the weapon - projectile.damage = (int)((modProj.lineColor == 1 ? 1500f : 70f) * (player.allDamage + player.minionDamage - 1f)); - if ((player.allDamage + player.minionDamage - 1f) != projectile.Calamity().spawnedPlayerMinionDamageValue) + projectile.damage = (int)((modProj.lineColor == 1 ? 1500f : 70f) * player.MinionDamage()); + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / modProj.spawnedPlayerMinionDamageValue * - (player.allDamage + player.minionDamage - 1f)); + player.MinionDamage()); projectile.damage = damage2; } projectile.ai[1] += 1f; @@ -394,7 +394,7 @@ namespace CalamityMod.Projectiles.Summon Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); if (projectile.owner == Main.myPlayer) { - for (int i = 0; i < 200; i++) + for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && Main.npc[i].defense < 9999 && ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || diff --git a/Projectiles/Summon/VileFeederProjectile.cs b/Projectiles/Summon/VileFeederProjectile.cs new file mode 100644 index 0000000000..7ddcdf7d14 --- /dev/null +++ b/Projectiles/Summon/VileFeederProjectile.cs @@ -0,0 +1,189 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class VileFeederProjectile : ModProjectile + { + private int bounce = 3; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eater of Souls Mini"); + Main.projFrames[projectile.type] = 4; + } + + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.minion = true; + projectile.extraUpdates = 3; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (projectile.alpha > 0) + { + projectile.alpha -= 50; + } + else + { + projectile.extraUpdates = 0; + } + if (projectile.alpha < 0) + { + projectile.alpha = 0; + } + projectile.frameCounter++; + if (projectile.frameCounter >= 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + int num3; + for (int num369 = 0; num369 < 1; num369 = num3 + 1) + { + int dustType = 7; + float num370 = projectile.velocity.X / 3f * (float)num369; + float num371 = projectile.velocity.Y / 3f * (float)num369; + int num372 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); + Main.dust[num372].position.X = projectile.Center.X - num370; + Main.dust[num372].position.Y = projectile.Center.Y - num371; + Dust dust = Main.dust[num372]; + dust.velocity *= 0f; + Main.dust[num372].scale = 0.5f; + num3 = num369; + } + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - MathHelper.PiOver2; + float num373 = projectile.position.X; + float num374 = projectile.position.Y; + float num375 = 100000f; + bool flag10 = false; + projectile.ai[0] += 1f; + if (projectile.ai[0] > 30f) + { + projectile.ai[0] = 30f; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num377 = npc.position.X + (float)(npc.width / 2); + float num378 = npc.position.Y + (float)(npc.height / 2); + float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); + if (num379 < 800f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + num375 = num379; + num373 = num377; + num374 = num378; + flag10 = true; + } + } + } + else + { + for (int num376 = 0; num376 < Main.maxNPCs; num376++) + { + if (Main.npc[num376].CanBeChasedBy(projectile, false)) + { + float num377 = Main.npc[num376].position.X + (float)(Main.npc[num376].width / 2); + float num378 = Main.npc[num376].position.Y + (float)(Main.npc[num376].height / 2); + float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); + if (num379 < 800f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num376].position, Main.npc[num376].width, Main.npc[num376].height)) + { + num375 = num379; + num373 = num377; + num374 = num378; + flag10 = true; + } + } + } + } + } + if (!flag10) + { + num373 = projectile.position.X + (float)(projectile.width / 2) + projectile.velocity.X * 100f; + num374 = projectile.position.Y + (float)(projectile.height / 2) + projectile.velocity.Y * 100f; + } + float num380 = 10f; + float num381 = 0.16f; + Vector2 vector30 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float num382 = num373 - vector30.X; + float num383 = num374 - vector30.Y; + float num384 = (float)Math.Sqrt((double)(num382 * num382 + num383 * num383)); + num384 = num380 / num384; + num382 *= num384; + num383 *= num384; + if (projectile.velocity.X < num382) + { + projectile.velocity.X = projectile.velocity.X + num381; + if (projectile.velocity.X < 0f && num382 > 0f) + { + projectile.velocity.X = projectile.velocity.X + num381 * 2f; + } + } + else if (projectile.velocity.X > num382) + { + projectile.velocity.X = projectile.velocity.X - num381; + if (projectile.velocity.X > 0f && num382 < 0f) + { + projectile.velocity.X = projectile.velocity.X - num381 * 2f; + } + } + if (projectile.velocity.Y < num383) + { + projectile.velocity.Y = projectile.velocity.Y + num381; + if (projectile.velocity.Y < 0f && num383 > 0f) + { + projectile.velocity.Y = projectile.velocity.Y + num381 * 2f; + } + } + else if (projectile.velocity.Y > num383) + { + projectile.velocity.Y = projectile.velocity.Y - num381; + if (projectile.velocity.Y > 0f && num383 < 0f) + { + projectile.velocity.Y = projectile.velocity.Y - num381 * 2f; + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + bounce--; + if (bounce <= 0) + { + projectile.Kill(); + } + else + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + } + return false; + } + + public override bool CanDamage() + { + return projectile.ai[0] >= 30f; + } + } +} diff --git a/Projectiles/Summon/VileFeederProjectile.png b/Projectiles/Summon/VileFeederProjectile.png new file mode 100644 index 0000000000000000000000000000000000000000..dd1074190cebb41bf5dd814c6eb1c9c503bed9e0 GIT binary patch literal 866 zcmV-o1D*VdP)Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;(K){{a7>y{D4^00OW{L_t(o!{wMyPZL2H#($%wR4Qnx zRMMCdvzR6rLj=@|pMcNc!30lw>gVv_2~L`L@H6-Y@ZujxIMl>QLo`iO3%XipQwnxG z%ud_g?otwVnns?>?mP3&JI~IaXJ%hP0OlUd>R0JJ1;FR`+rIu62noX%NO%httXlxo zqerTziHHPfRgVS0SaSq`&B9kRj3WBwM(Uc1EH9#ZRnYpC!|v^y8VllJwuE% z$_INAU}5^UVj54o>Nm@I*SZRSjP$o=E!FdvLJ5F)GUDH&jLScCMnW^f*;B7xJOkkM z%Xa|GEY|_}_I3<_$4?#tu##JC#|U?ff-3IZ9R*CpDB z42ofl(V1XQkJ@9?(QFrnLbD|SGiroU;L1L#H31ljM_smYM(tVC>nR?M0T7L;y=GVc zNPxt|6#>v}90E{lHh@8BcCFcv0P)dFKu5cawUPv|9VQH1v$L6u%Q2f&b|r7S{KIFo zG;aa$X{&H5&DQlRxm5|UG;f8kM=mBC8y^8!d-K7!f!6ND#e14rxMS32|FLHK-9{upYCNHs zI``~iO(|z(-|qREP#Hz6%p?GX@4sBTx}Roi=2m9XkV1Nuuirh}tEAztY_A4utmoYg z)^qCKtu>yo8TDv()=CTLoVZ?eoye|s=I_}PH?R7ZS9gBC5Wb5`QK1Dx}Vhln>PG4L�X6!IC zpBo9P=$9MuVsL+uGt2e1Zl5X8X%RR^-mHw)Xsy|UXQa=qAln$D;ln>V{0+Sx`B^*w s000tnMObu2SV=}YPjYExZggREX>V=-F@#v`?*IS*07*qoM6N<$f;2#g$^ZZW literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs new file mode 100644 index 0000000000..21bd2c84e9 --- /dev/null +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -0,0 +1,444 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class VileFeederSummon : ModProjectile + { + private bool spawnDust = true; + private float attackCooldown = 0f; + private int eaterCooldown = 0; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eater of Souls"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + if (spawnDust) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + int num226 = 36; + for (int num227 = 0; num227 < num226; num227++) + { + Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; + Vector2 vector7 = vector6 - projectile.Center; + int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 7, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); + Main.dust[num228].noGravity = true; + Main.dust[num228].velocity = vector7; + } + spawnDust = false; + } + + bool correctMinion = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (correctMinion) + { + if (player.dead) + { + modPlayer.vileFeeder = false; + } + if (modPlayer.vileFeeder) + { + projectile.timeLeft = 2; + } + } + + if (eaterCooldown < 0) + eaterCooldown = 0; + + if (projectile.ai[0] != 3f) + { + if (eaterCooldown > 0) + eaterCooldown--; + projectile.damage = (int)(VileFeeder.BaseDamage * player.MinionDamage()); + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = damage2; + } + float antiStickyFloat = 0.05f; + for (int index = 0; index < Main.maxProjectiles; index++) + { + Projectile proj = Main.projectile[index]; + bool flag23 = proj.type == ModContent.ProjectileType(); + if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) + { + if (projectile.position.X < proj.position.X) + { + projectile.velocity.X = projectile.velocity.X - antiStickyFloat; + } + else + { + projectile.velocity.X = projectile.velocity.X + antiStickyFloat; + } + if (projectile.position.Y < proj.position.Y) + { + projectile.velocity.Y = projectile.velocity.Y - antiStickyFloat; + } + else + { + projectile.velocity.Y = projectile.velocity.Y + antiStickyFloat; + } + } + } + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(270); + + bool flag24 = false; + if (projectile.ai[0] == 2f) + { + attackCooldown += 1f; + projectile.extraUpdates = 1; + if (attackCooldown > 40f) + { + attackCooldown = 1f; + projectile.ai[0] = 0f; + projectile.extraUpdates = 0; + projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + flag24 = true; + } + } + if (flag24) + { + return; + } + + Vector2 vector46 = projectile.position; + float num633 = 800f; //50 block detection range + bool targetFound = false; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (npcDist < num633 && !targetFound && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + num633 = npcDist; + vector46 = npc.Center; + targetFound = true; + } + } + } + else + { + for (int num645 = 0; num645 < Main.maxNPCs; num645++) + { + NPC nPC2 = Main.npc[num645]; + if (nPC2.CanBeChasedBy(projectile, false)) + { + float npcDist = Vector2.Distance(nPC2.Center, projectile.Center); + if (npcDist < num633 && !targetFound && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, nPC2.position, nPC2.width, nPC2.height)) + { + num633 = npcDist; + vector46 = nPC2.Center; + targetFound = true; + } + } + } + } + float maxPlayerRange = 1100f; + if (targetFound) + { + maxPlayerRange = 2400f; + } + if (Vector2.Distance(player.Center, projectile.Center) > maxPlayerRange) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + if (targetFound && projectile.ai[0] == 0f) + { + Vector2 vector47 = vector46 - projectile.Center; + float num648 = vector47.Length(); + vector47.Normalize(); + if (num648 > 200f) + { + float scaleFactor2 = 8f; + vector47 *= scaleFactor2; + projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + } + else + { + float num649 = 4f; + vector47 *= -num649; + projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + } + } + else + { + bool flag26 = false; + if (!flag26) + { + flag26 = projectile.ai[0] == 1f; + } + float num650 = 6f; + if (flag26) + { + num650 = 15f; + } + Vector2 center2 = projectile.Center; + Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f); + float playerDist = vector48.Length(); + if (playerDist > 200f && num650 < 8f) + { + num650 = 8f; + } + if (playerDist < 150f && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + if (playerDist > 2000f) + { + projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); + projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (playerDist > 70f) + { + vector48.Normalize(); + vector48 *= num650; + projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; + } + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } + if (attackCooldown > 0f) + { + attackCooldown += (float)Main.rand.Next(1, 4); + } + if (attackCooldown > 40f) + { + attackCooldown = 0f; + projectile.netUpdate = true; + } + if (projectile.ai[0] == 0f) + { + if (attackCooldown == 0f && targetFound && num633 < 500f) + { + attackCooldown += 1f; + if (Main.myPlayer == projectile.owner) + { + projectile.ai[0] = 2f; + Vector2 value20 = vector46 - projectile.Center; + value20.Normalize(); + projectile.velocity = value20 * 8f; + projectile.netUpdate = true; + } + } + } + } + else + { + projectile.frame = 0; + projectile.extraUpdates = 0; + int num988 = 10; + bool flag54 = false; + bool flag55 = false; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] % 30f == 0f) + { + flag55 = true; + } + int npcIndex = (int)projectile.ai[1]; + if (projectile.localAI[0] >= (float)(60000 * num988)) //tryna make it stay on there "forever" without glitching + { + flag54 = true; + } + else if (npcIndex < 0 || npcIndex >= Main.maxNPCs) + { + flag54 = true; + } + else if (Main.npc[npcIndex].active && !Main.npc[npcIndex].dontTakeDamage && Main.npc[npcIndex].defense < 9999) + { + projectile.Center = Main.npc[npcIndex].Center - projectile.velocity * 2f; + projectile.gfxOffY = Main.npc[npcIndex].gfxOffY; + if (flag55) + { + Main.npc[npcIndex].HitEffect(0, 1.0); + } + } + else + { + flag54 = true; + } + if (flag54) + { + projectile.ai[0] = 0f; + projectile.velocity.X = 0f; + projectile.velocity.Y = 0f; + } + if (projectile.owner == Main.myPlayer) + { + if (eaterCooldown > 0) + eaterCooldown -= Main.rand.Next(1,4); + + if (eaterCooldown <= 0) + { + int projNumber = Main.rand.Next(1,4); + for (int index2 = 0; index2 < projNumber; index2++) + { + float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; + float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; + xVector *= 10f; + yVector *= 10f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), (int)(VileFeeder.BaseDamage * player.MinionDamage() * 2f), projectile.knockBack, projectile.owner, 0f, 0f); + } + eaterCooldown = 60; + } + } + } + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + Player player = Main.player[projectile.owner]; + Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && !npc.dontTakeDamage && npc.defense < 9999 && + ((projectile.friendly && (!npc.friendly || (npc.type == 22 && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == 54 && projectile.owner < Main.maxPlayers && player.killClothier))) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1))) + { + if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) + { + bool flag3; + if (npc.type == 414) + { + Rectangle rect = npc.getRect(); + int num5 = 8; + rect.X -= num5; + rect.Y -= num5; + rect.Width += num5 * 2; + rect.Height += num5 * 2; + flag3 = projectile.Colliding(myRect, rect); + } + else + { + flag3 = projectile.Colliding(myRect, npc.getRect()); + } + if (flag3) + { + if (npc.reflectingProjectiles && projectile.CanReflect()) + { + npc.ReflectProjectile(projectile.whoAmI); + return; + } + projectile.ai[0] = 3f; + projectile.ai[1] = (float)i; + projectile.velocity = (npc.Center - projectile.Center) * 0.75f; + projectile.netUpdate = true; + projectile.StatusNPC(i); + projectile.damage = 0; + int num28 = 10; + Point[] array2 = new Point[num28]; + int num29 = 0; + for (int l = 0; l < Main.maxProjectiles; l++) + { + Projectile proj = Main.projectile[l]; + if (l != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 3f && proj.ai[1] == (float)i) + { + array2[num29++] = new Point(l, Main.projectile[l].timeLeft); + if (num29 >= array2.Length) + { + break; + } + } + } + if (num29 >= array2.Length) + { + int num30 = 0; + for (int m = 1; m < array2.Length; m++) + { + if (array2[m].Y < array2[num30].Y) + { + num30 = m; + } + } + Main.projectile[array2[num30].X].Kill(); + } + } + } + } + } + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (targetHitbox.Width > 8 && targetHitbox.Height > 8) + { + targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); + } + return null; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = Main.projectileTexture[projectile.type]; + int num214 = texture.Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 0; + } + } +} diff --git a/Projectiles/Summon/VileFeederSummon.png b/Projectiles/Summon/VileFeederSummon.png new file mode 100644 index 0000000000000000000000000000000000000000..e036795029ea28d18f9b1c365b2223108de1e9f7 GIT binary patch literal 1331 zcmV-31Px#AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;(K){{a7>y{D4^00e&bO3rfy8u{AY^Xa4$^oa*$<`ci z*>G`b*)J|F`&l2HXzIndyca`hX6>r%3(*3>jSLJ76CYM~lo`e}k8-8XQo;d9cXnw{UYv>~uTv$*0a)=WT7COH@9nov0Wfy$SHDqgO=Zad zFupkD8|O#l_~gmw0k|6cUit7_AdIb<6{4%3T+&;#?bvzs^m72r6c)5t{rrsw!12K> z0EeH+191DV0ss?}^8mc~nybaOKc8{z#(1W%pdFZ;Sk;{Vxv&Vp$UCn9aQ*TRTKVL} zqISNt7u^g}ed;Pr8NKk5RzCW{8vy+H>GyhlL-rj%+naL$#%EPelDr*3jnn5}e;)|* zR$?!soSgs1?3`W4)$y2MloLlcZu|y>S@QJR5&(aH-2uSh@pd5WvFG2tQf)Ju7@InG z@nZl^p9%7JN-zItOl8IN_?HdOk1oa{88gfnn$JMSh}t$Ia|}S{a3=r@x9@LBJ3)OX zsIMKjPeLN|4z{cLJ9ndTT$jf}HlpnkJ$vT3MlsRvj`lIpw;xQa->!5^M8CRJR(DV= z+jX4G=ehwX%-!<=4z+i*M)bw950KAw+aHe`68Tm{Z^nA>h#q4O+luHnJ3qP@i<%{R zk@Xlmrv`h0a8`c#*bo3mGe>}sDus(bzx-9h^6OJKfpFHgmlY-t?3C!Gz3ApV=}FBJ zy{YK3Vy8rJJuB*Zo;Vmd@g@)wy{VtR(}~{XWqXd#3?Bu;8AP-hxo<}LqDW>C?LdEC zbvfC;5DoM_$v(>L9VpI0|5G(+@m*T zKPzO8Gv~1F61{nTba~wD9=*8|5JmS^VW&iI{jEaX-lmKV65Elp!F%ew-UEf`CDt{Z zYJ4kQ2nlSHEh_ zQTJwX6Pat2{}0g<&cZR#H>a5B?K_T%J|_Bl)qf|1n#-Cc`VwkxwEvyZ@Q|X&-)|Pw z`w!F=TP6D8p}b`h5~sUJ^uArk=7E^#ci-{;Bl;Th(XQMo(Mx;wiQc5kW{F-D-C9~4 z%GWlc?GpVLpS`D*N54mJz5~VJ;|ArxUJ(5wzPf2h^pSscv;XuT*whvq&=6O20000I pbVXQnMOaBjI!|(GWo~p~bZKvH05ODE?C$^o002ovPDHLkV1kwEg0lbs literal 0 HcmV?d00001 diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 09a05b2ef5..f5091fe12b 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -415,7 +415,7 @@ namespace CalamityMod Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); if (projectile.owner == Main.myPlayer) { - for (int i = 0; i < 200; i++) + for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == 22 && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == 54 && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || @@ -453,7 +453,7 @@ namespace CalamityMod projectile.damage = 0; Point[] array2 = new Point[maxStick]; int num29 = 0; - for (int l = 0; l < 1000; l++) + for (int l = 0; l < Main.maxProjectiles; l++) { if (l != projectile.whoAmI && Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type && Main.projectile[l].ai[0] == 1f && Main.projectile[l].ai[1] == (float)i) {