unit ObjBase;

interface
uses
  Windows, Classes, SysUtils, StrUtils, StdCtrls, Graphics, Grobal2, HUtil32;
type
  pTBaseObject = ^TBaseObject;
  TBaseObject = class
    m_ObjType: TObjType;
    m_dwAddTime: LongWord;
    m_nMapX: Integer;
    m_nMapY: Integer;
    m_VisibleActors: TList;
    m_nCurrX :Integer;    
    m_nCurrY :Integer;
    m_nAntiMagic :ShortInt;
    m_nNextHitTime: Integer;
    m_nWalkSpeed: Integer;
    m_wStatusTimeArr: TStatusTime;
    m_boGhost: Boolean;
    m_boDeath: Boolean;
  public
    constructor Create(); virtual;
    destructor Destroy; override;
    function  GetHitSpeed: Integer;
    function  GetWalkSpeed: Integer;
    function  CanMove: Boolean;
  end;

  TGateObject = class(TBaseObject)
    m_nSMapX: Integer;
    m_nSMapY: Integer;
    m_boFlag: Boolean;
    m_sName: string;
    m_DEnvir: TObject;
    m_sSMapNO: string;
    m_sDMapNO: string;
  private
  public
    constructor Create(); override;
    destructor Destroy; override;
  end;

  TDoorObject = class(TBaseObject)
    m_n08: Integer;
    m_Status: pTDoorStatus;
  private
  public
    constructor Create(); override;
    destructor Destroy; override;
  end;
implementation
//uses M2Share;

constructor TBaseObject.Create();
begin
  m_ObjType := t_Actor;
  m_dwAddTime := GetTickCount;
  m_nMapX := 0;
  m_nMapY := 0;
end;

destructor TBaseObject.Destroy;
begin
  //g_BaseObjectList.Add('Handle:'+IntToStr(Integer(Self))+' TBaseObject.Destroy');
  inherited;
end;

//------------------------------------------------------------------------------

constructor TGateObject.Create();
begin
  inherited;
  m_ObjType := t_Gate;
  m_boFlag := False;
  m_nSMapX := -1;
  m_nSMapY := -1;
  m_sSMapNO := '';
  m_sDMapNO := '';
  m_DEnvir := nil;
  m_sName := IntToStr(Integer(Self));
end;

destructor TGateObject.Destroy;
begin
  inherited;
end;

constructor TDoorObject.Create();
begin
  inherited;
  m_ObjType := t_Door;
  m_n08 := 0;
  m_Status := nil;
end;

destructor TDoorObject.Destroy;
begin
  inherited;
end;

function TBaseObject.GetHitSpeed: Integer;
begin
  if (m_wStatusTimeArr[POISON_SLOWDOWN] > 0) then begin
    Result := (m_nNextHitTime div 2) + m_nNextHitTime;
    exit;
  end else begin
    Result := m_nNextHitTime;
  end;
end;

function TBaseObject.CanMove: Boolean;
begin
  if (not m_boDeath) and (not m_boGhost) and
    (m_wStatusTimeArr[POISON_STONE] = 0) and
    (m_wStatusTimeArr[POISON_FREEZE] = 0) and
    (m_wStatusTimeArr[POISON_SLOWDOWN] = 0) and
    (m_wStatusTimeArr[POISON_DONTMOVE] = 0) then
    Result := True
  else
    Result := False;
end;

function TBaseObject.GetWalkSpeed: Integer;
begin
    if (m_wStatusTimeArr[POISON_SLOWDOWN] > 0) then begin
    Result := (m_nWalkSpeed div 2) + m_nWalkSpeed;
    exit;
  end else begin
    Result := m_nWalkSpeed;
  end;
end;

end.

