Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #21  
Old 11-19-2002, 02:27 AM
Windcatcher
Demi-God
 
Join Date: Jan 2002
Posts: 1,175
Default

Quester, is this what you have in mind?

Code:
Unit Pathing;

Interface

Const
  MAX_POINTS = 256;             // Arbitrary
  MAX_GROUPS = 256;             // Arbitrary

Type
  TPPointType = (pptLand,pptWater,pptAir,pptWideOpen);
  PPPointGroup = ^TPPointGroup; // C would just use a pointer but Pascal uses these weird constructs :)
  TXYZPoint = Record
    X,Y,Z: Single;              // XYZ coordinates (equivalent to "float")
  End;
  TPPoint = Record
    XYZ        : TXYZPoint;
    _Type      : TPPointType;        // Type of PPoint
    Group      : PPPointGroup;       // Pointer to this group
    OtherGroup : PPPointGroup;       // Connector to another group, or Nil if this point doesn't connect anywhere
  End;
  TPPointGroup = Array[0..MAX_POINTS - 1] Of TPPoint;      // In Delphi I would use open arrays, which are
  TZoneGroups  = Array[0..MAX_GROUPS - 1] Of TPPointGroup; // dynamically allocatable...

Var
  ZoneGroups : TZoneGroups;

Function FindNextPoint(Source,Dest: TXYZPoint; CanTraverse: Set Of TPPointType): TXYZPoint;

Implementation

Function FindNextPoint(Source,Dest: TXYZPoint; CanTraverse: Set Of TPPointType): TXYZPoint;
// ---------------------------------------------------------------------------------
// Given a source point and a desired destination point, return the next point to which
// something can move.
// ---------------------------------------------------------------------------------
Var
  SourcePt : TPPoint;
  DestPt   : TPPoint;

  // Returning a pointer to the TPPoint is less intuitive, but more efficient when
  // implementing this in the server
  Procedure FindNearestPPoint(Const XYZ: TXYZPoint): TPPoint;
  Begin
    .
    .
    .
  End; // FindNearestPoint

Begin
  .
  . // Implement the pathing algorithm here, something I'm not familiar with...
  .
  // Find the nearest TPPoint to the source and destination coordinates

  SourcePt := FindNearestPoint(Source);
  DestPt   := FindNearestPoint(Dest);

  // Attempt to traverse the distance

  If (SourcePt._Type In CanTraverse) And (DestPt._Type In CanTraverse) Then
  Begin
    If (SourcePt._Type = pptWideOpen) And (DestPt._Type = pptWideOpen) And (SourcePt.Group = DestPt.Group) Then
    Begin
      // Both are in the same wide open area; simply move in a straight line
    End
    Else
    Begin
      // Find the nearest available destination, according to the A* pathing algorithm
    End;
  End
  Else
  Begin
    // Can't traverse; do something else here
  End;
End; // FindNextPoint

End.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:53 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3