⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 playscn.pas

📁 传奇源代码的delphi版本
💻 PAS
📖 第 1 页 / 共 5 页
字号:
         end;
      end;
end;

procedure TPlayScene.DrawLightEffect (lx, ly, bright: integer);
begin
   if (bright > 0) and (bright <= MAXLIGHT) then
      FogCopy (m_Lights[bright].PFog,
               0,
               0,
               m_Lights[bright].Width,
               m_Lights[bright].Height,
               m_PFogScreen,
               lx - (m_Lights[bright].Width-UNITX) div 2,
               ly - (m_Lights[bright].Height-UNITY) div 2,
               m_nFogWidth,
               m_nFogHeight,
               15);
end;

{-----------------------------------------------------------------------}

procedure TPlayScene.DrawMiniMap (surface: TDirectDrawSurface);
var
  d: TDirectDrawSurface;
  v: Boolean;
  mx, my,nx,ny, i: integer;
  rc: TRect;
  actor:TActor;
  x,y:integer;
  btColor:Byte;
begin

  if (GetTickCount > m_dwBlinkTime + 300) then begin
    m_dwBlinkTime := GetTickCount;
    m_boViewBlink := not m_boViewBlink;
  end;

  if (g_nMiniMapIndex < 0) then exit;
  d := g_WMMapImages.Images[g_nMiniMapIndex];
  if d = nil then exit;

  mx := (g_MySelf.m_nCurrX*48) div 32;
  my := (g_MySelf.m_nCurrY*32) div 32;

  rc.Left := _MAX(0, mx-60);
  rc.Top := _MAX(0, my-60);
  rc.Right := _MIN(d.ClientRect.Right, rc.Left + 120);
  rc.Bottom := _MIN(d.ClientRect.Bottom, rc.Top + 120);

  if g_nViewMinMapLv = 1 then
    DrawBlendEx (surface, (SCREENWIDTH-120), 0, d, rc.Left, rc.Top, 120, 120, 0)
  else
    surface.Draw ((SCREENWIDTH-120), 0, rc, d, FALSE);

  mx := (SCREENWIDTH-120) + (g_MySelf.m_nCurrX * 48) div 32 - rc.Left;
  my := (g_MySelf.m_nCurrY * 32) div 32 - rc.Top;

  for x:=0 to 3 do
    for y:=0 to 3 do
  surface.Pixels[mx+x, my+y] := 255;

  for nx:=g_MySelf.m_nCurrX - 30  to g_MySelf.m_nCurrX + 30 do begin
    for ny:=g_MySelf.m_nCurrY - 30 to g_MySelf.m_nCurrY + 30 do begin
      actor := FindActorXY(nx,ny);
      if (actor <> nil) and (actor <> g_MySelf) and (not actor.m_boDeath) then begin
        mx := (SCREENWIDTH-120) + (actor.m_nCurrX * 48) div 32 - rc.Left;
        my := (actor.m_nCurrY * 32) div 32 - rc.Top;

        if (g_myself.m_boGrouped) and (frmmain.IsGroupMember(actor.m_sUserName)) then
          btcolor:=$FC
        else begin
          if (actor.m_sUsername = g_LoverNameClient) then  //lover radar
            btcolor:=253
          else
            case actor.m_btRace of
              50,12: btColor:=251;
              0: btColor:=255;
              else btColor:=249;
            end;
        end;

        for x:=0 to 3 do
          for y:=0 to 3 do
            surface.Pixels[mx+x, my+y] := btColor
      end;
    end;
  end;
end;

procedure TPlayScene.DrawMap (surface: TDirectDrawSurface);
var
  d: TDirectDrawSurface;
  mx, my,nx,ny, i: integer;
  rc: TRect;
  actor:TActor;
  x,y:integer;
  btColor:Byte;
