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

📄 g_weapon.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
//procedure fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int mod);
procedure fire_shotgun (self : edict_p; start, aimdir : vec3_t; damage, kick, hspread, vspread, count, mod_ : integer);
var
  i : integer;
begin
  for i:=0 to count-1 do
//Y    fire_lead (self, start, aimdir, damage, kick, TE_SHOTGUN, hspread, vspread, mod_);
end;//procedure (GAME=CTF)


{*
=================
fire_blaster

Fires a single blaster bolt.  Used by the blaster and hyper blaster.
=================
*}
// (GAME=CTF)
//procedure blaster_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);
procedure blaster_touch (self, other : edict_p; plane : cplane_p; surf : csurface_p); cdecl;
var
  mod_ : integer;
begin
  if (other = self.owner) then
    Exit;

//  if (surf && (surf.flags & SURF_SKY)) then
  if ((surf <> Nil) AND ((surf.flags AND SURF_SKY) <> 0)) then
  begin
//Y    G_FreeEdict (self);
    Exit;
  end;

(*  if (self.owner.client <> Nil) then
    PlayerNoise (self.owner, self.s.origin, PNOISE_IMPACT);

  if (other.takedamage)
  then begin
//    if (self.spawnflags & 1)
    if ((self.spawnflags AND 1) <> 0)
    then mod_ := MOD_HYPERBLASTER
    else mod_ := MOD_BLASTER;
    T_Damage (other, self, self.owner, self.velocity, self.s.origin, plane.normal, self.dmg, 1, DAMAGE_ENERGY, mod_);
  end
  else begin
    gi.WriteByte (svc_temp_entity);
    gi.WriteByte (TE_BLASTER);
    gi.WritePosition (self.s.origin);
    if (!plane)
    then gi.WriteDir (vec3_origin)
    else gi.WriteDir (plane.normal);
    gi.multicast (self.s.origin, MULTICAST_PVS);
  end;

  G_FreeEdict (self);*)
end;//procedure (GAME=CTF)

// (GAME <> CTF)
//procedure fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int effect, qboolean hyper);
procedure fire_blaster (self : edict_p; start, dir : vec3_t; damage, speed, effect : integer; hyper : qboolean);
var
  bolt : edict_p;
  tr : trace_t;
begin
  VectorNormalize (dir);

(*Y  bolt := G_Spawn();

//only CFT
{$IFDEF CTF}
  bolt.svflags := SVF_PROJECTILE; // special net code is used for projectiles
{$ELSE}
  bolt.svflags := SVF_DEADMONSTER;
  // yes, I know it looks weird that projectiles are deadmonsters
  // what this means is that when prediction is used against the object
  // (blaster/hyperblaster shots), the player won't be solid clipped against
  // the object.  Right now trying to run into a firing hyperblaster
  // is very jerky since you are predicted 'against' the shots.
{$ENDIF}*)

  VectorCopy (start, bolt.s.origin);
  VectorCopy (start, bolt.s.old_origin);
(*Y  vectoangles (dir, bolt.s.angles);
  VectorScale (dir, speed, bolt.velocity);*)
  bolt.movetype := MOVETYPE_FLYMISSILE;
  bolt.clipmask := MASK_SHOT;
  bolt.solid := SOLID_BBOX;
  bolt.s.effects := bolt.s.effects OR effect;
  VectorClear (bolt.mins);
  VectorClear (bolt.maxs);
(*Y  bolt.s.modelindex := gi.modelindex ('models/objects/laser/tris.md2');
  bolt.s.sound := gi.soundindex ('misc/lasfly.wav');*)
  bolt.owner := self;
  bolt.touch := blaster_touch;
  bolt.nextthink := level.time + 2;
//Y  bolt.think := G_FreeEdict;
  bolt.dmg := damage;
  bolt.classname := 'bolt';
  if (hyper) then
    bolt.spawnflags := 1;
  gi.linkentity (bolt);

  if (self.client <> Nil) then
    check_dodge (self, bolt.s.origin, dir, speed);

//Y  tr := gi.trace (self.s.origin, NULL, NULL, bolt.s.origin, bolt, MASK_SHOT);
  if (tr.fraction < 1.0) then
  begin
    VectorMA (bolt.s.origin, -10, dir, bolt.s.origin);
    bolt.touch (bolt, tr.ent, Nil, Nil);
  end;
end;//procedure (GAME <> CTF)


{*
=================
fire_grenade
=================
*}
// (GAME=CTF)
//procedure static void Grenade_Explode (edict_t *ent);
procedure Grenade_Explode (ent : edict_p); cdecl;
var
  origin : vec3_t;
  mod_   : integer;
  points : float;
  v,
  dir    : vec3_t;
begin
(*Y  if (ent.owner.client <> Nil) then
    PlayerNoise (ent.owner, ent.s.origin, PNOISE_IMPACT);*)

  //FIXME: if we are onground then raise our Z just a bit since we are a point?
  if (ent.enemy <> Nil) then
  begin
    VectorAdd (ent.enemy.mins, ent.enemy.maxs, v);
    VectorMA (ent.enemy.s.origin, 0.5, v, v);
    VectorSubtract (ent.s.origin, v, v);
    points := ent.dmg - 0.5 * VectorLength (v);
    VectorSubtract (ent.enemy.s.origin, ent.s.origin, dir);
//    if (ent.spawnflags & 1)
    if ((ent.spawnflags AND 1) <> 0)
    then mod_ := MOD_HANDGRENADE
    else mod_ := MOD_GRENADE;
//Y    T_Damage (ent.enemy, ent, ent.owner, dir, ent.s.origin, vec3_origin, (int)points, (int)points, DAMAGE_RADIUS, mod_);
  end;

//  if (ent.spawnflags & 2)
  if ((ent.spawnflags AND 2) <> 0)
  then mod_ := MOD_HELD_GRENADE
  else
//    if (ent.spawnflags & 1)
    if ((ent.spawnflags AND 1) <> 0)
    then mod_ := MOD_HG_SPLASH
    else mod_ := MOD_G_SPLASH;
//Y  T_RadiusDamage(ent, ent.owner, ent.dmg, ent.enemy, ent.dmg_radius, mod_);

  VectorMA (ent.s.origin, -0.02, ent.velocity, origin);
  gi.WriteByte (svc_temp_entity);
(*Y  if (ent.waterlevel <> 0)
  then
    if (ent.groundentity <> Nil)
    then gi.WriteByte (TE_GRENADE_EXPLOSION_WATER)
    else gi.WriteByte (TE_ROCKET_EXPLOSION_WATER);
  end
  else
    if (ent.groundentity)
    then gi.WriteByte (TE_GRENADE_EXPLOSION)
    else gi.WriteByte (TE_ROCKET_EXPLOSION);
  end;*)
  gi.WritePosition (origin);
  gi.multicast (ent.s.origin, MULTICAST_PHS);

//Y  G_FreeEdict (ent);
end;//procedure (GAME=CTF)

// (GAME=CTF)
//procedure static void Grenade_Touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
procedure Grenade_Touch (ent, other : edict_p; plane : cplane_p; surf : csurface_p); cdecl;
begin
  if (other = ent.owner) then
    Exit;

//  if (surf && (surf.flags & SURF_SKY)) then
  if ((surf <> Nil) AND ((surf.flags AND SURF_SKY) <>0)) then
  begin
//Y    G_FreeEdict (ent);
    Exit;
  end;

//Y  if (!other.takedamage) then
  begin
//    if (ent.spawnflags & 1)
    if ((ent.spawnflags AND 1) <> 0)
    then
      if (random > 0.5)
      then gi.sound (ent, CHAN_VOICE, gi.soundindex ('weapons/hgrenb1a.wav'), 1, ATTN_NORM, 0)
      else gi.sound (ent, CHAN_VOICE, gi.soundindex ('weapons/hgrenb2a.wav'), 1, ATTN_NORM, 0)
    else
      gi.sound (ent, CHAN_VOICE, gi.soundindex ('weapons/grenlb1b.wav'), 1, ATTN_NORM, 0);
    Exit;
  end;

  ent.enemy := other;
  Grenade_Explode (ent);
end;//procedure (GAME=CTF)

// (GAME=CTF)
//procedure fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius);
procedure fire_grenade (self : edict_p; start, aimdir : vec3_t; damage, speed : integer; timer, damage_radius : float);
var
  grenade : edict_p;
  dir,
  forward_, right, up : vec3_t;
begin
//Y  vectoangles (aimdir, dir);
  AngleVectors (dir, @forward_, @right, @up);

//Y  grenade := G_Spawn();
  VectorCopy (start, grenade.s.origin);
  VectorScale (aimdir, speed, grenade.velocity);
  VectorMA (grenade.velocity, 200 + crandom() * 10.0, up, grenade.velocity);
  VectorMA (grenade.velocity, crandom() * 10.0, right, grenade.velocity);
  VectorSet (grenade.avelocity, 300, 300, 300);
  grenade.movetype := MOVETYPE_BOUNCE;
  grenade.clipmask := MASK_SHOT;
  grenade.solid := SOLID_BBOX;
  grenade.s.effects := grenade.s.effects OR EF_GRENADE;
  VectorClear (grenade.mins);
  VectorClear (grenade.maxs);
  grenade.s.modelindex := gi.modelindex ('models/objects/grenade/tris.md2');
  grenade.owner := self;
  grenade.touch := Grenade_Touch;
  grenade.nextthink := level.time + timer;
  grenade.think := Grenade_Explode;
  grenade.dmg := damage;
  grenade.dmg_radius := damage_radius;
  grenade.classname := 'grenade';

  gi.linkentity (grenade);
