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

📄 m_berserk.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): m_berserk.h                                                       }
{                                                                            }
{ Initial conversion by : Ben Watt (ben@delphigamedev.com)                   }
{ Initial conversion on : 11-March-2002                                      }
{                                                                            }
{ This file is part of the conversion of Quake2 source to Delphi.            }
{ 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                              }
{----------------------------------------------------------------------------}
{
==============================================================================

BERSERK

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


unit m_berserk;

interface

const MODEL_SCALE     = 1.000000;

var
  sound_pain,
  sound_die,
  sound_idle,
  sound_punch,
  sound_sight,
  sound_search       : Integer;

{$I g_local.inc}
{$I m_berserk.inc}

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

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

const
  berserk_frames_stand : Array[0..4] of mframe_t =
    ((aifunc:ai_stand; dist:0; thinkfunc:berserk_fidget),
     (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));

  berserk_move_stand : mmove_t =
    (firstframe:FRAME_stand1; lastframe:FRAME_stand5; frame:berserk_frames_stand; endfunc:nil);

procedure berserk_stand(self : edict_t);
begin
  self.monsterinfo.currentmove := berserk_move_stand;
end;

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

  berserk_move_stand_fidget : mmove_t =
    (firstframe:FRAME_standb1; lastframe:FRAME_standb20; frame:berserk_frames_stand_fidget; endfunc:berserk_stand);

procedure berserk_fidget(self : edict_t);
begin
  if (self.monsterinfo.aiflags and AI_STAND_GROUND) then
    exit;
  if (random() > 0.15) then
    exit;

  self.monsterinfo.currentmove := berserk_move_stand_fidget;
  gi.sound(self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
end;

const
  berserk_frames_walk : Array[0..11] of mframe_t =
    ((aifunc:ai_walk; dist:9.1; thinkfunc:nil),
     (aifunc:ai_walk; dist:6.3; thinkfunc:nil),
     (aifunc:ai_walk; dist:4.9; thinkfunc:nil),
     (aifunc:ai_walk; dist:6.7; thinkfunc:nil),
     (aifunc:ai_walk; dist:6.0; thinkfunc:nil),
     (aifunc:ai_walk; dist:8.2; thinkfunc:nil),
     (aifunc:ai_walk; dist:7.2; thinkfunc:nil),
     (aifunc:ai_walk; dist:6.1; thinkfunc:nil),
     (aifunc:ai_walk; dist:4.9; thinkfunc:nil),
     (aifunc:ai_walk; dist:4.7; thinkfunc:nil),
     (aifunc:ai_walk; dist:4.7; thinkfunc:nil),
     (aifunc:ai_walk; dist:4.8; thinkfunc:nil));

  berserk_move_walk : mmove_t =
    (firstframe:FRAME_walkc1; lastframe:FRAME_walkc11; frame:berserk_frames_walk; endfunc:nil);

procedure berserk_walk(self : edict_t);
begin
  self.monsterinfo.currentmove := berserk_move_walk;
end;

{

  *****************************
  SKIPPED THIS FOR NOW!
  *****************************

   Running -> Arm raised in air    }

//void()	berserk_runb1	=[	$r_att1 ,	berserk_runb2	] {ai_run(21);};
//void()	berserk_runb2	=[	$r_att2 ,	berserk_runb3	] {ai_run(11);};
//void()	berserk_runb3	=[	$r_att3 ,	berserk_runb4	] {ai_run(21);};
//void()	berserk_runb4	=[	$r_att4 ,	berserk_runb5	] {ai_run(25);};
//void()	berserk_runb5	=[	$r_att5 ,	berserk_runb6	] {ai_run(18);};
//void()	berserk_runb6	=[	$r_att6 ,	berserk_runb7	] {ai_run(19);};
// running with arm in air : start loop
//void()	berserk_runb7	=[	$r_att7 ,	berserk_runb8	] {ai_run(21);};
//void()	berserk_runb8	=[	$r_att8 ,	berserk_runb9	] {ai_run(11);};
//void()	berserk_runb9	=[	$r_att9 ,	berserk_runb10	] {ai_run(21);};
//void()	berserk_runb10	=[	$r_att10 ,	berserk_runb11	] {ai_run(25);};
//void()	berserk_runb11	=[	$r_att11 ,	berserk_runb12	] {ai_run(18);};
//void()	berserk_runb12	=[	$r_att12 ,	berserk_runb7	] {ai_run(19);};
// running with arm in air : end loop

const
  berserk_frames_run1 : Array[0..5] of mframe_t =
    ((aifunc:ai_run; dist:21; thinkfunc:nil),
     (aifunc:ai_run; dist:11; thinkfunc:nil),
     (aifunc:ai_run; dist:21; thinkfunc:nil),
     (aifunc:ai_run; dist:25; thinkfunc:nil),
     (aifunc:ai_run; dist:18; thinkfunc:nil),
     (aifunc:ai_run; dist:19; thinkfunc:nil));

  berserk_move_run1 : mmove_t =
    (firstframe:FRAME_run1; lastframe:FRAME_run6; frame:berserk_frames_run1; endfunc:nil);

procedure berserk_run(self : edict_t);
begin
  if (self.monsterinfo.aiflags and AI_STAND_GROUND) then
    self.monsterinfo.currentmove := berserk_move_stand
  else
    self.monsterinfo.currentmove := berserk_move_run1;
end;

procedure berserk_attack_spike(self : edict_t);
var
  aim : vec3_t;
begin
  aim := (MELEE_DISTANCE, 0, -24);
  fire_hit(self, aim, (15 + (random(6))), 400); // Faster attack -- upwards and backwards
end;

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

const
  berserk_frames_attack_spike : Array[0..5] of mframe_t =
    ((aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:berserk_swing),
     (aifunc:ai_charge; dist:0; thinkfunc:berserk_attack_spike),
     (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));

  berserk_move_attack_spike : mmove_t =
    (firstframe:FRAME_att_c1; lastframe:FRAME_att_c8; frame:berserk_frames_attack_spike; endfunc:berserk_run);

procedure berserk_attack_club(self : edict_t);
var
  aim : vec3_t;
begin
  VectorSet(aim, MELEE_DISTANCE, self.mins[0], -4);
  fire_hit(self, aim, (5 + (random(6))), 400);		// Slower attack
end;

const
  berserk_frames_attack_club : Array[0..11] 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:berserk_swing),
     (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:berserk_attack_club),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),
     (aifunc:ai_charge; dist:0; thinkfunc:nil),

⌨️ 快捷键说明

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