Updated Living Magma's sprite.

Added new Living Magma behavior.
Added the Tiny Living Magma.
This commit is contained in:
FyloZ 2020-07-05 15:20:24 -04:00
parent 3a9de1cc98
commit ccf33456d9
7 changed files with 197 additions and 23 deletions

View File

@ -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<MagmaBall>(),
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<ShrineBrick>() || (Main.tile[i, j].type == ModContent.TileType<LockedShrineDoor>() || Main.tile[i, j].type == ModContent.TileType<ShrineDoorClosed>() || Main.tile[i, j].type == ModContent.TileType<ShrineDoorOpened>()) || Main.tile[i, j].type == ModContent.TileType<RedHotSpike>())
{
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<ShrineBrick>() ||
Main.tile[i, j].type == ModContent.TileType<LockedShrineDoor>() ||
Main.tile[i, j].type == ModContent.TileType<ShrineDoorClosed>() ||
Main.tile[i, j].type == ModContent.TileType<ShrineDoorOpened>() ||
Main.tile[i, j].type == ModContent.TileType<RedHotSpike>())
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<TinyLivingMagma>());
}
return dead;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -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<LivingMagma>());
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<Singed>(), 600);
}
public override void AI()
{
Lighting.AddLight(npc.Center, LightingUtils.Rgb255ToRgb1(255, 155, 48));
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

View File

@ -0,0 +1,71 @@
using System;
using Decimation.Content.Buffs.Debuffs;
using Decimation.Lib.Util;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Decimation.Content.Projectiles
{
public class MagmaBall : DecimationProjectile
{
private bool HitPlayer
{
get => 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<Singed>(), 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);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

12
Lib/Util/LightingUtils.cs Normal file
View File

@ -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);
}
}
}