RedBeard

Member
Using latest ServUo:
Trying to make a shovel uncover the entrance to my custom dungeon by having players randomly look for it targeting the land tiles in the area.
One method sort of works(LandTile) I tried only allows me to target playermobile not the ground, but for some reason also allows targeting any static tile. If I use LandTarget it will not target anything.
Code:
   protected override void OnTarget(Mobile from, object targeted)
            {
                Map map = from.Map;
             
                LandTile lt = map.Tiles.GetLandTile(from.X, from.Y);
                // LandTarget land = targeted as LandTarget;


                if (targeted is LandTarget && ((LandTarget)targeted).TileID >= 22 && ((LandTarget)targeted).TileID <= 62)
                  // if (IsSandTile(lt.ID) && lt.Z == from.Z)
                {
 
You need to have the values of the targeted tiles in an array that it will look through to see if the targeted tile has the same id as one of the ids in the array. Look at the way harvest works for lumberjack, mining, etc. but instead of trees you use the tile ids of the land.
 
Tried that as well: LandTile lt = map.Tiles.GetLandTile(from.X, from.Y);
only allows me to target player, but for some reason I can target static tiles as well, like grasses and rocks when the target should be sand tiles only.

This: if (targeted is LandTarget && IsSandTile(lt.ID) && lt.Z == from.Z) ....won't let me target anything.

Code:
    private class ExcavateTarget : Target
        {
            
                        public static int[] m_SandTiles = new int[]
                   {
                        22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
                        32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
                        42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
                        52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
                        62, 68, 69, 70, 71, 72, 73, 74, 75,
                        286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
                        296, 297, 298, 299, 300, 301, 402, 424, 425, 426,
                        427, 441, 442, 443, 444, 445, 446, 447, 448, 449,
                        450, 451, 452, 453, 454, 455, 456, 457, 458, 459,
                        460, 461, 462, 463, 464, 465, 642, 643, 644, 645,
                        650, 651, 652, 653, 654, 655, 656, 657, 821, 822,
                        823, 824, 825, 826, 827, 828, 833, 834, 835, 836,
                        845, 846, 847, 848, 849, 850, 851, 852, 857, 858,
                        859, 860, 951, 952, 953, 954, 955, 956, 957, 958,
                        967, 968, 969, 970,
                        1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455,
                        1456, 1457, 1458, 1611, 1612, 1613, 1614, 1615, 1616,
                        1617, 1618, 1623, 1624, 1625, 1626, 1635, 1636, 1637,
                        1638, 1639, 1640, 1641, 1642, 1647, 1648, 1649, 1650, 1339
                   };

            private ExcavationShovel m_Item;
            private Mobile m_From;

            public ExcavateTarget(ExcavationShovel item, Mobile from) : base(12, false, TargetFlags.None)
            {
                m_Item = item;
                m_From = from;
            }

            protected override void OnTarget(Mobile from, object targeted)
            {
                Map map = from.Map;
               
                LandTile lt = map.Tiles.GetLandTile(from.X, from.Y) 
                  if (IsSandTile(lt.ID) && lt.Z == from.Z)
                {
Post automatically merged:

1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455,
1456, 1457, 1458, 1611, 1612, 1613, 1614, 1615, 1616,
1617, 1618, 1623, 1624, 1625, 1626, 1635, 1636, 1637,
1638, 1639, 1640, 1641, 1642, 1647, 1648, 1649, 1650, 1339 This is a static cave tile I added to confirm it will target statics
 
Last edited:
I would do this. Instead of having them target a tile, how about you just override the OnDoubleClick method, and have it automatically dig where the player is standing. Then allow it to check Map, X, Y, and Z, and make sure where they are standing is within 1 tile of the entrance. you can still make it do a dig animation and/or play a sound too if you like. This way you don't have to worry about what kind of tile target is being targeted.
 
The issue you are encountering is due to checking the mobiles Location instead of your targeted location...

LandTile lt = map.Tiles.GetLandTile(from.X, from.Y);

&& lt.Z == from.Z

try..

else if (targeted is LandTarget lt && IsSandTile(lt.TileID))
 
Last edited:
The issue you are encountering is due to checking the mobiles Location instead of your targeted location...

LandTile lt = map.Tiles.GetLandTile(from.X, from.Y);

&& lt.Z == from.Z

try..

else if (targeted is LandTarget lt && IsSandTile(lt.TileID))
yep I know 'from', but it still allowed me to target rocks and grasses for some reason and not sure why that is.
 
Where you were targeting, and what you were calculating were different spots.
So it was where your char was standing, not what you were targeting that was being processed.

The fix I showed works perfect.

P.S.
Statics are handled above where LandTarget is in HarvestTarget.cs..
 
Last edited:

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back