begin
  if (GetTickCount > m_dwBlinkTime + 300) then begin
    m_dwBlinkTime := GetTickCount;
    m_boViewBlink := not m_boViewBlink;
  end;

  if g_nMapIndex < 0 then exit;
  d := g_WMMapImages.Images[g_nMapIndex];
  if d = nil then exit;

  mx := (g_MySelf.m_nCurrX*48) div 32;
  my := (g_MySelf.m_nCurrY*32) div 32;

  rc.Left := (SCREENWIDTH div 2) - (d.Width div 2);
  rc.Top := 225 - (d.Height div 2);
  rc.Right := rc.Left + d.Width;
  rc.Bottom := rc.Top + d.Height;

  if (g_nViewMapLv = 1) then
    DrawBlendEx (surface, rc.Left, rc.Top, d, 0, 0, d.Width, d.Height, 0)
  else
    Surface.StretchDraw (rc, d.ClientRect, d, TRUE);

  // Draw you on the map!
  mx := round(g_MySelf.m_nCurrX / 1.338) + rc.Left;
  my := round(g_MySelf.m_nCurrY / 2.01) + rc.Top;

  for x:=0 to 3 do
    for y:=0 to 3 do
      surface.Pixels[mx+x, my+y] := 255;

  for nx:=g_MySelf.m_nCurrX - 30  to g_MySelf.m_nCurrX + 30 do begin
    for ny:=g_MySelf.m_nCurrY - 30 to g_MySelf.m_nCurrY + 30 do begin
      actor := FindActorXY(nx,ny);
      if (actor <> nil) and (actor <> g_MySelf) and (not actor.m_boDeath) then begin
           mx := round(actor.m_nCurrX / 1.338) + rc.Left;
           my := round(actor.m_nCurrY / 2.01) + rc.Top;
        if (g_myself.m_boGrouped) and (frmmain.IsGroupMember(actor.m_sUserName)) then
          btcolor:=$FC
        else begin
          if (actor.m_sUsername = g_LoverNameClient) then  //lover radar
            btcolor:=253
          else
            case actor.m_btRace of
              50,12: btColor:=251;
              0: btColor:=255;
              else btColor:=249;
            end;
        end;

        for x:=0 to 3 do
          for y:=0 to 3 do
            surface.Pixels[mx+x, my+y] := btColor
      end;
    end;
  end;
end;


{-----------------------------------------------------------------------}

procedure TPlayScene.PlayScene (MSurface: TDirectDrawSurface);
   function  CheckOverlappedObject (myrc, obrc: TRect): Boolean;
   begin
      if (obrc.Right > myrc.Left) and (obrc.Left < myrc.Right) and
         (obrc.Bottom > myrc.Top) and (obrc.Top < myrc.Bottom) then
         Result := TRUE
      else Result := FALSE;
   end;

var
   i, j, k, n, m, mmm, ix, iy, line, defx, defy, wunit, fridx, ani, anitick, ax, ay, idx, drawingbottomline: integer;
   DSurface, d: TDirectDrawSurface;
   blend, movetick: Boolean;
   //myrc, obrc: TRect;
   DropItem: PTDropItem;
   evn: TClEvent;
   actor: TActor;
   meff: TMagicEff;
   msgstr: string;
  ShowItem:pTShowItem;
  nFColor,nBColor:Integer;
  UserState: TUserStateInfo;
