Exemple #1
0
        public override void HoldItem(Player player)
        {
            if (player.noBuilding || player.whoAmI != Main.myPlayer || Shovel <= 0)
            {
                return;
            }

            if (player.position.X / 16f - Player.tileRangeX - item.tileBoost > Player.tileTargetX || (player.position.X + player.width) / 16f + Player.tileRangeX + item.tileBoost - 1f < Player.tileTargetX || player.position.Y / 16f - Player.tileRangeY - item.tileBoost > Player.tileTargetY || (player.position.Y + player.height) / 16f + Player.tileRangeY + item.tileBoost - 2f < Player.tileTargetY)
            {
                return;
            }

            if (item.pick > 0)
            {
                Pick      = item.pick;
                item.pick = 0;
                if (player.selectedItem == 58)
                {
                    Main.mouseItem = item.Clone();
                }
            }
            if (!Main.GamepadDisableCursorItemIcon)
            {
                player.showItemIcon = true;
                Main.ItemIconCacheUpdate(item.type);
            }
            Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY];

            if (tile.active() && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type] &&
                player.toolTime == 0 && player.itemAnimation > 0 && player.controlUseItem)
            {
                PickTile(player, Player.tileTargetX, Player.tileTargetY);
                player.itemTime = (int)(item.useTime * player.pickSpeed / PlayerHooks.TotalUseTimeMultiplier(player, item));
            }
        }
Exemple #2
0
        public override void UseStyle(Player player)
        {
            if (checkWarpLocation(player.GetModPlayer <tsorcRevampPlayer>().warpX, player.GetModPlayer <tsorcRevampPlayer>().warpY))
            {
                if (Main.rand.NextBool())   //ambient dust during use

                // position, width, height, type, speed.X, speed.Y, alpha, color, scale
                {
                    Dust.NewDust(player.position, player.width, player.height, 57, 0f, 0.5f, 150, default(Color), 1f);
                }

                if (player.itemTime == 0)
                {
                    Main.NewText("Picking up where you left off...", 255, 240, 20);
                    player.itemTime = (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
                }
                else if (player.itemTime == (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item)) / 2)
                {
                    for (int dusts = 0; dusts < 70; dusts++)   //dusts on tp (source)
                    {
                        Dust.NewDust(player.position, player.width, player.height, 57, player.velocity.X * 0.5f, (player.velocity.Y * 0.5f) + 0.5f, 150, default(Color), 1.5f);
                    }

                    //destroy grapples
                    player.grappling[0] = -1;
                    player.grapCount    = 0;
                    for (int p = 0; p < 1000; p++)
                    {
                        if (Main.projectile[p].active && Main.projectile[p].owner == player.whoAmI && Main.projectile[p].aiStyle == 7)
                        {
                            Main.projectile[p].Kill();
                        }
                    }

                    player.position.X = (float)(player.GetModPlayer <tsorcRevampPlayer>().warpX * 16) - (float)((float)player.width / 2.0);
                    player.position.Y = (float)(player.GetModPlayer <tsorcRevampPlayer>().warpY * 16) - (float)player.height;
                    player.velocity.X = 0f;
                    player.velocity.Y = 0f;
                    player.fallStart  = (int)player.Center.Y;

                    for (int dusts = 0; dusts < 70; dusts++)   //dusts on tp (destination)
                    {
                        Dust.NewDust(player.position, player.width, player.height, 57, player.velocity.X * 0.5f, (player.velocity.Y * 0.5f) + 0.5f * 0.5f, 150, default(Color), 1.5f);
                    }
                }
            }
            else
            {
                Main.NewText("Your warp location is broken! Please file a bug report!", 255, 240, 20);
            }
        }
