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

📄 p_weapon.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  begin    ChangeWeapon (ent);    Exit;  end;  if (ent.client.weaponstate = WEAPON_ACTIVATING) then  begin    ent.client.weaponstate := WEAPON_READY;    ent.client.ps.gunframe := 16;    Exit;  end;  if (ent.client.weaponstate = WEAPON_READY) then  begin    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.pers.inventory[ent.client.ammo_index] <> 0)      then begin        ent.client.ps.gunframe := 1;        ent.client.weaponstate := WEAPON_FIRING;        ent.client.grenade_time := 0;      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;      Exit;    end;    if ((ent.client.ps.gunframe = 29) OR (ent.client.ps.gunframe = 34) OR        (ent.client.ps.gunframe = 39) OR (ent.client.ps.gunframe = 48)) then      if random(15) <> 0 then  //Y ???        Exit;{Y}    if (++ent.client.ps.gunframe > 48) then      ent.client.ps.gunframe := 16;    Exit;  end;//if  if (ent.client.weaponstate = WEAPON_FIRING) then  begin    if (ent.client.ps.gunframe = 5) then      gi.sound (ent, CHAN_WEAPON, gi.soundindex('weapons/hgrena1b.wav'), 1, ATTN_NORM, 0);    if (ent.client.ps.gunframe = 11) then    begin      if (ent.client.grenade_time=0) then      begin        ent.client.grenade_time := level.time + GRENADE_TIMER + 0.2;        ent.client.weapon_sound := gi.soundindex('weapons/hgrenc1b.wav');      end;      // they waited too long, detonate it in their hand      if (NOT ent.client.grenade_blew_up) AND (level.time >= ent.client.grenade_time) then      begin        ent.client.weapon_sound := 0;        weapon_grenade_fire (ent, true);        ent.client.grenade_blew_up := true;      end;      if ((ent.client.buttons AND BUTTON_ATTACK) <> 0) then        Exit;      if (ent.client.grenade_blew_up) then        if (level.time >= ent.client.grenade_time)        then begin          ent.client.ps.gunframe := 15;          ent.client.grenade_blew_up := false;        end        else          Exit;    end;    if (ent.client.ps.gunframe = 12) then    begin      ent.client.weapon_sound := 0;      weapon_grenade_fire (ent, false);    end;    if ((ent.client.ps.gunframe = 15) AND (level.time < ent.client.grenade_time)) then      Exit;    Inc(ent.client.ps.gunframe);    if (ent.client.ps.gunframe = 16) then    begin      ent.client.grenade_time := 0;      ent.client.weaponstate := WEAPON_READY;    end;  end;//ifend;//procedure (GAME=CTF){*======================================================================GRENADE LAUNCHER======================================================================*}// (GAME=CTF)procedure weapon_grenadelauncher_fire (ent : edict_p); //??? only impvar  offset,  forward_, right,  start           : vec3_t;  radius          : float;//	int		damage = 120;  damage : integer;begin  damage := 120; //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);  VectorScale (forward_, -2, ent.client.kick_origin);  ent.client.kick_angles[0] := -1;  fire_grenade (ent, start, forward_, damage, 600, 2.5, radius);  gi.WriteByte (svc_muzzleflash);//Y  gi.WriteShort (ent-g_edicts);  gi.WriteByte (MZ_GRENADE OR is_silenced);  gi.multicast (ent.s.origin, MULTICAST_PVS);  Inc(ent.client.ps.gunframe);  PlayerNoise(ent, start, PNOISE_WEAPON);//  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]);end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_GrenadeLauncher (ent : edict_p); //for g_itemsconst  pause_frames : array [0..3] of integer = (34, 51, 59, 0);  fire_frames  : array [0..1] of integer = (6, 0);begin  Weapon_Generic (ent, 5, 16, 59, 64, pause_frames, fire_frames{, weapon_grenadelauncher_fire});end;//procedure (GAME=CTF){*======================================================================ROCKET======================================================================*}// (GAME=CTF)procedure Weapon_RocketLauncher_Fire (ent : edict_p); //??? only impvar  offset, start,  forward_, right : vec3_t;  damage_radius   : float;  damage,  radius_damage   : integer;begin  damage := 100 + {(int)}Trunc(random * 20.0);  radius_damage := 120;  damage_radius := 120;  if (is_quad) then  begin    damage := damage *4;    radius_damage := radius_damage *4;  end;  AngleVectors (ent.client.v_angle, @forward_, @right, Nil);  VectorScale (forward_, -2, ent.client.kick_origin);  ent.client.kick_angles[0] := -1;  VectorSet(offset, 8, 8, ent.viewheight-8);  P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start);  fire_rocket (ent, start, forward_, damage, 650, damage_radius, radius_damage);  // send muzzle flash  gi.WriteByte (svc_muzzleflash);//Y  gi.WriteShort (ent-g_edicts);  gi.WriteByte (MZ_ROCKET OR is_silenced);  gi.multicast (ent.s.origin, MULTICAST_PVS);  Inc(ent.client.ps.gunframe);  PlayerNoise(ent, start, PNOISE_WEAPON);{Y}  if ( (Trunc(dmflags.value) AND DF_INFINITE_AMMO) = 0 ) then    Dec(ent.client.pers.inventory[ent.client.ammo_index]);end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_RocketLauncher (ent : edict_p); //for g_itemsconst  pause_frames : array [0..4] of integer = (25, 33, 42, 50, 0);  fire_frames  : array [0..1] of integer = (5, 0);begin  Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames{, Weapon_RocketLauncher_Fire});end;//procedure (GAME=CTF){*======================================================================BLASTER / HYPERBLASTER======================================================================*}// (GAME=CTF)procedure Blaster_Fire (ent : edict_p; g_offset : vec3_t; damage : integer; hyper : qboolean; effect : integer); //??? only impvar  forward_, right,  start,  offset          : vec3_t;begin  if (is_quad) then    damage := damage *4;  AngleVectors (ent.client.v_angle, @forward_, @right, Nil);  VectorSet(offset, 24, 8, ent.viewheight-8);  VectorAdd (offset, g_offset, offset);  P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start);  VectorScale (forward_, -2, ent.client.kick_origin);  ent.client.kick_angles[0] := -1;  fire_blaster (ent, start, forward_, damage, 1000, effect, hyper);  // send muzzle flash  gi.WriteByte (svc_muzzleflash);//Y  gi.WriteShort (ent-g_edicts);  if (hyper)  then gi.WriteByte (MZ_HYPERBLASTER OR is_silenced)  else gi.WriteByte (MZ_BLASTER OR is_silenced);  gi.multicast (ent.s.origin, MULTICAST_PVS);  PlayerNoise(ent, start, PNOISE_WEAPON);end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_Blaster_Fire (ent : edict_p); //??? only impvar  damage : integer;begin  if (deathmatch.value <> 0)  then damage := 15  else damage := 10;  Blaster_Fire (ent, vec3_origin, damage, false, EF_BLASTER);  Inc(ent.client.ps.gunframe);end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_Blaster (ent : edict_p); //for g_itemsconst  pause_frames : array [0..2] of integer = (19, 32, 0);  fire_frames  : array [0..1] of integer = (5, 0);begin  Weapon_Generic (ent, 4, 8, 52, 55, pause_frames, fire_frames{, Weapon_Blaster_Fire});end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_HyperBlaster_Fire (ent : edict_p); //??? only impvar  rotation : float;  offset   : vec3_t;  effect,  damage   : integer;begin  ent.client.weapon_sound := gi.soundindex('weapons/hyprbl1a.wav');//  if (!(ent.client.buttons & BUTTON_ATTACK))  if ( (ent.client.buttons AND BUTTON_ATTACK) = 0 )  then begin    Inc(ent.client.ps.gunframe);  end  else begin    if (ent.client.pers.inventory[ent.client.ammo_index]=0)    then 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 begin      rotation := (ent.client.ps.gunframe - 5) * 2*M_PI/6;      offset[0] := -4 * sin(rotation);      offset[1] := 0;      offset[2] := 4 * cos(rotation);      if ((ent.client.ps.gunframe = 6) OR (ent.client.ps.gunframe = 9))      then effect := EF_HYPERBLASTER      else effect := 0;      if (deathmatch.value <> 0)      then damage := 15      else damage := 20;      Blaster_Fire (ent, offset, damage, true, effect);//      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.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    Inc(ent.client.ps.gunframe);    if (ent.client.ps.gunframe = 12) AND (ent.client.pers.inventory[ent.client.ammo_index] <> 0) then      ent.client.ps.gunframe := 6;  end;//else  if (ent.client.ps.gunframe = 12) then  begin    gi.sound(ent, CHAN_AUTO, gi.soundindex('weapons/hyprbd1a.wav'), 1, ATTN_NORM, 0);    ent.client.weapon_sound := 0;  end;end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_HyperBlaster (ent : edict_p); //for g_itemsconst  pause_frames : array [0..0] of integer = (0); //OR pause_frames : integer = 0;  fire_frames  : array [0..6] of integer = (6, 7, 8, 9, 10, 11, 0);begin  Weapon_Generic (ent, 5, 20, 49, 53, pause_frames, fire_frames{, Weapon_HyperBlaster_Fire});end;//procedure (GAME=CTF){*======================================================================MACHINEGUN / CHAINGUN======================================================================*}// (GAME=CTF)procedure Machinegun_Fire (ent : edict_p); //??? only impvar  i : integer;  start,  forward_, right,  angles,  offset         : vec3_t;{	int			damage = 8;	int			kick = 2;}  damage, kick : integer;begin  damage := 8;  kick   := 2; //Y//  if (!(ent.client.buttons & BUTTON_ATTACK)) then  if ( (ent.client.buttons AND BUTTON_ATTACK) = 0 ) then  begin    ent.client.machinegun_shots := 0;    Inc(ent.client.ps.gunframe);    Exit;  end;  if (ent.client.ps.gunframe = 5)  then ent.client.ps.gunframe := 4  else ent.client.ps.gunframe := 5;  if (ent.client.pers.inventory[ent.client.ammo_index] < 1) then  begin    ent.client.ps.gunframe := 6;    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);    Exit;  end;  if (is_quad) then  begin    damage := damage *4;    kick := kick *4;  end;  for i:=1 to 2 do  begin    ent.client.kick_origin[i] := crandom() * 0.35;    ent.client.kick_angles[i] := crandom() * 0.7;  end;  ent.client.kick_origin[0] := crandom() * 0.35;  ent.client.kick_angles[0] := ent.client.machinegun_shots * -1.5;  // raise the gun as it is firing  if (deathmatch.value=0) then  begin    Inc(ent.client.machinegun_shots);    if (ent.client.machinegun_shots > 9) then      ent.client.machinegun_shots := 9;  end;  // get start / end positions  VectorAdd (ent.client.v_angle, ent.client.kick_angles, angles);  AngleVectors (angles, @forward_, @right, Nil);  VectorSet(offset, 0, 8, ent.viewheight-8);  P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start);  fire_bullet (ent, start, forward_, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN);  gi.WriteByte (svc_muzzleflash);//Y  gi.WriteShort (ent-g_edicts);  gi.WriteByte (MZ_MACHINEGUN OR is_silenced);  gi.multicast (ent.s.origin, MULTICAST_PVS);  PlayerNoise(ent, start, PNOISE_WEAPON);//  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.anim_priority := ANIM_ATTACK;  if ((ent.client.ps.pmove.pm_flags AND PMF_DUCKED) <> 0)  then begin(*Y    ent.s.frame := FRAME_crattak1 - (int) (random()+0.25);    ent.client.anim_end := FRAME_crattak9;*)  end  else begin

⌨️ 快捷键说明

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