Ejemplo n.º 1
0
        public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
        {
            //Hardcoded frame coordinate values because using TileObjectData is cancer.
            if (PoMUtil.TryGetTileEntity(i, j, 18, 18, out TileEntity te))
            {
                var mapDevice = (MapDeviceTE)te;

                if (!mapDevice.mapItem.IsAir || mapDevice.timeLeft > 0)
                {
                    int frame = Main.tileFrame[type];
                    if (frame >= activeAnimationFrameCount)
                    {
                        frame = activeAnimationFrameCount - (frame - activeAnimationFrameCount) - 2;
                    }

                    //Map present or portal is open
                    frameYOffset = animationFrameHeight * (activeAnimationFirstFrame + frame);
                }
                else
                {
                    //Map absent
                    frameYOffset = 0;
                }
            }
        }
Ejemplo n.º 2
0
 public override void ProjModifyHitPvp(Item item, Player player, Projectile projectile, Player target, ref float damageMultiplier, ref bool crit)
 {
     if (item == player.HeldItem && PoMUtil.IsLowHP(target))
     {
         damageMultiplier += Type1.GetValue();
     }
 }
Ejemplo n.º 3
0
        public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
        {
            //Hardcoded dimension values because using TileObjectData is cancer.
            var forgePos = new Point16(i - 2, j - 1);

            if (TileEntity.ByPosition.TryGetValue(forgePos, out TileEntity te))
            {
                var forge = (ModifierForgeTE)te;

                if (!forge.modifiedItem.IsAir)
                {
                    var screenDrawOffset = PoMUtil.DrawToScreenOffset();

                    var itemTexture    = Main.itemTexture[forge.modifiedItem.type];
                    var itemWidth      = 24;
                    var itemHeight     = (int)(itemWidth * (itemTexture.Height / (float)itemTexture.Width));
                    var itemScale      = itemWidth / (float)itemTexture.Width;
                    var itemDrawOffset = new Point16((48 - itemWidth) / 2, 5 - itemHeight);

                    var itemPosition = new Vector2(
                        forgePos.X * 16 - Main.screenPosition.X + screenDrawOffset.X + itemDrawOffset.X,
                        forgePos.Y * 16 - Main.screenPosition.Y + screenDrawOffset.Y + itemDrawOffset.Y);
                    spriteBatch.Draw(itemTexture, itemPosition, null, Color.White, 0, Vector2.Zero, itemScale, SpriteEffects.None, 0);
                }
            }
        }
Ejemplo n.º 4
0
        public override void AI()
        {
            if (++projectile.frameCounter >= 4)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= 3)
                {
                    projectile.frame = 0;
                }
            }

            projectile.direction = projectile.spriteDirection = projectile.velocity.X > 0f ? 1 : -1;
            projectile.rotation  = projectile.velocity.ToRotation();
            if (projectile.spriteDirection == -1)
            {
                projectile.rotation += MathHelper.Pi;
            }

            Vector2 position = projectile.position + new Vector2(
                Main.rand.NextFloat(projectile.width),
                Main.rand.NextFloat(projectile.height));

            Dust.NewDustPerfect(
                position,
                ModContent.DustType <Dusts.FireDebris>(),
                Velocity: projectile.velocity * 0.4f,
                Alpha: 100,
                Scale: Main.rand.NextFloat(2f, 3f));;

            if (Main.netMode != NetmodeID.Server)
            {
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (PoMUtil.CanHitPvp(owner, player))
                {
                    if (projectile.getRect().Intersects(player.getRect()))
                    {
                        projectile.Kill();
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    Rectangle rect = projectile.getRect();
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc = Main.npc[i];
                        if (PoMUtil.CanHitNPC(npc))
                        {
                            if (rect.Intersects(npc.getRect()))
                            {
                                projectile.Kill();
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
        {
            //Hardcoded frame coordinate values because using TileObjectData is cancer.
            if (PoMUtil.TryGetTileEntity(i, j, 18, 18, out TileEntity te))
            {
                var forge = (ModifierForgeTE)te;

                if (forge.modifierItem.modItem is ModifierFragment)
                {
                    if (forge.modifiedItem.IsAir)
                    {
                        //Filled but not active
                        frameYOffset = animationFrameHeight;
                    }
                    else
                    {
                        int frame = Main.tileFrame[type];
                        if (frame >= activeAnimationFrameCount)
                        {
                            frame = activeAnimationFrameCount - (frame - activeAnimationFrameCount) - 2;
                        }

                        //Filled and active
                        frameYOffset = animationFrameHeight * (activeAnimationFirstFrame + frame);
                    }
                }
                else
                {
                    //Not filled
                    frameYOffset = 0;
                }
            }
        }
 public override void PostHurt(Item item, Player player, bool pvp, bool quiet, double damage, int hitDirection, bool crit)
 {
     if (AffixItemItem.IsArmorEquipped(item, player) && PoMUtil.IsLowHP(player))
     {
         player.AddBuff(ModContent.BuffType <Adrenaline>(), (int)Math.Round(Type1.GetValue() * 60));
     }
 }
Ejemplo n.º 7
0
        public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
        {
            //Hardcoded dimension values because using TileObjectData is cancer.
            var mapDevicePos = new Point16(i - 3, j - 3);

            if (TileEntity.ByPosition.TryGetValue(mapDevicePos, out TileEntity te))
            {
                var mapDevice = (MapDeviceTE)te;

                if (!mapDevice.mapItem.IsAir)
                {
                    var screenDrawOffset = PoMUtil.DrawToScreenOffset();

                    var itemTexture    = Main.itemTexture[mapDevice.mapItem.type];
                    var itemSize       = 24;
                    var itemScale      = itemSize / (float)itemTexture.Width;
                    var itemDrawOffset = new Point16(20, 16);

                    var itemPosition = new Vector2(
                        mapDevicePos.X * 16 - Main.screenPosition.X + screenDrawOffset.X + itemDrawOffset.X,
                        mapDevicePos.Y * 16 - Main.screenPosition.Y + screenDrawOffset.Y + itemDrawOffset.Y);
                    spriteBatch.Draw(itemTexture, itemPosition, null, Color.White, 0, Vector2.Zero, itemScale, SpriteEffects.None, 0);
                    ((Items.Map)mapDevice.mapItem.modItem).map.DrawIcon(spriteBatch, itemPosition, itemTexture.Size(), 0, itemScale);
                }
            }
        }
Ejemplo n.º 8
0
        public override bool NewRightClick(int i, int j)
        {
            Player player = Main.LocalPlayer;

            Main.mouseRightRelease = false;
            if (player.sign >= 0)
            {
                Main.PlaySound(SoundID.MenuClose);
                player.sign      = -1;
                Main.editSign    = false;
                Main.npcChatText = "";
            }

            //TODO: (Or not to do) Hardcoded frame coordinate values because using TileObjectData is cancer.
            if (PoMUtil.TryGetTileEntity(i, j, 18, 18, out TileEntity te))
            {
                ModifierForgeTE clickedForge = (ModifierForgeTE)te;
                if (ModifierForgeUI.Instance.IsVisible && activeForge == clickedForge)
                {
                    ModifierForgeUI.HideUI();
                }
                else
                {
                    ModifierForgeUI.ShowUI(clickedForge);
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 9
0
 public override void ProjModifyHitNPC(Item item, Player player, Projectile projectile, NPC target, ref float damageMultiplier, ref float knockbackMultiplier, ref bool crit, ref int hitDirection)
 {
     if (player.HeldItem == item)
     {
         float value = Type1.GetValue();
         damageMultiplier += value * PoMUtil.CountBuffs(target.buffType);
     }
 }
Ejemplo n.º 10
0
 public override void ProjModifyHitPvp(Item item, Player player, Projectile projectile, Player target, ref float damageMultiplier, ref bool crit)
 {
     if (player.HeldItem == item)
     {
         float value = Type1.GetValue();
         damageMultiplier += value * PoMUtil.CountBuffs(target.buffType);
     }
 }
        public override bool PreHurt(Item item, Player player, bool pvp, bool quiet, ref float damageMultiplier, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
        {
            if (AffixItemItem.IsArmorEquipped(item, player) && PoMUtil.IsLowHP(player))
            {
                damageMultiplier += Type1.GetValue();
            }

            return(true);
        }
Ejemplo n.º 12
0
        public override void AI()
        {
            Main.player[projectile.owner].heldProj = projectile.whoAmI;

            projectile.frameCounter++;
            if (projectile.frameCounter >= 3)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame > Main.projFrames[projectile.type])
                {
                    projectile.Kill();
                }
            }

            for (int i = 0; i < 5; i++)
            {
                Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <FireDebris>());
            }


            if (Main.netMode != NetmodeID.Server)
            {
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (!hitPlayer && PoMUtil.CanHitPvp(owner, player))
                {
                    Rectangle localRect = player.getRect();
                    if (localRect.Intersects(projectile.Hitbox))
                    {
                        player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage + (int)Math.Round(player.statLife * projectile.ai[0]), player.direction, true);
                        hitPlayer = true;
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc     = Main.npc[i];
                        NPC realNPC = npc.realLife >= 0 ? Main.npc[npc.realLife] : npc;
                        if (!hitNPCs[realNPC.whoAmI] && PoMUtil.CanHitNPC(npc))
                        {
                            Rectangle npcRect = npc.getRect();
                            if (npcRect.Intersects(projectile.Hitbox))
                            {
                                owner.ApplyDamageToNPC(npc, projectile.damage + (int)Math.Round(realNPC.lifeMax * projectile.ai[0] * 0.10f), 1, npc.direction, false);
                                hitNPCs[realNPC.whoAmI] = true;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public override bool NewRightClick(int i, int j)
        {
            Player player = Main.LocalPlayer;

            Main.mouseRightRelease = false;
            if (player.sign >= 0)
            {
                Main.PlaySound(SoundID.MenuClose);
                player.sign      = -1;
                Main.editSign    = false;
                Main.npcChatText = "";
            }

            //TODO: (Or not to do) Hardcoded frame coordinate values because using TileObjectData is cancer.
            if (PoMUtil.TryGetTileEntity(i, j, 18, 18, out TileEntity te))
            {
                MapDeviceTE clickedMD = (MapDeviceTE)te;
                if (clickedMD.timeLeft > 0 && IsTilePortal(clickedMD, i, j))
                {
                    Map map            = ((Items.Map)clickedMD.mapItem.modItem).map;
                    var teleportBounds = new Vector4(
                        map.openMap.dimensions.Left + (map.openMap.dimensions.Width * map.spawnArea.X),
                        map.openMap.dimensions.Top + (map.openMap.dimensions.Height * map.spawnArea.Y),
                        map.openMap.dimensions.Width * map.spawnArea.Z,
                        map.openMap.dimensions.Height * map.spawnArea.W);
                    var newPlayerPos = new Vector2(
                        Main.rand.NextFloat(teleportBounds.X * 16, (teleportBounds.X + teleportBounds.Z - 1) * 16),
                        Main.rand.NextFloat(teleportBounds.Y * 16, (teleportBounds.Y + teleportBounds.W - 2) * 16));
#if DEBUG
                    var oldPos = player.position;
#endif
                    player.Teleport(newPlayerPos, 3);
#if DEBUG
                    player.Teleport(oldPos, 3);
#endif
                }
                else
                {
                    if (MapDeviceUI.Instance.IsVisible && activeMD == clickedMD)
                    {
                        MapDeviceUI.HideUI();
                    }
                    else
                    {
                        MapDeviceUI.ShowUI(clickedMD);
                    }
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 14
0
        void Explode()
        {
            PlayExplodeSound();
            for (int i = 0; i < 30; i++)
            {
                Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(1.0f, 3.5f);
                Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <Dusts.FireDebris>(), velocity.X, velocity.Y, Alpha: 100, Scale: Main.rand.NextFloat(3.5f, 7f));
                velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(1.0f, 2.5f);
                Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1.5f, 3.1f));
            }

            if (Main.netMode != NetmodeID.Server)
            {
                Vector2   projectileCenter = projectile.Center;
                Rectangle hitRect          = new Rectangle(
                    (int)(projectileCenter.X - explosionHalfSize.X),
                    (int)(projectileCenter.Y - explosionHalfSize.Y),
                    (int)explosionHalfSize.X * 2,
                    (int)explosionHalfSize.Y * 2);
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (PoMUtil.CanHitPvp(owner, player))
                {
                    if (player.getRect().Intersects(hitRect))
                    {
                        player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage, player.direction, true);
                        player.GetModPlayer <BuffPlayer>().AddIgnitedBuff(player, (int)projectile.ai[0], PathOfModifiers.ailmentDuration);
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc = Main.npc[i];
                        if (PoMUtil.CanHitNPC(npc))
                        {
                            Rectangle npcRect = npc.getRect();
                            if (npcRect.Intersects(hitRect))
                            {
                                owner.ApplyDamageToNPC(npc, projectile.damage, 1, npc.direction, false);
                                npc.GetGlobalNPC <BuffNPC>().AddIgnitedBuff(npc, (int)projectile.ai[0], PathOfModifiers.ailmentDuration);
                            }
                        }
                    }

                    Projectile.NewProjectile(projectileCenter, Vector2.Zero, ModContent.ProjectileType <BurningAir>(), (int)projectile.ai[0], 0, projectile.owner, 100f);
                }
            }
        }
Ejemplo n.º 15
0
        public override void Kill(int timeLeft)
        {
            PlaySound();
            if (Main.netMode != NetmodeID.Server)
            {
                Rectangle explosionBounds = new Rectangle(
                    (int)(projectile.Center.X - explosionHalfSize.X),
                    (int)(projectile.Center.Y - explosionHalfSize.Y),
                    (int)explosionHalfSize.X * 2,
                    (int)explosionHalfSize.Y * 2);
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (PoMUtil.CanHitPvp(owner, player))
                {
                    if (player.getRect().Intersects(explosionBounds))
                    {
                        player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage, player.direction, true);
                        player.GetModPlayer <BuffPlayer>().AddIgnitedBuff(player, (int)projectile.ai[0], PathOfModifiers.ailmentDuration);
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc = Main.npc[i];
                        if (PoMUtil.CanHitNPC(npc))
                        {
                            Rectangle npcBounds = npc.getRect();
                            if (npcBounds.Intersects(explosionBounds))
                            {
                                owner.ApplyDamageToNPC(npc, projectile.damage, 1, npc.direction, false);
                                npc.GetGlobalNPC <BuffNPC>().AddIgnitedBuff(npc, (int)projectile.ai[0], PathOfModifiers.ailmentDuration);
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < 20; i++)
            {
                Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.6f, 2f);
                Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <Dusts.FireDebris>(), velocity.X, velocity.Y, Alpha: 100, Scale: Main.rand.NextFloat(2f, 4f));
                velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.6f, 1.5f);
                Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, velocity.X, velocity.Y, Scale: Main.rand.NextFloat(1f, 2f));
            }
        }
Ejemplo n.º 16
0
 public override void OnKill()
 {
     if (Main.netMode != NetmodeID.MultiplayerClient)
     {
         if (timeLeft > 0)
         {
             CloseMap();
         }
         else if (!mapItem.IsAir)
         {
             PoMUtil.DropItem(new Vector2(Position.X * 16, Position.Y * 16), mapItem, 2);
         }
     }
     if (Main.netMode != NetmodeID.Server && MapDevice.activeMD == this)
     {
         MapDeviceUI.HideUI();
     }
 }
Ejemplo n.º 17
0
        public override void OnKill()
        {
            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                if (!modifiedItem.IsAir)
                {
                    PoMUtil.DropItem(new Vector2(Position.X * 16, Position.Y * 16), modifiedItem, 2);
                }
                if (!modifierItem.IsAir)
                {
                    PoMUtil.DropItem(new Vector2(Position.X * 16, Position.Y * 16), modifierItem, 2);
                }
            }

            if (Main.netMode != NetmodeID.Server && ModifierForge.activeForge == this)
            {
                ModifierForgeUI.HideUI();
            }
        }
Ejemplo n.º 18
0
        public override void MouseOver(int i, int j)
        {
            if (PoMUtil.TryGetTileEntity(i, j, 18, 18, out TileEntity te))
            {
                var mapDevice = (MapDeviceTE)te;

                Player player = Main.LocalPlayer;
                player.showItemIcon = true;
                if (mapDevice.timeLeft > 0 && IsTilePortal(mapDevice, i, j))
                {
                    player.showItemIcon2 = mod.ItemType("ModifierForge");
                }
                else
                {
                    player.showItemIcon2 = mod.ItemType("MapDevice");
                }
                player.showItemIconText = "";
                player.noThrow          = 2;
            }
        }
Ejemplo n.º 19
0
        bool FindNewTarget()
        {
            Entity closestEntity = null;
            float  minLengthSqr  = float.MaxValue;

            for (int i = 0; i < Main.maxNPCs; i++)
            {
                NPC npc = Main.npc[i];
                if (PoMUtil.CanHitNPC(npc))
                {
                    float lengthSqr = (npc.Center - projectile.position).LengthSquared();
                    if (lengthSqr < maxJumpLengthSqr && lengthSqr < minLengthSqr && !hitEntities.Contains(npc))
                    {
                        closestEntity = npc;
                        minLengthSqr  = lengthSqr;
                    }
                }
            }
            Player owner = Main.player[projectile.owner];

            for (int i = 0; i < Main.maxPlayers; i++)
            {
                Player player = Main.player[i];
                if (PoMUtil.CanHitPvp(owner, player))
                {
                    float lengthSqr = (player.Center - projectile.position).LengthSquared();
                    if (lengthSqr < maxJumpLengthSqr && lengthSqr < minLengthSqr && !hitEntities.Contains(player))
                    {
                        closestEntity = player;
                        minLengthSqr  = lengthSqr;
                    }
                }
            }

            isNPC  = closestEntity is NPC;
            target = closestEntity;

            return(closestEntity != null);
        }
Ejemplo n.º 20
0
        public override void ModifyWeaponDamage(Item item, Player player, ref float add, ref float multiplier, ref float flat)
        {
            float value = Type1.GetValue();

            add += value * PoMUtil.CountBuffs(player.buffType);
        }
Ejemplo n.º 21
0
        public override void AI()
        {
            Texture2D texture     = Main.projectileTexture[projectile.type];
            int       frameHeight = texture.Height / Main.projFrames[projectile.type];

            if (projectile.scale < maxScale)
            {
                projectile.scale += scaleIncrease;
                if (projectile.scale >= maxScale)
                {
                    projectile.scale = maxScale;
                }
                projectile.Size      = size * collisionScale * projectile.scale;
                projectile.position -= new Vector2(texture.Width, frameHeight) * collisionScale * scaleIncrease / 2;
            }
            else
            {
                projectile.Kill();
            }


            projectile.frameCounter++;
            if (projectile.frameCounter >= 5)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame >= 3)
                {
                    projectile.frame = 0;
                }
            }

            for (int i = 0; i < 5; i++)
            {
                Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <ReflectNovaDebris>());
            }


            if (Main.netMode != NetmodeID.Server)
            {
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (!hitPlayer && PoMUtil.CanHitPvp(owner, player))
                {
                    Rectangle localRect = player.getRect();
                    if (localRect.Intersects(projectile.Hitbox))
                    {
                        player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage + (int)Math.Round(player.statLife * projectile.ai[0]), player.direction, true);
                        hitPlayer = true;
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc     = Main.npc[i];
                        NPC realNPC = npc.realLife >= 0 ? Main.npc[npc.realLife] : npc;
                        if (!hitNPCs[realNPC.whoAmI] && PoMUtil.CanHitNPC(npc))
                        {
                            Rectangle npcRect = npc.getRect();
                            if (npcRect.Intersects(projectile.Hitbox))
                            {
                                owner.ApplyDamageToNPC(npc, projectile.damage + (int)Math.Round(realNPC.lifeMax * projectile.ai[0]), 1, npc.direction, false);
                                hitNPCs[realNPC.whoAmI] = true;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
        public override bool PreAI()
        {
            if (!init)
            {
                for (int i = 0; i < 20; i++)
                {
                    Vector2 dustVelocity = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(5f, 10f);
                    Dust.NewDustPerfect(projectile.position, ModContent.DustType <Dusts.LightningDebris>(), dustVelocity, 0, Color.White, Scale: Main.rand.NextFloat(0.8f, 1.6f));
                }
                init = true;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter >= frameTime)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame >= frameNumber.Y)
                {
                    projectile.Kill();
                }
            }

            if (Main.netMode != NetmodeID.Server)
            {
                Rectangle hitRect = new Rectangle(
                    (int)(projectile.position.X - (halfSize.X * collisionScale)),
                    (int)(projectile.position.Y - (halfSize.Y * collisionScale)),
                    (int)(halfSize.X * 2 * collisionScale),
                    (int)(halfSize.Y * 2 * collisionScale));
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (PoMUtil.CanHitPvp(owner, player) && !hitEntities.Contains(player))
                {
                    if (player.getRect().Intersects(hitRect))
                    {
                        player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage, player.direction, true);
                        hitEntities.Add(player);
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc = Main.npc[i];
                        if (PoMUtil.CanHitNPC(npc) && !hitEntities.Contains(npc))
                        {
                            Rectangle npcRect = npc.getRect();
                            if (npcRect.Intersects(hitRect))
                            {
                                owner.ApplyDamageToNPC(npc, projectile.damage, 1, npc.direction, false);
                                hitEntities.Add(npc);
                            }
                        }
                    }
                }
            }

            Lighting.AddLight(projectile.position, emittedLight);

            return(false);
        }
Ejemplo n.º 24
0
        public override void ModifyHitPvp(Item item, Player player, Player target, ref float damageMultiplier, ref bool crit)
        {
            float value = Type1.GetValue();

            damageMultiplier += value * PoMUtil.CountBuffs(target.buffType);
        }
Ejemplo n.º 25
0
        public void Explode()
        {
            for (int i = 1; i < nodes.Count; i++)
            {
                Vector2 position1 = nodes[i - 1];
                Vector2 position2 = nodes[i];
                Vector2 velocity  = position2 - position1;
                Vector2 direction = velocity.SafeNormalize(Vector2.Zero);
                int     howMany   = (int)(velocity.Length() / dustInterval);

                for (int j = 0; j < howMany; j++)
                {
                    Dust.NewDustPerfect(position1 + (direction * dustInterval * j), ModContent.DustType <LightningVapour>(), Velocity: new Vector2(0, Main.rand.NextFloat(-0.3f, -1f)), Scale: Main.rand.NextFloat(0.3f, 0.8f));
                }
            }

            for (int i = 0; i < 40; i++)
            {
                Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(7f, 12f);
                Dust.NewDustPerfect(targetPosition, ModContent.DustType <LightningDebris>(), velocity, Scale: Main.rand.NextFloat(1f, 2f));
            }

            if (Main.netMode != NetmodeID.Server)
            {
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (PoMUtil.CanHitPvp(owner, player))
                {
                    Rectangle localRect = player.getRect();
                    if (localRect.Intersects(boltRect) || localRect.Intersects(airRect))
                    {
                        player.Hurt(PlayerDeathReason.ByPlayer(projectile.owner), projectile.damage, player.direction, true);
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc = Main.npc[i];
                        if (PoMUtil.CanHitNPC(npc))
                        {
                            Rectangle npcRect = npc.getRect();
                            if (npcRect.Intersects(boltRect) || npcRect.Intersects(airRect))
                            {
                                owner.ApplyDamageToNPC(npc, projectile.damage, 1, npc.direction, false);
                            }
                        }
                    }
                }
            }

            int smallerRadius = (int)(airRadius * 0.8f);

            for (int i = 0; i < 24; i++)
            {
                Vector2 position = targetPosition + new Vector2(Main.rand.NextFloat(-smallerRadius, smallerRadius), Main.rand.NextFloat(-smallerRadius, smallerRadius));
                Dust.NewDustPerfect(position, ModContent.DustType <ShockedAir>(), Scale: Main.rand.NextFloat(0.6f, 1.5f));
            }
            isCloud             = true;
            projectile.timeLeft = PathOfModifiers.ailmentDuration * (projectile.extraUpdates + 1);
        }
Ejemplo n.º 26
0
        public override bool PreAI()
        {
            if (!init)
            {
                targetPosition       = projectile.velocity;
                projectile.velocity  = (targetPosition - projectile.Center).SafeNormalize(Vector2.Zero) * 8f;
                projectile.direction = projectile.spriteDirection = projectile.velocity.X > 0f ? 1 : -1;
                projectile.rotation  = projectile.velocity.ToRotation();
                if (projectile.spriteDirection == -1)
                {
                    projectile.rotation += MathHelper.Pi;
                }
                init = true;
            }

            if (++projectile.frameCounter >= 7)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= 2)
                {
                    projectile.frame = 0;
                }
            }

            if (!projectile.tileCollide && (targetPosition - projectile.Center).LengthSquared() < tileCollideRadiusSqr)
            {
                projectile.tileCollide = true;
            }

            Vector2 position = projectile.position + new Vector2(
                Main.rand.NextFloat(projectile.width),
                Main.rand.NextFloat(projectile.height));

            Dust.NewDustPerfect(
                position,
                ModContent.DustType <Dusts.FireDebris>(),
                Velocity: projectile.velocity * 0.1f,
                Alpha: 100,
                Scale: Main.rand.NextFloat(2f, 3f));

            if (Main.netMode != NetmodeID.Server)
            {
                Player owner = Main.player[projectile.owner];

                Player player = Main.LocalPlayer;
                if (PoMUtil.CanHitPvp(owner, player))
                {
                    if (projectile.getRect().Intersects(player.getRect()))
                    {
                        projectile.Kill();
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    Rectangle rect = projectile.getRect();
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        NPC npc = Main.npc[i];
                        if (PoMUtil.CanHitNPC(npc))
                        {
                            if (rect.Intersects(npc.getRect()))
                            {
                                projectile.Kill();
                                break;
                            }
                        }
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 27
0
        bool DetectBounds()
        {
            List <Rectangle> boundss = new List <Rectangle>();
            List <Tuple <Point, bool, bool> > adjacentTiles = new List <Tuple <Point, bool, bool> >();
            Point size           = new Point(4, 4);
            int   length         = size.X * 2 + size.Y * 2 + 4;
            int   x              = 0;
            int   y              = 0;
            bool  lastTileOfType = false;

            for (int i = 0; i < length; i++)
            {
                bool scanHoriz = true;
                bool scanVert  = true;
                if (i == 0)
                {
                }
                else if (i > 0 && i < size.X + 2)
                {
                    x++;
                    scanHoriz = !lastTileOfType;
                }
                else if (i < size.X + 2 + size.Y + 1)
                {
                    y++;
                    scanVert = !lastTileOfType;
                }
                else if (i < size.X + 2 + size.Y + 1 + size.X + 1)
                {
                    x--;
                    scanHoriz = !lastTileOfType;
                }
                else
                {
                    y--;
                    scanVert = !lastTileOfType;
                }

                Point tilePos  = new Point(Position.X - 1 + x, Position.Y - 1 + y);
                Tile  tile     = Main.tile[tilePos.X, tilePos.Y];
                int?  tileType = PoMUtil.GetTileType(tile);
                if (tileType.HasValue && tileType == ModContent.TileType <MapBorder>())
                {
                    adjacentTiles.Add(new Tuple <Point, bool, bool>(tilePos, scanHoriz, scanVert));
                    lastTileOfType = true;
                }
                else
                {
                    lastTileOfType = false;
                }
            }

            foreach (var tilePos in adjacentTiles)
            {
                PoMUtil.FindAdjacentBounds(tilePos.Item1, boundss, tilePos.Item2, tilePos.Item3);
            }

            Rectangle tileBounds         = new Rectangle(Position.X, Position.Y, size.X - 1, size.Y - 1);
            Rectangle tileBoundsInflated = tileBounds;

            tileBoundsInflated.Inflate(2, 2);
            for (int i = boundss.Count - 1; i >= 0; i--)
            {
                Rectangle bound      = boundss[i];
                bool      intersecnt = tileBoundsInflated.X < bound.X + bound.Width && bound.X < tileBoundsInflated.X + tileBoundsInflated.Width && tileBoundsInflated.Y < bound.Y + bound.Height && bound.Y < tileBoundsInflated.Y + tileBoundsInflated.Height;
                if (!bound.Intersects(tileBoundsInflated) || bound.Contains(tileBounds) || MapBorder.InteresectsOrContainsActiveBounds(bound))
                {
                    boundss.RemoveAt(i);
                }
            }

            if (boundss.Count > 0)
            {
                bounds = boundss.Aggregate((b1, b2) => b1.Width * b1.Height > b2.Width * b2.Height ? b1 : b2);

                return(true);
            }
            else
            {
                bounds = null;
                return(false);
            }
        }