📄 g_weapon.pas
字号:
end;
VectorCopy (tr.endpos, from);
end;//while
// send gun puff / flash
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_RAILTRAIL);
gi.WritePosition (start);
gi.WritePosition (tr.endpos);
gi.multicast (self.s.origin, MULTICAST_PHS);
//idsoft gi.multicast (start, MULTICAST_PHS);
if (water) then
begin
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_RAILTRAIL);
gi.WritePosition (start);
gi.WritePosition (tr.endpos);
gi.multicast (tr.endpos, MULTICAST_PHS);
end;
if (self.client) then
PlayerNoise(self, tr.endpos, PNOISE_IMPACT);
end;//procedure (GAME=CTF)
{*
=================
fire_bfg
=================
*}
// (GAME=CTF)
procedure bfg_explode (edict_t *self);
var
edict_t *ent;
points : float;
v : vec3_t;
dist : float;
begin
if (self.s.frame = 0) then
begin
// the BFG effect
ent := NULL;
{Y} while ((ent = findradius(ent, self.s.origin, self.dmg_radius)) != NULL)
begin
if (!ent.takedamage) then
Continue;
if (ent = self.owner) then
Continue;
if (!CanDamage (ent, self)) then
Continue;
if (!CanDamage (ent, self.owner)) then
Continue;
VectorAdd (ent.mins, ent.maxs, v);
VectorMA (ent.s.origin, 0.5, v, v);
VectorSubtract (self.s.origin, v, v);
dist := VectorLength(v);
points := self.radius_dmg * (1.0 - sqrt(dist/self.dmg_radius));
if (ent = self.owner) then
points := points * 0.5;
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_BFG_EXPLOSION);
gi.WritePosition (ent.s.origin);
gi.multicast (ent.s.origin, MULTICAST_PHS);
T_Damage (ent, self, self.owner, self.velocity, ent.s.origin, vec3_origin, (int)points, 0, DAMAGE_ENERGY, MOD_BFG_EFFECT);
end;//while
end;
selfnextthink := level.time + FRAMETIME;
self.s.frame++;
if (self.s.frame = 5) then
self.think := G_FreeEdict;
end;//procedure (GAME=CTF)
// (GAME=CTF)
procedure bfg_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);
begin
if (other = self.owner) then
Exit;
// if (surf && (surf.flags & SURF_SKY)) then
if ( surf AND (surf.flags AND SURF_SKY) <> 0 ) then
begin
G_FreeEdict (self);
Exit;
end;
if (self.owner.client) then
PlayerNoise(self.owner, self.s.origin, PNOISE_IMPACT);
// core explosion - prevents firing it into the wall/floor
if (other.takedamage) then
T_Damage (other, self, self.owner, self.velocity, self.s.origin, plane.normal, 200, 0, 0, MOD_BFG_BLAST);
T_RadiusDamage(self, self.owner, 200, other, 100, MOD_BFG_BLAST);
gi.sound (self, CHAN_VOICE, gi.soundindex ('weapons/bfg__x1b.wav'), 1, ATTN_NORM, 0);
self.solid := SOLID_NOT;
self.touch := NULL;
VectorMA (self.s.origin, -1 * FRAMETIME, self.velocity, self.s.origin);
VectorClear (self.velocity);
self.s.modelindex := gi.modelindex ('sprites/s_bfg3.sp2');
self.s.frame := 0;
self.s.sound := 0;
// self.s.effects &= ~EF_ANIM_ALLFAST;
self.s.effects := self.s.effects AND (NOT EF_ANIM_ALLFAST);
self.think := bfg_explode;
self.nextthink := level.time + FRAMETIME;
self.enemy := other;
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_BFG_BIGEXPLOSION);
gi.WritePosition (self.s.origin);
gi.multicast (self.s.origin, MULTICAST_PVS);
end;//procedure (GAME=CTF)
// (GAME <> CTF)
procedure bfg_think (edict_t *self);
var
edict_t *ent;
edict_t *ignore;
point,
dir,
start,
end_ : vec3_t;
dmg : integer;
tr : trace_t;
begin
if (deathmatch.value)
then dmg := 5
else dmg := 10;
ent := NULL;
while ((ent = findradius(ent, self.s.origin, 256)) != NULL)
begin
if (ent = self) then
Continue;
if (ent = self.owner) then
Continue;
if (!ent.takedamage) then
Continue;
// if (!(ent.svflags & SVF_MONSTER) AND (!ent.client) AND (strcmp(ent.classname, 'misc_explobox') <> 0)) then
if ( ((ent.svflags AND SVF_MONSTER) = 0) AND
(!ent.client) AND
(strcmp(ent.classname, 'misc_explobox') <> 0) ) then
Continue;
//only CFT
{$IFDEF CTF}
//ZOID
//don't target players in CTF
if (ctf.value) AND (ent.client) AND (self.owner.client) AND
(ent.client.resp.ctf_team = self.owner.client.resp.ctf_team) then
Continue;
//ZOID
{$ENDIF}
VectorMA (ent.absmin, 0.5, ent.size, point);
VectorSubtract (point, self.s.origin, dir);
VectorNormalize (dir);
ignore := self;
VectorCopy (self.s.origin, start);
VectorMA (start, 2048, dir, end_);
while (1) do
begin
tr := gi.trace (start, NULL, NULL, end_, ignore, CONTENTS_SOLID or CONTENTS_MONSTER or CONTENTS_DEADMONSTER);
if (!tr.ent) then
break;
// hurt it if we can
// if ((tr.ent.takedamage) AND !(tr.ent.flags & FL_IMMUNE_LASER) AND (tr.ent <> self.owner)) then
if ( (tr.ent.takedamage) AND
((tr.ent.flags AND FL_IMMUNE_LASER) = 0) AND
(tr.ent <> self.owner) ) then
T_Damage (tr.ent, self, self.owner, dir, tr.endpos, vec3_origin, dmg, 1, DAMAGE_ENERGY, MOD_BFG_LASER);
// if we hit something that's not a monster or player we're done
// if (!(tr.ent.svflags & SVF_MONSTER) AND (!tr.ent.client)) then
if ( ((tr.ent.svflags AND SVF_MONSTER) = 0) AND (!tr.ent.client) ) then
begin
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_LASER_SPARKS);
gi.WriteByte (4);
gi.WritePosition (tr.endpos);
gi.WriteDir (tr.plane.normal);
gi.WriteByte (self.s.skinnum);
gi.multicast (tr.endpos, MULTICAST_PVS);
break;
end;
ignore := tr.ent;
VectorCopy (tr.endpos, start);
end;//while
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_BFG_LASER);
gi.WritePosition (self.s.origin);
gi.WritePosition (tr.endpos);
gi.multicast (self.s.origin, MULTICAST_PHS);
end;//while
self.nextthink = level.time + FRAMETIME;
end;//procedure (GAME <> CTF)
// (GAME=CTF)
procedure fire_bfg (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, float damage_radius);
var
edict_t *bfg;
begin
bfg := G_Spawn();
VectorCopy (start, bfg.s.origin);
VectorCopy (dir, bfg.movedir);
vectoangles (dir, bfg.s.angles);
VectorScale (dir, speed, bfg.velocity);
bfg.movetype := MOVETYPE_FLYMISSILE;
bfg.clipmask := MASK_SHOT;
bfg.solid := SOLID_BBOX;
// bfg->s.effects |= EF_BFG | EF_ANIM_ALLFAST;
bfg.s.effects := bfg.s.effects OR EF_BFG OR EF_ANIM_ALLFAST;
VectorClear (bfg.mins);
VectorClear (bfg.maxs);
bfg.s.modelindex := gi.modelindex ('sprites/s_bfg1.sp2');
bfg.owner := self;
bfg.touch := bfg_touch;
bfg.nextthink := level.time + 8000/speed;
bfg.think := G_FreeEdict;
bfg.radius_dmg := damage;
bfg.dmg_radius := damage_radius;
bfg.classname := 'bfg blast';
bfg.s.sound := gi.soundindex ('weapons/bfg__l1a.wav');
bfg.think := bfg_think;
bfg.nextthink := level.time + FRAMETIME;
bfg.teammaster := bfg;
bfg.teamchain := NULL;
if (self.client) then
check_dodge (self, bfg.s.origin, dir, speed);
gi.linkentity (bfg);
end;//procedure (GAME=CTF)
// End of file
My current problems:
--------------------
1) all local variable
2) C2PAS: "if" & "for"
3) OK!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -