From ccf33456d9a1de99a073fa935b74cec2dfc9de73 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sun, 5 Jul 2020 15:20:24 -0400 Subject: [PATCH] Updated Living Magma's sprite. Added new Living Magma behavior. Added the Tiny Living Magma. --- Content/NPCs/LivingMagma.cs | 97 +++++++++++++++++++++++------- Content/NPCs/LivingMagma.png | Bin 1038 -> 1140 bytes Content/NPCs/TinyLivingMagma.cs | 40 ++++++++++++ Content/NPCs/TinyLivingMagma.png | Bin 0 -> 783 bytes Content/Projectiles/MagmaBall.cs | 71 ++++++++++++++++++++++ Content/Projectiles/MagmaBall.png | Bin 0 -> 351 bytes Lib/Util/LightingUtils.cs | 12 ++++ 7 files changed, 197 insertions(+), 23 deletions(-) create mode 100644 Content/NPCs/TinyLivingMagma.cs create mode 100644 Content/NPCs/TinyLivingMagma.png create mode 100644 Content/Projectiles/MagmaBall.cs create mode 100644 Content/Projectiles/MagmaBall.png create mode 100644 Lib/Util/LightingUtils.cs diff --git a/Content/NPCs/LivingMagma.cs b/Content/NPCs/LivingMagma.cs index 141da44..742645d 100644 --- a/Content/NPCs/LivingMagma.cs +++ b/Content/NPCs/LivingMagma.cs @@ -1,14 +1,26 @@ -using Decimation.Content.Buffs.Buffs; -using Decimation.Content.Buffs.Debuffs; +using Decimation.Content.Buffs.Debuffs; +using Decimation.Content.Projectiles; using Decimation.Content.Tiles.ShrineoftheMoltenOne; +using Decimation.Lib.Util; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Decimation.Content.NPCs { - class LivingMagma : ModNPC + internal class LivingMagma : ModNPC { + private static readonly int SpitInterval = 60; + private static readonly int SpitDuration = 240; + + private int SpitCounter { get; set; } + private int SpittingCounter { get; set; } = SpitDuration; + private bool Spitting { get; set; } + private bool HasSpit { get; set; } + + private Vector2 MouthPosition => npc.Center + new Vector2(npc.width / 2f * npc.direction, 0); + public override void SetStaticDefaults() { DisplayName.SetDefault("Living Magma"); @@ -17,7 +29,7 @@ namespace Decimation.Content.NPCs public override void SetDefaults() { - npc.width = 34; + npc.width = 40; npc.height = 28; npc.aiStyle = 1; npc.damage = 50; @@ -34,7 +46,6 @@ namespace Decimation.Content.NPCs npc.knockBackResist = 0.8f; aiType = NPCID.ToxicSludge; animationType = NPCID.ToxicSludge; - npc.lavaImmune = true; npc.buffImmune[BuffID.OnFire] = true; npc.buffImmune[BuffID.Burning] = true; @@ -42,8 +53,36 @@ namespace Decimation.Content.NPCs public override void AI() { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Fire); - base.AI(); + if (npc.velocity.Length() > 0) HasSpit = false; + if (SpitCounter >= SpitInterval && !HasSpit && Main.expertMode && npc.velocity.Length() == 0f && + Main.rand.NextBool(5)) Spitting = true; + + if (Spitting) + { + if (SpittingCounter == 60) + { + Projectile.NewProjectile(MouthPosition, new Vector2(8 * npc.direction, -2), + ModContent.ProjectileType(), + 45, 4); + Main.PlaySound(SoundID.NPCDeath13, MouthPosition); + + HasSpit = true; + } + + if (SpittingCounter-- < 0) + { + Spitting = false; + SpittingCounter = SpitDuration; + } + } + else + { + base.AI(); + } + + if (SpitCounter++ > SpitInterval) SpitCounter = 0; + + Lighting.AddLight(npc.Center, LightingUtils.Rgb255ToRgb1(255, 155, 48)); } public override void HitEffect(int hitDirection, double damage) @@ -53,27 +92,39 @@ namespace Decimation.Content.NPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - int x = (int)Main.LocalPlayer.position.X / 16; - int y = (int)Main.LocalPlayer.position.Y / 16; + if (!Main.hardMode) return 0; + + int x = (int) Main.LocalPlayer.position.X / 16; + int y = (int) Main.LocalPlayer.position.Y / 16; int validBlockCount = 0; for (int i = -50 + x; i <= 50 + x; i++) - { - for (int j = -50 + y; j <= 50 + y; j++) - { - if (i >= 0 && i <= Main.maxTilesX && j >= 0 && j <= Main.maxTilesY) - { - if (Main.tile[i, j].type == ModContent.TileType() || (Main.tile[i, j].type == ModContent.TileType() || Main.tile[i, j].type == ModContent.TileType() || Main.tile[i, j].type == ModContent.TileType()) || Main.tile[i, j].type == ModContent.TileType()) - { - validBlockCount++; - } - } - } - } + for (int j = -50 + y; j <= 50 + y; j++) + if (i >= 0 && i <= Main.maxTilesX && j >= 0 && j <= Main.maxTilesY) + if (Main.tile[i, j].type == ModContent.TileType() || + Main.tile[i, j].type == ModContent.TileType() || + Main.tile[i, j].type == ModContent.TileType() || + Main.tile[i, j].type == ModContent.TileType() || + Main.tile[i, j].type == ModContent.TileType()) + validBlockCount++; - if (validBlockCount >= 15 && Main.hardMode) + if (validBlockCount >= 15) return SpawnCondition.Underworld.Chance * 2; return 0; } + + public override bool CheckDead() + { + bool dead = base.CheckDead(); + + if (dead) + { + int tinySlimeAmount = Main.rand.Next(2, 4); + for (int i = 0; i < tinySlimeAmount; i++) + NPC.NewNPC((int) npc.Center.X, (int) npc.Center.Y, ModContent.NPCType()); + } + + return dead; + } } -} +} \ No newline at end of file diff --git a/Content/NPCs/LivingMagma.png b/Content/NPCs/LivingMagma.png index 507f70488d8afb07e8b9248748b6bb73f8b16438..4058192ff9be082c37aa2211b75675bfac0c77d5 100644 GIT binary patch literal 1140 zcmV-)1dIELP)La!XXISin%DLwV+tqM6J{`mZA_WRghf%00l)Zg`}|X zY$6smiV)9A1PjFzX6IYkxBG71?9LrK?~>-Yn;$#h`{vEOecw!)4P}2#Wq2CZ0c~pz zN*U$vp!%~59$dZC=m8M`gXP(w1oeA6GUeTk?dE&?^?J5lAjbR|QUk~W`F7=~vFz0B z@5I7$2eX!5|5V5rm;ytzQYgmc45Xi@;d0l?Js^!`E%!}6P(U$e~E4i@h0%J>p|h&tH5hi|=n z$(tcHfT-m-i(-GmzH_xdGjuiVbRK8QbNievmHLvHq4)s-0Tb$^79&Uz+o2p5Pkn*Z z@0^%3zaUaTdl~~ueM!6zVH|Y8l(}dC!IG_+Kgp_Pqh<NCCMR?U1w>vGFoyxi_ZY)wpuXP>sjvH8gi{D(z01wD-)jNgt1TTYyrFIg<9{RvoG{ z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0|kDk>=c9Dp|8VOvc2mU=qfaM9^_5!w@?` z+8Pe2U-jKmvw~5$G_zL6bF+)dgqsy?MXppo*@R0C)ap9_01I*isXNQsv;Y7A07*qo IM6N<$f-o@d-T(jq diff --git a/Content/NPCs/TinyLivingMagma.cs b/Content/NPCs/TinyLivingMagma.cs new file mode 100644 index 0000000..d89f2b1 --- /dev/null +++ b/Content/NPCs/TinyLivingMagma.cs @@ -0,0 +1,40 @@ +using Decimation.Content.Buffs.Debuffs; +using Decimation.Lib.Util; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Decimation.Content.NPCs +{ + public class TinyLivingMagma : ModNPC + { + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tiny Living Magma"); + Main.npcFrameCount[npc.type] = 3; + } + + public override void SetDefaults() + { + npc.CloneDefaults(ModContent.NPCType()); + npc.width = 30; + npc.height = 24; + npc.damage = 36; + npc.defense = 14; + npc.lifeMax = 240; + aiType = NPCID.ToxicSludge; + animationType = NPCID.ToxicSludge; + } + + public override void HitEffect(int hitDirection, double damage) + { + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 600); + } + + public override void AI() + { + Lighting.AddLight(npc.Center, LightingUtils.Rgb255ToRgb1(255, 155, 48)); + } + } +} \ No newline at end of file diff --git a/Content/NPCs/TinyLivingMagma.png b/Content/NPCs/TinyLivingMagma.png new file mode 100644 index 0000000000000000000000000000000000000000..7131fc21ef156a141797fddbec84c4001d677741 GIT binary patch literal 783 zcmV+q1MvKbP)LQg{0008jNkl%Y^=0X`~wARyHoH71hKQQ@N7;HY%B!N z(oXS&Y~D)d9A?8MCQ7zhvdPZAyd;ynnawJZU0Gy!DhZG@B8egQ42@)c$*58P*|!=6 ztH$a>!2uBf{o{I0z~Zz?)b*oL?sdjgdGhGSY$q@#GZYOV4TNO`{brci?A26@`Pn&j zzrDXx_tVpp{7r@_o}p*}X&{Zpy3s?rve0At{IJ?pkH8S>%Q7{{P&9xrM4dIG(+6iu zMj6bsci)WX&HZszZoWRKd*kvtpEE0q>fWB1F&N+3+x~GbeKQm*AUY>(%U}cyy=*Kf z6V=v~X-cootkp4?8eqs40B!FM5G?DVgJBNfa_vJ^U3Eu|CM+|W5qNOCRCsdjm)KSI z=K*odaH|vyQP1s+A@_jDR#D7;W)flbU=GkduXp^Eude!g?w>C5Jq;H;I_mMgK|iFA z7vTUg4zcJ8vpUc-dM={O&{YMy#ryifH$$-k8rC7YdOx#1BfI)CV@E#1dImtvCqNS6 z|A3+3LXmPD98feuksR1i3@4?d5sHMF@KQP&p-7ksFQsD@iv8H6w6xbq^<{-(RzJ^8 zkvLH>2@vcc#l=u&k8!4#-w0ah(Yp*vx-7Wru+{e7Wl(rPOwLsT#xZlY^{hr2 z|9sFPm$iL#fM_^ahxUrV662Zaza3x(eu~SjmjAaCRmqNMxhY&XyTI zf)*_xCis9k!^t=Lr$W)Lq&|}~isV=l9uTFX?768VBh projectile.ai[0] == 1f; + set => projectile.ai[0] = value ? 1 : 0; + } + + protected override void Init() + { + projectile.width = 22; + projectile.height = 20; + projectile.aiStyle = -1; + projectile.hostile = true; + projectile.penetrate = 1; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, LightingUtils.Rgb255ToRgb1(255, 155, 48)); + Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.LavaMoss); + + projectile.velocity.Y += 1 / 4f; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + int dustAmount = 16; + for (int i = 0; i < dustAmount; i++) + { + Dust.NewDust(target.position, target.width, target.height, DustID.Fire, 0, + 0, 0, default, projectile.scale * 3f); + } + + target.AddBuff(ModContent.BuffType(), 300); + + HitPlayer = true; + projectile.Kill(); + } + + public override void Kill(int timeLeft) + { + if (HitPlayer) return; + + int dustAmount = 4; + for (int i = 0; i < dustAmount; i++) + { + Vector2 velocity = Vector2.One.RotatedBy(Math.PI * (2f / dustAmount)); + Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, velocity.X, + velocity.Y, 0, default, projectile.scale * 3f); + } + + Tile currentTile = Framing.GetTileSafely((int) Math.Floor(projectile.position.X / 16f), + (int) Math.Ceiling(projectile.position.Y / 16f)); + currentTile.liquid = 1; + currentTile.lava(true); + + Main.PlaySound(SoundID.NPCDeath19, projectile.Center); + } + } +} \ No newline at end of file diff --git a/Content/Projectiles/MagmaBall.png b/Content/Projectiles/MagmaBall.png new file mode 100644 index 0000000000000000000000000000000000000000..5fd08d91b50bcef53e0ee389d1a7fe906c74020e GIT binary patch literal 351 zcmV-l0igbgP)ktN_9svC@Mpt!gc*kS_>JutoV;0_cQuF?63 z!WY&54dFw50&_Vd%?)<9_dszW%;hlW;qn1Y9v&Akm&064b%Xz34g#kJ``k}p%h4@> zxd`0{xO{SOG9Orqk>&<7oVW+J$$qH_m_~Qu%a_lvreAm%LtP5v!(B{ugJCwng5>qg z$6%q5EBq)f%w_(H!nfD_1LosQ$8<9o79_7PvZA=~;B^*A96())?jv|=fR-8XvH}(q zR5utsNYEn_JxRb)4SH%hbYKtIu_#3yNC4gCu;fRv!7u~Rv-*V_m%vi!E=13%I9*J0 xgV8O(o9!4F7+@}i=R86haMdj6`p^vq0PWPq=h3v2ng9R*07*qoM6N<$f&gSGln?*_ literal 0 HcmV?d00001 diff --git a/Lib/Util/LightingUtils.cs b/Lib/Util/LightingUtils.cs new file mode 100644 index 0000000..106b62d --- /dev/null +++ b/Lib/Util/LightingUtils.cs @@ -0,0 +1,12 @@ +using Microsoft.Xna.Framework; + +namespace Decimation.Lib.Util +{ + public class LightingUtils + { + public static Vector3 Rgb255ToRgb1(int r, int g, int b) + { + return new Vector3(r / 255f, g / 255f, b / 255f); + } + } +} \ No newline at end of file