fix: Fixes the limitation on static tiles for harvesting (#1396)
* fix: Fixes the limitation on static tiles for harvesting * Fixes dirt targeting
This commit is contained in:
parent
79c6f0375c
commit
ba4c4627c3
8 changed files with 103 additions and 78 deletions
|
|
@ -85,13 +85,13 @@ namespace Server.Engines.Harvest
|
|||
return;
|
||||
}
|
||||
|
||||
if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc))
|
||||
if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc, out var isLand))
|
||||
{
|
||||
OnBadHarvestTarget(from, tool, toHarvest);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!def.Validate(tileID))
|
||||
if (!def.Validate(tileID, isLand))
|
||||
{
|
||||
OnBadHarvestTarget(from, tool, toHarvest);
|
||||
return;
|
||||
|
|
@ -367,14 +367,14 @@ namespace Server.Engines.Harvest
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc))
|
||||
if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc, out var isLand))
|
||||
{
|
||||
from.EndAction(locked);
|
||||
OnBadHarvestTarget(from, tool, toHarvest);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!def.Validate(tileID))
|
||||
if (!def.Validate(tileID, isLand))
|
||||
{
|
||||
from.EndAction(locked);
|
||||
OnBadHarvestTarget(from, tool, toHarvest);
|
||||
|
|
@ -423,13 +423,13 @@ namespace Server.Engines.Harvest
|
|||
|
||||
public virtual HarvestDefinition GetDefinition() => Definitions[0];
|
||||
|
||||
public virtual HarvestDefinition GetDefinition(int tileID)
|
||||
public virtual HarvestDefinition GetDefinition(int tileID, bool isLand)
|
||||
{
|
||||
for (var i = 0; i < Definitions.Length; i++)
|
||||
{
|
||||
var check = Definitions[i];
|
||||
|
||||
if (check.Validate(tileID))
|
||||
if (check.Validate(tileID, isLand))
|
||||
{
|
||||
return check;
|
||||
}
|
||||
|
|
@ -445,13 +445,13 @@ namespace Server.Engines.Harvest
|
|||
return;
|
||||
}
|
||||
|
||||
if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc))
|
||||
if (!GetHarvestDetails(from, tool, toHarvest, out var tileID, out var map, out var loc, out var isLand))
|
||||
{
|
||||
OnBadHarvestTarget(from, tool, toHarvest);
|
||||
return;
|
||||
}
|
||||
|
||||
var def = GetDefinition(tileID);
|
||||
var def = GetDefinition(tileID, isLand);
|
||||
|
||||
if (def == null)
|
||||
{
|
||||
|
|
@ -487,33 +487,36 @@ namespace Server.Engines.Harvest
|
|||
}
|
||||
|
||||
public virtual bool GetHarvestDetails(
|
||||
Mobile from, Item tool, object toHarvest, out int tileID, out Map map,
|
||||
out Point3D loc
|
||||
Mobile from, Item tool, object toHarvest, out int tileID, out Map map, out Point3D loc, out bool isLand
|
||||
)
|
||||
{
|
||||
if (toHarvest is Static staticObj && !staticObj.Movable)
|
||||
if (toHarvest is Static { Movable: false } staticObj)
|
||||
{
|
||||
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
|
||||
tileID = staticObj.ItemID;
|
||||
map = staticObj.Map;
|
||||
loc = staticObj.GetWorldLocation();
|
||||
isLand = false;
|
||||
}
|
||||
else if (toHarvest is StaticTarget staticTarget)
|
||||
{
|
||||
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
|
||||
tileID = staticTarget.ItemID;
|
||||
map = from.Map;
|
||||
loc = staticTarget.Location;
|
||||
isLand = false;
|
||||
}
|
||||
else if (toHarvest is LandTarget landTarget)
|
||||
{
|
||||
tileID = landTarget.TileID;
|
||||
map = from.Map;
|
||||
loc = landTarget.Location;
|
||||
isLand = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tileID = 0;
|
||||
map = null;
|
||||
loc = Point3D.Zero;
|
||||
isLand = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue