My sprite is rushing through the 4 frames that I've given it. If I don't fix this problem I'll start having seizures. Jokes aside, I've never utilized " Main.frameRate = 6;"
and from what I'm guessing, its supposed to change the framerate. Though, still after changing the integer the sprite still doesn't change and it just keeps going through the frames as quickly as possible.
How can I lower the framerate to better fit my NPC?
and from what I'm guessing, its supposed to change the framerate. Though, still after changing the integer the sprite still doesn't change and it just keeps going through the frames as quickly as possible.
How can I lower the framerate to better fit my NPC?
Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Eldritch.NPCs
{
public class Warden : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Shard Warden");
Main.npcFrameCount[npc.type] = 4;
Main.frameRate = 6;
}
public override void SetDefaults()
{
npc.aiStyle = 17; //5 is the flying AI
npc.lifeMax = 1000; //boss life
npc.damage = 60; //boss damage
npc.defense = 10; //boss defense
npc.knockBackResist = 0f;
animationType = NPCID.Vulture;
Main.npcFrameCount[npc.type] = 4;
npc.width = 100;
npc.height = 100;
npc.value = Item.buyPrice(0, 40, 75, 45);
npc.npcSlots = 1f;
npc.boss = true;
npc.lavaImmune = true;
npc.noGravity = true;
npc.noTileCollide = true;
npc.buffImmune[24] = true;
//music = mod.GetSoundSlot(SoundType.Music, "PrxticleModPack/Music/Destructias");
npc.netAlways = true;
}
public void AutoloadHead(ref string bossHeadTexture)
{
bossHeadTexture = "Eldritch/NPCs/Warden_Head.png"; //the boss head texture
}
public override void BossLoot(ref string name, ref int potionType)
{
potionType = ItemID.HealingPotion; //boss drops
if (Main.rand.Next(2) == 1)
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Shard1"), 50);
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 1f * bossLifeScale); //boss life scale in expertmode
npc.damage = (int)(npc.damage * 0.6f); //boss damage increase in expermode
}
public override void AI()
{
Player P = Main.player[npc.target];
npc.ai[0]++;
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
{
npc.rotation += npc.direction * 0.8f;
npc.TargetClosest(true);
}
npc.netUpdate = true;
npc.ai[1]++;
if (npc.ai[1] >= 120)
{
float Speed = 7.5f; //projectile speed
Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
int damage = 30; //projectile damage
int type = mod.ProjectileType("Warden_Proj"); //put your projectile
//int type = 467; //put your projectile
Main.PlaySound(3, (int)npc.position.X, (int)npc.position.Y, 17);
float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
npc.ai[1] = 0;
}
npc.ai[1] += 0;
if (npc.life <= 500)
npc.ai[2]++; //Charge Attack
if (npc.ai[2] >= 20)
{
npc.velocity.X *= 0.98f;
npc.velocity.Y *= 0.98f;
Vector2 vector8 = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f));
{
float rotation = (float)Math.Atan2((vector8.Y) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height * 0.5f)), (vector8.X) - (Main.player[npc.target].position.X + (Main.player[npc.target].width * 0.5f)));
npc.velocity.X = (float)(Math.Cos(rotation) * 12) * -1;
npc.velocity.Y = (float)(Math.Sin(rotation) * 12) * -1;
}
//Dust
npc.ai[0] %= (float)Math.PI * 2f;
Vector2 offset = new Vector2((float)Math.Cos(npc.ai[0]), (float)Math.Sin(npc.ai[0]));
Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 20);
npc.ai[2] = -300;
Color color = new Color();
Rectangle rectangle = new Rectangle((int)npc.position.X, (int)(npc.position.Y + ((npc.height - npc.width) / 2)), npc.width, npc.width);
int count = 30;
for (int i = 1; i <= count; i++)
{
int dust = Dust.NewDust(npc.position, rectangle.Width, rectangle.Height, 6, 0, 0, 100, color, 2.5f);
Main.dust[dust].noGravity = false;
}
return;
}
}
}
}
Last edited: