public static bool canMineTile(int x, int y, int pickPower)
        {
            int  dmg  = 0;
            Tile tile = Main.tile[x, y];

            TileLoader.PickPowerCheck(tile, pickPower, ref dmg);
            if (dmg > 0)
            {
                return(true);
            }
            if (Main.tileNoFail[(int)tile.type])
            {
                return(true);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                return(false);
            }
            if (tile.type == 37 && pickPower < 50)
            {
                return(false);
            }
            if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
            {
                return(false);
            }
            if ((tile.type == 25 || tile.type == 56 || tile.type == 58 || tile.type == 203 ||
                 tile.type == 117 || tile.type == 404 || Main.tileDungeon[(int)tile.type]) && pickPower < 65)
            {
                return(false);
            }
            if ((tile.type == 107 || tile.type == 221) && pickPower < 100)
            {
                return(false);
            }
            if ((tile.type == 108 || tile.type == 222) && pickPower < 110)
            {
                return(false);
            }
            if ((tile.type == 111 || tile.type == 223) && pickPower < 150)
            {
                return(false);
            }
            if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        private bool canPick(int x, int y, int pickPower)
        {
            Tile tile = Main.tile[x, y];

            if ((tile.type == 211 && pickPower <= 200) ||
                ((tile.type == 25 || tile.type == 203) && pickPower <= 65) ||
                (tile.type == 117 && pickPower <= 65) ||
                (tile.type == 37 && pickPower <= 50) ||
                (tile.type == 404 && pickPower <= 65)
//				|| ((tile.type == 22 || tile.type == 204) && (double)AY[index] > Main.worldSurface && pickPower < 55)
                || (tile.type == 56 && pickPower <= 65) ||
                (tile.type == 58 && pickPower <= 65) ||
                ((tile.type == 226 || tile.type == 237) && pickPower <= 210) ||
                (Main.tileDungeon[tile.type] && pickPower <= 65)
//				|| ((double)AX[index] < (double)Main.maxTilesX * 0.35 || (double)AX[index] > (double)Main.maxTilesX * 0.65)
                || (tile.type == 107 && pickPower <= 100) ||
                (tile.type == 108 && pickPower <= 110) ||
                (tile.type == 111 && pickPower <= 150) ||
                (tile.type == 221 && pickPower <= 100) ||
                (tile.type == 222 && pickPower <= 110) ||
                (tile.type == 223 && pickPower <= 150)
                )
            {
                return(false);
            }

            int check = 1;

            TileLoader.PickPowerCheck(tile, pickPower, ref check);
            if (check == 0)
            {
                return(false);
            }

            Tile tileUpper = Main.tile[x, y - 1];

            if (
                tileUpper.type == TileID.Containers ||
                tileUpper.type == TileID.DemonAltar
                )
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public override bool checkCanMove(int index, int dX, int dY, int pickPower)
        {
            Tile tile = Main.tile[AX[index], AY[index]];

            if
            (
                (
                    !petDictionaryA.ContainsKey(AX[index] + dX) ||
                    !petDictionaryA[AX[index] + dX].ContainsKey(AY[index] + dY)
                ) &&
                AX[index] + dX < Main.Map.MaxWidth &&
                AX[index] + dX > 1 &&
                AY[index] + dY < Main.Map.MaxHeight &&
                AY[index] + dY > 1
                //&& Main.Map.IsRevealed(AX[index] + dX,AY[index] + dY)
                //&&
                //(
                //	tile == null
                //	||
                //	(
                //		tile != null
                //		&&
                //		(
                //			!tile.active()
                //			||
                //			(
                //				tile.active()
                //				&&
                //				(
                //					oreTile.ContainsKey(tile.type)
                //					&& oreTile[tile.type]
                //				)
                //			)
                //		)
                //	)
                //)
            )
            {
            }
            else
            {
                return(false);
            }

            if ((tile.type == 211 && pickPower <= 200) ||
                ((tile.type == 25 || tile.type == 203) && pickPower <= 65) ||
                (tile.type == 117 && pickPower <= 65) ||
                (tile.type == 37 && pickPower <= 50) ||
                (tile.type == 404 && pickPower <= 65)
//				|| ((tile.type == 22 || tile.type == 204) && (double)AY[index] > Main.worldSurface && pickPower < 55)
                || (tile.type == 56 && pickPower <= 65) ||
                (tile.type == 58 && pickPower <= 65) ||
                ((tile.type == 226 || tile.type == 237) && pickPower <= 210) ||
                (Main.tileDungeon[tile.type] && pickPower <= 65)
//				|| ((double)AX[index] < (double)Main.maxTilesX * 0.35 || (double)AX[index] > (double)Main.maxTilesX * 0.65)
                || (tile.type == 107 && pickPower <= 100) ||
                (tile.type == 108 && pickPower <= 110) ||
                (tile.type == 111 && pickPower <= 150) ||
                (tile.type == 221 && pickPower <= 100) ||
                (tile.type == 222 && pickPower <= 110) ||
                (tile.type == 223 && pickPower <= 150)
                )
            {
                return(false);
            }

            int check = 1;

            TileLoader.PickPowerCheck(tile, pickPower, ref check);
            if (check == 0)
            {
                return(false);
            }

            return(true);
        }
예제 #4
0
        /// <summary>
        /// Gets the damage scale (amount to multiply a pickaxe hit by) of a given tile.
        /// </summary>
        /// <param name="tile"></param>
        /// <param name="baseDamage">Amount of damage (e.g. pickaxe power) applied to the tile.</param>
        /// <param name="isAbsolute">Returns indication that tile will guarantee destruction on this hit.</param>
        /// <returns></returns>
        public static float GetDamageScale(Tile tile, float baseDamage, out bool isAbsolute)
        {
            isAbsolute = false;
            float scale = 0f;

            if (Main.tileNoFail[(int)tile.type])
            {
                isAbsolute = true;
            }
            if (Main.tileDungeon[(int)tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                scale = 1f / 2f;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                scale = 1f / 4f;
            }
            else if (tile.type == 226)
            {
                scale = 1f / 4f;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                scale = 1f / 2f;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                scale = 1f / 3f;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                scale = 1f / 4f;
            }
            else if (tile.type == 211)
            {
                scale = 1f / 5f;
            }
            else
            {
                int moddedDamage = 0;
                TileLoader.MineDamage((int)baseDamage, ref moddedDamage);

                scale = (float)moddedDamage / baseDamage;
            }

            if (tile.type == 211 && baseDamage < 200)
            {
                scale = 0f;
            }
            if ((tile.type == 25 || tile.type == 203) && baseDamage < 65)
            {
                scale = 0f;
            }
            else if (tile.type == 117 && baseDamage < 65)
            {
                scale = 0f;
            }
            else if (tile.type == 37 && baseDamage < 50)
            {
                scale = 0f;
            }
            else if (tile.type == 404 && baseDamage < 65)
            {
                scale = 0f;
            }
            else if ((tile.type == 22 || tile.type == 204) && /*(double)y > Main.worldSurface &&*/ baseDamage < 55)
            {
                scale = 0f;
            }
            else if (tile.type == 56 && baseDamage < 65)
            {
                scale = 0f;
            }
            else if (tile.type == 58 && baseDamage < 65)
            {
                scale = 0f;
            }
            else if ((tile.type == 226 || tile.type == 237) && baseDamage < 210)
            {
                scale = 0f;
            }
            else if (Main.tileDungeon[(int)tile.type] && baseDamage < 65)
            {
                //if( (double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65 ) {
                //	scale = 0f;
                //}
                scale = 0f;
            }
            else if (tile.type == 107 && baseDamage < 100)
            {
                scale = 0f;
            }
            else if (tile.type == 108 && baseDamage < 110)
            {
                scale = 0f;
            }
            else if (tile.type == 111 && baseDamage < 150)
            {
                scale = 0f;
            }
            else if (tile.type == 221 && baseDamage < 100)
            {
                scale = 0f;
            }
            else if (tile.type == 222 && baseDamage < 110)
            {
                scale = 0f;
            }
            else if (tile.type == 223 && baseDamage < 150)
            {
                scale = 0f;
            }
            else
            {
                if (TileLoader.GetTile(tile.type) != null)
                {
                    int moddedDamage = 0;
                    TileLoader.PickPowerCheck(tile, (int)baseDamage, ref moddedDamage);

                    scale = (float)moddedDamage / baseDamage;
                }
                else
                {
                    scale = 1f;
                }
            }

            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                scale = 1f;
            }
            if (tile.type == 165 || Main.tileRope[(int)tile.type] || tile.type == 199 || Main.tileMoss[(int)tile.type])
            {
                isAbsolute = true;
            }

            return(scale);
            //if( this.hitTile.AddDamage( tileId, scale, false ) >= 100 && ( tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[(int)tile.type] ) ) {
            //	scale = 0f;
            //}
            //if( tile.type == 128 || tile.type == 269 ) {
            //	if( tile.frameX == 18 || tile.frameX == 54 ) {
            //		x--;
            //		tile = Main.tile[x, y];
            //		this.hitTile.UpdatePosition( tileId, x, y );
            //	}
            //	if( tile.frameX >= 100 ) {
            //		scale = 0f;
            //		Main.blockMouse = true;
            //	}
            //}
            //if( tile.type == 334 ) {
            //	if( tile.frameY == 0 ) {
            //		y++;
            //		tile = Main.tile[x, y];
            //		this.hitTile.UpdatePosition( tileId, x, y );
            //	}
            //	if( tile.frameY == 36 ) {
            //		y--;
            //		tile = Main.tile[x, y];
            //		this.hitTile.UpdatePosition( tileId, x, y );
            //	}
            //	int i = (int)tile.frameX;
            //	bool flag = i >= 5000;
            //	bool flag2 = false;
            //	if( !flag ) {
            //		int num2 = i / 18;
            //		num2 %= 3;
            //		x -= num2;
            //		tile = Main.tile[x, y];
            //		if( tile.frameX >= 5000 ) {
            //			flag = true;
            //		}
            //	}
            //	if( flag ) {
            //		i = (int)tile.frameX;
            //		int num3 = 0;
            //		while( i >= 5000 ) {
            //			i -= 5000;
            //			num3++;
            //		}
            //		if( num3 != 0 ) {
            //			flag2 = true;
            //		}
            //	}
            //	if( flag2 ) {
            //		scale = 0f;
            //		Main.blockMouse = true;
            //	}
            //}
        }
예제 #5
0
        private bool checkCanPick(int index, int pickPower)
        {
            if (index >= _AX.Count || index >= _AY.Count || index <= -1)
            {
                return(false);
            }

            Tile tile      = Main.tile[_AX[index], _AY[index]];
            Tile tileUpper = Main.tile[_AX[index], _AY[index] - 1];

            if (tile == null)
            {
                return(false);
            }

            //_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
            if ((tile.type == 211 && pickPower <= 200) ||
                ((tile.type == 25 || tile.type == 203) && pickPower <= 65) ||
                (tile.type == 117 && pickPower <= 65) ||
                (tile.type == 37 && pickPower <= 50) ||
                (tile.type == 404 && pickPower <= 65)
//				|| ((tile.type == 22 || tile.type == 204) && (double)_AY[index] > Main.worldSurface && pickPower < 55)
                || (tile.type == 56 && pickPower <= 65) ||
                (tile.type == 58 && pickPower <= 65) ||
                ((tile.type == 226 || tile.type == 237) && pickPower <= 210) ||
                (Main.tileDungeon[tile.type] && pickPower <= 65)
//				|| ((double)_AX[index] < (double)Main.maxTilesX * 0.35 || (double)_AX[index] > (double)Main.maxTilesX * 0.65)
                || (tile.type == 107 && pickPower <= 100) ||
                (tile.type == 108 && pickPower <= 110) ||
                (tile.type == 111 && pickPower <= 150) ||
                (tile.type == 221 && pickPower <= 100) ||
                (tile.type == 222 && pickPower <= 110) ||
                (tile.type == 223 && pickPower <= 150)
                )
            {
                return(false);
            }

            int check = 1;

            TileLoader.PickPowerCheck(tile, pickPower, ref check);
            if (check == 0)
            {
                return(false);
            }
            //_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

            if (
                tile.active() &&
                _oreTile.ContainsKey(tile.type)
                &&
                (
                    tileUpper == null
                    ||
                    (
                        tileUpper.type != TileID.Containers &&
                        tileUpper.type != TileID.DemonAltar
                    )
                )
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        /// <summary>
        /// <para>Hit tile with pick without needing a player.</para>
        /// <para>Equivalent to if an actual player hit it.</para>
        /// <para>Modified from Terraria's Player.PickTile code.</para>
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="pickPower"></param>
        public static void PickTile(int x, int y, int pickPower)
        {
            int  damage = 0;
            int  tileId = MoreMechanisms.globalHitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[tile.type])
            {
                damage = 100;
            }

            if (Main.tileDungeon[tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                damage += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                damage += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                damage += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                damage += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref damage);
            }

            if (tile.type == 211 && pickPower < 200)
            {
                damage = 0;
            }

            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                damage = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                damage = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                damage = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                damage = 0;
            }
            else
            {
                if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
                {
                    damage = 0;
                }
                else if (tile.type == 56 && pickPower < 65)
                {
                    damage = 0;
                }
                else if (tile.type == 58 && pickPower < 65)
                {
                    damage = 0;
                }
                else
                {
                    if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
                    {
                        damage = 0;
                    }
                    else if (Main.tileDungeon[tile.type] && pickPower < 65)
                    {
                        if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                        {
                            damage = 0;
                        }
                    }
                    else if (tile.type == 107 && pickPower < 100)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 108 && pickPower < 110)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 111 && pickPower < 150)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 221 && pickPower < 100)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 222 && pickPower < 110)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 223 && pickPower < 150)
                    {
                        damage = 0;
                    }
                    else
                    {
                        TileLoader.PickPowerCheck(tile, pickPower, ref damage);
                    }
                }
            }

            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                damage += pickPower;
            }

            if (tile.type == 165 || Main.tileRope[tile.type] || tile.type == 199 || Main.tileMoss[tile.type])
            {
                damage = 100;
            }

            if (MoreMechanisms.globalHitTile.AddDamage(tileId, damage, false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[tile.type]))
            {
                damage = 0;
            }

            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    MoreMechanisms.globalHitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    damage          = 0;
                    Main.blockMouse = true;
                }
            }

            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    MoreMechanisms.globalHitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    MoreMechanisms.globalHitTile.UpdatePosition(tileId, x, y);
                }
                int  j      = tile.frameX;
                bool flag   = j >= 5000;
                bool cancel = false;
                if (!flag)
                {
                    int num5 = j / 18;
                    num5 %= 3;
                    x    -= num5;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag = true;
                    }
                }

                if (flag)
                {
                    j = tile.frameX;
                    int num3 = 0;
                    while (j >= 5000)
                    {
                        j -= 5000;
                        num3++;
                    }
                    if (num3 != 0)
                    {
                        cancel = true;
                    }
                }

                if (cancel)
                {
                    damage          = 0;
                    Main.blockMouse = true;
                }
            }

            if (!WorldGen.CanKillTile(x, y))
            {
                damage = 0;
            }

            if (MoreMechanisms.globalHitTile.AddDamage(tileId, damage, true) >= 100)
            {
                //AchievementsHelper.CurrentlyMining = true;
                MoreMechanisms.globalHitTile.Clear(tileId);
                if (Main.netMode == 1 && Main.tileContainer[Main.tile[x, y].type])
                {
                    WorldGen.KillTile(x, y, true, false, false);
                    NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 1f, 0, 0, 0);
                    if (Main.tile[x, y].type == 21 || (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type]))
                    {
                        NetMessage.SendData(34, -1, -1, null, 1, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (Main.tile[x, y].type == 467)
                    {
                        NetMessage.SendData(34, -1, -1, null, 5, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 3, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type])
                    {
                        NetMessage.SendData(34, -1, -1, null, 101, (float)x, (float)y, 0f, 0, Main.tile[x, y].type, 0);
                    }
                    if (Main.tile[x, y].type >= 470 && TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 103, (float)x, (float)y, 0f, 0, Main.tile[x, y].type, 0);
                    }
                }
                else
                {
                    int  num2 = y;
                    bool num6 = Main.tile[x, num2].active();
                    WorldGen.KillTile(x, num2, false, false, false);
                    if (num6 && !Main.tile[x, num2].active())
                    {
                        //AchievementsHelper.HandleMining();
                    }
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)num2, 0f, 0, 0, 0);
                    }
                }
                //AchievementsHelper.CurrentlyMining = false;
            }
            else
            {
                WorldGen.KillTile(x, y, true, false, false);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 1f, 0, 0, 0);
                }
            }
            if (damage != 0)
            {
                MoreMechanisms.globalHitTile.Prune();
            }
        }
예제 #7
0
        /// <summary>
        /// <para>Returns true if the pickPower provided could mine the tile.</para>
        /// <para>Modified from Terraria's Player.PickTile code.</para>
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="pickPower"></param>
        public static bool CanPickTile(int x, int y, int pickPower)
        {
            int damage = 0;
            int tileId = MoreMechanisms.globalHitTile.HitObject(x, y, 1);

            Tile tile = Main.tile[x, y];

            if (Main.tileNoFail[tile.type])
            {
                damage = 100;
            }

            if (Main.tileDungeon[tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                damage += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                damage += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                damage += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                damage += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref damage);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                damage = 0;
            }
            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                damage = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                damage = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                damage = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                damage = 0;
            }
            else
            {
                if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
                {
                    damage = 0;
                }
                else if (tile.type == 56 && pickPower < 65)
                {
                    damage = 0;
                }
                else if (tile.type == 58 && pickPower < 65)
                {
                    damage = 0;
                }
                else
                {
                    if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
                    {
                        damage = 0;
                    }
                    else if (Main.tileDungeon[tile.type] && pickPower < 65)
                    {
                        if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                        {
                            damage = 0;
                        }
                    }
                    else if (tile.type == 107 && pickPower < 100)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 108 && pickPower < 110)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 111 && pickPower < 150)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 221 && pickPower < 100)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 222 && pickPower < 110)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 223 && pickPower < 150)
                    {
                        damage = 0;
                    }
                    else
                    {
                        TileLoader.PickPowerCheck(tile, pickPower, ref damage);
                    }
                }
            }
            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                damage += pickPower;
            }
            if (tile.type == 165 || Main.tileRope[tile.type] || tile.type == 199 || Main.tileMoss[tile.type])
            {
                damage = 100;
            }
            if (/*MoreMechanisms.hitTile.AddDamage(tileId, num, false) >= 100 && */ (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[tile.type]))
            {
                damage = 0;
            }
            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    //MoreMechanisms.hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    damage          = 0;
                    Main.blockMouse = true;
                }
            }
            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    //MoreMechanisms.hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    //MoreMechanisms.hitTile.UpdatePosition(tileId, x, y);
                }
                int  j     = tile.frameX;
                bool flag3 = j >= 5000;
                bool flag2 = false;
                if (!flag3)
                {
                    int num5 = j / 18;
                    num5 %= 3;
                    x    -= num5;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag3 = true;
                    }
                }
                if (flag3)
                {
                    j = tile.frameX;
                    int num3 = 0;
                    while (j >= 5000)
                    {
                        j -= 5000;
                        num3++;
                    }
                    if (num3 != 0)
                    {
                        flag2 = true;
                    }
                }
                if (flag2)
                {
                    damage          = 0;
                    Main.blockMouse = true;
                }
            }
            if (!WorldGen.CanKillTile(x, y))
            {
                damage = 0;
            }

            return(damage != 0);
        }
예제 #8
0
        public void MineBlock(int x, int y, int pickPower, Chest chest, HitTile hitTile)
        {
            hitTile.UpdatePosition(Main.tile[x, y].type, x, y);
            int  num    = 0;
            int  tileId = hitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[(int)tile.type])
            {
                num = 100;
            }
            if (Main.tileDungeon[(int)tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                num += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                num += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                num += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                num += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref num);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                num = 0;
            }
            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                num = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                num = 0;
            }
            else if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
            {
                num = 0;
            }
            else if (tile.type == 56 && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 58 && pickPower < 65)
            {
                num = 0;
            }
            else if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
            {
                num = 0;
            }
            else if (Main.tileDungeon[(int)tile.type] && pickPower < 65)
            {
                if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                {
                    num = 0;
                }
            }
            else if (tile.type == 107 && pickPower < 100)
            {
                num = 0;
            }
            else if (tile.type == 108 && pickPower < 110)
            {
                num = 0;
            }
            else if (tile.type == 111 && pickPower < 150)
            {
                num = 0;
            }
            else if (tile.type == 221 && pickPower < 100)
            {
                num = 0;
            }
            else if (tile.type == 222 && pickPower < 110)
            {
                num = 0;
            }
            else if (tile.type == 223 && pickPower < 150)
            {
                num = 0;
            }
            else
            {
                TileLoader.PickPowerCheck(tile, pickPower, ref num);
            }
            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                num += pickPower;
            }
            if (tile.type == 165 || Main.tileRope[(int)tile.type] || tile.type == 199 || Main.tileMoss[(int)tile.type])
            {
                num = 100;
            }
            if (hitTile.AddDamage(tileId, num, false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[(int)tile.type]))
            {
                num = 0;
            }
            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    num             = 0;
                    Main.blockMouse = true;
                }
            }
            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                int  i     = (int)tile.frameX;
                bool flag  = i >= 5000;
                bool flag2 = false;
                if (!flag)
                {
                    int num2 = i / 18;
                    num2 %= 3;
                    x    -= num2;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    i = (int)tile.frameX;
                    int num3 = 0;
                    while (i >= 5000)
                    {
                        i -= 5000;
                        num3++;
                    }
                    if (num3 != 0)
                    {
                        flag2 = true;
                    }
                }
                if (flag2)
                {
                    num             = 0;
                    Main.blockMouse = true;
                }
            }
            if (!WorldGen.CanKillTile(x, y))
            {
                num = 0;
            }
            if (hitTile.AddDamage(tileId, num, true) >= 100)
            {
                hitTile.Clear(tileId);
                if (Main.netMode == 2 && Main.tileContainer[(int)Main.tile[x, y].type])
                {
                    WorldGen.KillTile(x, y, true, false, false);
                    NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y, 1f, 0, 0, 0);
                    if (TileLoader.IsChest((int)Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, "", 1, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (TileLoader.IsDresser((int)Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, "", 3, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                }
                else
                {
                    int  num4  = y;
                    bool flag3 = Main.tile[x, num4].active();
                    WorldGen.KillTile(x, num4, false, false, false);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)num4, 0f, 0, 0, 0);
                    }
                }
            }
            else
            {
                WorldGen.KillTile(x, y, true, false, false);
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y, 1f, 0, 0, 0);
                }
            }
            if (num != 0)
            {
                hitTile.Prune();
            }
        }
예제 #9
0
        public void PickTile2(int x, int y, int pickPower, Tiles.AutoPicker autoPicker)
        {
            int  num8   = 0;
            int  tileId = hitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[tile.type])
            {
                num8 = 100;
            }
            if (Main.tileDungeon[tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                num8 += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                num8 += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                num8 += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                num8 += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                num8 += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                num8 += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                num8 += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref num8);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                num8 = 0;
            }
            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                num8 = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                num8 = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                num8 = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                num8 = 0;
            }
            else if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
            {
                num8 = 0;
            }
            else if (tile.type == 56 && pickPower < 65)
            {
                num8 = 0;
            }
            else if (tile.type == 58 && pickPower < 65)
            {
                num8 = 0;
            }
            else if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
            {
                num8 = 0;
            }
            else if (Main.tileDungeon[tile.type] && pickPower < 65)
            {
                if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                {
                    num8 = 0;
                }
            }
            else if (tile.type == 107 && pickPower < 100)
            {
                num8 = 0;
            }
            else if (tile.type == 108 && pickPower < 110)
            {
                num8 = 0;
            }
            else if (tile.type == 111 && pickPower < 150)
            {
                num8 = 0;
            }
            else if (tile.type == 221 && pickPower < 100)
            {
                num8 = 0;
            }
            else if (tile.type == 222 && pickPower < 110)
            {
                num8 = 0;
            }
            else if (tile.type == 223 && pickPower < 150)
            {
                num8 = 0;
            }
            else
            {
                TileLoader.PickPowerCheck(tile, pickPower, ref num8);
            }
            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                num8 += pickPower;
            }
            if (tile.type == 165 || Main.tileRope[tile.type] || tile.type == 199 || Main.tileMoss[tile.type])
            {
                num8 = 100;
            }
            if (hitTile.AddDamage(tileId, num8, updateAmount: false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[tile.type]))
            {
                num8 = 0;
            }
            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    num8            = 0;
                    Main.blockMouse = true;
                }
            }
            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                int  j     = tile.frameX;
                bool flag3 = j >= 5000;
                bool flag2 = false;
                if (!flag3)
                {
                    int num7 = j / 18;
                    num7 %= 3;
                    x    -= num7;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag3 = true;
                    }
                }
                if (flag3)
                {
                    j = tile.frameX;
                    int num5 = 0;
                    while (j >= 5000)
                    {
                        j -= 5000;
                        num5++;
                    }
                    if (num5 != 0)
                    {
                        flag2 = true;
                    }
                }
                if (flag2)
                {
                    num8            = 0;
                    Main.blockMouse = true;
                }
            }
            if (!Terraria.WorldGen.CanKillTile(x, y))
            {
                num8 = 0;
            }
            if (hitTile.AddDamage(tileId, num8) >= 100)
            {
                AchievementsHelper.CurrentlyMining = true;
                hitTile.Clear(tileId);
                if (Main.netMode == 1 && Main.tileContainer[Main.tile[x, y].type])
                {
                    WorldGen.AutoPicker.KillTile2(autoPicker, x, y, fail: true);
                    NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
                    if (Main.tile[x, y].type == 21 || (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type]))
                    {
                        NetMessage.SendData(34, -1, -1, null, 1, x, y);
                    }
                    if (Main.tile[x, y].type == 467)
                    {
                        NetMessage.SendData(34, -1, -1, null, 5, x, y);
                    }
                    if (TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 3, x, y);
                    }
                    if (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type])
                    {
                        NetMessage.SendData(34, -1, -1, null, 101, x, y, 0f, 0, Main.tile[x, y].type);
                    }
                    if (Main.tile[x, y].type >= 470 && TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 103, x, y, 0f, 0, Main.tile[x, y].type);
                    }
                }
                else
                {
                    int  num4 = y;
                    bool num9 = Main.tile[x, num4].active();
                    WorldGen.AutoPicker.KillTile2(autoPicker, x, num4);
                    if (num9 && !Main.tile[x, num4].active())
                    {
                        AchievementsHelper.HandleMining();
                    }
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(17, -1, -1, null, 0, x, num4);
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
            else
            {
                WorldGen.AutoPicker.KillTile2(autoPicker, x, y, fail: true);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
                }
            }
            if (num8 != 0)
            {
                hitTile.Prune();
            }
        }