using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace FarLandsMod.NPCs
{
public class FarLandsGlobalNPC : GlobalNPC
{
public override bool InstancePerEntity
{
get
{
return true;
}
}
public bool HedgePetrify = false;
public override void ResetEffects(NPC npc)
{
HedgePetrify = false;
}
public override bool PreAI(NPC npc)
{
if (HedgePetrify)
{
return false;
}
else
{
return true;
}
}
//Not sure where to put the X/Y/damage effects of the debuff. Putting them in UpdateLifeRegen has worked.
public override void UpdateLifeRegen(NPC npc, ref int damage)
{
if (HedgePetrify)
{
//THIS is where I CAN set the npc's damage to 0, but it never reverts back if I do
//npc.damage = 0;
//The following stops lateral movement fine; however, while it does bring airborne targets to the ground, npcs still tend to "shake". I'm not sure how to clean that up, but it works for now so I leave it. I'm suspecting some kind of Y = 10 until tile collision then Y = 0 code might resolve it, but I'm having trouble getting anything else to work. Movement resumes on fade, I think because preAI returns to true and reassigns X and Y values
npc.velocity.X = 0;
if (npc.velocity.Y == 0)
{
npc.velocity.Y = 0;
}
else
{
npc.velocity.Y = 10;
}
if (npc.lifeRegen > 0)
{
npc.lifeRegen = 0;
}
}
}
//The following draws a small amount of dust while they're debuffed. Hoping to replace it with something that changes their palette to greyish until fade. When I get there.
public override void DrawEffects(NPC npc, ref Color drawColor)
{
if (HedgePetrify)
{
if (Main.rand.Next(4) < 3)
{
int dust = Dust.NewDust(npc.position - new Vector2(1f, 1f), npc.width + 1, npc.height + 1, mod.DustType("Smoke"), npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 10, default(Color), 1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 1f;
Main.dust[dust].velocity.Y -= 0.1f;
if (Main.rand.Next(4) == 0)
{
Main.dust[dust].noGravity = false;
Main.dust[dust].scale *= 0.1f;
}
}
}
}
}
}