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

📄 m_actor.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): asm_i386.h                                                        }
{                                                                            }
{ Initial conversion by : Jan Horn (jhorn@global.co.za)                      }
{ Initial conversion on : 12-Jan-2002                                        }
{                                                                            }
{ This File contains part of convertion of Quake2 source to ObjectPascal.    }
{ More information about this project can be found at:                       }
{ http://www.sulaco.co.za/quake2/                                            }
{                                                                            }
{ Copyright (C) 1997-2001 Id Software, Inc.                                  }
{                                                                            }
{ This program is free software; you can redistribute it and/or              }
{ modify it under the terms of the GNU General Public License                }
{ as published by the Free Software Foundation; either version 2             }
{ of the License, or (at your option) any later version.                     }
{                                                                            }
{ This program is distributed in the hope that it will be useful,            }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of             }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                       }
{                                                                            }
{ See the GNU General Public License for more details.                       }
{                                                                            }
{----------------------------------------------------------------------------}
{ Updated on :                                                               }
{ Updated by :                                                               }
{                                                                            }
{----------------------------------------------------------------------------}
{ * Still dependent (to compile correctly) on:                               }
{ 1.) g_local.h and game.h                                                   }
{----------------------------------------------------------------------------}
{ * TODO:                                                                    }
{ 1.) test compilation with the above two units                              }
{ 2.) Validate converted items.  Some routines were converted as if STATIC   }
{     which was incorrect.  Tried to make visible all that needed to be but  }
{     would still benefit from an additional set of eyes.                    }
{----------------------------------------------------------------------------}

unit m_actor;

interface

const MAX_ACTOR_NAMES = 8;

{$I m_actor.inc}

const actor_names : Array[0..MAX_ACTOR_NAMES-1] of PChar=(
	'Hellrot',
	'Tokay',
	'Killme',
	'Disruptor',
	'Adrianator',
	'Rambear',
	'Titus',
	'Bitterman'
);

{****** TO BE REMOVED - BELOW *******}
const
  RAND_MAX = $7fff;
  { Above line Added by Scott }

const AI_STAND_GROUND = $00000001;

type edict_p = ^edict_t;
     mframe_t = Record
	aifunc : procedure(self : integer; dist : single);
	dist   : Single;
	thinkfunc : procedure(self : edict_p);
     end;

     mmove_t = Record
       firstframe : Integer;
       lastframe  :Integer;
       frame   : ^mframe_t;
       endfunc : procedure(self : edict_p);
     end;

     TMonsterinfo = record
       currentmove : mmove_t;
       aiflags : Integer;
     end;

     edict_t = record
       monsterinfo : TMonsterinfo;
       s : Record
         frame : integer;
         skinnum : integer;
       end;
       pain_debounce_time : word;
       enemy : edict_p;
       movetarget : edict_p;
       max_health : Integer;
       health : Integer;
       client : edict_p;
     end;

     Tlevel = record
       time : Word;
     end;
var level : tlevel;
type vect3_t = Integer;
type vec3_t = single;
type cplane_t = single;
type csurface_t = single;

procedure ai_stand(s : integer; dist : single);
procedure ai_walk(s : integer; dist : single);
procedure ai_run(s : integer; dist : single);
procedure ai_move(s : integer; dist : single);
procedure ai_turn(s : integer; dist : single);
procedure ai_charge(s : integer; dist : single);
{****** TO BE REMOVED - ABOVE *******}


procedure actor_stand(self : Pedict_p);
procedure actor_walk(self : Pedict_p);
procedure actor_run(self : Pedict_p);
procedure actor_dead(self : Pedict_p);
procedure actor_die(self, inflictor, attacker: Pedict_p; damage: Integer; point: vec3_t);
procedure actor_fire(self : Pedict_p);

const actor_frames_stand : Array[0..39] of mframe_t = (
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil),
        (aifunc:ai_stand; dist:0; thinkfunc:nil));
      actor_move_stand : mmove_t = (firstframe:FRAME_stand101; lastframe:FRAME_stand140; frame:@actor_frames_stand; endfunc:nil);

const actor_frames_walk : Array[0..10] of mframe_t = (
        (aifunc:ai_walk; dist:0;  thinkfunc:nil),
	(aifunc:ai_walk; dist:6;  thinkfunc:nil),
	(aifunc:ai_walk; dist:10; thinkfunc:nil),
	(aifunc:ai_walk; dist:3;  thinkfunc:nil),
	(aifunc:ai_walk; dist:2;  thinkfunc:nil),
	(aifunc:ai_walk; dist:7;  thinkfunc:nil),
	(aifunc:ai_walk; dist:10; thinkfunc:nil),
	(aifunc:ai_walk; dist:1;  thinkfunc:nil),
	(aifunc:ai_walk; dist:4;  thinkfunc:nil),
	(aifunc:ai_walk; dist:0;  thinkfunc:nil),
	(aifunc:ai_walk; dist:0;  thinkfunc:nil));
      actor_move_walk : mmove_t = (firstframe:FRAME_walk01; lastframe:FRAME_walk08; frame:@actor_frames_walk; endfunc:nil);

const actor_frames_run : Array[0..11] of mframe_t = (
        (aifunc:ai_run; dist:4;  thinkfunc:nil),
        (aifunc:ai_run; dist:15; thinkfunc:nil),
	(aifunc:ai_run; dist:15; thinkfunc:nil),
	(aifunc:ai_run; dist:8;  thinkfunc:nil),
	(aifunc:ai_run; dist:20; thinkfunc:nil),
	(aifunc:ai_run; dist:15; thinkfunc:nil),
	(aifunc:ai_run; dist:8;  thinkfunc:nil),
	(aifunc:ai_run; dist:17; thinkfunc:nil),
	(aifunc:ai_run; dist:12; thinkfunc:nil),
	(aifunc:ai_run; dist:-2; thinkfunc:nil),
	(aifunc:ai_run; dist:-2; thinkfunc:nil),
	(aifunc:ai_run; dist:-1; thinkfunc:nil));
      actor_move_run : mmove_t = (firstframe:FRAME_run02; lastframe:FRAME_run07; frame:@actor_frames_run; endfunc:nil);

const actor_frames_pain1 : Array[0..2] of mframe_t = (
	(aifunc:ai_move; dist:-5; thinkfunc:nil),
	(aifunc:ai_move; dist:4;  thinkfunc:nil),
	(aifunc:ai_move; dist:1;  thinkfunc:nil));
      actor_move_pain1 : mmove_t = (firstframe:FRAME_pain101; lastframe:FRAME_pain103; frame:@actor_frames_pain1; endfunc:actor_run);

const actor_frames_pain2 : Array[0..2] of mframe_t = (
	(aifunc:ai_move; dist:-4; thinkfunc:nil),
	(aifunc:ai_move; dist:4;  thinkfunc:nil),
	(aifunc:ai_move; dist:0;  thinkfunc:nil));
      actor_move_pain2 : mmove_t = (firstframe:FRAME_pain201; lastframe:FRAME_pain203; frame:@actor_frames_pain2; endfunc:actor_run);

const actor_frames_pain3 : Array[0..2] of mframe_t = (
	(aifunc:ai_move; dist:-1; thinkfunc:nil),
	(aifunc:ai_move; dist:1;  thinkfunc:nil),
	(aifunc:ai_move; dist:0;  thinkfunc:nil));
      actor_move_pain3 : mmove_t = (firstframe:FRAME_pain301; lastframe:FRAME_pain303; frame:@actor_frames_pain3; endfunc:actor_run);

const actor_frames_flipoff : Array[0..13] of mframe_t = (
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil));
      actor_move_flipoff : mmove_t = (firstframe:FRAME_flip01; lastframe:FRAME_flip14; frame:@actor_frames_flipoff; endfunc:actor_run);

const actor_frames_taunt : Array[0..16] of mframe_t = (
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil),
	(aifunc:ai_turn; dist:0; thinkfunc:nil));
      actor_move_taunt : mmove_t = (firstframe:FRAME_taunt01; lastframe:FRAME_taunt17; frame:@actor_frames_taunt; endfunc:actor_run);

