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

📄 m_gladiator.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): m_gladiator.h                                                     }
{                                                                            }
{ Initial conversion by : Ben Watt (ben@delphigamedev.com)                   }
{ Initial conversion on : 07 March-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                              }
{----------------------------------------------------------------------------}
{
==============================================================================

GLADIATOR

==============================================================================
}

unit m_gladiator;

interface

const MODEL_SCALE     = 1.000000;

var
  sound_pain1,
  sound_pain2,
  sound_die,
  sound_gun,
  sound_cleaver_swing,
  sound_cleaver_hit,
  sound_cleaver_miss,
  sound_idle,
  sound_search,
  sound_sight            : Integer;

{$I g_local.inc}
{$I m_gladiator.inc}

procedure gladiator_idle(self : edict_t);
begin
  gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
end;

procedure gladiator_sight(self, other : edict_t);
begin
  gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
end;

procedure gladiator_search(self : edict_t);
begin
  gi.sound(self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
end;

procedure gladiator_cleaver_swing(self : edict_t);
begin
  gi.sound(self, CHAN_WEAPON, sound_cleaver_swing, 1, ATTN_NORM, 0);
end;

const
  gladiator_frames_stand : Array[0..6] 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));

  gladiator_move_stand : mmove_t =
    (firstframe:FRAME_stand1; lastframe:FRAME_stand7; frame:gladiator_frames_stand; endfunc:nil);

procedure gladiator_stand(self : edict_t);
begin
  self.monsterinfo.currentmove := gladiator_move_stand;
end;

const
  gladiator_frames_walk : Array[0..15] of mframe_t =
    ((aifunc:ai_walk; dist:15; thinkfunc:nil),
     (aifunc:ai_walk; dist:7;  thinkfunc:nil),
     (aifunc:ai_walk; dist:6;  thinkfunc:nil),
     (aifunc:ai_walk; dist:5;  thinkfunc:nil),
     (aifunc:ai_walk; dist:2;  thinkfunc:nil),
     (aifunc:ai_walk; dist:0;  thinkfunc:nil),
     (aifunc:ai_walk; dist:2;  thinkfunc:nil),
     (aifunc:ai_walk; dist:8;  thinkfunc:nil),
     (aifunc:ai_walk; dist:12; thinkfunc:nil),
     (aifunc:ai_walk; dist:8;  thinkfunc:nil),
     (aifunc:ai_walk; dist:5;  thinkfunc:nil),
     (aifunc:ai_walk; dist:5;  thinkfunc:nil),
     (aifunc:ai_walk; dist:2;  thinkfunc:nil),
     (aifunc:ai_walk; dist:2;  thinkfunc:nil),
     (aifunc:ai_walk; dist:1;  thinkfunc:nil),
     (aifunc:ai_walk; dist:8;  thinkfunc:nil));

  gladiator_move_walk : mmove_t =
    (firstframe:FRAME_walk1; lastframe:FRAME_walk16; frame:gladiator_frames_walk; endfunc:nil);

procedure gladiator_walk(self : edict_t);
begin
  self.monsterinfo.currentmove := gladiator_move_walk;
end;

const
  gladiator_frames_run : Array[0..5] of mframe_t =
    ((aifunc:ai_run; dist:23; thinkfunc:nil),
     (aifunc:ai_run; dist:14; thinkfunc:nil),
     (aifunc:ai_run; dist:14; thinkfunc:nil),
     (aifunc:ai_run; dist:21; thinkfunc:nil),
     (aifunc:ai_run; dist:12; thinkfunc:nil),
     (aifunc:ai_run; dist:13; thinkfunc:nil));

  gladiator_move_run : mmove_t =
    (firstframe:FRAME_run1; lastframe:FRAME_run6; frame:gladiator_frames_run; endfunc:nil);

procedure gladiator_run(self : edict_t);
begin
  if (self.monsterinfo.aiflags and AI_STAND_GROUND) then
    self.monsterinfo.currentmove := gladiator_move_stand
  else
    self.monsterinfo.currentmove := gladiator_move_run;
end;

procedure GaldiatorMelee(self : edict_t);
var
  aim : vec3_t;
begin
  VectorSet(aim, MELEE_DISTANCE, self.mins[0], -4);
  if (fire_hit(self, aim, (20 + (random(5))), 300)) then
    gi.sound(self, CHAN_AUTO, sound_cleaver_hit, 1, ATTN_NORM, 0);
  else
    gi.sound(self, CHAN_AUTO, sound_cleaver_miss, 1, ATTN_NORM, 0);
end;

const
  gladiator_frames_attack_melee : Array[0..16] of mframe_t =
    ((aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:gladiator_cleaver_swing),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:GaldiatorMelee),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:gladiator_cleaver_swing),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:GaldiatorMelee),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil));

  gladiator_move_attack_melee : mmove_t =
    (firstframe:FRAME_melee1; lastframe:FRAME_melee17; frame:gladiator_frames_attack_melee; endfunc:gladiator_run);

procedure gladiator_melee(self : edict_t);
begin
  self.monsterinfo.currentmove := gladiator_move_attack_melee;
end;

procedure GladiatorGun(self : edict_t);
var
  start       : vec3_t;
  dir         : vec3_t;
  fwrd, right : vec3_t;
begin
  AngleVectors(self.s.angles, fwrd, right, nil);
  G_ProjectSource(self.s.origin, monster_flash_offset[MZ2_GLADIATOR_RAILGUN_1], fwrd, right, start);

  // calc direction to where we targted
  VectorSubtract(self.pos1, start, dir);
  VectorNormalize(dir);

  monster_fire_railgun(self, start, dir, 50, 100, MZ2_GLADIATOR_RAILGUN_1);
end;

const

⌨️ 快捷键说明

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