sahisahi
Member
So the next code doesnt compute Z coords, i would like to add a z -75
Thanks ServUO community.
Code:
protected override void OnTick()
{
if (m_attachment == null) return;
Mobile draggedby = m_attachment.DraggedBy;
object parent = m_attachment.AttachedTo;
if (parent == null || !(parent is Mobile || parent is Item) || draggedby == null || draggedby.Deleted || draggedby == parent || !draggedby.Alive )
{
Stop();
return;
}
//location of the mobile
Point3D newloc = draggedby.Location;
Map newmap = draggedby.Map;
if (newmap == null || newmap == Map.Internal)
{
// if the m has an invalid map, then stop
m_attachment.DraggedBy = null;
Stop();
return;
}
// update the location object if the parent has moved
if (newloc != m_attachment.CurrentLoc || newmap != m_attachment.CurrentMap)
{
m_attachment.CurrentLoc = newloc;
m_attachment.CurrentMap = newmap;
int x = newloc.X;
int y = newloc.Y;
int lag = m_attachment.Distance;
// compute the new location for the object
switch (draggedby.Direction & Direction.Mask)
{
case Direction.North: y -= lag; break;
case Direction.Right: x += lag; y -= lag; break;
case Direction.East: x += lag; break;
case Direction.Down: x += lag; y += lag; break;
case Direction.South: y += lag; break;
case Direction.Left: x -= lag; y += lag; break;
case Direction.West: x -= lag; break;
case Direction.Up: x -= lag; y -= lag; break;
}
if (parent is Mobile)
{
((Mobile)parent).Location = new Point3D(x, y, newloc.Z);
((Mobile)parent).Map = newmap;
}
else
if (parent is Item)
{
((Item)parent).Location = new Point3D(x, y, newloc.Z);
((Item)parent).Map = newmap;
}
}
}
}
}
Thanks ServUO community.