Beispiel #1
0
 public override void OnHitByNPC(NPC npc, int damage, bool crit)
 {
     if (AnguishTime > 0)
     {
         AnguishTime = 0;
     }
     if (Amulettorture && TortureTime == 0 && player.statLife < 150)
     {
         TortureTime = 18000;
         player.HealEffect(player.statLifeMax2 - player.statLife);
         player.statLife = player.statLifeMax2;
         player.AddBuff(BuffID.Wrath, 18000);
         player.AddBuff(BuffID.Rage, 18000);
     }
     if (Vengeance)
     {
         MessageTime = 90;
         MessageDust = ModContent.GetInstance <Dusts.VengMessage>();
         Dust.NewDust(new Vector2(player.Center.X - 86, player.position.Y - 40), 0, 0, ModContent.DustType <Dusts.VengMessage>());
         player.ApplyDamageToNPC(npc, damage * 10, 0f, 0, false);
         npc.netUpdate = true;
         Vengeance     = false;
         player.ClearBuff(ModContent.BuffType <Buffs.Vengeance>());
         for (int o = 0; o < 36; o++)
         {
             Vector2 rotate = new Vector2(2).RotatedBy(MathHelper.ToRadians(10 * o));
             int     dust   = Dust.NewDust(player.Center, 0, 0, 90);
             Main.dust[dust].noGravity = true;
             Main.dust[dust].scale     = 1f;
             Main.dust[dust].velocity  = rotate;
         }
     }
 }
Beispiel #2
0
        internal override void PostSetupContent()
        {
            if (!Main.dedServ)
            {
                int             count = 0;
                ArmorShaderData shader;
                do
                {
                    shader = GameShaders.Armor.GetSecondaryShader(count + 1, Main.LocalPlayer);
                    count++;
                } while (shader != null);
                shaderCount = count - 1;

                count = Terraria.ID.DustID.Count;
                ModDust dust;
                while (true)
                {
                    dust = ModDust.GetDust(count);
                    if (dust == null)
                    {
                        break;
                    }
                    count++;
                }
                dustCount = count;

                dustUI = new DustUI(userInterface);
                dustUI.Activate();
                userInterface.SetState(dustUI);
            }
        }
Beispiel #3
0
        public override void PostSetupContent()
        {
            if (!Main.dedServ)
            {
                int             count = 0;
                ArmorShaderData shader;

                do
                {
                    shader = GameShaders.Armor.GetSecondaryShader(count + 1, Main.LocalPlayer);
                    count++;
                }while (shader != null);

                shaderCount = count - 1;
                count       = Terraria.ID.DustID.Count - 1;

                ModDust dust;

                do
                {
                    dust = ModDust.GetDust(count);
                    count++;                     // We start the count one index prior to what it should be. Since this is a do-while, it'll always add one.
                }while (dust != null);

                dustCount = count;
            }
        }
Beispiel #4
0
 public override void WingUpdate(Player player, bool inUse)
 {
     if (inUse)
     {
         ModDust.NewDust(player.position, player.width, player.height, mod, "Flame", 0, 0, 0, Color.Red);
     }
     base.WingUpdate(player, inUse);
 }
Beispiel #5
0
        public static ModDust GetModDust(string modname, string dustname)
        {
            ModDust dust = new ModDust();

            if (ModLoader.GetMod(modname) != null)
            {
                Mod mod = ModLoader.GetMod(modname);
                try
                {
                    dust = mod.GetDust(dustname);
                }
                catch (Exception)
                {
                    dust = null;
                    throw new Exception("Can't find this dust" + dustname);
                }
            }

            return(dust);
        }
Beispiel #6
0
        //internal int frameCounter = 0;
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            if (++frameTimer > frameDelay)
            {
                frameCounter = frameCounter + 1;
                frameTimer   = 0;
            }

            CalculatedStyle dimensions = base.GetInnerDimensions();

            spriteBatch.Draw(backgroundTexture, dimensions.Position(), null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
            Rectangle rectangle = dimensions.ToRectangle();

            int       frames;
            Texture2D texture;
            int       height;
            int       width;
            int       frame;
            int       x;
            int       y;

            if (type < Terraria.ID.DustID.Count)
            {
                frames  = 3;
                frame   = frameCounter % frames;
                texture = TextureAssets.Dust.Value;
                height  = 8;
                width   = 8;
                x       = (type % 100) * 10;
                y       = (type / 100) * 30;
                y      += (height + 2) * frame;
            }
            else
            {
                frames = 1;
                var dust = ModDust.GetDust(type);
                texture = dust.Texture2D;
                height  = texture.Height / frames;
                width   = texture.Width;
                frame   = frameCounter % frames;
                x       = 0;
                y       = height * frame;           // maybe guess? if rectangle?
            }

            Rectangle sourceRectangle = new Rectangle(x, y, width, height);

            float drawScale      = 2f;
            float availableWidth = (float)backgroundTexture.Width * scale;

            if (width * drawScale > availableWidth || height * drawScale > availableWidth)
            {
                if (width > height)
                {
                    drawScale = availableWidth / width;
                }
                else
                {
                    drawScale = availableWidth / height;
                }
            }
            Vector2 drawPosition = dimensions.Position();

            drawPosition.X += backgroundTexture.Width * scale / 2f - (float)width * drawScale / 2f;
            drawPosition.Y += backgroundTexture.Height * scale / 2f - (float)height * drawScale / 2f;

            Main.spriteBatch.Draw(texture, drawPosition, sourceRectangle, Color.White, 0, Vector2.Zero, drawScale, SpriteEffects.None, 0);
            //if (IsMouseHovering)
            //{
            //	Main.hoverItemName = Main.projName[type];
            //}
        }
Beispiel #7
0
        public override void AI()
        {
            //int dustType = mod.DustType("DirtSolution");
            if (minDistance >= 0)
            {
                if (projectile.owner == Main.myPlayer)
                {
                    Player p        = Main.player[Main.myPlayer];
                    float  xCenter  = projectile.position.X + (float)(projectile.width / 2);
                    float  yCenter  = projectile.position.Y + (float)(projectile.height / 2);
                    float  pxCenter = p.position.X + (float)(p.width / 2);
                    float  pyCenter = p.position.Y + (float)(p.height / 2);
                    double distance = Math.Sqrt((xCenter - pxCenter) * (xCenter - pxCenter) + (yCenter - pyCenter) * (yCenter - pyCenter));

                    if (distance > minDistance)
                    {
                        Convert((int)(projectile.position.X + (float)(projectile.width / 2)) / 16, (int)(projectile.position.Y + (float)(projectile.height / 2)) / 16, radius);
                    }
                }
            }
            if (projectile.timeLeft > maxTime)
            {
                projectile.timeLeft = maxTime;
            }
            if (projectile.ai[0] > 7f)
            {
                float dustScale = 1f;
                if (projectile.ai[0] == 8f)
                {
                    dustScale = 0.2f;
                }
                else if (projectile.ai[0] == 9f)
                {
                    dustScale = 0.4f;
                }
                else if (projectile.ai[0] == 10f)
                {
                    dustScale = 0.6f;
                }
                else if (projectile.ai[0] == 11f)
                {
                    dustScale = 0.8f;
                }
                projectile.ai[0] += 1f;
                for (int i = 0; i < radius * 2 + 1; i++)
                {
                    int     dustIndex = -1;
                    ModDust md        = ModDust.GetDust(dustType);
                    if (md == null || !(md is BaseLightlessDust))
                    {
                        dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1f);
                    }
                    else
                    {
                        dustIndex = Dust.NewDust(new Vector2(projectile.position.X - radius * 16, projectile.position.Y), projectile.width + radius * 32, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1f);
                    }

                    Dust dust = Main.dust[dustIndex];
                    dust.noGravity  = true;
                    dust.scale     *= 1.75f;
                    dust.velocity.X = dust.velocity.X * 2f;
                    dust.velocity.Y = dust.velocity.Y * 2f;
                    dust.scale     *= dustScale;
                }
            }
            else
            {
                projectile.ai[0] += 1f;
            }
            projectile.rotation += 0.3f * (float)projectile.direction;
        }