示例#1
0
        void Bleed(NPC target, int hitDamage)
        {
            int     damage   = (int)MathHelper.Clamp(hitDamage * Type2.GetValue(), 1, int.MaxValue);
            int     duration = (int)MathHelper.Clamp(Type3.GetValue() * 60, 1, int.MaxValue);
            BuffNPC pomNPC   = target.GetGlobalNPC <BuffNPC>();

            pomNPC.AddBleedBuff(target, damage, duration);
        }
示例#2
0
        public override bool PreAI()
        {
            if (!init)
            {
                float airRadius   = projectile.ai[0];
                float airDiameter = airRadius * 2;
                airRect = new Rectangle(
                    (int)(projectile.position.X - airRadius),
                    (int)(projectile.position.Y - airRadius),
                    (int)(airDiameter),
                    (int)(airDiameter));
                init = true;
            }

            for (int i = 0; i < Main.maxPlayers; i++)
            {
                Player player = Main.player[i];
                if (player.active && !player.dead)
                {
                    Rectangle playerRect = player.getRect();
                    if (playerRect.Intersects(airRect))
                    {
                        player.GetModPlayer <BuffPlayer>().AddBurningAirBuff(player, projectile.damage);
                    }
                }
            }

            for (int i = 0; i < Main.maxNPCs; i++)
            {
                NPC npc = Main.npc[i];
                if (npc.active && (!npc.friendly || npc.townNPC) && !npc.dontTakeDamage)
                {
                    Rectangle npcRect = npc.getRect();
                    if (npcRect.Intersects(airRect))
                    {
                        BuffNPC pomNPC = npc.GetGlobalNPC <BuffNPC>();
                        pomNPC.AddBurningAirBuff(npc, projectile.damage);
                    }
                }
            }

            Lighting.AddLight(projectile.Center, emittedLight);

            float dustsF = (airRect.Width * airRect.Height) / dustScarcity;
            int   dusts  = (int)Math.Ceiling(dustsF);

            if (Main.rand.NextFloat(1f) <= dustsF)
            {
                for (int i = 0; i < dusts; i++)
                {
                    Dust.NewDustPerfect(new Vector2(Main.rand.NextFloat(airRect.Left, airRect.Right), Main.rand.NextFloat(airRect.Bottom, airRect.Top)), ModContent.DustType <FireDebris>(), Alpha: 130, Velocity: new Vector2(Main.rand.NextFloat(-0.7f, 0.7f), Main.rand.NextFloat(-0.8f, -0.2f)), Scale: Main.rand.NextFloat(1f, 4f));
                }
            }

            return(false);
        }
示例#3
0
        void ReceiveAddChilledBuffNPC(BinaryReader reader, int fromWho)
        {
            byte  npcID        = reader.ReadByte();
            float multiplier   = reader.ReadSingle();
            int   dutaionTicks = reader.ReadInt32();

            NPC     npc    = Main.npc[npcID];
            BuffNPC pomNPC = npc.GetGlobalNPC <BuffNPC>();

            pomNPC.AddChilledBuff(npc, multiplier, dutaionTicks, false);

            if (Main.netMode == NetmodeID.Server)
            {
                ModPacket packet = GetPacket((byte)PacketType.AddChilledBuffNPC);
                packet.Write(npcID);
                packet.Write(multiplier);
                packet.Write(dutaionTicks);
                packet.Send(-1, fromWho);
            }
        }
示例#4
0
        void ReceiveAddPoisonBuffNPC(BinaryReader reader, int fromWho)
        {
            byte npcID        = reader.ReadByte();
            int  damage       = reader.ReadInt32();
            int  dutaionTicks = reader.ReadInt32();

            NPC     npc    = Main.npc[npcID];
            BuffNPC pomNPC = npc.GetGlobalNPC <BuffNPC>();

            pomNPC.AddPoisonBuff(npc, damage, dutaionTicks, false);

            if (Main.netMode == NetmodeID.Server)
            {
                ModPacket packet = GetPacket((byte)PacketType.AddPoisonBuffNPC);
                packet.Write(npcID);
                packet.Write(damage);
                packet.Write(dutaionTicks);
                packet.Send(-1, fromWho);
            }
        }
示例#5
0
        public override bool PreAI()
        {
            if (!init)
            {
                nodes.AddLast(projectile.Center);
                isNPC  = projectile.velocity.X == 1;
                target = isNPC ? (Entity)Main.npc[(int)projectile.velocity.Y] : (Entity)Main.player[(int)projectile.velocity.Y];
                init   = true;
            }

            Vector2 targetPosition = target.Center;

            if (projectile.position != targetPosition)
            {
                float nextInboundY = Main.rand.NextFloat(0, boundHeight * 2);
                float diff         = nextInboundY - inboundY;
                if (Math.Abs(diff) < minVariance.X)
                {
                    nextInboundY = inboundY + (Math.Sign(diff) * minVariance.X);
                }

                float velocityX = Main.rand.NextFloat(0, varianceLength) + varianceXOffset;
                if (velocityX < 0)
                {
                    if (justWentBack)
                    {
                        velocityX    = minVariance.Y;
                        justWentBack = false;
                    }
                    else if (velocityX > -minVariance.Y)
                    {
                        velocityX = -minVariance.Y;
                    }
                }
                else
                {
                    justWentBack = false;
                }
                if (velocityX < 0)
                {
                    justWentBack = true;
                }

                Vector2 position = new Vector2(projectile.position.X + velocityX, projectile.position.Y - inboundY + nextInboundY);
                position = position.RotatedBy((target.position - nodes.Last.Value).ToRotation(), nodes.Last.Value);
                inboundY = nextInboundY;

                if ((targetPosition - position).LengthSquared() < snapRadiusSqr)
                {
                    position            = targetPosition;
                    projectile.timeLeft = PathOfModifiers.ailmentDuration;
                }

                projectile.position = position;

                nodes.AddLast(projectile.position);

                if (!removingNodes && nodes.Count > maxNodes)
                {
                    removingNodes = true;
                }

                foreach (var node in nodes)
                {
                    Lighting.AddLight(node, emittedLight);
                }
            }
            else
            {
                Player owner = Main.player[projectile.owner];
                if (isNPC)
                {
                    NPC npc = (NPC)target;
                    if (PoMUtil.CanHitNPC(npc))
                    {
                        if (Main.myPlayer == projectile.owner)
                        {
                            PlaySound();
                            owner.ApplyDamageToNPC(npc, projectile.damage, 1, npc.direction, false);
                            BuffNPC pomNPC = npc.GetGlobalNPC <BuffNPC>();
                            pomNPC.AddShockedBuff(npc, projectile.ai[0], PathOfModifiers.ailmentDuration, true);
                        }
                        SpawnDebris(targetPosition);
                        hitEntities.Add(npc);
                    }
                }
                else
                {
                    Player player = (Player)target;
                    if (PoMUtil.CanHitPvp(owner, player))
                    {
                        if (player.whoAmI == Main.myPlayer)
                        {
                            PlaySound();
                            player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage, player.direction, true);
                            player.GetModPlayer <BuffPlayer>().AddShockedBuff(player, projectile.ai[0], PathOfModifiers.ailmentDuration, true);
                        }
                        SpawnDebris(targetPosition);
                        hitEntities.Add(player);
                    }
                }

                if (jumpsLeft > 0)
                {
                    if (FindNewTarget())
                    {
                        jumpsLeft--;
                        projectile.timeLeft = jumpTimeLimit;
                    }
                    else
                    {
                        projectile.Kill();
                    }
                }
                else
                {
                    projectile.Kill();
                }
            }

            if (removingNodes && nodes.Count > 1)
            {
                SpawnVapour(nodes.First.Value, nodes.First.Next.Value);
                nodes.RemoveFirst();
            }

            return(false);
        }
示例#6
0
        public override bool PreAI()
        {
            if (!init)
            {
                nodes.Add(projectile.Center);
                targetPosition = projectile.position + new Vector2(0, projectile.ai[1]);
                boltRect       = new Rectangle(
                    (int)boundLeft,
                    (int)projectile.position.Y,
                    projectile.width,
                    (int)projectile.ai[1]);
                airRect = new Rectangle(
                    (int)(targetPosition.X - airRadius),
                    (int)(targetPosition.Y - airRadius),
                    (int)(airRadius * 2),
                    (int)(airRadius * 2));
                float halfWidth = projectile.width / 2f;
                boundLeft  = targetPosition.X - halfWidth;
                boundRight = targetPosition.X + halfWidth - (minVariance.X * 2);
                init       = true;
            }

            if (isCloud)
            {
                for (int i = 0; i < Main.maxPlayers; i++)
                {
                    Player player = Main.player[i];
                    if (player.active && !player.dead)
                    {
                        Rectangle playerRect = player.getRect();
                        if (playerRect.Intersects(airRect))
                        {
                            player.GetModPlayer <BuffPlayer>().AddShockedAirBuff(player, projectile.ai[0]);
                        }
                    }
                }

                for (int i = 0; i < Main.maxNPCs; i++)
                {
                    NPC npc = Main.npc[i];
                    if (npc.active && (!npc.friendly || npc.townNPC) && !npc.dontTakeDamage)
                    {
                        Rectangle npcRect = npc.getRect();
                        if (npcRect.Intersects(airRect))
                        {
                            BuffNPC pomNPC = npc.GetGlobalNPC <BuffNPC>();
                            pomNPC.AddShockedAirBuff(npc, projectile.ai[0]);
                        }
                    }
                }

                Lighting.AddLight(targetPosition, emittedLight);
            }
            else
            {
                if (projectile.position != targetPosition)
                {
                    float nextX = Main.rand.NextFloat(boundLeft, boundRight);
                    float diff  = nextX - projectile.position.X;
                    if (Math.Abs(diff) < minVariance.X)
                    {
                        nextX += minVariance.X * 2;
                    }

                    float velocityY = Main.rand.NextFloat(0, varianceHeight) + varianceYOffset;
                    if (velocityY < 0)
                    {
                        if (justWentUp)
                        {
                            velocityY  = minVariance.Y;
                            justWentUp = false;
                        }
                        else if (velocityY > -minVariance.Y)
                        {
                            velocityY = -minVariance.Y;
                        }
                    }
                    else
                    {
                        justWentUp = false;
                    }
                    if (velocityY < 0)
                    {
                        justWentUp = true;
                    }

                    Vector2 position = new Vector2(nextX, projectile.position.Y + velocityY);

                    if ((position.Y > targetPosition.Y ||
                         (targetPosition - position).LengthSquared() < snapRadiusSqr))
                    {
                        position            = targetPosition;
                        projectile.timeLeft = PathOfModifiers.ailmentDuration;
                    }

                    projectile.position = position;

                    nodes.Add(projectile.Center);

                    foreach (var node in nodes)
                    {
                        Lighting.AddLight(node, emittedLight);
                    }
                }
                else
                {
                    Explode();
                }
            }


            return(false);
        }