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

📄 actor.pas

📁 在网上有很多传奇源程序DELPHI
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      //傍拜 2
      0,1,1,0,0,0,1,1,    0,1,1,0,0,0,1,1,    1,1,1,0,0,0,0,0,
      1,1,1,0,0,1,1,1,    1,1,1,1,1,1,1,1,    0,1,1,1,1,1,1,1,
      0,0,0,1,1,1,0,0,    0,1,1,1,1,0,1,1,
      //傍拜3
      1,1,0,1,0,0,0,0,    1,1,0,0,0,0,0,0,    1,1,1,1,1,0,0,0,
      1,1,0,0,1,0,0,0,    1,1,1,0,0,0,0,1,    0,1,1,0,0,0,0,0,
      0,0,0,0,1,1,1,0,    1,1,1,1,1,0,0,0,
      //付过
      0,0,0,0,0,0,1,1,    0,0,0,0,0,0,1,1,    0,0,0,0,0,0,1,1,
      1,0,0,0,0,1,1,1,    1,1,1,1,1,1,1,1,    0,1,1,1,1,1,1,1,
      0,0,1,1,0,0,1,1,    0,0,0,1,0,0,1,1,
      //澵扁
      0,0,1,0,1,1,1,1,    1,1,0,0,0,1,0,0,
      //嘎扁
      0,0,0,1,1,1,1,1,    1,1,1,1,1,1,1,1,    1,1,1,1,1,1,1,1,
      1,1,1,1,1,1,1,1,    0,0,0,1,1,1,1,1,    0,0,0,1,1,1,1,1,
      0,0,0,1,1,1,1,1,    0,0,0,1,1,1,1,1,
      //静矾咙
      0,0,1,1,1,1,1,1,    0,1,1,1,1,1,1,1,    1,1,1,1,1,1,1,1,
      1,1,1,1,1,1,1,1,    0,0,0,1,1,1,1,1,    0,0,0,1,1,1,1,1,
      0,0,0,1,1,1,1,1,    0,0,0,1,1,1,1,1
      )
   );

   EffDir : array[0..7] of byte = (0, 0, 1, 1, 1, 1, 1, 0);