end;//procedure (GAME=CTF)

// (GAME=CTF)
//procedure fire_grenade2 (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius, qboolean held);
procedure fire_grenade2 (self : edict_p; start, aimdir : vec3_t; damage, speed : integer; timer, damage_radius : float; held : qboolean);
var
  grenade : edict_p;
  dir,
  forward_, right, up : vec3_t;
begin
//Y  vectoangles (aimdir, dir);
  AngleVectors (dir, @forward_, @right, @up);

//Y  grenade := G_Spawn();
  VectorCopy (start, grenade.s.origin);
//Y  VectorScale (aimdir, speed, grenade.velocity);
  VectorMA (grenade.velocity, 200 + crandom() * 10.0, up, grenade.velocity);
  VectorMA (grenade.velocity, crandom() * 10.0, right, grenade.velocity);
  VectorSet (grenade.avelocity, 300, 300, 300);
  grenade.movetype := MOVETYPE_BOUNCE;
  grenade.clipmask := MASK_SHOT;
  grenade.solid := SOLID_BBOX;
  grenade.s.effects := grenade.s.effects OR EF_GRENADE;
  VectorClear (grenade.mins);
  VectorClear (grenade.maxs);
  grenade.s.modelindex := gi.modelindex ('models/objects/grenade2/tris.md2');
  grenade.owner := self;
  grenade.touch := Grenade_Touch;
  grenade.nextthink := level.time + timer;
  grenade.think := Grenade_Explode;
  grenade.dmg := damage;
  grenade.dmg_radius := damage_radius;
  grenade.classname := 'hgrenade';
  if (held)
  then grenade.spawnflags := 3
  else grenade.spawnflags := 1;
  grenade.s.sound := gi.soundindex('weapons/hgrenc1b.wav');

  if (timer <= 0.0)
  then Grenade_Explode (grenade)
  else begin
    gi.sound (self, CHAN_WEAPON, gi.soundindex ('weapons/hgrent1a.wav'), 1, ATTN_NORM, 0);
    gi.linkentity (grenade);
  end;
end;//procedure (GAME=CTF)


{*
=================
fire_rocket
=================
*}
// (GAME=CTF)
//procedure rocket_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
procedure rocket_touch (ent, other : edict_p; plane : cplane_p; surf : csurface_p); cdecl;
var
  origin : vec3_t;
  n      : integer;
begin
  if (other = ent.owner) then
    Exit;

//  if (surf && (surf.flags & SURF_SKY)) then
  if ((surf <> Nil) AND ((surf.flags AND SURF_SKY) <> 0)) then
  begin
//Y    G_FreeEdict (ent);
    Exit;
  end;

(*Y  if (ent.owner.client <> Nil) then
    PlayerNoise (ent.owner, ent.s.origin, PNOISE_IMPACT);*)

  // calculate position for the explosion entity
  VectorMA (ent.s.origin, -0.02, ent.velocity, origin);

(*Y  if (other.takedamage)
  then T_Damage (other, ent, ent.owner, ent.velocity, ent.s.origin, plane.normal, ent.dmg, 0, 0, MOD_ROCKET)
  else begin
    // don't throw any debris in net games
    if (!deathmatch.value AND !coop.value) then
//      if ((surf) && !(surf.flags & (SURF_WARP|SURF_TRANS33|SURF_TRANS66|SURF_FLOWING))) then
      if ( (surf) AND
           (surf.flags AND (SURF_WARP OR SURF_TRANS33 OR SURF_TRANS66 OR SURF_FLOWING) = 0) ) then
      begin
        n := random(5);
//        while(n--)
        while n<>0 do
        begin
          ThrowDebris (ent, 'models/objects/debris2/tris.md2', 2, ent.s.origin);
          Dec(n);
        end;//while
      end;
  end;

  T_RadiusDamage (ent, ent.owner, ent.radius_dmg, other, ent.dmg_radius, MOD_R_SPLASH);

  gi.WriteByte (svc_temp_entity);
  if (ent.waterlevel <> 0)
  then gi.WriteByte (TE_ROCKET_EXPLOSION_WATER)
  else gi.WriteByte (TE_ROCKET_EXPLOSION);*)
  gi.WritePosition (origin);
  gi.multicast (ent.s.origin, MULTICAST_PHS);

//Y  G_FreeEdict (ent);
end;//procedure (GAME=CTF)

⌨️ 快捷键说明

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