Exemple #3
0
        // UseStyle is called each frame that the item is being actively used.
        public override void UseStyle(Player player)
        {
            // Each frame, make some dust
            if (Main.rand.NextBool())
            {
                int dust = Dust.NewDust(player.position, player.width, player.height, 57, 0f, 0f, 0, default(Color), 1.5f);
                Main.dust[dust].noGravity = true;
                Main.dust[dust].velocity *= 3f;
                Main.dust[dust].scale    += 0.6f;
            }
            // This sets up the itemTime correctly.
            if (player.itemTime == 0)
            {
                player.itemTime = (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
            }
            else if (player.itemTime == (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item)) / 2)
            {
                // This code runs once halfway through the useTime of the item. You'll notice with magic mirrors you are still holding the item for a little bit after you've teleported.

                // Make dust 70 times for a cool effect.
                for (int d = 0; d < 70; d++)
                {
                    int dust2 = Dust.NewDust(player.position, player.width, player.height, 57, player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 0, default(Color), 1.5f);
                    Main.dust[dust2].noGravity = true;
                    Main.dust[dust2].velocity *= 3f;
                    Main.dust[dust2].scale    += 0.6f;
                }
                // This code releases all grappling hooks and kills them.
                player.grappling[0] = -1;
                player.grapCount    = 0;
                for (int p = 0; p < 1000; p++)
                {
                    if (Main.projectile[p].active && Main.projectile[p].owner == player.whoAmI && Main.projectile[p].aiStyle == 7)
                    {
                        Main.projectile[p].Kill();
                    }
                }
                // The actual method that moves the player back to bed/spawn.
                player.Spawn();
                // Make dust 70 times for a cool effect. This dust is the dust at the destination.
                for (int d = 0; d < 70; d++)
                {
                    int dust3 = Dust.NewDust(player.position, player.width, player.height, 57, 0f, 0f, 0, default(Color), 1.5f);
                    Main.dust[dust3].noGravity = true;
                    Main.dust[dust3].velocity *= 3f;
                    Main.dust[dust3].scale    += 0.6f;
                }
            }
        }
Exemple #4
0
 public override bool UseItem(Player player)
 {
     foreach (NPC npc in Main.npc)
     {
         if (npc.active && npc.type == ModContent.NPCType <PixieLamp>())
         {
             return(false);
         }
     }
     if (player.itemAnimation > 0 && player.itemTime == 0)
     {
         player.itemTime = (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
         NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType <PixieLamp>(), 0, 0.0f, 0.0f, 0.0f, 0.0f, 255);
     }
     return(base.UseItem(player));
 }
        public override void PostAI(Projectile projectile)
        {
            if (projectile.type == 439)
            {
                Player player = Main.player[projectile.owner];
                Item   item   = player.inventory[player.selectedItem];
                int    time   = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
                projectile.ai[0] += 20f / time - 1;
                projectile.ai[1] += 20f / time - 1;
            }

            if (projectile.type == ProjectileID.VortexBeater)
            {
                Player player = Main.player[projectile.owner];
                Item   item   = player.inventory[player.selectedItem];
                int    time   = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
                projectile.ai[0] += 20f / time - 1;
                projectile.ai[1] -= 20f / time - 1;

                if (projectile.ai[0] >= 40f)
                {
                    projectile.ai[1] -= .1f;
                    if (Main.rand.Next(1, 10) == 1)
                    {
                        projectile.soundDelay--;
                    }
                }
                if (projectile.ai[0] >= 80f)
                {
                    projectile.ai[1] -= .2f;

                    if (Main.rand.Next(1, 10) <= 2)
                    {
                        projectile.soundDelay--;
                    }
                }
                if (projectile.ai[0] >= 120f)
                {
                    projectile.ai[1] -= .3f;
                    if (Main.rand.Next(1, 10) <= 3)
                    {
                        projectile.soundDelay--;
                    }
                }
            }
        }
Exemple #6
0
        private void UnderworldTransportCheck(On.Terraria.Player.orig_ItemCheck orig, Player player, int i)
        {
            Item item = player.inventory[player.selectedItem];

            if (player.controlUseItem && player.controlUseTile && item.type == ItemID.LavaBucket &&
                Main.tile[Player.tileTargetX, Player.tileTargetY].type == TileID.Obsidian &&
                ModWorldHelper.CreateUnderworldTransport(Player.tileTargetX, Player.tileTargetY)) // 最后这个是生成
            {
                Main.PlaySound(SoundID.DoorOpen, (int)player.position.X, (int)player.position.Y, 1, 1f, 0f);
                item.stack--;
                player.PutItemInInventory(ItemID.EmptyBucket, player.selectedItem);
                player.itemTime = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
            }
            else
            {
                orig(player, i);
            }
        }
        public override void UseStyle(Player player)
        {
            if (player.altFunctionUse == 2)
            {
            }
            else
            {
                if (Main.rand.NextBool(2))
                {
                    Dust.NewDust(player.position, player.width, player.height, 10, 0f, 0f, 150, default(Color), 1.1f);
                }

                if (player.itemTime == 0)
                {
                    player.itemTime = (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
                }

                else if (player.itemTime == (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item)) / 2)
                {
                    for (int d = 0; d < 45; d++)
                    {
                        Dust.NewDust(player.position, player.width, player.height, 10, player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 150, default(Color), 1.5f);
                    }

                    player.grappling[0] = -1;
                    player.grapCount    = 0;

                    for (int p = 0; p < 1000; p++)
                    {
                        if (Main.projectile[p].active && Main.projectile[p].owner == player.whoAmI && Main.projectile[p].aiStyle == 7)
                        {
                            Main.projectile[p].Kill();
                        }
                    }

                    player.Spawn();

                    for (int d = 0; d < 45; d++)
                    {
                        Dust.NewDust(player.position, player.width, player.height, 10, 0f, 0f, 150, default(Color), 1.5f);
                    }
                }
            }
        }
        // UseStyle is called each frame that the item is being actively used.
        public override void UseStyle(Player player, Rectangle heldItemFrame)
        {
            // Each frame, make some dust
            if (Main.rand.NextBool())
            {
                Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, Color.White, 1.1f);                 // Makes dust from the player's position and copies the hitbox of which the dust may spawn. Change these arguments if needed.
            }

            // This sets up the itemTime correctly.
            if (player.itemTime == 0)
            {
                player.itemTime = (int)(Item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, Item));
            }
            else if (player.itemTime == (int)(Item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, Item)) / 2)
            {
                // This code runs once halfway through the useTime of the Item. You'll notice with magic mirrors you are still holding the item for a little bit after you've teleported.

                // Make dust 70 times for a cool effect.
                for (int d = 0; d < 70; d++)
                {
                    Dust.NewDust(player.position, player.width, player.height, 15, player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 150, default, 1.5f);
 public override bool UseItem(Item item, Player player)
 {
     if (item.type == mod.ItemType("BlazingHeart") && player.itemAnimation > 0 && player.statLifeMax >= 300 && player.statLifeMax < 400 && player.itemTime == 0)
     {
         player.itemTime      = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
         player.statLifeMax  += 10;
         player.statLifeMax2 += 10;
         player.statLife     += 10;
         if (Main.myPlayer == player.whoAmI)
         {
             player.HealEffect(10, true);
         }
         AchievementsHelper.HandleSpecialEvent(player, 2);
     }
     if (item.type == mod.ItemType("DazzlingHeart") && player.itemAnimation > 0 && player.statLifeMax >= 400 && player.statLifeMax < 450 && player.itemTime == 0)
     {
         player.itemTime      = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
         player.statLifeMax  += 5;
         player.statLifeMax2 += 5;
         player.statLife     += 5;
         if (Main.myPlayer == player.whoAmI)
         {
             player.HealEffect(5, true);
         }
         AchievementsHelper.HandleSpecialEvent(player, 2);
     }
     if (item.type == 1291 && player.itemAnimation > 0 && player.statLifeMax >= 450 && player.statLifeMax < 500 && player.itemTime == 0)
     {
         player.itemTime      = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
         player.statLifeMax  += 5;
         player.statLifeMax2 += 5;
         player.statLife     += 5;
         if (Main.myPlayer == player.whoAmI)
         {
             player.HealEffect(5, true);
         }
         AchievementsHelper.HandleSpecialEvent(player, 2);
     }
     return(base.UseItem(item, player));
 }
Exemple #10
0
        public override void UseStyle(Player player)
        {
            if (Main.rand.NextBool(2))
            {
                Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.1f);
            }
            // This sets up the itemTime correctly.
            if (player.itemTime == 0)
            {
                player.itemTime = (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
            }
            else if (player.itemTime == (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item)) / 2)
            {
                // This code runs once halfway through the useTime of the item. You'll notice with magic mirrors you are still holding the item for a little bit after you've teleported.

                for (int d = 0; d < 70; d++)
                {
                    Dust.NewDust(player.position, player.width, player.height, 15, player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 150, default(Color), 1.5f);
                }
                // This code releases all grappling hooks and kills them.
                player.grappling[0] = -1;
                player.grapCount    = 0;
                for (int p = 0; p < 1000; p++)
                {
                    if (Main.projectile[p].active && Main.projectile[p].owner == player.whoAmI && Main.projectile[p].aiStyle == 7)
                    {
                        Main.projectile[p].Kill();
                    }
                }
                // The actual method that moves the player back to bed/spawn.
                player.Spawn();
                for (int d = 0; d < 70; d++)
                {
                    Dust.NewDust(player.position, player.width, player.height, 15, 0f, 0f, 150, default(Color), 1.5f);
                }
            }
        }
Exemple #11
0
 public override void UseStyle(Item item, Player player)
 {
     if (player.GetModPlayer <HalfbornPlayer>().demonForm)
     {
         if (player.HeldItem.useStyle != 1)
         {
             HalfbornPlayer.modifyPlayerItemLocation(player, -5, 10);
         }
         else
         {
             if (player.itemTime == 0)
             {
                 // player.itemTime = (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
             }
             else if (player.itemTime == (int)(item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item)) / 3)
             {
                 if (player.bodyFrame.Y >= 1 * player.bodyFrame.Height && player.bodyFrame.Y <= 3 * player.bodyFrame.Height)
                 {
                     HalfbornPlayer.modifyPlayerItemLocation(player, -12, -14);
                 }
             }
         }
     }
 }
Exemple #12
0
 public override bool UseItem(Item item, Player player)
 {
     if (ItemID.Sets.ExtractinatorMode[player.inventory[player.selectedItem].type] >= 0 && Main.tile[Player.tileTargetX, Player.tileTargetY].active() && Main.tile[Player.tileTargetX, Player.tileTargetY].type == mod.TileType("UniversalCrafter"))
     {
         if (player.position.X / 16f - Player.tileRangeX - player.inventory[player.selectedItem].tileBoost - player.blockRange <= Player.tileTargetX && (player.position.X + player.width) / 16f + Player.tileRangeX + player.inventory[player.selectedItem].tileBoost - 1f + player.blockRange >= Player.tileTargetX && player.position.Y / 16f - Player.tileRangeY - player.inventory[player.selectedItem].tileBoost - player.blockRange <= Player.tileTargetY && (player.position.Y + player.height) / 16f + Player.tileRangeY + player.inventory[player.selectedItem].tileBoost - 2f + player.blockRange >= Player.tileTargetY && player.itemTime == 0 && player.itemAnimation > 0 && player.controlUseItem)
         {
             player.itemTime = (int)(player.inventory[player.selectedItem].useTime / PlayerHooks.TotalUseTimeMultiplier(player, player.inventory[player.selectedItem]));
             Main.PlaySound(7, -1, -1, 1, 1f, 0f);
             int extractType = ItemID.Sets.ExtractinatorMode[player.inventory[player.selectedItem].type];
             ExtractinatorUse(extractType);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int   num75 = item.shoot;
            float num76 = item.shootSpeed;

            if (item.melee && num75 != 25 && num75 != 26 && num75 != 35)
            {
                num76 /= player.meleeSpeed;
            }
            bool  flag10 = false;
            int   num77  = item.damage;
            float num78  = item.knockBack;

            num78 = player.GetWeaponKnockback(item, num78);
            if (num75 == 228)
            {
                num78 = 0f;
            }
            player.itemTime = (int)((float)item.useTime / PlayerHooks.TotalUseTimeMultiplier(player, item));
            Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
            bool    flag12  = true;
            int     type5   = item.type;
            Vector2 value   = Vector2.UnitX.RotatedBy((double)player.fullRotation, default(Vector2));
            Vector2 vector3 = Main.MouseWorld - vector2;
            Vector2 vector4 = player.itemRotation.ToRotationVector2() * (float)player.direction;

            if (vector3 != Vector2.Zero)
            {
                vector3.Normalize();
            }
            float num81 = Vector2.Dot(value, vector3);

            if (flag12)
            {
                if (num81 > 0f)
                {
                    player.ChangeDir(1);
                }
                else
                {
                    player.ChangeDir(-1);
                }
            }
            if (num75 == 9)
            {
                vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)Main.rand.Next(201) * -(float)player.direction + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f);
                num78   = 0f;
                num77  *= 2;
            }
            float num82 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
            float num83 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;

            if (player.gravDir == -1f)
            {
                num83 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y;
            }
            float num84 = (float)Math.Sqrt((double)(num82 * num82 + num83 * num83));
            float num85 = num84;

            if ((float.IsNaN(num82) && float.IsNaN(num83)) || (num82 == 0f && num83 == 0f))
            {
                num82 = (float)player.direction;
                num83 = 0f;
                num84 = num76;
            }
            else
            {
                num84 = num76 / num84;
            }
            num82 *= num84;
            num83 *= num84;
            if (num75 == 12)
            {
                vector2.X += num82 * 3f;
                vector2.Y += num83 * 3f;
            }
            if (item.useStyle == 5)
            {
                player.itemRotation = (float)Math.Atan2((double)(num83 * (float)player.direction), (double)(num82 * (float)player.direction)) - player.fullRotation;
                NetMessage.SendData(13, -1, -1, null, player.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                NetMessage.SendData(41, -1, -1, null, player.whoAmI, 0f, 0f, 0f, 0, 0, 0);
            }
            if (num75 == 17)
            {
                vector2.X = (float)Main.mouseX + Main.screenPosition.X;
                vector2.Y = (float)Main.mouseY + Main.screenPosition.Y;
                if (player.gravDir == -1f)
                {
                    vector2.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
                }
            }
            if (num75 == 76)
            {
                num75 += Main.rand.Next(3);
                num85 /= (float)(Main.screenHeight / 2);
                if (num85 > 1f)
                {
                    num85 = 1f;
                }
                float num87 = num82 + (float)Main.rand.Next(-40, 41) * 0.01f;
                float num88 = num83 + (float)Main.rand.Next(-40, 41) * 0.01f;
                num87 *= num85 + 0.25f;
                num88 *= num85 + 0.25f;
                int num89 = Projectile.NewProjectile(vector2.X, vector2.Y, num87, num88, num75, num77, num78, Main.myPlayer, 0f, 0f);
                Main.projectile[num89].ai[1] = 1f;
                num85 = num85 * 2f - 1f;
                if (num85 < -1f)
                {
                    num85 = -1f;
                }
                if (num85 > 1f)
                {
                    num85 = 1f;
                }
                Main.projectile[num89].ai[0] = num85;
                NetMessage.SendData(27, -1, -1, null, num89, 0f, 0f, 0f, 0, 0, 0);
            }
            float   ai4      = Main.rand.NextFloat() * num76 * 0.75f * (float)player.direction;
            Vector2 velocity = new Vector2(num82, num83);

            Projectile.NewProjectile(vector2, velocity, num75, num77, num78, Main.myPlayer, ai4, 0f);
            return(false);
        }
 internal void FireMossPlacement(Player player)
 {
     if (player.HeldItem.type == mod.ItemType <FireMossSeeds>())
     {
         if (player.toolTime == 0 && player.controlUseItem)
         {
             Item item = player.HeldItem;
             if (player.whoAmI == Main.myPlayer &&
                 FireMossSeeds.ValidTarget(Player.tileTargetX, Player.tileTargetY))
             {
                 if (WorldGen.PlaceTile(Player.tileTargetX, Player.tileTargetY, item.createTile, false, true, player.whoAmI))
                 {
                     player.ConsumeItem(mod.ItemType <FireMossSeeds>());
                     NetMessage.SendData(17, -1, -1, null, 1,
                                         (float)Player.tileTargetX, (float)Player.tileTargetY,
                                         (float)item.createTile, 0);
                     player.toolTime = (int)((float)item.useTime * player.tileSpeed / PlayerHooks.TotalUseTimeMultiplier(player, item));
                     player.itemTime = player.toolTime;
                 }
             }
         }
     }
 }
Exemple #15
0
        public override bool UseItem(Item item, Player player)
        {
            if (player.GetModPlayer <AAPlayer>().StripeManOre)
            {
                int tileTargetX = (int)((Main.mouseX + Main.screenPosition.X) / 16f);
                int tileTargetY = (int)((Main.mouseY + Main.screenPosition.Y) / 16f);
                if (Main.tile[tileTargetX, tileTargetY].active() && Main.tile[tileTargetX, tileTargetY].type == 219 && item.createTile > 0 && (Main.tileSand[item.createTile] || TileID.Sets.Conversion.Sand[item.createTile]))
                {
                    bool flag = player.position.X / 16f - Player.tileRangeX - player.inventory[player.selectedItem].tileBoost - player.blockRange <= Player.tileTargetX && (player.position.X + player.width) / 16f + Player.tileRangeX + player.inventory[player.selectedItem].tileBoost - 1f + player.blockRange >= Player.tileTargetX && player.position.Y / 16f - Player.tileRangeY - player.inventory[player.selectedItem].tileBoost - player.blockRange <= Player.tileTargetY && (player.position.Y + player.height) / 16f + Player.tileRangeY + player.inventory[player.selectedItem].tileBoost - 2f + player.blockRange >= Player.tileTargetY;
                    if (flag && player.itemTime == 0 && player.itemAnimation > 0 && player.controlUseItem)
                    {
                        player.itemTime = (int)(player.inventory[player.selectedItem].useTime / PlayerHooks.TotalUseTimeMultiplier(player, player.inventory[player.selectedItem]));
                        Main.PlaySound(7, -1, -1, 1, 1f, 0f);
                        ExtractinatorUse2(item.type);
                        for (int i = 0; i < 58; i++)
                        {
                            if (player.inventory[i].type == item.type && player.inventory[i].stack > 0)
                            {
                                player.inventory[i].stack--;
                                if (player.inventory[i].stack <= 0)
                                {
                                    player.inventory[i].SetDefaults(0, false);
                                }
                                break;
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemple #16
0
 public override bool UseItem(Item item, Player player)
 {
     if (ItemID.Sets.ExtractinatorMode[player.inventory[player.selectedItem].type] >= 0 && Main.tile[Player.tileTargetX, Player.tileTargetY].active() && Main.tile[Player.tileTargetX, Player.tileTargetY].type == ModContent.TileType <UniversalCrafterTile>() && player.whoAmI == Main.myPlayer)
     {
         if (player.position.X / 16f - Player.tileRangeX - player.inventory[player.selectedItem].tileBoost - player.blockRange <= Player.tileTargetX && (player.position.X + player.width) / 16f + Player.tileRangeX + player.inventory[player.selectedItem].tileBoost - 1f + player.blockRange >= Player.tileTargetX && player.position.Y / 16f - Player.tileRangeY - player.inventory[player.selectedItem].tileBoost - player.blockRange <= Player.tileTargetY && (player.position.Y + player.height) / 16f + Player.tileRangeY + player.inventory[player.selectedItem].tileBoost - 2f + player.blockRange >= Player.tileTargetY && player.itemTime == 0 && player.itemAnimation > 0 && player.controlUseItem)
         {
             player.itemTime = (int)(player.inventory[player.selectedItem].useTime / PlayerHooks.TotalUseTimeMultiplier(player, player.inventory[player.selectedItem]));
             Main.PlaySound(SoundID.Grab, -1, -1, 1, 1f, 0f);
             int extractType = ItemID.Sets.ExtractinatorMode[player.inventory[player.selectedItem].type];
             typeof(Player).GetMethod("ExtractinatorUse", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).Invoke(player, new object[] { extractType });
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
        /// <summary> Maing logic for using the renovator. </summary>
        private bool UseRenovator(Item item, byte paintColour)
        {
            // Check to consume the appropriate item
            if (!CheckUseTile(item))
            {
                return(false);                     // Can't even use the item anyway
            }
            Point?target = null;
            byte  mode   = 255;

            mode   = RenovatorUseItemMode(item, mode);
            target = FindTileTarget(mode, paintColour);

            // nothing
            if (target == null)
            {
                return(false);
            }

            // Place twice as fast
            float newItemTime = (player.HeldItem.useTime / PlayerHooks.TotalUseTimeMultiplier(player, player.HeldItem));

            if (mode == 1)
            {
                player.itemTime = (int)(newItemTime * (player.wallSpeed) * 0.5f);
            }
            else
            {
                player.itemTime = (int)(newItemTime * (player.tileSpeed) * 0.5f);
            }
            player.itemTime = Math.Max(1, player.itemTime);

            Main.PlaySound(7, -1, -1, 1, 1f, 0f);

            int tileX = target.Value.X;
            int tileY = target.Value.Y;

            if (item.createTile >= 0)
            {
                byte slope = Main.tile[tileX, tileY].slope();
                bool half  = Main.tile[tileX, tileY].halfBrick();

                WorldGen.PlaceTile(tileX, tileY, item.createTile, false, true, player.whoAmI, item.placeStyle);
                WorldGen.paintTile(tileX, tileY, 0, true);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 1, tileX, tileY, (float)item.createTile, item.placeStyle);
                }

                WorldGen.SlopeTile(tileX, tileY, slope);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 14, tileX, tileY, 0f);
                }

                if (half)
                {
                    WorldGen.PoundTile(tileX, tileY);
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(17, -1, -1, null, 7, tileX, tileY, 1f);
                    }
                }
            }
            else
            {
                Main.tile[tileX, tileY].wall = 0;
                WorldGen.PlaceWall(tileX, tileY, item.createWall, false);
                WorldGen.paintWall(tileX, tileY, 0, true);
                WallLoader.PlaceInWorld(tileX, tileY, item);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 3, tileX, tileY, (float)item.createWall);
                }
            }

            // Consume the item
            ConsumeTile(item);
            return(true);
        }