📄 p_weapon.pas
字号:
(*Y ent.s.frame := FRAME_attack1 - (int) (random()+0.25); ent.client.anim_end := FRAME_attack8;*) end;end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_Machinegun (ent : edict_p); //for g_itemsconst pause_frames : array [0..2] of integer = (23, 45, 0); fire_frames : array [0..2] of integer = (4, 5, 0);begin Weapon_Generic (ent, 3, 5, 45, 49, pause_frames, fire_frames{, Machinegun_Fire});end;//procedure (GAME=CTF)// (GAME=CTF)procedure Chaingun_Fire (ent : edict_p); //??? only impvar i, shots, damage : integer; start, forward_, right, up, offset : vec3_t; r, u : float;// int kick = 2; kick : integer;begin kick := 2; //Y if (deathmatch.value <> 0) then damage := 6 else damage := 8; if (ent.client.ps.gunframe = 5) then gi.sound(ent, CHAN_AUTO, gi.soundindex('weapons/chngnu1a.wav'), 1, ATTN_IDLE, 0);// if ((ent.client.ps.gunframe = 14) AND !(ent.client.buttons & BUTTON_ATTACK)) if (ent.client.ps.gunframe = 14) AND ((ent.client.buttons AND BUTTON_ATTACK) = 0) then begin ent.client.ps.gunframe := 32; ent.client.weapon_sound := 0; Exit; end else if ( (ent.client.ps.gunframe = 21) AND ((ent.client.buttons AND BUTTON_ATTACK) <> 0 ) AND (ent.client.pers.inventory[ent.client.ammo_index] <> 0) ) then ent.client.ps.gunframe := 15 else Inc(ent.client.ps.gunframe);(*Y if (ent.client.ps.gunframe = 22) then begin begin ent.client.weapon_sound := 0; gi.sound(ent, CHAN_AUTO, gi.soundindex('weapons/chngnd1a.wav'), 1, ATTN_IDLE, 0); end else ent.client.weapon_sound := gi.soundindex('weapons/chngnl1a.wav');*) 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 - (ent.client.ps.gunframe & 1); ent.client.anim_end := FRAME_crattak9;*) end else begin(*Y ent.s.frame := FRAME_attack1 - (ent.client.ps.gunframe & 1); ent.client.anim_end := FRAME_attack8;*) end; if (ent.client.ps.gunframe <= 9) then shots := 1 else if (ent.client.ps.gunframe <= 14) then begin if (ent.client.buttons AND BUTTON_ATTACK) <> 0 then shots := 2 else shots := 1; end else shots := 3; if (ent.client.pers.inventory[ent.client.ammo_index] < shots) then shots := ent.client.pers.inventory[ent.client.ammo_index]; if (shots=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); Exit; end; if (is_quad) then begin damage := damage *4; kick := kick *4; end; for i:=0 to 2 do begin ent.client.kick_origin[i] := crandom() * 0.35; ent.client.kick_angles[i] := crandom() * 0.7; end; for i:=0 to shots-1 do begin // get start / end positions AngleVectors (ent.client.v_angle, @forward_, @right, @up); r := 7 + crandom()*4; u := crandom()*4; VectorSet(offset, 0, r, u + 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_CHAINGUN); end; // send muzzle flash gi.WriteByte (svc_muzzleflash);//Y gi.WriteShort (ent-g_edicts); gi.WriteByte ((MZ_CHAINGUN1 + shots - 1) 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 ent.client.pers.inventory[ent.client.ammo_index] := ent.client.pers.inventory[ent.client.ammo_index] -shots;end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_Chaingun (ent : edict_p); //for g_itemsconst pause_frames : array [0..4] of integer = (38, 43, 51, 61, 0); fire_frames : array [0..17] of integer = (5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0);begin Weapon_Generic (ent, 4, 31, 61, 64, pause_frames, fire_frames{, Chaingun_Fire});end;//procedure (GAME=CTF){*======================================================================SHOTGUN / SUPERSHOTGUN======================================================================*}// (GAME=CTF)procedure weapon_shotgun_fire (ent : edict_p); //??? only impvar start, forward_, right, offset : vec3_t;{ int damage = 4; int kick = 8;} damage, kick : integer;begin damage := 4; kick := 8; //Y if (ent.client.ps.gunframe = 9) then begin Inc(ent.client.ps.gunframe); Exit; end; AngleVectors (ent.client.v_angle, @forward_, @right, Nil); VectorScale (forward_, -2, ent.client.kick_origin); ent.client.kick_angles[0] := -2; VectorSet(offset, 0, 8, ent.viewheight-8); P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start); if (is_quad) then begin damage := damage *4; kick := kick *4; end; if (deathmatch.value <> 0) then fire_shotgun (ent, start, forward_, damage, kick, 500, 500, DEFAULT_DEATHMATCH_SHOTGUN_COUNT, MOD_SHOTGUN) else fire_shotgun (ent, start, forward_, damage, kick, 500, 500, DEFAULT_SHOTGUN_COUNT, MOD_SHOTGUN); // send muzzle flash gi.WriteByte (svc_muzzleflash);//Y gi.WriteShort (ent-g_edicts); gi.WriteByte (MZ_SHOTGUN 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_Shotgun (ent : edict_p); //for g_itemsconst pause_frames : array [0..3] of integer = (22, 28, 34, 0); fire_frames : array [0..2] of integer = (8, 9, 0);begin Weapon_Generic (ent, 7, 18, 36, 39, pause_frames, fire_frames{, weapon_shotgun_fire});end;//procedure (GAME=CTF)// (GAME=CTF)procedure weapon_supershotgun_fire (ent : edict_p); //??? only impvar start, forward_, right, offset, v : vec3_t;{ int damage = 6; int kick = 12;} damage, kick : integer;begin damage := 6; kick := 12; //Y AngleVectors (ent.client.v_angle, @forward_, @right, Nil); VectorScale (forward_, -2, ent.client.kick_origin); ent.client.kick_angles[0] := -2; VectorSet(offset, 0, 8, ent.viewheight-8); P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start); if (is_quad) then begin damage := damage *4; kick := kick *4; end; v[PITCH] := ent.client.v_angle[PITCH]; v[YAW] := ent.client.v_angle[YAW] - 5; v[ROLL] := ent.client.v_angle[ROLL]; AngleVectors (v, @forward_, Nil, Nil); fire_shotgun (ent, start, forward_, damage, kick, DEFAULT_SHOTGUN_HSPREAD, DEFAULT_SHOTGUN_VSPREAD, DEFAULT_SSHOTGUN_COUNT DIV 2, MOD_SSHOTGUN); v[YAW] := ent.client.v_angle[YAW] + 5; AngleVectors (v, @forward_, Nil, Nil); fire_shotgun (ent, start, forward_, damage, kick, DEFAULT_SHOTGUN_HSPREAD, DEFAULT_SHOTGUN_VSPREAD, DEFAULT_SSHOTGUN_COUNT DIV 2, MOD_SSHOTGUN); // send muzzle flash gi.WriteByte (svc_muzzleflash);//Y gi.WriteShort (ent-g_edicts); gi.WriteByte (MZ_SSHOTGUN 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 ) ) if ( (TRunc(dmflags.value) AND DF_INFINITE_AMMO) = 0 ) then ent.client.pers.inventory[ent.client.ammo_index] := ent.client.pers.inventory[ent.client.ammo_index] -2;end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_SuperShotgun (ent : edict_p); //for g_itemsconst pause_frames : array [0..3] of integer = (29, 42, 57, 0); fire_frames : array [0..1] of integer = (7, 0);begin Weapon_Generic (ent, 6, 17, 57, 61, pause_frames, fire_frames{, weapon_supershotgun_fire});end;//procedure (GAME=CTF){*======================================================================RAILGUN======================================================================*}// (GAME=CTF)procedure weapon_railgun_fire (ent : edict_p); //??? only impvar start, forward_, right, offset : vec3_t; damage, kick : integer;begin if (deathmatch.value <> 0) then begin // normal damage is too extreme in dm damage := 100; kick := 200; end else begin damage := 150; kick := 250; end; if (is_quad) then begin damage := damage *4; kick := kick *4; end; AngleVectors (ent.client.v_angle, @forward_, @right, Nil); VectorScale (forward_, -3, ent.client.kick_origin); ent.client.kick_angles[0] := -3; VectorSet(offset, 0, 7, ent.viewheight-8); P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start); fire_rail (ent, start, forward_, damage, kick); // send muzzle flash gi.WriteByte (svc_muzzleflash);//Y gi.WriteShort (ent-g_edicts); gi.WriteByte (MZ_RAILGUN 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 ) ) 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_Railgun (ent : edict_p); //for g_itemsconst pause_frames : array [0..1] of integer = (56, 0); fire_frames : array [0..1] of integer = (4, 0);begin Weapon_Generic (ent, 3, 18, 56, 61, pause_frames, fire_frames{, weapon_railgun_fire});end;//procedure (GAME=CTF){*======================================================================BFG10K======================================================================*}// (GAME=CTF)procedure weapon_bfg_fire (ent : edict_p); //???only impvar offset, start, forward_, right : vec3_t; damage : integer;// float damage_radius = 1000;begin if (deathmatch.value <> 0) then damage := 200 else damage := 500; if (ent.client.ps.gunframe = 9) then begin // send muzzle flash gi.WriteByte (svc_muzzleflash);//Y gi.WriteShort (ent-g_edicts); gi.WriteByte (MZ_BFG or is_silenced); gi.multicast (ent.s.origin, MULTICAST_PVS); Inc(ent.client.ps.gunframe); PlayerNoise(ent, ent.s.origin, PNOISE_WEAPON); Exit; end; // cells can go down during windup (from power armor hits), so // check again and abort firing if we don't have enough now if (ent.client.pers.inventory[ent.client.ammo_index] < 50) then begin Inc(ent.client.ps.gunframe); Exit; end; if (is_quad) then damage := damage *4; AngleVectors (ent.client.v_angle, @forward_, @right, Nil); VectorScale (forward_, -2, ent.client.kick_origin); // make a big pitch kick with an inverse fall ent.client.v_dmg_pitch := -40; ent.client.v_dmg_roll := crandom()*8; ent.client.v_dmg_time := level.time + DAMAGE_TIME; VectorSet(offset, 8, 8, ent.viewheight-8); P_ProjectSource (ent.client, ent.s.origin, offset, forward_, right, start); fire_bfg (ent, start, forward_, damage, 400, damage_radius); Inc(ent.client.ps.gunframe); PlayerNoise(ent, start, PNOISE_WEAPON);// if (! ( (int)dmflags.value & DF_INFINITE_AMMO ) ) if ( (Trunc(dmflags.value) AND DF_INFINITE_AMMO) = 0 ) then ent.client.pers.inventory[ent.client.ammo_index] := ent.client.pers.inventory[ent.client.ammo_index] -50;end;//procedure (GAME=CTF)// (GAME=CTF)procedure Weapon_BFG (ent : edict_p); //for g_itemsconst pause_frames : array [0..4] of integer = (39, 45, 50, 55, 0); fire_frames : array [0..2] of integer = (9, 17, 0);begin Weapon_Generic (ent, 8, 32, 55, 58, pause_frames, fire_frames{, weapon_bfg_fire});end;//procedure (GAME=CTF)//======================================================================// End of fileend.My current problems:
--------------------
1) C2PAS: "if" & "for"
C-code:
if (pause_frames) then
for (n = 0; pause_frames[n]; n++)
PAS-code:
if Assigned(pause_frames) then
begin
n := 0;
while pause_frames[n] <> 0 do
begin
...
Inc(n);
end;
end;
2) OK!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -