From b1be78586fb97ee5f5ef08982dfb650653b6cff6 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 31 Jul 2021 18:33:08 -0500 Subject: [PATCH] Hit effects and loot for repair units --- Gores/DraedonLabCritters/RepairUnit1.png | Bin 0 -> 186 bytes Gores/DraedonLabCritters/RepairUnit2.png | Bin 0 -> 178 bytes Gores/DraedonLabCritters/RepairUnit3.png | Bin 0 -> 227 bytes NPCs/DraedonLabThings/RepairUnitCritter.cs | 33 +++++++++++++++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Gores/DraedonLabCritters/RepairUnit1.png create mode 100644 Gores/DraedonLabCritters/RepairUnit2.png create mode 100644 Gores/DraedonLabCritters/RepairUnit3.png diff --git a/Gores/DraedonLabCritters/RepairUnit1.png b/Gores/DraedonLabCritters/RepairUnit1.png new file mode 100644 index 0000000000000000000000000000000000000000..c7fa6eae856aec1fc11e82ef264bce2b0780192d GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^96-#&!3-ob9C+3PDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(j232Ka=yva+(OD60lJI{^g}V&@cr)RhGJ1^@s5pTR+E;L?!K~Z35*gqYF-%3P|ILyYdZekuF;TZLSEBa7Iull3?KI$VC9%`-~a=I{&xPn U_P-W8fkrZTy85}Sb4q9e0L%$CVE_OC literal 0 HcmV?d00001 diff --git a/Gores/DraedonLabCritters/RepairUnit3.png b/Gores/DraedonLabCritters/RepairUnit3.png new file mode 100644 index 0000000000000000000000000000000000000000..971883e554874e9bbd3c06777a608c26b55469dc GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~i!3-n?Kj!QJQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7Tv=IJgPfg;JZ&1Hd`%5ayaNM)GL!k3gn$%#NswRge=uN>@@94e z3UL;AL>2=rIS9gxJ0@no1q!-&x;TbNgqNOmo)m zk8D=K&>h7MJ=P`%)};MvsaEb;EZUS+d)sY8_?rC}USz3Fs$r;G$Edl|$w&og9)qW= KpUXO@geCw(1V&{5 literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index 678a9cff58..c01975ffba 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -1,6 +1,8 @@ +using CalamityMod.Items.DraedonMisc; using CalamityMod.Walls.DraedonStructures; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; @@ -129,7 +131,7 @@ namespace CalamityMod.NPCs.DraedonLabThings if (onSolidGround && distanceToAheadBelowTile.HasValue && distanceToAheadBelowTile.Value >= 2 && distanceToAheadBelowTile.Value < 9) { Vector2 jumpDestination = npc.Center + Vector2.UnitX * npc.spriteDirection * (distanceToAheadBelowTile.Value * 16f + 8f); - npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 6f); + npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 8.5f); } // Attempt to jump over vertical obstacles. @@ -144,7 +146,7 @@ namespace CalamityMod.NPCs.DraedonLabThings if (WorldGen.SolidTile((int)(npc.Center.X / 16 + (distanceToObstacle ?? 0) * npc.spriteDirection), (int)(npc.Center.Y / 16) - i)) obstacleHeight++; } - npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 6f + StuckCount * 0.7f + obstacleHeight * 0.4f); + npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 9f + StuckCount * 0.7f + obstacleHeight * 0.4f); if (MathHelper.Distance(npc.position.X, npc.oldPosition.X) < 0.2f) { @@ -276,9 +278,36 @@ namespace CalamityMod.NPCs.DraedonLabThings } } + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(npc.position, npc.width, npc.height, 226); + if (npc.life <= 0) + { + for (int i = 1; i <= 3; i++) + Gore.NewGorePerfect(npc.Center, npc.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.7f, 1f), mod.GetGoreSlot($"Gores/DraedonLabCritters/RepairUnit{i}")); + } + } + + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 2, 2, 4); + } + public override void FindFrame(int frameHeight) { npc.frame.Y = (int)(CurrentFrame * frameHeight); } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D critterTexture = Main.npcTexture[npc.type]; + Texture2D glowmask = ModContent.GetTexture("CalamityMod/NPCs/DraedonLabThings/RepairUnitCritterGlowmask"); + Vector2 drawPosition = npc.Center - Main.screenPosition + Vector2.UnitY * npc.gfxOffY; + SpriteEffects direction = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, npc.frame, npc.GetAlpha(drawColor), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, npc.frame, npc.GetAlpha(Color.White), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, direction, 0f); + return false; + } } }