type
   TActor = class
      RecogId: integer;
      XX:   word;
      YY:   word;
      Dir:  byte;
      Sex:  byte;
      Race:    byte;
      Hair:    byte;
      Dress:   byte;
      Weapon:  byte;
      Job:  byte; //战士 0:法师  1:道士  2:保留
      Appearance: word;  // DIV 10=种族(外貌),
                          // Mod 10=外貌图片在图片库中的位置(第几种)
      DeathState: byte;   //死亡状态
      Feature: integer;
      State:   integer;   //状态
      Death: Boolean;
      Skeleton: Boolean;
      BoDelActor: Boolean;
      BoDelActionAfterFinished: Boolean;
      DescUserName: string;   //玩家的名称
      UserName: string;       //玩家ID
      NameColor: integer;     //名字的颜色
      Abil: TAbility;         //属性
      Gold: integer;          //金币数量
      HitSpeed: shortint; //攻击速度 0: 正常, (-)减慢 (+)加快
      Visible: Boolean;
      BoHoldPlace: Boolean;

      Saying: array[0..MAXSAY-1] of string;    //最近说的话
      SayWidths: array[0..MAXSAY-1] of integer;  //每句话的宽度
      SayTime: longword;
      SayX, SayY: integer;
      SayLineCount: integer;

      ShiftX:  integer;
      ShiftY:  integer;

      px, hpx, wpx:   integer;           //身体、头发、武器图片显示位置
      py, hpy, wpy:   integer;
      Rx, Ry: integer;
      DownDrawLevel: integer;  //割 伎 捞傈俊 弊府霸 窃...
      TargetX, TargetY: integer; //移动的目标位置坐标
      TargetRecog: integer; //
      HiterCode: integer;
      MagicNum: integer;
      CurrentEvent: integer; //辑滚狼 捞亥飘 酒捞叼
      BoDigFragment: Boolean;  //挖肉中?..
      BoThrow: Boolean;

      BodyOffset, HairOffset, WeaponOffset: integer;
      BoUseMagic: Boolean;
      BoHitEffect: Boolean;
      BoUseEffect: Boolean;  //瓤苞甫 荤侩窍绰瘤..
      HitEffectNumber: integer;
      WaitMagicRequest: longword;
      WaitForRecogId: integer;  //磊脚捞 荤扼瘤搁 WaitFor狼 actor甫 visible 矫挪促.
      WaitForFeature: integer;
      WaitForStatus: integer;


      CurEffFrame: integer;
      SpellFrame: integer; //付过狼 矫傈 橇贰烙
      CurMagic: TUseMagicInfo;
      //GlimmingMode: Boolean;
      //CurGlimmer: integer;
      //MaxGlimmer: integer;
      //GlimmerTime: longword;
      GenAniCount: integer;
      BoOpenHealth: Boolean;
      BoInstanceOpenHealth: Boolean;
      OpenHealthStart: longword;
      OpenHealthTime: integer;

      //SRc: TRect;  //Screen Rect 拳搁狼 角力谅钎(付快胶 扁霖)
      BodySurface: TDirectDrawSurface;

      Grouped: Boolean; //唱客 弊缝牢 荤恩
      CurrentAction: integer;
      ReverseFrame: Boolean;
      WarMode: Boolean;
      WarModeTime: longword;
      ChrLight: integer;
      MagLight: integer;
      RushDir: integer;  //0, 1 茄锅篮 哭率 茄锅篮 坷弗率

      LockEndFrame: Boolean;
      LastStruckTime: longword;
      SendQueryUserNameTime: longword;
      DeleteTime: longword;

      //荤款靛 瓤苞
      MagicStruckSound: integer;
      borunsound: Boolean;
      footstepsound: integer;  //林牢傍牢版快, CM_WALK, CM_RUN
      strucksound: integer;  //嘎阑锭 唱绰 家府    SM_STRUCK
      struckweaponsound: integer;

      appearsound: integer;  //殿厘家府 0
      normalsound: integer;  //老馆家府 1
      attacksound: integer;  //         2
      weaponsound: integer; //          3
      screamsound: integer;  //         4
      diesound: integer;     //磷阑锭   5  唱绰 家府    SM_DEATHNOW
      die2sound: integer;

      magicstartsound: integer;
      magicfiresound: integer;
      magicexplosionsound: integer;

   private
   protected
      startframe: integer;
      endframe: integer;
      currentframe: integer;
      effectstart: integer;
      effectframe: integer;
      effectend: integer;
      effectstarttime: longword;
      effectframetime: longword;
      frametime: longword;   //茄 橇贰烙寸 矫埃
      starttime: longword;   //弥辟狼 橇贰烙阑 嘛篮 矫埃
      maxtick: integer;
      curtick: integer;
      movestep: integer;
      msgmuch: Boolean;
      struckframetime: longword;
      currentdefframe: integer;
      defframetime: longword;
      defframecount: integer;
      SkipTick: integer;
      smoothmovetime: longword;
      genanicounttime: longword;
      loadsurfacetime: longword;

      oldx, oldy, olddir: integer;
      actbeforex, actbeforey: integer;  //青悼 傈狼 谅钎
      wpord: integer;

      procedure CalcActorFrame; dynamic;
      procedure DefaultMotion; dynamic;
      function  GetDefaultFrame (wmode: Boolean): integer; dynamic;
      procedure DrawEffSurface (dsurface, source: TDirectDrawSurface; ddx, ddy: integer; blend: Boolean; ceff: TColorEffect);
      procedure DrawWeaponGlimmer (dsurface: TDirectDrawSurface; ddx, ddy: integer);
   public
      MsgList: TList;       //list of PTChrMsg
      RealActionMsg: TChrMsg; //FrmMain俊辑 荤侩窃

      constructor Create; dynamic;
      destructor Destroy; override;
      procedure  SendMsg (ident: word; x, y, cdir, feature, state: integer; str: string; sound: integer);
      procedure  UpdateMsg (ident: word; x, y, cdir, feature, state: integer; str: string; sound: integer);
      procedure  CleanUserMsgs;
      procedure  ProcMsg;
      procedure  ProcHurryMsg;
      function   IsIdle: Boolean;
      function   ActionFinished: Boolean;
      function   CanWalk: Integer;
      function   CanRun: Integer;
      function   Strucked: Boolean;
      procedure  Shift (dir, step, cur, max: integer);
      procedure  ReadyAction (msg: TChrMsg);
      function   CharWidth: Integer;
      function   CharHeight: Integer;
      function   CheckSelect (dx, dy: integer): Boolean;
      procedure  CleanCharMapSetting (x, y: integer);
      procedure  Say (str: string);
      procedure  SetSound; dynamic;
      procedure  Run; dynamic;
      procedure  RunSound; dynamic;
      procedure  RunActSound (frame: integer); dynamic;
      procedure  RunFrameAction (frame: integer); dynamic;  //橇贰烙付促 刀漂窍霸 秦具且老
      procedure  ActionEnded; dynamic;
      function   Move (step: integer): Boolean;
      procedure  MoveFail;
      function   CanCancelAction: Boolean;
      procedure  CancelAction;
      procedure  FeatureChanged; dynamic;
      function   Light: integer; dynamic;
      procedure  LoadSurface; dynamic;
      function   GetDrawEffectValue: TColorEffect;
      procedure  DrawChr (dsurface: TDirectDrawSurface; dx, dy: integer; blend: Boolean); dynamic;
      procedure  DrawEff (dsurface: TDirectDrawSurface; dx, dy: integer); dynamic;
   end;

   TNpcActor = class (TActor)
   private
   public
      procedure  Run; override;
      procedure  CalcActorFrame; override;
      function   GetDefaultFrame (wmode: Boolean): integer; override;
      procedure  LoadSurface; override;
   end;

   THumActor = class (TActor)
   private
      HairSurface: TDirectDrawSurface;
      WeaponSurface: TDirectDrawSurface;
      BoWeaponEffect: Boolean;  //公扁 力访己傍,柄咙 瓤苞
      CurWpEffect: integer;
      CurBubbleStruck: integer;
      wpeffecttime: longword;
      BoHideWeapon: Boolean;
   protected
      procedure CalcActorFrame; override;
      procedure DefaultMotion; override;
      function  GetDefaultFrame (wmode: Boolean): integer; override;
   public
      constructor Create; override;
      destructor Destroy; override;
      procedure  Run; override;
      procedure  RunFrameAction (frame: integer); override;
      function   Light: integer; override;
      procedure  LoadSurface; override;
      procedure  DoWeaponBreakEffect;
      procedure  DrawChr (dsurface: TDirectDrawSurface; dx, dy: integer; blend: Boolean); override;
   end;

   function RaceByPM (race: integer): PTMonsterAction;
   function GetMonImg (appr: integer): TWMImages;
   function GetOffset (appr: integer): integer;



implementation

uses
   ClMain, SoundUtil, clEvent;

//根据种族返回动作定义
function RaceByPM (race: integer): PTMonsterAction;
begin
   Result := nil;
   case race of
      10:      Result := @MA10;
      11:      Result := @MA11;
      12:      Result := @MA12;
      13:      Result := @MA13;
      14, 17, 18, 23:  Result := @MA14;
      15, 22:  Result := @MA15;
      16:      Result := @MA16;
      30, 31:  Result := @MA17;
      19, 20, 21, 40, 45, 52, 53:  Result := @MA19;
      41, 42:  Result := @MA20;
      43:      Result := @MA21;
      47:      Result := @MA22;
      48, 49:  Result := @MA23;
      32:      Result := @MA24;  //傈哎, 傍拜捞 2啊瘤 规侥
      33:      Result := @MA25;
      54:      Result := @MA28;
      55:      Result := @MA29;
      98:      Result := @MA27;
      99:      Result := @MA26;
      50:      Result := @MA50;
   end;
end;
 //根据外貌确定图片库
function GetMonImg (appr: integer): TWMImages;
begin
   Result := FrmMain.WMonImg; //Default
   case (appr div 10) of
      0: Result := FrmMain.WMonImg;   //
      1: Result := FrmMain.WMon2Img;  //侥牢檬
      2: Result := FrmMain.WMon3Img;
      3: Result := FrmMain.WMon4Img;
      4: Result := FrmMain.WMon5Img;
      5: Result := FrmMain.WMon6Img;
      6: Result := FrmMain.WMon7Img;
      7: Result := FrmMain.WMon8Img;
      8: Result := FrmMain.WMon9Img;
      9: Result := FrmMain.WMon10Img;
      10: Result := FrmMain.WMon11Img;
      11: Result := FrmMain.WMon12Img;
      12: Result := FrmMain.WMon13Img;
      13: Result := FrmMain.WMon14Img;
      14: Result := FrmMain.WMon15Img;
      15: Result := FrmMain.WMon16Img;
      16: Result := FrmMain.WMon17Img;
      17: Result := FrmMain.WMon18Img;
      90: Result := FrmMain.WEffectImg;  //己巩, 己寒
   end;
end;

function GetOffset (appr: integer): integer;
var
   nrace, npos: integer;
begin
   Result := 0;
   nrace := appr div 10;
   npos := appr mod 10;
   case nrace of
      0:    Result := npos * 280;  //8橇贰烙
      1:    Result := npos * 230;
      2, 3, 7..16:    Result := npos * 360;  //10橇贰烙 扁夯
      4:    begin
               Result := npos * 360;        //
               if npos = 1 then Result := 600;  //厚阜盔面
            end;
      5:    Result := npos * 430;   //粱厚
      6:    Result := npos * 440;   //林付脚厘,龋过,空
      17:   Result := npos * 350;   //脚荐
      90:   case npos of
               0: Result := 80;   //己巩
               1: Result := 168;
               2: Result := 184;
               3: Result := 200;
            end;
   end;
end;


⌨️ 快捷键说明

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