📄 cl_tent.pas
字号:
FillChar(ent, sizeof(ent), 0);
if (b.model = cl_mod_lightning) then
begin
model_length := 35.0;
d := d - 20; // correction so it doesn't end in middle of tesla
end
else
model_length := 30.0;
steps := ceil(d / model_length);
len := (d - model_length) / (steps - 1);
// PMM - special case for lightning model .. if the real length is shorter than the model,
// flip it around & draw it from the end to the start. This prevents the model from going
// through the tesla mine (instead it goes through the target)
if (b.model = cl_mod_lightning) and (d <= model_length) then
begin
// Com_Printf ('special case'#10);
VectorCopy(b^.end_, vec3_t(ent.origin));
// offset to push beam outside of tesla model (negative because dist is from end to start
// for this beam)
// for j := 0 to 2 do
// ent.origin[j] := ent.origin[j] - (dist[j]*10.0);
ent.model := b.model;
ent.flags := RF_FULLBRIGHT;
ent.angles[0] := pitch;
ent.angles[1] := yaw;
ent.angles[2] := random(360);
V_AddEntity(@ent);
exit;
end;
while (d > 0) do
begin
VectorCopy(org, vec3_t(ent.origin));
ent.model := b.model;
if (b.model = cl_mod_lightning) then
begin
ent.flags := RF_FULLBRIGHT;
ent.angles[0] := -pitch;
ent.angles[1] := yaw + 180.0;
ent.angles[2] := rand() mod 360;
end
else
begin
ent.angles[0] := pitch;
ent.angles[1] := yaw;
ent.angles[2] := rand() mod 360;
end;
// Com_Printf('B: %d ^. %d'#10, b.entity, b.dest_entity);
V_AddEntity(@ent);
for j := 0 to 2 do
org[j] := org[j] + (Dist[j] * len);
d := d - model_length;
end;
end;
end;
{
=========
ROGUE - draw player locked beams
CL_AddPlayerBeams
=========
}
procedure CL_AddPlayerBeams;
var
i, j: Integer;
b: Beam_p;
Dist, Org, F, R, U, Len: Vec3_t;
d: Single;
Framenum: Integer;
Ent: entity_t;
Yaw, Pitch, Forward_, Len_, Steps, Model_length: Single;
Hand_Multiplier: Single;
Oldframe: frame_p;
PS, OPS: player_State_p;
begin
//PMM
if (hand <> nil) then
begin
if (hand^.value = 2) then
hand_multiplier := 0
else if (hand^.value = 1) then
hand_multiplier := -1
else
hand_multiplier := 1;
end
else
hand_multiplier := 1;
//PMM
// update beams
for i := 0 to MAX_BEAMS - 1 do
begin
b := @cl_playerbeams[i];
if (b^.model = nil) or (b^.endtime < cl.time) then
continue;
if (cl_mod_heatbeam <> nil) and (b.model = cl_mod_heatbeam) then
begin
// if coming from the player, update the start position
if b.entity = (cl.playernum + 1) then
begin // entity 0 is the world
// set up gun position
// code straight out of CL_AddViewWeapon
ps := @cl.frame.playerstate;
j := (cl.frame.serverframe - 1) and UPDATE_MASK;
oldframe := @cl.frames[j];
if (oldframe^.serverframe <> cl.frame.serverframe - 1) or (not oldframe^.valid) then
oldframe := @cl.frame; // previous frame was dropped or involid
ops := @oldframe^.playerstate;
for j := 0 to 2 do
b.start[j] := cl.refdef.vieworg[j] + ops^.gunoffset[j]
+ cl.lerpfrac * (ps^.gunoffset[j] - ops^.gunoffset[j]);
VectorMA(b.start, (hand_multiplier * b.offset[0]), cl.v_right, org);
VectorMA(org, b.offset[1], cl.v_forward, org);
VectorMA(org, b.offset[2], cl.v_up, org);
if (hand <> nil) and (hand^.value = 2) then
VectorMA(org, -1, cl.v_up, org);
// FIXME - take these out when final
VectorCopy(cl.v_right, r);
VectorCopy(cl.v_forward, f);
VectorCopy(cl.v_up, u);
end
else
VectorCopy(b.start, org);
end
else
begin
// if coming from the player, update the start position
if b.entity = (cl.playernum + 1) then
begin // entity 0 is the world
VectorCopy(vec3_t(cl.refdef.vieworg), b.start);
b.start[2] := b.start[2] - 22; // adjust for view height
end;
VectorAdd(b.start, b.offset, org);
end;
// calculate pitch and yaw
VectorSubtract(b.end_, org, dist);
//PMM
if (cl_mod_heatbeam <> nil) and (b.model = cl_mod_heatbeam) and (b.entity = (cl.playernum + 1)) then
begin
len_ := VectorLength(dist);
VectorScale(f, len_, dist);
VectorMA(dist, (hand_multiplier * b.offset[0]), r, dist);
VectorMA(dist, b.offset[1], f, dist);
VectorMA(dist, b.offset[2], u, dist);
if (hand <> nil) and (hand^.value = 2) then
VectorMA(org, -1, cl.v_up, org);
end;
//PMM
if (dist[1] = 0) and (dist[0] = 0) then
begin
yaw := 0;
if (dist[2] > 0) then
pitch := 90
else
pitch := 270;
end
else
begin
// PMM - fixed to correct for pitch of 0
if (dist[0] <> 0) then
// was yaw := (atan2(dist[1], dist[0]) * 180 / M_PI)
yaw := (ArcTan2(dist[1], dist[0]) * 180 / M_PI)
else if (dist[1] > 0) then
yaw := 90
else
yaw := 270;
if (yaw < 0) then
Yaw := Yaw + 360;
forward_ := sqrt(Sqr(dist[0]) + Sqr(dist[1]));
pitch := (ArcTan(dist[2] / forward_) * -180.0 / M_PI);
if (pitch < 0) then
Pitch := Pitch + 360;
end;
if (cl_mod_heatbeam <> nil) and (b.model = cl_mod_heatbeam) then
begin
if b.entity <> (cl.playernum + 1) then
begin
Framenum := 2;
// Com_Printf ('Third person\n');
ent.angles[0] := -pitch;
ent.angles[1] := yaw + 180.0;
ent.angles[2] := 0;
// Com_Printf ('%f %f - %f %f %f\n', -pitch, yaw+180.0, b.offset[0], b.offset[1], b.offset[2]);
AngleVectors(vec3_t(ent.angles), @f, @r, @u);
// if it's a non-origin offset, it's a player, so use the hardcoded player offset
if 0 = VectorCompare(b.offset, vec3_origin) then
begin
VectorMA(org, -(b.offset[0]) + 1, r, org);
VectorMA(org, -(b.offset[1]), f, org);
VectorMA(org, -(b.offset[2]) - 10, u, org);
end
else
begin
// if it's a monster, do the particle effect
CL_MonsterPlasma_Shell(b.start);
end;
end
else
begin
framenum := 1;
end;
end;
// if it's the heatbeam, draw the particle effect
if (cl_mod_heatbeam <> nil) and (b.model = cl_mod_heatbeam) and (b.entity = (cl.playernum + 1)) then
begin
CL_Heatbeam(org, dist);
end;
// add new entities for the beams
d := VectorNormalize(dist);
FillChar(ent, sizeof(ent), 0);
if (b.model = cl_mod_heatbeam) then
begin
model_length := 32.0
end
else if (b.model = cl_mod_lightning) then
begin
model_length := 35.0;
d := d - 20.0; // correction so it doesn't end in middle of tesla
end
else
model_length := 30.0;
steps := ceil(d / model_length);
len_ := (d - model_length) / (steps - 1);
// PMM - special case for lightning model .. if the real length is shorter than the model,
// flip it around & draw it from the end to the start. This prevents the model from going
// through the tesla mine (instead it goes through the target)
if (b.model = cl_mod_lightning) and (d <= model_length) then
begin
// Com_Printf ('special case\n');
VectorCopy(b.end_, vec3_t(ent.origin));
// offset to push beam outside of tesla model (negative because dist is from end to start
// for this beam)
// for j := 0 to 2 do
// ent.origin[j] := ent.origin[j] - dist[j]*10.0;
ent.model := b.model;
ent.flags := RF_FULLBRIGHT;
ent.angles[0] := pitch;
ent.angles[1] := yaw;
ent.angles[2] := random(360);
V_AddEntity(@ent);
exit;
end;
while (d > 0) do
begin
VectorCopy(org, vec3_t(ent.origin));
ent.model := b.model;
if (cl_mod_heatbeam <> nil) and (b.model = cl_mod_heatbeam) then
begin
// ent.flags := RF_FULLBRIGHT or RF_TRANSLUCENT;
// ent.alpha := 0.3;
ent.flags := RF_FULLBRIGHT;
ent.angles[0] := -pitch;
ent.angles[1] := yaw + 180.0;
ent.angles[2] := (cl.time) mod 360;
// ent.angles[2] := rand()%360;
ent.frame := framenum;
end
else if (b.model = cl_mod_lightning) then
begin
ent.flags := RF_FULLBRIGHT;
ent.angles[0] := -pitch;
ent.angles[1] := yaw + 180.0;
ent.angles[2] := rand() mod 360;
end
else
begin
ent.angles[0] := pitch;
ent.angles[1] := yaw;
ent.angles[2] := rand() mod 360;
end;
// Com_Printf('B: %d ^. %d\n', b.entity, b.dest_entity);
V_AddEntity(@ent);
for j := 0 to 2 do
org[j] := org[j] + dist[j] * len_;
d := d - model_length;
end;
end;
end;
{
=========
CL_AddExplosions
=========
}
procedure CL_AddExplosions;
var
Ent: Entity_p;
i, f: Integer;
Ex: Explosion_p;
Frac: Single;
begin
FillChar(ent, sizeof(ent), 0);
for i := 0 to MAX_EXPLOSIONS - 1 do
begin
ex := @cl_explosions[i];
if (ex.type_ = ex_free) then
continue;
Frac := (cl.time - ex.start) / 100.0;
f := floor(frac);
ent := @ex.ent;
case ex.type_ of
ex_mflash: if (f >= ex.frames - 1) then
ex.type_ := ex_free;
ex_misc:
if (f >= ex.frames - 1) then
ex.type_ := ex_free
else
ent^.alpha := 1.0 - frac / (ex.frames - 1);
ex_flash:
if (f >= 1) then
ex.type_ := ex_free
else
ent^.alpha := 1.0;
ex_poly:
begin
if (f >= ex.frames - 1) then
ex.type_ := ex_free
else
begin
ent^.alpha := (16.0 - f) / 16.0;
if (f < 10) then
begin
ent^.skinnum := (f shr 1);
if (ent^.skinnum < 0) then
ent^.skinnum := 0;
end
else
begin
ent^.flags := ent^.flags or RF_TRANSLUCENT;
if (f < 13) then
ent^.skinnum := 5
else
ent^.skinnum := 6;
end;
end;
end;
ex_poly2:
if (f >= ex.frames - 1) then
ex.type_ := ex_free
else
begin
ent^.alpha := (5.0 - f) / 5.0;
ent^.skinnum := 0;
ent^.flags := ent^.flags or RF_TRANSLUCENT;
end;
end;
if (ex.type_ = ex_free) then
continue;
if (ex.light <> 0) then
V_AddLight(vec3_t(ent^.origin), ex.light * ent^.alpha, ex.lightcolor[0], ex.lightcolor[1], ex.lightcolor[2]);
VectorCopy(vec3_t(ent^.origin), vec3_t(ent^.oldorigin));
if (f < 0) then
f := 0;
ent^.frame := ex.baseframe + f + 1;
ent^.oldframe := ex.baseframe + f;
ent^.backlerp := 1.0 - cl.lerpfrac;
V_AddEntity(ent);
end;
end;
{
=========
CL_AddLasers
=========
}
procedure CL_AddLasers;
var
l: Laser_p;
i: Integer;
begin
for i := 0 to MAX_LASERS - 1 do
begin
l := @cl_lasers[i];
if (l^.endtime >= cl.time) then
V_AddEntity(@l^.ent);
end;
end;
{ PMM - CL_Sustains }
procedure CL_ProcessSustain();
var
s: cl_sustain_p;
i: Integer;
begin
for i := 0 to MAX_SUSTAINS - 1 do
begin
s := @cl_sustains[i];
if (s.id <> 0) then
if ((s.endtime >= cl.time) and (cl.time >= s.nextthink)) then
begin
// Com_Printf ('think %d %d %d'#10, cl.time, s^.nextthink, s^.thinkinterval);
s.think(s);
end
else if (s.endtime < cl.time) then
s.id := 0;
end;
end;
{
=========
CL_AddTEnts
=========
}
procedure CL_AddTEnts;
begin
CL_AddBeams();
// PMM - draw plasma beams
CL_AddPlayerBeams();
CL_AddExplosions();
CL_AddLasers();
// PMM - set up sustain
CL_ProcessSustain();
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -