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

📄 p_weapon.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 4 页
字号:
//Y  index := ITEM_INDEX(item);  // see if we're already using it  if ( ((item = ent.client.pers.weapon) OR (item = ent.client.newweapon)) AND       (ent.client.pers.inventory[index] = 1) ) then  begin    gi.cprintf (ent, PRINT_HIGH, 'Can"t drop current weapon\n');    Exit;  end;//if//Y  Drop_Item (ent, item);  Dec(ent.client.pers.inventory[index]);end;//procedure (GAME=CTF){*================Weapon_GenericA generic function to handle the basics of weapon thinking================*}(*Yconst  FRAME_FIRE_FIRST	 = (FRAME_ACTIVATE_LAST + 1);  FRAME_IDLE_FIRST	 = (FRAME_FIRE_LAST + 1);  FRAME_DEACTIVATE_FIRST = (FRAME_IDLE_LAST + 1);*)// (GAME <> CTF){$IFDEF CTF}{procedure static void Weapon_Generic2 (edict_t *ent,                                       int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST,                                       int *pause_frames, int *fire_frames, void ( *fire)(edict_t *ent));}procedure Weapon_Generic2 (ent : edict_p;
                           FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST, FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST : integer;                           pause_frames, fire_frames : array of integer{;, void ( *fire)(edict_t *ent)});var
  n : integer;
begin
  if (ent.deadflag <> 0) OR (ent.s.modelindex <> 255) then // VWep animations screw up corpses
    Exit;

  if (ent.client.weaponstate = WEAPON_DROPPING) then
  begin
    if (ent.client.ps.gunframe = FRAME_DEACTIVATE_LAST)
    then begin
      ChangeWeapon (ent);
      Exit;
    end
    else begin
      if ((FRAME_DEACTIVATE_LAST - ent.client.ps.gunframe) = 4) then
      begin
        ent.client.anim_priority := ANIM_REVERSE;
        if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)
        then begin
(*Y          ent.s.frame := FRAME_crpain4+1;
          ent.client.anim_end := FRAME_crpain1;*)
        end
        else begin
(*Y          ent.s.frame := FRAME_pain304+1;
          ent.client.anim_end := FRAME_pain301;*)
        end;
      end;
    end;//else

    Inc(ent.client.ps.gunframe);
    Exit;
  end;

  if (ent.client.weaponstate = WEAPON_ACTIVATING) then
  begin
//Y    if (ent.client.ps.gunframe = FRAME_ACTIVATE_LAST) OR (instantweap.value <> 0) then
    begin
      ent.client.weaponstate := WEAPON_READY;
//Y      ent.client.ps.gunframe := FRAME_IDLE_FIRST;
      // we go recursive here to instant ready the weapon
      Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST,
                       FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST, pause_frames,
                       fire_frames{, fire});
      Exit;
    end;

    Inc(ent.client.ps.gunframe);
    Exit;
  end;

//  if ((ent->client->newweapon) && (ent->client->weaponstate != WEAPON_FIRING)) then
  if (ent.client.newweapon <> Nil) AND (ent.client.weaponstate <> WEAPON_FIRING) then
  begin
    ent.client.weaponstate := WEAPON_DROPPING;
(*Y    if (instantweap.value <> 0)
    then*) begin
      ChangeWeapon(ent);
      Exit;
    end(*Y
    else
      ent.client.ps.gunframe := FRAME_DEACTIVATE_FIRST*);

//Y    if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4) then
    begin
      ent.client.anim_priority := ANIM_REVERSE;
      if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)
      then begin
(*Y        ent.s.frame := FRAME_crpain4+1;
        ent.client.anim_end := FRAME_crpain1;*)
      end
      else begin
(*Y        ent.s.frame := FRAME_pain304+1;
        ent.client.anim_end := FRAME_pain301;*)
      end;
    end;
    Exit;
  end;

  if (ent.client.weaponstate = WEAPON_READY) then
  begin
//    if ( ((ent.client.latched_buttons|ent.client.buttons) & BUTTON_ATTACK) )
    if ( ((ent.client.latched_buttons OR ent.client.buttons) AND BUTTON_ATTACK) <> 0 )
    then begin
      ent.client.latched_buttons := ent.client.latched_buttons AND (NOT BUTTON_ATTACK);
      if ( (ent.client.ammo_index=0) OR
           (ent.client.pers.inventory[ent.client.ammo_index] >= ent.client.pers.weapon.quantity) )
      then begin
(*Y        ent.client.ps.gunframe := FRAME_FIRE_FIRST;
        ent.client.weaponstate := WEAPON_FIRING;*)

        // start the animation
        ent.client.anim_priority := ANIM_ATTACK;
        if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)
        then begin
(*Y          ent.s.frame := FRAME_crattak1-1;
          ent.client.anim_end := FRAME_crattak9;*)
        end
        else begin
(*Y          ent.s.frame := FRAME_attack1-1;
          ent.client.anim_end := FRAME_attack8;*)
        end;
      end
      else begin
        if (level.time >= ent.pain_debounce_time) then
        begin
          gi.sound(ent, CHAN_VOICE, gi.soundindex('weapons/noammo.wav'), 1, ATTN_NORM, 0);
          ent.pain_debounce_time := level.time + 1;
        end;
        NoAmmoWeaponChange (ent);
      end;//else
    end
    else begin
      if (ent.client.ps.gunframe = FRAME_IDLE_LAST) then
      begin
//Y        ent.client.ps.gunframe := FRAME_IDLE_FIRST;
        Exit;
      end;

(*Y      if (pause_frames) then
        for (n = 0; pause_frames[n]; n++)*)
          if (ent.client.ps.gunframe = pause_frames[n]) then
            if random(15) <> 0 then //Y ???
              Exit;

      Inc(ent.client.ps.gunframe);
      Exit;
    end;//else
  end;//if

  if (ent.client.weaponstate = WEAPON_FIRING) then
  begin
//Y    for (n = 0; fire_frames[n]; n++)
      if (ent.client.ps.gunframe = fire_frames[n]) then
      begin
(*Y//ZOID
        if (!CTFApplyStrengthSound(ent)) then
//ZOID*)
          if (ent.client.quad_framenum > level.framenum) then
            gi.sound(ent, CHAN_ITEM, gi.soundindex('items/damage3.wav'), 1, ATTN_NORM, 0);
(*Y//ZOID
        CTFApplyHasteSound(ent);
//ZOID

        fire (ent);
        Break;*)
      end;

//    if (!fire_frames[n]) then
    if (fire_frames[n]=0) then
      Inc(ent.client.ps.gunframe);

//Y    if (ent.client.ps.gunframe = FRAME_IDLE_FIRST+1) then
      ent.client.weaponstate := WEAPON_READY;
  end;//if
end;//procedure onlyCTF
//ZOID{procedure Weapon_Generic (edict_t *ent,
                          int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST,
                          int *pause_frames, int *fire_frames, void ( *fire)(edict_t *ent))}
procedure Weapon_Generic (ent : edict_p;
                          FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST, FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST : integer;
                          pause_frames, fire_frames : array of integer{;, void ( *fire)(edict_t *ent)});
var
  oldstate : integer;                           
begin
//Y  oldstate := ent.client.weaponstate;

  Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST,
                   FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST, pause_frames,
                   fire_frames{, fire});

  // run the weapon frame again if hasted
  if (*((stricmp(ent.client.pers.weapon.pickup_name, 'Grapple') = 0) AND*)
     (ent.client.weaponstate = WEAPON_FIRING) then
    Exit;

(*if ((CTFApplyHaste(ent) ||
		(Q_stricmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 &&
		ent->client->weaponstate != WEAPON_FIRING))
		&& oldstate == ent->client->weaponstate)* )

  if ( CTFApplyHaste(ent) OR
       ( (Q_stricmp(ent.client.pers.weapon.pickup_name, 'Grapple') = 0) AND
         (ent.client.weaponstate <> WEAPON_FIRING) )
     ) AND
     (oldstate = ent.client.weaponstate) then*)
    Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST,
                     FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST, pause_frames,
                     fire_frames{, fire});