const actor_frames_death1 : Array[0..6] of mframe_t = (
        (aifunc:ai_move; dist:0;  thinkfunc:nil),
        (aifunc:ai_move; dist:0;  thinkfunc:nil),
        (aifunc:ai_move; dist:-13;thinkfunc:nil),
        (aifunc:ai_move; dist:14; thinkfunc:nil),
        (aifunc:ai_move; dist:3;  thinkfunc:nil),
        (aifunc:ai_move; dist:-2; thinkfunc:nil),
        (aifunc:ai_move; dist:1;  thinkfunc:nil));
      actor_move_death1 : mmove_t = (firstframe:FRAME_death101; lastframe:FRAME_death107; frame:@actor_frames_death1; endfunc:actor_dead);

const actor_frames_death2 : Array[0..12] of mframe_t = (
        (aifunc:ai_move; dist:0;   thinkfunc:nil),
        (aifunc:ai_move; dist:7;   thinkfunc:nil),
        (aifunc:ai_move; dist:-6;  thinkfunc:nil),
        (aifunc:ai_move; dist:-5;  thinkfunc:nil),
        (aifunc:ai_move; dist:1;   thinkfunc:nil),
        (aifunc:ai_move; dist:0;   thinkfunc:nil),
        (aifunc:ai_move; dist:-1;  thinkfunc:nil),
        (aifunc:ai_move; dist:-2;  thinkfunc:nil),
        (aifunc:ai_move; dist:-1;  thinkfunc:nil),
        (aifunc:ai_move; dist:-9;  thinkfunc:nil),
        (aifunc:ai_move; dist:-13; thinkfunc:nil),
        (aifunc:ai_move; dist:-13; thinkfunc:nil),
        (aifunc:ai_move; dist:0;   thinkfunc:nil));
      actor_move_death2 : mmove_t = (firstframe:FRAME_death201; lastframe:FRAME_death213; frame:@actor_frames_death2; endfunc:actor_dead);

const actor_frames_attack : Array[0..3] of mframe_t = (
	(aifunc:ai_charge; dist:-2; thinkfunc:actor_fire),
	(aifunc:ai_charge; dist:-2; thinkfunc:nil),
	(aifunc:ai_charge; dist:3;  thinkfunc:nil),
	(aifunc:ai_charge; dist:2;  thinkfunc:nil));
      actor_move_attack : mmove_t = (firstframe:FRAME_attak01; lastframe:FRAME_attak04; frame:@actor_frames_attack; endfunc:actor_run);

const messages : Array[0..3] of PChar = (
          'Watch it', '#$@*&', 'Idiot','Check your targets');

procedure actor_attack(self : Pedict_p);
procedure actor_use(self, other, activator : edict_p);
procedure SP_misc_actor(self : Pedict_p);
procedure target_actor_touch(self, other: Pedict_p; plane: Pcplane_t; surf: Pcsurface_t);
procedure SP_target_actor(self: Pedict_p);


implementation

//uses g_local, g_ai {From Game Directory};



{****** TO BE REMOVED *******}
procedure ai_stand(s : integer; dist : single);
begin
end;
procedure ai_walk(s : integer; dist : single);
begin
end;
procedure ai_run(s : integer; dist : single);
begin
end;
procedure ai_move(s : integer; dist : single);
begin
end;
procedure ai_turn(s : integer; dist : single);
begin
end;
{****** TO BE REMOVED *******}


procedure actor_stand(self : Pedict_p);
begin
  self^.monsterinfo.currentmove := @actor_move_stand;
  // randomize on startup
  if (level.time < 1.0) then
    self^.s.frame := self^.monsterinfo.currentmove^.firstframe + (Random(RAND_MAX) mod (self^.monsterinfo.currentmove^.lastframe - self^.monsterinfo.currentmove^.firstframe + 1));
end;


procedure actor_walk(self : Pedict_p);
begin
  self^.monsterinfo.currentmove := @actor_move_walk;
end;

procedure actor_run(self : Pedict_p);
begin
  if ((level.time < self^.pain_debounce_time) AND (self.enemy = nil)) then
  begin
    if (self^.movetarget <> nil) then
      actor_walk(self)
    else
      actor_stand(self);
    Exit;
  end;

  if (self^.monsterinfo.aiflags AND AI_STAND_GROUND) <> 0 then
  begin

⌨️ 快捷键说明

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