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

📄 m_brain.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 2 页
字号:
// PLEASE, don't modify this file
// 99% complete

{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): m_brain.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                                                              }
{                                                                            }
{ .) unit: g_ai                                                              }
{                                                                            }
{ 1) inc:  m_brain                                                           }
{                                                                            }
{----------------------------------------------------------------------------}
{ * TODO:                                                                    }
{ 1) Do more tests                                                           }
{                                                                            }
{----------------------------------------------------------------------------}

{*
==============================================================================

brain

==============================================================================
*}


unit m_brain;

interface

uses g_local;

procedure SP_monster_brain (self : edict_p); cdecl;

implementation

uses q_shared, gameUnit, g_ai, g_local_add, g_main, game_add, g_misc,
  g_weapon, g_monster, g_utils, CPas;

{$I m_brain.inc}




var
  sound_chest_open,
  sound_tentacles_extend,
  sound_tentacles_retract,
  sound_death,
  sound_idle1,
  sound_idle2,
  sound_idle3,
  sound_pain1,
  sound_pain2,
  sound_sight,
  sound_search,
  sound_melee1,
  sound_melee2,
  sound_melee3: Integer;

procedure brain_sight (self, other : edict_p); cdecl;
begin
  gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
end;

procedure brain_search (self : edict_p); cdecl;
begin
  gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
end;


//void brain_run (edict_t *self);
procedure brain_run (self : edict_p); cdecl; forward; //Y: need test
//void brain_dead (edict_t *self);
procedure brain_dead (self : edict_p); cdecl; forward; //Y: need test


//
// STAND
//
const
  brain_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: Nil) );
  brain_move_stand : mmove_t = (firstframe: FRAME_stand01;  lastframe: FRAME_stand30;  frame: @brain_frames_stand;  endfunc: Nil);

procedure brain_stand (self : edict_p); cdecl; //Y: need test
begin
  self^.monsterinfo.currentmove := @brain_move_stand;
end;


//
// IDLE
//
const
  brain_frames_idle : 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: Nil) );
  brain_move_idle : mmove_t = (firstframe: FRAME_stand31;  lastframe: FRAME_stand60;  frame: @brain_frames_idle;  endfunc: brain_stand);

procedure brain_idle (self : edict_p); cdecl;
begin
  gi.sound (self, CHAN_AUTO, sound_idle3, 1, ATTN_IDLE, 0);
  self^.monsterinfo.currentmove := @brain_move_idle;
end;


//
// WALK
//
const
  brain_frames_walk1 : array [0..10] of mframe_t = (
    (aifunc: ai_walk;  dist: 7;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 2;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 3;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 3;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 1;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 9;  thinkfunc: Nil),
    (aifunc: ai_walk;  dist: -4; thinkfunc: Nil),
    (aifunc: ai_walk;  dist: -1; thinkfunc: Nil),
    (aifunc: ai_walk;  dist: 2;  thinkfunc: Nil) );
  brain_move_walk1 : mmove_t = (firstframe: FRAME_walk101;  lastframe: FRAME_walk111;  frame: @brain_frames_walk1;  endfunc: Nil);

(*// walk2 is FUBAR, do not use
#if 0
void brain_walk2_cycle (edict_t *self)
{
	if (_random() > 0.1)
		self->monsterinfo.nextframe = FRAME_walk220;
}

mframe_t brain_frames_walk2 [] =
{
	ai_walk,	3,	NULL,
	ai_walk,	-2,	NULL,
	ai_walk,	-4,	NULL,
	ai_walk,	-3,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	1,	NULL,
	ai_walk,	12,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	-3,	NULL,
	ai_walk,	0,	NULL,

	ai_walk,	-2,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	1,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	10,	NULL,		// Cycle Start

	ai_walk,	-1,	NULL,
	ai_walk,	7,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	3,	NULL,
	ai_walk,	-3,	NULL,
	ai_walk,	2,	NULL,
	ai_walk,	4,	NULL,
	ai_walk,	-3,	NULL,
	ai_walk,	2,	NULL,
	ai_walk,	0,	NULL,

	ai_walk,	4,	brain_walk2_cycle,
	ai_walk,	-1,	NULL,
	ai_walk,	-1,	NULL,
	ai_walk,	-8,	NULL,
	ai_walk,	0,	NULL,
	ai_walk,	1,	NULL,
	ai_walk,	5,	NULL,
	ai_walk,	2,	NULL,
	ai_walk,	-1,	NULL,
	ai_walk,	-5,	NULL
};
mmove_t brain_move_walk2 = {FRAME_walk201, FRAME_walk240, brain_frames_walk2, NULL};
#endif*)

procedure brain_walk (self : edict_p); cdecl;
begin
//idsoft	if (random() <= 0.5)
  self^.monsterinfo.currentmove := @brain_move_walk1;
//idsoft	else
//idsoft		self->monsterinfo.currentmove = &brain_move_walk2;
end;


const
  brain_frames_defense : array [0..8] 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),
    (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) );
  brain_move_defense : mmove_t = (firstframe: FRAME_defens01;  lastframe: FRAME_defens08;  frame: @brain_frames_defense;  endfunc: Nil);

  brain_frames_pain3 : array [0..5] of mframe_t = (
    (aifunc: ai_move;  dist: -2; thinkfunc: Nil),
    (aifunc: ai_move;  dist: 2;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 1;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 3;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: -4; thinkfunc: Nil) );
  brain_move_pain3 : mmove_t = (firstframe: FRAME_pain301;  lastframe: FRAME_pain306;  frame: @brain_frames_pain3;  endfunc: brain_run);

  brain_frames_pain2 : array [0..7] of mframe_t = (
    (aifunc: ai_move;  dist: -2; 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),
    (aifunc: ai_move;  dist: 3;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 1;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: -2; thinkfunc: Nil) );
  brain_move_pain2 : mmove_t = (firstframe: FRAME_pain201;  lastframe: FRAME_pain208;  frame: @brain_frames_pain2;  endfunc: brain_run);

  brain_frames_pain1 : array [0..20] of mframe_t = (
    (aifunc: ai_move;  dist: -6; thinkfunc: Nil),
    (aifunc: ai_move;  dist: -2; thinkfunc: Nil),
    (aifunc: ai_move;  dist: -6; 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),
    (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),
    (aifunc: ai_move;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 2;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 2;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 1;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 7;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 3;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: -1; thinkfunc: Nil) );
  brain_move_pain1 : mmove_t = (firstframe: FRAME_pain101;  lastframe: FRAME_pain121;  frame: @brain_frames_pain1;  endfunc: brain_run);


//
// DUCK
//
procedure brain_duck_down (self : edict_p); cdecl;
begin
  if ((self^.monsterinfo.aiflags AND AI_DUCKED) <> 0) then
    Exit;
  self^.monsterinfo.aiflags := self^.monsterinfo.aiflags OR AI_DUCKED;
  self^.maxs[2] := self^.maxs[2] - 32;
  self^.takedamage := DAMAGE_YES;  //Y: g_local - C2PAS

⌨️ 快捷键说明

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