示例#1
0
        void ReceiveAddShockedBuffNPC(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.AddShockedBuff(npc, multiplier, dutaionTicks, false);

            if (Main.netMode == NetmodeID.Server)
            {
                ModPacket packet = GetPacket((byte)PacketType.AddShockedBuffNPC);
                packet.Write(npcID);
                packet.Write(multiplier);
                packet.Write(dutaionTicks);
                packet.Send(-1, fromWho);
            }
        }
示例#2
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);
        }