begin
   drawingbottomline:=0;
   if (g_MySelf = nil) then begin
      msgstr := '正在退出游戏,请稍候...';
      with MSurface.Canvas do begin
         SetBkMode (Handle, TRANSPARENT);
         BoldTextOut (MSurface, (SCREENWIDTH-TextWidth(msgstr)) div 2, (SCREENHEIGHT - 600) +200,
                      clWhite, clBlack, msgstr);
         Release;
      end;
      exit;
   end;

   g_boDoFastFadeOut := FALSE;

   movetick := FALSE;
   if GetTickCount - m_dwMoveTime >= 100 then begin
      m_dwMoveTime := GetTickCount;
      movetick := TRUE;
      Inc (m_nMoveStepCount);
      if m_nMoveStepCount > 1 then m_nMoveStepCount := 0;
   end;
   if GetTickCount - m_dwAniTime >= 50 then begin
      m_dwAniTime := GetTickCount;
      Inc (m_nAniCount);
      if m_nAniCount > 100000 then m_nAniCount := 0;
   end;

   try
   i := 0;
   while TRUE do begin
      if i >= m_ActorList.Count then break;
      actor := m_ActorList[i];
      if movetick then actor.m_boLockEndFrame := FALSE;
      if not actor.m_boLockEndFrame then begin
         actor.ProcMsg;
         if movetick then
            if actor.Move(m_nMoveStepCount) then begin
               Inc (i);
               continue;
            end;
         actor.Run;
         if actor <> g_MySelf then actor.ProcHurryMsg;
      end;
      if actor = g_MySelf then actor.ProcHurryMsg;

      if actor.m_nWaitForRecogId <> 0 then begin
         if actor.IsIdle then begin
            DelChangeFace (actor.m_nWaitForRecogId);
            NewActor (actor.m_nWaitForRecogId, actor.m_nCurrX, actor.m_nCurrY, actor.m_btDir, actor.m_nWaitForFeature, actor.m_nWaitForStatus);
            actor.m_nWaitForRecogId := 0;
            actor.m_boDelActor := TRUE;
         end;
      end;
      if actor.m_boDelActor then begin

         g_FreeActorList.Add (actor);
         m_ActorList.Delete (i);
         if g_TargetCret = actor then g_TargetCret := nil;
         if g_FocusCret = actor then g_FocusCret := nil;
         if g_MagicTarget = actor then g_MagicTarget := nil;
      end else
         Inc (i);
   end;
   except
      DebugOutStr ('101');
   end;

   try
   i := 0;
   while TRUE do begin
      if i >= m_GroundEffectList.Count then break;
      meff := m_GroundEffectList[i];
      if meff.m_boActive then begin
         if not meff.Run then begin
            meff.Free;
            m_GroundEffectList.Delete (i);
            continue;
         end;
      end;
      Inc (i);
   end;
   i := 0;
   while TRUE do begin
      if i >= m_EffectList.Count then break;
      meff := m_EffectList[i];
      if meff.m_boActive then begin
         if not meff.Run then begin
            meff.Free;
            m_EffectList.Delete (i);
            continue;
         end;
      end;
      Inc (i);
   end;
   i := 0;
   while TRUE do begin
      if i >= m_FlyList.Count then break;
      meff := m_FlyList[i];
      if meff.m_boActive then begin
         if not meff.Run then begin
            meff.Free;
            m_FlyList.Delete (i);
            continue;
         end;
      end;
      Inc (i);
   end;
   
   EventMan.Execute;
   except
      DebugOutStr ('102');
   end;

   try
   ClearDropItem();
   for k:=0 to EventMan.EventList.Count-1 do begin
      evn := TClEvent (EventMan.EventList[k]);
      if (Abs(evn.m_nX-g_MySelf.m_nCurrX) > 30) and (Abs(evn.m_nY-g_MySelf.m_nCurrY) > 30) then begin
         evn.Free;
         EventMan.EventList.Delete (k);
         break; 
      end;
   end;
   except
      DebugOutStr ('103');
   end;

   try
   with Map.m_ClientRect do begin
{$IF SWH = SWH800}
      Left   := g_MySelf.m_nRx - 9;
      Top    := g_MySelf.m_nRy - 9;
      Right  := g_MySelf.m_nRx + 9;
      Bottom := g_MySelf.m_nRy + 8;
{$ELSEIF SWH = SWH1024}
      Left   := g_MySelf.m_nRx - 12;
      Top    := g_MySelf.m_nRy - 12;
      Right  := g_MySelf.m_nRx + 12;
      Bottom := g_MySelf.m_nRy + 15;
{$IFEND}
   end;
   Map.UpdateMapPos (g_MySelf.m_nRx, g_MySelf.m_nRy);

   ///////////////////////
   //ViewFog := FALSE;
   ///////////////////////

   if g_boNoDarkness or (g_MySelf.m_boDeath) then begin
      g_boViewFog := FALSE;
   end;

   if g_boViewFog then begin 
      ZeroMemory (m_PFogScreen, MAPSURFACEHEIGHT * MAPSURFACEWIDTH);
      ClearLightMap;
   end;

//   drawingbottomline := 450;
   drawingbottomline := SCREENHEIGHT;
   m_ObjSurface.Fill(0);

   DrawTileMap;

   m_ObjSurface.Draw (0, 0,
                    Rect(UNITX*3 + g_MySelf.m_nShiftX,
                         UNITY*2 + g_MySelf.m_nShiftY,
                         UNITX*3 + g_MySelf.m_nShiftX + MAPSURFACEWIDTH,
                         UNITY*2 + g_MySelf.m_nShiftY + MAPSURFACEHEIGHT),
                    m_MapSurface,
                    FALSE);

   except
      DebugOutStr ('104');
   end;

   defx := -UNITX*2 - g_MySelf.m_nShiftX + AAX + 14;
   defy := -UNITY*2 - g_MySelf.m_nShiftY;
   m_nDefXX := defx;
   m_nDefYY := defy;

   try
   m := defy - UNITY;
   for j:=(Map.m_ClientRect.Top - Map.m_nBlockTop) to (Map.m_ClientRect.Bottom - Map.m_nBlockTop + LONGHEIGHT_IMAGE) do begin
      if j < 0 then begin Inc (m, UNITY); continue; end;
      n := defx-UNITX*2;

      for i:=(Map.m_ClientRect.Left - Map.m_nBlockLeft-2) to (Map.m_ClientRect.Right - Map.m_nBlockLeft+2) do begin
         if (i >= 0) and (i < LOGICALMAPUNIT*3) and (j >= 0) and (j < LOGICALMAPUNIT*3) then begin
            fridx := (Map.m_MArr[i, j].wFrImg) and $7FFF;
            if fridx > 0 then begin
               ani := Map.m_MArr[i, j].btAniFrame;
               wunit := Map.m_MArr[i, j].btArea;
               if (ani and $80) > 0 then begin
                  blend := TRUE;
                  ani := ani and $7F;
               end;
               if ani > 0 then begin
                  anitick := Map.m_MArr[i, j].btAniTick;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -