added z coords for portal discovery and minster disovery
This commit is contained in:
parent
91cd934878
commit
bb493febb4
7 changed files with 168 additions and 1573 deletions
|
|
@ -41,6 +41,29 @@ namespace MosswartMassacre
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return any WorldObject's raw world position by reading the
|
||||
/// physics-object pointer (same offsets: +0x84/88/8C).
|
||||
/// </summary>
|
||||
public static unsafe Vector3 GetWorldObjectPosition(int objectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!CoreManager.Current.Actions.IsValidObject(objectId))
|
||||
return new Vector3();
|
||||
|
||||
byte* p = (byte*)CoreManager.Current.Actions.Underlying.GetPhysicsObjectPtr(objectId);
|
||||
return new Vector3(
|
||||
*(float*)(p + 0x84), // X
|
||||
*(float*)(p + 0x88), // Y
|
||||
*(float*)(p + 0x8C)); // Z
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new Vector3();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convenience: returns the current landcell (upper 16 bits of landblock).
|
||||
/// </summary>
|
||||
|
|
@ -65,6 +88,26 @@ namespace MosswartMassacre
|
|||
return new Coordinates(ew, ns, pos.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get AC-style coordinates (EW/NS/Z) for any WorldObject.
|
||||
/// </summary>
|
||||
public static Coordinates GetWorldObjectCoordinates(WorldObject wo)
|
||||
{
|
||||
if (wo == null) return new Coordinates();
|
||||
|
||||
Vector3 pos = GetWorldObjectPosition(wo.Id);
|
||||
|
||||
// Get landcell from the object's coordinates
|
||||
var coordsObj = wo.Coordinates();
|
||||
if (coordsObj == null) return new Coordinates();
|
||||
|
||||
// Convert DECAL coords to our Coordinates with Z
|
||||
double ew = coordsObj.EastWest;
|
||||
double ns = coordsObj.NorthSouth;
|
||||
|
||||
return new Coordinates(ew, ns, pos.Z);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------
|
||||
* 3) Generic math helpers you may want later
|
||||
* -------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue