📄 m_actor.pas
字号:
{----------------------------------------------------------------------------}
{ }
{ 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
uses
q_shared_add,
g_local_add,
g_ai;
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'
);
procedure actor_stand(self : edict_p); cdecl;
procedure actor_walk(self : edict_p); cdecl;
procedure actor_run(self : edict_p); cdecl;
procedure actor_dead(self : edict_p); cdecl;
procedure actor_die(self, inflictor, attacker: edict_p; damage: Integer; const point: vec3_t); cdecl;
procedure actor_fire(self : edict_p); cdecl;
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 : edict_p); cdecl;
procedure actor_use(self, other, activator : edict_p); cdecl;
procedure SP_misc_actor(self : edict_p); cdecl;
procedure target_actor_touch(self, other: edict_p; plane: cplane_p; surf: csurface_p); cdecl;
procedure SP_target_actor(self: edict_p); cdecl;
implementation
uses
q_shared,
g_utils,
g_main,
m_flash,
g_monster,
g_local,
GameUnit,
g_misc,
CPas,
game_add;
procedure actor_stand(self : edict_p);
begin
self^.monsterinfo.currentmove := @actor_move_stand;
// randomize on startup
if (level.time < 1.0) then
self^.s.frame := self^.monsterinfo.currentmove^.firstframe + (rand() mod (self^.monsterinfo.currentmove^.lastframe - self^.monsterinfo.currentmove^.firstframe + 1));
end;
procedure actor_walk(self : edict_p);
begin
self^.monsterinfo.currentmove := @actor_move_walk;
end;
procedure actor_run(self : edict_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
actor_stand(self);
Exit;
end;
self^.monsterinfo.currentmove := @actor_move_run;
end;
procedure actor_pain(self, other : edict_p; kick : single; damage : Integer); cdecl;
var n : Integer;
v : vec3_t;
name : PChar;
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;
// gi.sound (self, CHAN_VOICE, actor.sound_pain, 1, ATTN_NORM, 0);
if (other^.client <> nil) AND (_random() < 0.4) then
begin
VectorSubtract(other^.s.origin, self^.s.origin, v);
self^.ideal_yaw := vectoyaw(v);
if (_random() < 0.5) then
self^.monsterinfo.currentmove := @actor_move_flipoff
else
self^.monsterinfo.currentmove := @actor_move_taunt;
name := actor_names[Cardinal(Self) - Cardinal(g_edicts) MOD MAX_ACTOR_NAMES]; //(self - g_edicts)%MAX_ACTOR_NAMES
{ TODO: Original: gi.cprintf (other, PRINT_CHAT, "%s: %s!\n", name, messages[rand()%3]); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -