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

📄 m_berserk.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
     (aifunc:ai_charge; dist:0; thinkfunc:nil));

  berserk_move_attack_club : mmove_t =
    (firstframe:FRAME_att_c9; lastframe:FRAME_att_c20; frame:berserk_frames_attack_club; endfunc:berserk_run);

procedure berserk_strike(self : edict_t);
begin
  //FIXME play impact sound
end;

const
  berserk_frames_attack_strike : Array[0..13] 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:berserk_swing),
     (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:berserk_strike),
     (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:9.7;  thinkfunc:nil),
     (aifunc:ai_move; dist:13.6; thinkfunc:nil));

  berserk_move_attack_strike : mmove_t =
    (firstframe:FRAME_att_c21; lastframe:FRAME_att_c34; frame:berserk_frames_attack_strike; endfunc:berserk_run);

procedure berserk_melee(self : edict_t);
begin
  if rand(2) = 0 then
    self.monsterinfo.currentmove := berserk_move_attack_spike;
  else
    self.monsterinfo.currentmove := berserk_move_attack_club;
end;


{
//void() 	berserk_atke1	=[	$r_attb1,	berserk_atke2	] {ai_run(9);};
//void() 	berserk_atke2	=[	$r_attb2,	berserk_atke3	] {ai_run(6);};
//void() 	berserk_atke3	=[	$r_attb3,	berserk_atke4	] {ai_run(18.4);};
//void() 	berserk_atke4	=[	$r_attb4,	berserk_atke5	] {ai_run(25);};
//void() 	berserk_atke5	=[	$r_attb5,	berserk_atke6	] {ai_run(14);};
//void() 	berserk_atke6	=[	$r_attb6,	berserk_atke7	] {ai_run(20);};
//void() 	berserk_atke7	=[	$r_attb7,	berserk_atke8	] {ai_run(8.5);};
//void() 	berserk_atke8	=[	$r_attb8,	berserk_atke9	] {ai_run(3);};
//void() 	berserk_atke9	=[	$r_attb9,	berserk_atke10	] {ai_run(17.5);};
//void() 	berserk_atke10	=[	$r_attb10,	berserk_atke11	] {ai_run(17);};
//void() 	berserk_atke11	=[	$r_attb11,	berserk_atke12	] {ai_run(9);};
//void() 	berserk_atke12	=[	$r_attb12,	berserk_atke13	] {ai_run(25);};
//void() 	berserk_atke13	=[	$r_attb13,	berserk_atke14	] {ai_run(3.7);};
//void() 	berserk_atke14	=[	$r_attb14,	berserk_atke15	] {ai_run(2.6);};
//void() 	berserk_atke15	=[	$r_attb15,	berserk_atke16	] {ai_run(19);};
//void() 	berserk_atke16	=[	$r_attb16,	berserk_atke17	] {ai_run(25);};
//void() 	berserk_atke17	=[	$r_attb17,	berserk_atke18	] {ai_run(19.6);};
//void() 	berserk_atke18	=[	$r_attb18,	berserk_run1	] {ai_run(7.8);};
}

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

  berserk_move_pain1 : mmove_t =
    (firstframe:FRAME_painc1; lastframe:FRAME_painc4; frame:berserk_frames_pain1; endfunc:berserk_run);

  berserk_frames_pain2 : Array[0..19] 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),
     (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:0; thinkfunc:nil));

  berserk_move_pain2 : mmove_t =
    (firstframe:FRAME_painb1; lastframe:FRAME_painb20; frame:berserk_frames_pain2; endfunc:berserk_run);

procedure berserk_pain(self, other : edict_t; kick : single; damage : 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;
  gi.sound(self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);

  if skill.value = 3 then
    exit;		// no pain anims in nightmare

  if ((damage < 20) or (random() < 0.5)) then
    self.monsterinfo.currentmove := berserk_move_pain1;
	else
    self.monsterinfo.currentmove := berserk_move_pain2;
end;

procedure berserk_dead(self : edict_t);
begin
  VectorSet(self.mins, -16, -16, -24);
  VectorSet(self.maxs,  16,  16,  -8);
  self.movetype := MOVETYPE_TOSS;
  self.svflags := self.svflags or SVF_DEADMONSTER;
  self.nextthink := 0;
  gi.linkentity(self);
end;

const
  berserk_frames_death1 : Array[0..12] 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),
     (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));

  berserk_move_death1 : mmove_t =
    (firstframe:FRAME_death1; lastframe:FRAME_death13; frame:berserk_frames_death1; endfunc:berserk_dead);

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

  berserk_move_death2 : mmove_t =
    (firstframe:FRAME_deathc1; lastframe:FRAME_deathc8; frame:berserk_frames_death2; endfunc:berserk_dead);

procedure berserk_die(self, inflictor, attacker : edict_t; damage : integer; point : vec3_t);
var
  n : integer;
begin
  if (self.health <= self.gib_health) then
  begin
    gi.sound(self, CHAN_VOICE, gi.soundindex('misc/udeath.wav'), 1, ATTN_NORM, 0);
    for n := 0 to 1 do
      ThrowGib(self, 'models/objects/gibs/bone/tris.md2', damage, GIB_ORGANIC);
    for n := 0 to 3 do
      ThrowGib(self, 'models/objects/gibs/sm_meat/tris.md2', damage, GIB_ORGANIC);
    ThrowHead(self, 'models/objects/gibs/head2/tris.md2', damage, GIB_ORGANIC);
    self.deadflag := DEAD_DEAD;
    exit;
  end;

  if (self.deadflag = DEAD_DEAD) then
    exit;

  gi.sound(self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
  self.deadflag := DEAD_DEAD;
  self.takedamage := DAMAGE_YES;

  if damage >= 50 then
    self.monsterinfo.currentmove := berserk_move_death1;
  else
    self.monsterinfo.currentmove := berserk_move_death2;
end;


{QUAKED monster_berserk (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
}
procedure SP_monster_berserk(self : edict_t);
begin
  if (deathmatch.value) then
  begin
    G_FreeEdict(self);
    exit;
  end;

  // pre-caches
  sound_pain   := gi.soundindex('berserk/berpain2.wav');
  sound_die    := gi.soundindex('berserk/berdeth2.wav');
  sound_idle   := gi.soundindex('berserk/beridle1.wav');
  sound_punch  := gi.soundindex('berserk/attack.wav');
  sound_search := gi.soundindex('berserk/bersrch1.wav');
  sound_sight  := gi.soundindex('berserk/sight.wav');

  self.s.modelindex := gi.modelindex('models/monsters/berserk/tris.md2');
  VectorSet(self.mins, -16, -16, -24);
  VectorSet(self.maxs,  16,  16,  32);
  self.movetype := MOVETYPE_STEP;
  self.solid    := SOLID_BBOX;

  self.health     := 240;
  self.gib_health := -60;
  self.mass       := 250;

  self.pain := berserk_pain;
  self.die  := berserk_die;

  self.monsterinfo.stand  := berserk_stand;
  self.monsterinfo.walk   := berserk_walk;
  self.monsterinfo.run    := berserk_run;
  self.monsterinfo.dodge  := nil;
  self.monsterinfo.attack := nil;
  self.monsterinfo.melee  := berserk_melee;
  self.monsterinfo.sight  := berserk_sight;
  self.monsterinfo.search := berserk_search;

  self.monsterinfo.currentmove := berserk_move_stand;
  self.monsterinfo.scale       := MODEL_SCALE;

  gi.linkentity(self);

  walkmonster_start(self);
end;

end.

⌨️ 快捷键说明

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