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

📄 m_insane.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 3 页
字号:

  insane_move_stand_death: mmove_t = (firstframe: FRAME_st_death2; lastframe:FRAME_st_death18; frame:@insane_frames_stand_death,
    endfunc: @insane_dead);

  insane_frames_crawl: array [0..8] of mframe_t = (
    (aifunc: aiwalk; dist: 0, thinkfunc: insane_scream),
    (aifunc: aiwalk; dist: 1.5, thinkfunc: null),
    (aifunc: aiwalk; dist: 2.1, thinkfunc: null),
    (aifunc: aiwalk; dist: 3.6, thinkfunc: null),
    (aifunc: aiwalk; dist: 2, thinkfunc: null),
    (aifunc: aiwalk; dist: 0.9, thinkfunc: null),
    (aifunc: aiwalk; dist: 3, thinkfunc: null),
    (aifunc: aiwalk; dist: 3.4, thinkfunc: null),
    (aifunc: aiwalk; dist: 2.4, thinkfunc: null));

  insane_move_crawl: mmove_t = (firstframe: FRAME_crawl1; lastframe:FRAME_crawl19; frame:@insane_frames_crawl,
    endfunc: nil);

  insane_move_runcrawl: mmove_t = (firstframe: FRAME_crawl1; lastframe:FRAME_crawl19; frame:@insane_framescrawl,
    endfunc: nil);

  insane_frames_crawl_pain: array [0..8] of mframe_t = (
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null));

  insane_move_crawl_pain: mmove_t = (firstframe: FRAME_cr_pain1; lastframe:FRAME_cr_pain10; frame:@insane_frames_crawl_pain,
    endfunc: insane_run);

  insane_frames_crawl_pain: array [0..6] of mframe_t = (
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null));

  insane_move_crawl_death: mmove_t = (firstframe: FRAME_cr_death10; lastframe:FRAME_cr_death16; frame:@insane_frames_crawl_death,
    endfunc: insane_death);

  insane_frames_cross: array [0..14] of mframe_t = (
    (aifunc: aimove; dist: 0, thinkfunc: insane_moan),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),

    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null));

  insane_move_cross: mmove_t = (firstframe: FRAME_cross1; lastframe:FRAME_cross15; frame:@insane_frames_cross,
    endfunc: insane_cross);

  insane_frames_struggle_cross: array [0..14] of mframe_t = (
    (aifunc: aimove; dist: 0, thinkfunc: insane_scream),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),

    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null),
    (aifunc: aimove; dist: 0, thinkfunc: null));

  insane_move_struggle_cross: mmove_t = (firstframe: FRAME_cross16; lastframe:FRAME_cross30; frame:@insane_frames_struggle_cross,
    endfunc: insane_cross);

procedure insane_fist(self: edict_p);
begin
  gi.sound(self, CHAN_VOICE, sound_fist, 1, ATTN_IDLE, 0);
end;

procedure insane_shake(self: edict_p)
begin
  gi.sound(self, CHAN_VOICE, sound_shake, 1, ATTN_IDLE, 0);
end;

procedure insane_moan(self: edict_p)
begin
  gi.sound(self, CHAN_VOICE, sound_moan, 1, ATTN_IDLE, 0);
end;

procedure insane_scream (self: edict_p)
begin
  gi.sound(self, CHAN_VOICE, sound_scream[random() mod 8], 1, ATTN_IDLE, 0);
end;

procedure insane_cross(self: edict_p)
begin
  if (random() < 0.8) then
    self^.monsterinfo.currentmove:= @insane_move_cross;
  else
    self^.monsterinfo.currentmove:= @insane_move_struggle_cross;
end;

procedure insane_walk(self: edict_p)
begin
  if (self^.spawnflags and 16) <> 0 then // Hold Ground?
    if (self^.s.frame = FRAME_cr_pain10) then begin
      self^.monsterinfo.currentmove:= @insane_move_down;
      exit;
    end;
  if (self^.spawnflags and 4) <> 0 then self^.monsterinfo.currentmove:= @insane_move_crawl
  else
    if (random() <= 0.5) then self^.monsterinfo.currentmove:= @insane_move_walk_normal;
    else self^.monsterinfo.currentmove:= @insane_move_walk_insane;
end;

procedure insane_run(self: edict_p)
begin
  if (self^.spawnflags and 16) <> 0 then // Hold Ground?
    if (self^.s.frame = FRAME_cr_pain10) then begin
      self^.monsterinfo.currentmove = @insane_move_down;
      exit;
    end;
  if (self^.spawnflags and 4) <> 0  then // Crawling?
    self^.monsterinfo.currentmove:= @insane_move_runcrawl
  else
    if (random() <= 0.5) then   // Else, mix it up
      self^.monsterinfo.currentmove:= @insane_move_run_normal
    else
      self^.monsterinfo.currentmove:= @insane_move_run_insane;
end;

procedure insane_pain(self: edict_p; other: edict_p; kick: singke; damage: integer)
var
l, r: integer;
begin
//  if (self->health < (self->max_health / 2))
//    self->s.skinnum = 1;

  if (level.time < self^.pain_debounce_time) then exit;

  self^.pain_debounce_time:= level.time + 3;

  r:= 1 + (random and 1);
  if (self^.health < 25) then
    l:= 25
  else if (self^.health < 50) then
    l:= 50
  else if (self^.health < 75) then
    l:= 75
  else l:= 100;

  gi.sound(self, CHAN_VOICE, gi.soundindex (va("player/male/pain%i_%i.wav", l, r)), 1, ATTN_IDLE, 0);

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

  // Don't go into pain frames if crucified.
  if (self^.spawnflags and 8) <> 0 then begin
    self^.monsterinfo.currentmove = @insane_move_struggle_cross;
    exit;
  end;

  if  ( ((self^.s.frame >= FRAME_crawl1) and (self^.s.frame <= FRAME_crawl9)) or ((self^.s.frame >= FRAME_stand99) and (self^.s.frame <= FRAME_stand160)) ) then begin
    self^.monsterinfo.currentmove = @insane_move_crawl_pain;
  end else self^.monsterinfo.currentmove = @insane_move_stand_pain;

end;

procedure insane_onground(self: edict_p)
begin
  self^.monsterinfo.currentmove = @insane_move_down;
end;

procedure insane_checkdown(self: edict_t)
begin
//  if ( (self->s.frame == FRAME_stand94) || (self->s.frame == FRAME_stand65) )
  if (self->spawnflags & 32) then exit;        // Always stand
  if (random() < 0.3) then
    if (random() < 0.5) then
      self^.monsterinfo.currentmove:= @insane_move_uptodown
    else
      self^.monsterinfo.currentmove:= @insane_move_jumpdown;
end;

procedure insane_checkup(self: edict_p)
begin
  // If Hold_Ground and Crawl are set
  if ((self^.spawnflags and 4) and (self^.spawnflags and 16)) <> 0 then exit;
  if (random < 0.5) then
    self^.monsterinfo.currentmove = @insane_move_downtoup;

end;

procedure insane_stand(self: edict_p)
begin
  if (self^.spawnflags and 8) <> 0 then begin      // If crucified
    self^.monsterinfo.currentmove:= @insane_move_cross;
    self^.monsterinfo.aiflags:= self^.monsterinfoaiflags or AI_STAND_GROUND;
  end
  // If Hold_Ground and Crawl are set
  else if ((self^.spawnflags and 4) and (self^.spawnflags and 16)) <> 0 then
    self^.monsterinfo.currentmove:= @insane_move_down
  else
    if (random < 0.5) then
      self^.monsterinfo.currentmove = @insane_move_stand_normal
    else self^.monsterinfo.currentmove:= @insane_move_stand_insane;
end;

procedure insane_dead(self: edict_p)
begin
  if (self->spawnflags and 8) <> 0 then begin
    self^.flags:= self^.flags or FL_FLY;
  end else begin
    VectorSet(self^.mins, -16, -16, -24);
    VectorSet(self^.maxs, 16, 16, -8);
    self^.movetype = MOVETYPE_TOSS;
  end;

  self^.svflags:= self^.svflags or SVF_DEADMONSTER;
  self^.nextthink:= 0;
  gi.linkentity(self);
end;

procedure insane_die(self: edict_p, inflictor: edict_p, attacker: edict_p, 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_IDLE, 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, gi.soundindex(va("player/male/death%i.wav", (random(32767) mod 4)+1)), 1, ATTN_IDLE, 0);

  self^.deadflag:= DEAD_DEAD;
  self^.takedamage:= DAMAGE_YES;

  if (self^.spawnflags and 8) <> 0 then begin
    insane_dead(self);
  end else begin
    if (((self^.s.frame >= FRAME_crawl1) and (self^.s.frame <= FRAME_crawl9)) or ((self->s.frame >= FRAME_stand99) and (self->s.frame <= FRAME_stand160))) then
      self->monsterinfo.currentmove = &insane_move_crawl_death
    else
      self^.monsterinfo.currentmove = @insane_move_stand_death;
  end;
end;

{/*QUAKED misc_insane (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND
*/}
procedure SP_misc_insane(self: edict_p)
begin
//  static int skin = 0;  //@@

  if (deathmatch^.value) then begin
    G_FreeEdict(self);
    exit;
  end;

  sound_fist:= gi.soundindex ("insane/insane11.wav");
  sound_shake:= gi.soundindex ("insane/insane5.wav");
  sound_moan:= gi.soundindex ("insane/insane7.wav");
  sound_scream[0]:= gi.soundindex ("insane/insane1.wav");
  sound_scream[1]:= gi.soundindex ("insane/insane2.wav");
  sound_scream[2]:= gi.soundindex ("insane/insane3.wav");
  sound_scream[3]:= gi.soundindex ("insane/insane4.wav");
  sound_scream[4]:= gi.soundindex ("insane/insane6.wav");
  sound_scream[5]:= gi.soundindex ("insane/insane8.wav");
  sound_scream[6]:= gi.soundindex ("insane/insane9.wav");
  sound_scream[7]:= gi.soundindex ("insane/insane10.wav");

  self^.movetype:= MOVETYPE_STEP;
  self^.solid:= SOLID_BBOX;
  self^.s.modelindex:= gi.modelindex("models/monsters/insane/tris.md2");

  VectorSet(self^.mins, -16, -16, -24);
  VectorSet(self^.maxs, 16, 16, 32);

  self^.health = 100;
  self^.gib_health = -50;
  self^.mass = 300;

  self^.pain = insane_pain;
  self^.die = insane_die;

  self^.monsterinfo.stand:= insane_stand;
  self^.monsterinfo.walk:= insane_walk;
  self^.monsterinfo.run:= insane_run;
  self^.monsterinfo.dodge:= NULL;
  self^.monsterinfo.attack:= NULL;
  self^.monsterinfo.melee:= NULL;
  self^.monsterinfo.sight:= NULL;
  self^.monsterinfo.aiflags:= self^.monsterinfo.aiflags or AI_GOOD_GUY;

//@@
//  self->s.skinnum = skin;
//  skin++;
//  if (skin > 12)
//    skin = 0;

  gi.linkentity(self);

  if (self^.spawnflags and 16) <> 0 then        // Stand Ground
    self^.monsterinfo.aiflags:= self^.monsterinfo.aiflags or AI_STAND_GROUND;

  self^.monsterinfo.currentmove:= @insane_move_stand_normal;
  
  self^.monsterinfo.scale:= MODEL_SCALE;

  if (self->spawnflags and 8) <> 0 then begin          // Crucified ?
    VectorSet(self^.mins, -16, 0, 0);
    VectorSet(self^.maxs, 16, 8, 32);
    self^.flags:= self^.flags or FL_NO_KNOCKBACK;
    flymonster_start(self);
  end else begin
    walkmonster_start(self);
    self^.s.skinnum:= random(32767) mod 3;
  end;
end;

⌨️ 快捷键说明

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