📄 m_infantry.pas
字号:
{----------------------------------------------------------------------------}
{ }
{ File(s): m_infantry.h }
{ }
{ Initial conversion by : Ben Watt (ben@delphigamedev.com) }
{ Initial conversion on : 28-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 }
{----------------------------------------------------------------------------}
unit m_infantry;
interface
const MODEL_SCALE = 1.000000;
var
sound_pain1,
sound_pain2,
sound_die1,
sound_die2,
sound_gunshot,
sound_weapon_cock,
sound_punch_swing,
sound_punch_hit,
sound_sight,
sound_search,
sound_idle : Integer;
{$I g_local.inc}
{$I m_infantry.inc}
procedure infantry_stand(self : edict_t);
procedure infantry_fidget(self : edict_t);
procedure infantry_walk(self : edict_t);
procedure infantry_run(self : edict_t);
procedure infantry_pain(self, other : edict_t; kick : single; damage : Integer);
procedure InfantryMachineGun(self : edict_t);
procedure infantry_sight(self : edict_t);
procedure infantry_dead(self : edict_t);
procedure infantry_die(self, inflictor, attacker : edict_t; damage : Integer; point: vec3_t);
procedure infantry_duck_down(self : edict_t);
procedure infantry_duck_hold(self : edict_t);
procedure infantry_duck_up(self : edict_t);
procedure infantry_dodge(self, attacker : edict_t, eta : Float);
procedure infantry_cock_gun(self : edict_t);
procedure infantry_fire(self : edict_t);
procedure infantry_swing(self : edict_t);
procedure infantry_smack(self : edict_t);
procedure infantry_attack(self : edict_t);
procedure SP_monster_infantry(self : edict_t);
const
infantry_frames_stand : Array[0..21] 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));
infantry_move_stand : mmove_t =
(firstframe:FRAME_stand50; lastframe:FRAME_stand71; frame:infantry_frames_stand; endfunc:nil);
procedure infantry_stand(self : edict_t);
begin
self.monsterinfo.currentmove := infantry_move_stand;
end;
const
infantry_frames_fidget : Array[0..48] of mframe_t =
((aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:3; thinkfunc:nil),
(aifunc:ai_stand; dist:6; thinkfunc:nil),
(aifunc:ai_stand; dist:3; 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:1; 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:1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:-1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:-2; thinkfunc:nil),
(aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:-1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:-1; 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:-1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:-1; thinkfunc:nil),
(aifunc:ai_stand; dist:-1; thinkfunc:nil),
(aifunc:ai_stand; dist:0; thinkfunc:nil),
(aifunc:ai_stand; dist:-3; thinkfunc:nil),
(aifunc:ai_stand; dist:-2; thinkfunc:nil),
(aifunc:ai_stand; dist:-3; thinkfunc:nil),
(aifunc:ai_stand; dist:-3; thinkfunc:nil),
(aifunc:ai_stand; dist:-2; thinkfunc:nil));
infantry_move_fidget : mmove_t =
(firstframe:FRAME_stand01; lastframe:FRAME_stand49; frame:infantry_frames_fidget; endfunc:infantry_stand);
procedure infantry_fidget(self : edict_t);
begin
self.monsterinfo.currentmove := infantry_move_fidget;
gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
end;
const
infantry_frames_walk : Array[0..11] of mframe_t =
((aifunc:ai_walk; dist:5; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:5; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:5; thinkfunc:nil),
(aifunc:ai_walk; dist:6; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:4; thinkfunc:nil),
(aifunc:ai_walk; dist:5; thinkfunc:nil));
infantry_move_walk : mmove_t =
(firstframe:FRAME_walk03; lastframe:FRAME_walk14; frame:infantry_frames_walk; endfunc:nil);
procedure infantry_walk(self : edict_t);
begin
self.monsterinfo.currentmove := infantry_move_walk;
end;
const
infantry_frames_run : Array[0..7] of mframe_t =
((aifunc:ai_run; dist:10; thinkfunc:nil),
(aifunc:ai_run; dist:20; thinkfunc:nil),
(aifunc:ai_run; dist:5; thinkfunc:nil),
(aifunc:ai_run; dist:7; thinkfunc:nil),
(aifunc:ai_run; dist:30; thinkfunc:nil),
(aifunc:ai_run; dist:35; thinkfunc:nil),
(aifunc:ai_run; dist:2; thinkfunc:nil),
(aifunc:ai_run; dist:6; thinkfunc:nil));
infantry_move_run : mmove_t =
(firstframe:FRAME_run01; lastframe:FRAME_run08; frame:infantry_frames_run; endfunc:nil);
procedure infantry_run(self : edict_t);
begin
if (self.monsterinfo.aiflags and AI_STAND_GROUND) = 1 then
self.monsterinfo.currentmove := infantry_move_stand
else
self.monsterinfo.currentmove := infantry_move_run;
end;
const
infantry_frames_pain1 : Array[0..9] of mframe_t =
((aifunc:ai_run; dist:-3; thinkfunc:nil),
(aifunc:ai_run; dist:-2; thinkfunc:nil),
(aifunc:ai_run; dist:-1; thinkfunc:nil),
(aifunc:ai_run; dist:-2; thinkfunc:nil),
(aifunc:ai_run; dist:-1; thinkfunc:nil),
(aifunc:ai_run; dist:1; thinkfunc:nil),
(aifunc:ai_run; dist:-1; thinkfunc:nil),
(aifunc:ai_run; dist:1; thinkfunc:nil),
(aifunc:ai_run; dist:6; thinkfunc:nil),
(aifunc:ai_run; dist:2; thinkfunc:nil));
infantry_move_pain1 : mmove_t =
(firstframe:FRAME_pain101; lastframe:FRAME_pain110; frame:infantry_frames_pain1; endfunc:infantry_run);
const
infantry_frames_pain2 : Array[0..9] of mframe_t =
((aifunc:ai_run; dist:-3; thinkfunc:nil),
(aifunc:ai_run; dist:-3; thinkfunc:nil),
(aifunc:ai_run; dist:0; thinkfunc:nil),
(aifunc:ai_run; dist:-1; thinkfunc:nil),
(aifunc:ai_run; dist:-2; thinkfunc:nil),
(aifunc:ai_run; dist:0; thinkfunc:nil),
(aifunc:ai_run; dist:0; thinkfunc:nil),
(aifunc:ai_run; dist:2; thinkfunc:nil),
(aifunc:ai_run; dist:5; thinkfunc:nil),
(aifunc:ai_run; dist:2; thinkfunc:nil));
infantry_move_pain2 : mmove_t =
(firstframe:FRAME_pain201; lastframe:FRAME_pain210; frame:infantry_frames_pain2; endfunc:infantry_run);
procedure infantry_pain(self, other : edict_t; kick : Single; damage : Integer);
var
n : integer;
begin
if self.health < self.max_health/2 then
self.s.skinnum := 1;
if level.time < self.pain_debounce_time then
exit;
self.pain_debounce_time := level.time + 3;
if skill.value = 3 then
exit; // no pain anims in nightmare
n = random(2);
if n = 0 then
begin
self.monsterinfo.currentmove := infantry_move_pain1;
gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
end
else
self.monsterinfo.currentmove := infantry_move_pain2;
gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
end;
const
aimangles : Array[0..11] of vec3_t =
(( 0.0, 5.0, 0.0),
(10.0, 15.0, 0.0),
(20.0, 25.0, 0.0),
(25.0, 35.0, 0.0),
(30.0, 40.0, 0.0),
(30.0, 45.0, 0.0),
(25.0, 50.0, 0.0),
(20.0, 40.0, 0.0),
(15.0, 35.0, 0.0),
(40.0, 35.0, 0.0),
(70.0, 35.0, 0.0),
(90.0, 35.0, 0.0));
procedure InfantryMachineGun(self : edict_t);
var
start, target : vec3_t;
fwrd, right : vec3_t;
vec : vec3_t;
flash_number : integer;
begin
if self.s.frame = FRAME_attack111 then
begin
flash_number := MZ2_INFANTRY_MACHINEGUN_1;
AngleVectors(self.s.angles, fwrd, right, nil);
G_ProjectSource(self.s.origin, monster_flash_offset[flash_number], fwrd, right, start);
if (self.enemy <> nil) then
begin
VectorMA(self.enemy.s.origin, -0.2, self.enemy.velocity, target);
target[2] := target[2] + self.enemy.viewheight;
VectorSubtract(target, start, fwrd);
VectorNormalize(fwrd);
end
else
AngleVectors(self.s.angles, fwrd, right, nil);
end
else
begin
flash_number := MZ2_INFANTRY_MACHINEGUN_2 + (self.s.frame - FRAME_death211);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -