📄 m_chick.pas
字号:
{----------------------------------------------------------------------------}
{ }
{ File(s): m_chick.c }
{ }
{ Initial conversion by : YgriK (Igor Karpov) - glYgriK@hotbox.ru }
{ Initial conversion on : 12-Feb-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) unit: g_local }
{ 2) unit: q_shared }
{ 3) unit: game }
{ 4) unit: m_flash }
{ }
{ .) unit: g_ai }
{ }
{ 1) inc: m_chick }
{ }
{----------------------------------------------------------------------------}
{ * TODO: }
{ 1) Do more tests }
{ }
{----------------------------------------------------------------------------}
{*
==============================================================================
chick
==============================================================================
*}
unit m_chick;
interface
uses g_local;
procedure SP_monster_chick (self : edict_p); cdecl;
implementation
uses q_shared, gameunit, m_flash , g_ai, g_main, g_local_add, game_add,
g_misc, g_weapon, g_utils, g_monster, CPas;
{$I m_chick.inc}
procedure chick_stand (self : edict_p); cdecl; forward;
procedure chick_run (self : edict_p); cdecl; forward;
procedure chick_reslash (self : edict_p); cdecl; forward;
procedure chick_rerocket (self : edict_p); cdecl; forward;
procedure chick_attack1 (self : edict_p); cdecl; forward;
var
sound_missile_prelaunch,
sound_missile_launch,
sound_melee_swing,
sound_melee_hit,
sound_missile_reload,
sound_death1,
sound_death2,
sound_fall_down,
sound_idle1,
sound_idle2,
sound_pain1,
sound_pain2,
sound_pain3,
sound_sight,
sound_search : integer;
procedure ChickMoan (self : edict_p); cdecl;
begin
if (_random() < 0.5) then
gi.sound (self, CHAN_VOICE, sound_idle1, 1, ATTN_IDLE, 0)
else
gi.sound (self, CHAN_VOICE, sound_idle2, 1, ATTN_IDLE, 0);
end;
const
chick_frames_fidget : array [0..29] 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: ChickMoan),
(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) );
chick_move_fidget : mmove_t = (firstframe: FRAME_stand201; lastframe: FRAME_stand230; frame: @chick_frames_fidget; endfunc: chick_stand);
procedure chick_fidget (self : edict_p); cdecl;
begin
if (self^.monsterinfo.aiflags AND AI_STAND_GROUND) <> 0 then
Exit;
if (_random() <= 0.3) then
self^.monsterinfo.currentmove := @chick_move_fidget;
end;
const
chick_frames_stand : array [0..29] 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: chick_fidget) );
chick_move_stand : mmove_t = (firstframe: FRAME_stand101; lastframe: FRAME_stand130; frame: @chick_frames_stand; endfunc: Nil);
procedure chick_stand (self : edict_p);
begin
self^.monsterinfo.currentmove := @chick_move_stand;
end;
const
chick_frames_start_run : array [0..9] of mframe_t = (
(aifunc: ai_run; dist: 1; thinkfunc: Nil),
(aifunc: ai_run; dist: 0; thinkfunc: Nil),
(aifunc: ai_run; dist: 0; thinkfunc: Nil),
(aifunc: ai_run; dist: -1; thinkfunc: Nil),
(aifunc: ai_run; dist: -1; thinkfunc: Nil),
(aifunc: ai_run; dist: 0; thinkfunc: Nil),
(aifunc: ai_run; dist: 1; thinkfunc: Nil),
(aifunc: ai_run; dist: 3; thinkfunc: Nil),
(aifunc: ai_run; dist: 6; thinkfunc: Nil),
(aifunc: ai_run; dist: 3; thinkfunc: Nil) );
chick_move_start_run : mmove_t = (firstframe: FRAME_walk01; lastframe: FRAME_walk10; frame: @chick_frames_start_run; endfunc: chick_run);
chick_frames_run : array [0..9] of mframe_t = (
(aifunc: ai_run; dist: 6; thinkfunc: Nil),
(aifunc: ai_run; dist: 8; thinkfunc: Nil),
(aifunc: ai_run; dist: 13; thinkfunc: Nil),
(aifunc: ai_run; dist: 5; thinkfunc: Nil),
(aifunc: ai_run; dist: 7; thinkfunc: Nil),
(aifunc: ai_run; dist: 4; thinkfunc: Nil),
(aifunc: ai_run; dist: 11; thinkfunc: Nil),
(aifunc: ai_run; dist: 5; thinkfunc: Nil),
(aifunc: ai_run; dist: 9; thinkfunc: Nil),
(aifunc: ai_run; dist: 7; thinkfunc: Nil) );
chick_move_run : mmove_t = (firstframe: FRAME_walk11; lastframe: FRAME_walk20; frame: @chick_frames_run; endfunc: Nil);
chick_frames_walk : array [0..9] of mframe_t = (
(aifunc: ai_walk; dist: 6; thinkfunc: Nil),
(aifunc: ai_walk; dist: 8; thinkfunc: Nil),
(aifunc: ai_walk; dist: 13; thinkfunc: Nil),
(aifunc: ai_walk; dist: 5; thinkfunc: Nil),
(aifunc: ai_walk; dist: 7; thinkfunc: Nil),
(aifunc: ai_walk; dist: 4; thinkfunc: Nil),
(aifunc: ai_walk; dist: 11; thinkfunc: Nil),
(aifunc: ai_walk; dist: 5; thinkfunc: Nil),
(aifunc: ai_walk; dist: 9; thinkfunc: Nil),
(aifunc: ai_walk; dist: 7; thinkfunc: Nil) );
chick_move_walk : mmove_t = (firstframe: FRAME_walk11; lastframe: FRAME_walk20; frame: @chick_frames_walk; endfunc: Nil);
procedure chick_walk (self : edict_p); cdecl;
begin
self^.monsterinfo.currentmove := @chick_move_walk;
end;
procedure chick_run (self : edict_p); cdecl;
begin
if (self^.monsterinfo.aiflags AND AI_STAND_GROUND) <> 0 then
begin
self^.monsterinfo.currentmove := @chick_move_stand;
Exit;
end;
if (self^.monsterinfo.currentmove = @chick_move_walk) OR (self^.monsterinfo.currentmove = @chick_move_start_run) then
self^.monsterinfo.currentmove := @chick_move_run
else
self^.monsterinfo.currentmove := @chick_move_start_run;
end;
const
chick_frames_pain1 : array [0..4] of mframe_t = (
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil) );
chick_move_pain1 : mmove_t = (firstframe: FRAME_pain101; lastframe: FRAME_pain105; frame: @chick_frames_pain1; endfunc: chick_run);
chick_frames_pain2 : array [0..4] of mframe_t = (
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil) );
chick_move_pain2 : mmove_t = (firstframe: FRAME_pain201; lastframe: FRAME_pain205; frame: @chick_frames_pain2; endfunc: chick_run);
chick_frames_pain3 : array [0..20] of mframe_t = (
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: -6; thinkfunc: Nil),
(aifunc: ai_move; dist: 3; thinkfunc: Nil),
(aifunc: ai_move; dist: 11; thinkfunc: Nil),
(aifunc: ai_move; dist: 3; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 4; thinkfunc: Nil),
(aifunc: ai_move; dist: 1; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: -3; thinkfunc: Nil),
(aifunc: ai_move; dist: -4; thinkfunc: Nil),
(aifunc: ai_move; dist: 5; thinkfunc: Nil),
(aifunc: ai_move; dist: 7; thinkfunc: Nil),
(aifunc: ai_move; dist: -2; thinkfunc: Nil),
(aifunc: ai_move; dist: 3; thinkfunc: Nil),
(aifunc: ai_move; dist: -5; thinkfunc: Nil),
(aifunc: ai_move; dist: -2; thinkfunc: Nil),
(aifunc: ai_move; dist: -8; thinkfunc: Nil),
(aifunc: ai_move; dist: 2; thinkfunc: Nil) );
chick_move_pain3 : mmove_t = (firstframe: FRAME_pain301; lastframe: FRAME_pain321; frame: @chick_frames_pain3; endfunc: chick_run);
procedure chick_pain (self, other : edict_p; kick : single; damage : integer); cdecl;
var
r : single;
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;
r := _random();
if (r < 0.33) then
gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0)
else if (r < 0.66) then
gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0)
else
gi.sound (self, CHAN_VOICE, sound_pain3, 1, ATTN_NORM, 0);
if (skill^.value = 3) then
Exit; // no pain anims in nightmare
if (damage <= 10) then
self^.monsterinfo.currentmove := @chick_move_pain1
else if (damage <= 25) then
self^.monsterinfo.currentmove := @chick_move_pain2
else
self^.monsterinfo.currentmove := @chick_move_pain3;
end;
procedure chick_dead (self : edict_p); cdecl;
begin
VectorSet (self^.mins, -16, -16, 0);
VectorSet (self^.maxs, 16, 16, 16);
self^.movetype := MOVETYPE_TOSS;
self^.svflags := self^.svflags OR SVF_DEADMONSTER;
self^.nextthink := 0;
gi.linkentity (self);
end;
const
chick_frames_death2 : array [0..22] of mframe_t = (
(aifunc: ai_move; dist: -6; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: -1; thinkfunc: Nil),
(aifunc: ai_move; dist: -5; 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: 10; thinkfunc: Nil),
(aifunc: ai_move; dist: 2; thinkfunc: Nil),
(aifunc: ai_move; dist: 3; thinkfunc: Nil),
(aifunc: ai_move; dist: 1; thinkfunc: Nil),
(aifunc: ai_move; dist: 2; thinkfunc: Nil),
(aifunc: ai_move; dist: 0; thinkfunc: Nil),
(aifunc: ai_move; dist: 3; thinkfunc: Nil),
(aifunc: ai_move; dist: 3; thinkfunc: Nil),
(aifunc: ai_move; dist: 1; thinkfunc: Nil),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -