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

📄 m_tank.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;   thinkfunc: TankRocket),
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),
    (aifunc: ai_charge;  dist: -1;  thinkfunc: TankRocket) ); 	// 30	Loop End
  tank_move_attack_fire_rocket : mmove_t =
    (firstframe: FRAME_attak322; lastframe: FRAME_attak330;  frame: @tank_frames_attack_fire_rocket;  endfunc: tank_refire_rocket);

  tank_frames_attack_post_rocket : array [0..22] of mframe_t = (
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  			// 31
    (aifunc: ai_charge;  dist: -1;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: -1;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 2;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 3;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 4;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 2;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  			// 40

    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: -9;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: -8;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: -7;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: -1;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: -1;  thinkfunc: tank_footstep),
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  			// 50

    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),  
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;   thinkfunc: Nil) );
  tank_move_attack_post_rocket : mmove_t =
    (firstframe: FRAME_attak331;  lastframe: FRAME_attak353;  frame: @tank_frames_attack_post_rocket;  endfunc: tank_run);

  tank_frames_attack_chain : array [0..28] of mframe_t = (
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: Nil;        dist: 0;  thinkfunc: TankMachineGun),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil),
    (aifunc: ai_charge;  dist: 0;  thinkfunc: Nil) );
  tank_move_attack_chain : mmove_t =
    (firstframe: FRAME_attak401;  lastframe: FRAME_attak429;  frame: @tank_frames_attack_chain;  endfunc: tank_run);

procedure tank_refire_rocket (self : edict_p); cdecl;
begin
  // Only on hard or nightmare
  if (skill.value >= 2) then
    if (self.enemy.health > 0) then
      if (visible(self, self.enemy)) then
        if (_random() <= 0.4) then
        begin
          self.monsterinfo.currentmove := @tank_move_attack_fire_rocket;
          Exit;
        end;
  self.monsterinfo.currentmove := @tank_move_attack_post_rocket;
end;//procedure

procedure tank_doattack_rocket (self : edict_p); cdecl;
begin
  self.monsterinfo.currentmove := @tank_move_attack_fire_rocket;
end;//procedure

procedure tank_attack (self : edict_p); cdecl;
var
  vec    : vec3_t;
  range,
  r      : single;
begin
  if (self.enemy.health < 0) then
  begin
    self.monsterinfo.currentmove := @tank_move_attack_strike;
    self.monsterinfo.aiflags     := self.monsterinfo.aiflags AND (NOT AI_BRUTAL);
    Exit;
  end;

  VectorSubtract (self.enemy.s.origin, self.s.origin, vec);
  range := VectorLength (vec);

  r := _random();

  if (range <= 125)
  then
    if (r < 0.4)
    then self.monsterinfo.currentmove := @tank_move_attack_chain
    else self.monsterinfo.currentmove := @tank_move_attack_blast
  else
    if (range <= 250)
    then
      if (r < 0.5)
      then self.monsterinfo.currentmove := @tank_move_attack_chain
      else self.monsterinfo.currentmove := @tank_move_attack_blast
    else
      if (r < 0.33)
      then self.monsterinfo.currentmove := @tank_move_attack_chain
      else
        if (r < 0.66)
        then begin
          self.monsterinfo.currentmove := @tank_move_attack_pre_rocket;
          self.pain_debounce_time := level.time + 5.0;	// no pain for a while
        end
        else
          self.monsterinfo.currentmove := @tank_move_attack_blast;
end;//procedure


//
// death
//

procedure tank_dead (self : edict_p); cdecl;
begin
  VectorSet (self.mins, -16, -16, -16);
  VectorSet (self.maxs, 16, 16, -0);
  self.movetype := MOVETYPE_TOSS;
  self.svflags  := self.svflags or SVF_DEADMONSTER;
  self.nextthink := 0;
  gi.linkentity (self);
end;//procedure

const
  tank_frames_death1 : array [0..31] of mframe_t = (
    (aifunc: ai_move;  dist: -7;  thinkfunc: Nil), 
    (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: 6;   thinkfunc: Nil), 
    (aifunc: ai_move;  dist: 1;   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: 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: 0;   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: 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: -4;  thinkfunc: Nil), 
    (aifunc: ai_move;  dist: -6;  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: -15; thinkfunc: tank_thud),
    (aifunc: ai_move;  dist: -5;  thinkfunc: Nil),
    (aifunc: ai_move;  dist: 0;   thinkfunc: Nil),
    (aifunc: ai_move;  dist: 0;   thinkfunc: Nil),
    (aifunc: ai_move;  dist: 0;   thinkfunc: Nil) );
  tank_move_death : mmove_t =
    (firstframe: FRAME_death101; lastframe: FRAME_death132; frame: @tank_frames_death1;  endfunc: tank_dead);

procedure tank_die (self, inflictor, attacker : edict_p; damage : integer; const point : vec3_t); cdecl;
var
  n : integer;
begin
// check for gib
  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 {4} do
      ThrowGib (self, 'models/objects/gibs/sm_meat/tris.md2', damage, GIB_ORGANIC);

    for n:=0 to 3 do
      ThrowGib (self, 'models/objects/gibs/sm_metal/tris.md2', damage, GIB_METALLIC);
    ThrowGib  (self, 'models/objects/gibs/chest/tris.md2', damage, GIB_ORGANIC);
    ThrowHead (self, 'models/objects/gibs/gear/tris.md2',  damage, GIB_METALLIC);
    self.deadflag := DEAD_DEAD;
    Exit;
  end;

  if (self.deadflag = DEAD_DEAD) then
    Exit;

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

  self.monsterinfo.currentmove := @tank_move_death;
end;//procedure


//
// monster_tank
//

{*QUAKED monster_tank (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
*/
/*QUAKED monster_tank_commander (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
*}

procedure SP_monster_tank (self : edict_p);
begin
  if (deathmatch.value <> 0) then
  begin
    G_FreeEdict (self);
    Exit;
  end;

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

  sound_pain   := gi.soundindex ('tank/tnkpain2.wav');
  sound_thud   := gi.soundindex ('tank/tnkdeth2.wav');
  sound_idle   := gi.soundindex ('tank/tnkidle1.wav');
  sound_die    := gi.soundindex ('tank/death.wav');
  sound_step   := gi.soundindex ('tank/step.wav');
  sound_windup := gi.soundindex ('tank/tnkatck4.wav');
  sound_strike := gi.soundindex ('tank/tnkatck5.wav');
  sound_sight  := gi.soundindex ('tank/sight1.wav');

  gi.soundindex ('tank/tnkatck1.wav');
  gi.soundindex ('tank/tnkatk2a.wav');
  gi.soundindex ('tank/tnkatk2b.wav');
  gi.soundindex ('tank/tnkatk2c.wav');
  gi.soundindex ('tank/tnkatk2d.wav');
  gi.soundindex ('tank/tnkatk2e.wav');
  gi.soundindex ('tank/tnkatck3.wav');

(*Y  if (strcmp(self.classname, 'monster_tank_commander') = 0)
  then begin
    self.health := 1000;
    self.gib_health := -225;
  end
  else begin
    self.health := 750;
    self.gib_health := -200;
  end;*)

  self.mass := 500;

  self.pain := tank_pain;
  self.die := tank_die;
  self.monsterinfo.stand := tank_stand;
  self.monsterinfo.walk := tank_walk;
  self.monsterinfo.run := tank_run;
  self.monsterinfo.dodge := Nil;
  self.monsterinfo.attack := tank_attack;
  self.monsterinfo.melee := Nil;
  self.monsterinfo.sight := tank_sight;
  self.monsterinfo.idle := tank_idle;

  gi.linkentity (self);

  self.monsterinfo.currentmove := @tank_move_stand;
  self.monsterinfo.scale := MODEL_SCALE;

  walkmonster_start(self);

  if (strcmp(self.classname, 'monster_tank_commander') = 0) then
    self.s.skinnum := 2;
end;//procedure

// End of file
end.

⌨️ 快捷键说明

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