end;//procedure onlyCTF
//ZOID*)
{$ELSE}procedure Weapon_Generic (ent : edict_p;                          FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST, FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST : integer;//                          int *pause_frames, int *fire_frames, void ( *fire)(edict_t *ent));                          pause_frames, fire_frames : array of integer{, void ( *fire)(edict_t *ent)});var  n : integer;begin  if (ent.deadflag <> 0) OR (ent.s.modelindex <> 255) then // VWep animations screw up corpses    Exit;  if (ent.client.weaponstate = WEAPON_DROPPING) then  begin    if (ent.client.ps.gunframe = FRAME_DEACTIVATE_LAST)    then begin      ChangeWeapon (ent);      Exit;    end    else begin      if ((FRAME_DEACTIVATE_LAST - ent.client.ps.gunframe) = 4) then      begin        ent.client.anim_priority := ANIM_REVERSE;        if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)        then begin(*Y          ent.s.frame := FRAME_crpain4+1;          ent.client.anim_end := FRAME_crpain1;*)        end        else begin(*Y          ent.s.frame := FRAME_pain304+1;          ent.client.anim_end := FRAME_pain301;*)        end;      end;    end;//else    Inc(ent.client.ps.gunframe);    Exit;  end;  if (ent.client.weaponstate = WEAPON_ACTIVATING) then  begin    if (ent.client.ps.gunframe = FRAME_ACTIVATE_LAST) then    begin      ent.client.weaponstate := WEAPON_READY;//Y      ent.client.ps.gunframe := FRAME_IDLE_FIRST;      Exit;    end;    Inc(ent.client.ps.gunframe);    Exit;  end;  if (ent.client.newweapon <> Nil) AND (ent.client.weaponstate <> WEAPON_FIRING) then  begin    ent.client.weaponstate := WEAPON_DROPPING;//Y    ent.client.ps.gunframe := FRAME_DEACTIVATE_FIRST;//Y    if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4) then    begin      ent.client.anim_priority := ANIM_REVERSE;{Y}      if (ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0      then begin(*Y        ent.s.frame := FRAME_crpain4+1;        ent.client.anim_end := FRAME_crpain1;*)      end      else begin(*Y        ent.s.frame := FRAME_pain304+1;        ent.client.anim_end := FRAME_pain301;*)      end;    end;    Exit;  end;  if (ent.client.weaponstate = WEAPON_READY) then  begin//    if ( ((ent.client.latched_buttons OR ent.client.buttons) & BUTTON_ATTACK) )    if ( ((ent.client.latched_buttons OR ent.client.buttons) AND BUTTON_ATTACK) <> 0 )    then begin      ent.client.latched_buttons := ent.client.latched_buttons AND (NOT BUTTON_ATTACK);      if ( (ent.client.ammo_index=0) OR           (ent.client.pers.inventory[ent.client.ammo_index] >= ent.client.pers.weapon.quantity) )      then begin(*Y        ent.client.ps.gunframe := FRAME_FIRE_FIRST;        ent.client.weaponstate := WEAPON_FIRING;*)        // start the animation        ent.client.anim_priority := ANIM_ATTACK;        if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)        then begin(*Y          ent.s.frame := FRAME_crattak1-1;          ent.client.anim_end := FRAME_crattak9;*)        end        else begin(*Y          ent.s.frame := FRAME_attack1-1;          ent.client.anim_end := FRAME_attack8;*)        end;      end      else begin        if (level.time >= ent.pain_debounce_time) then        begin          gi.sound(ent, CHAN_VOICE, gi.soundindex('weapons/noammo.wav'), 1, ATTN_NORM, 0);          ent.pain_debounce_time := level.time + 1;        end;        NoAmmoWeaponChange (ent);      end;//else    end    else begin      if (ent.client.ps.gunframe = FRAME_IDLE_LAST) then      begin//Y        ent.client.ps.gunframe := FRAME_IDLE_FIRST;        Exit;      end;(*Y      if (pause_frames) then        for (n = 0; pause_frames[n]; n++)*)          if (ent.client.ps.gunframe = pause_frames[n]) then            if random(15) <> 0 then //Y              Exit;      Inc(ent.client.ps.gunframe);      Exit;    end;//else  end;//if  if (ent.client.weaponstate = WEAPON_FIRING) then  begin//Y    for (n = 0; fire_frames[n]; n++)        if (ent.client.ps.gunframe = fire_frames[n]) then        begin          if (ent.client.quad_framenum > level.framenum) then            gi.sound(ent, CHAN_ITEM, gi.soundindex('items/damage3.wav'), 1, ATTN_NORM, 0);(*Y          fire (ent);          Break;*)        end;    if (fire_frames[n]=0) then      Inc(ent.client.ps.gunframe);//Y    if (ent.client.ps.gunframe = FRAME_IDLE_FIRST+1) then      ent.client.weaponstate := WEAPON_READY;  end;//ifend;//procedure onlyGAME*){$ENDIF}{*======================================================================GRENADE======================================================================*}const  GRENADE_TIMER	   = 3.0;  GRENADE_MINSPEED = 400;  GRENADE_MAXSPEED = 800;// (GAME <> CTF)procedure weapon_grenade_fire (ent : edict_p; held : qboolean); //??? only impvar  offset,  forward_, right,  start           : vec3_t;  timer,  radius          : float;  speed : integer;//	int		damage = 125;  damage : integer;begin  damage := 125;  //Y  radius := damage+40;  if (is_quad) then    damage := damage *4;  VectorSet(offset, 8, 8, ent.viewheight-8);//Y  AngleVectors (ent.client.v_angle, forward_, right, NULL);  P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start);  timer := ent.client.grenade_time - level.time;(*Y  speed := GRENADE_MINSPEED + (GRENADE_TIMER - timer) * ((GRENADE_MAXSPEED - GRENADE_MINSPEED) / GRENADE_TIMER);*)  fire_grenade2 (ent, start, forward_, damage, speed, timer, radius, held);//  if (! ( (int)dmflags.value & DF_INFINITE_AMMO ) ) then  if ( (Trunc(dmflags.value) AND DF_INFINITE_AMMO) = 0 ) then    Dec(ent.client.pers.inventory[ent.client.ammo_index]);  ent.client.grenade_time := level.time + 1.0;  if (ent.deadflag <> 0) OR (ent.s.modelindex <> 255) then // VWep animations screw up corpses    Exit;{$IFNDEF CTF}  //onlyGAME  if (ent.health <= 0) then    Exit;{$ENDIF}  if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)  then begin    ent.client.anim_priority := ANIM_ATTACK;(*Y    ent.s.frame := FRAME_crattak1-1;    ent.client.anim_end := FRAME_crattak3;*)  end  else begin    ent.client.anim_priority := ANIM_REVERSE;(*Y    ent.s.frame := FRAME_wave08;    ent.client.anim_end := FRAME_wave01;*)  end;end;//procedure (GAME <> CTF)// (GAME=CTF)procedure Weapon_Grenade (ent : edict_p); //for g_itemsbegin  if ((ent.client.newweapon <> Nil) AND (ent.client.weaponstate = WEAPON_READY)) then

⌨️ 快捷键说明

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