Skip to content

Commit

Permalink
fix: added generic beam effect func, crystal hazard shock beam now co…
Browse files Browse the repository at this point in the history
…rrectly uses new ESR beam effect.
  • Loading branch information
Subject9x committed Oct 27, 2024
1 parent 0b042a9 commit 0b63a43
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 27 deletions.
2 changes: 1 addition & 1 deletion client/main/client_parse_funcs.qc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ float() CSQC_Parse_TempEntity =
return TRUE;

case TE_VFX_RAIL:
trailparticles( world, ReadShort(), te_read_vector(), te_read_vector() );
particle_spawn_beam(ReadByte(), te_read_vector(), te_read_vector(), ReadFloat());
return TRUE;

case TE_PARTICLE_CUBE:
Expand Down
16 changes: 10 additions & 6 deletions client/main/client_playermovement.qc
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ void() CS_PlayerPhysics =
// acceleration
wishdir = normalize(wishvel);
wishspeed = vlen(wishvel);
if (wishspeed > cs_maxspeed)
if (wishspeed > cs_maxspeed){
wishspeed = cs_maxspeed;
}
if (time >= self.teleport_time)
{
f = wishspeed - (self.velocity * wishdir);
if (f > 0)
if (f > 0){
self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed);
}
}
}
else if (self.waterlevel >= 2)
Expand All @@ -100,22 +102,24 @@ void() CS_PlayerPhysics =
makevectors(self.v_angle);
//wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
if (wishvel == '0 0 0')
if (wishvel == '0 0 0'){
wishvel = '0 0 -60'; // drift towards bottom

}
wishdir = normalize(wishvel);
wishspeed = vlen(wishvel);
if (wishspeed > cs_maxspeed)
if (wishspeed > cs_maxspeed){
wishspeed = cs_maxspeed;
}
wishspeed = wishspeed * 0.7;

// water friction
self.velocity = self.velocity * (1 - frametime * cs_friction);

// water acceleration
f = wishspeed - (self.velocity * wishdir);
if (f > 0)
if (f > 0){
self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed);
}
}
else if (time < self.ladder_time)
{
Expand Down
2 changes: 2 additions & 0 deletions client/util/headers/particle_sys.qh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ void( vector org, vector windVel ) te_mech_crit;

void( entity item )te_weapon_fire_handler;

void(float beamType, vector particleOrg, vector particleEnd, float width) particle_spawn_beam;

//void() te_explode_mech_piece_th;
//void(entity piece) te_explode_mech_piece;

Expand Down
93 changes: 93 additions & 0 deletions client/util/particle_sys.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,99 @@ void(vector dir, float count) CL_ParticleRain={
};


void() particle_beam_th={

if(time > self.beamTime){
self.beamActive = FALSE;
remove(self);
}
}

void() particle_beam_las_draw={
if(vlen(self.beamOrg - CLIENT_vis_org) > PARTICLE_HAZ_DISTANCE){
return;
}
if(self.beamActive == FALSE){
return;
}
Draw_CylindricLine(self.beamOrg, self.beamEnd, self.beamWidth, "particles/laserbeam", 0.5, time * (random() * -6), self.drawcolor1, 0.75, DRAWFLAG_NORMAL | DRAWFLAG_MIPMAP, CLIENT_vis_org);
};

void() particle_beam_lightning_draw={
local float segCount;
local vector bAngl;
local float segment;
local vector segOrg;
local vector nexOrg;
local float itr;
local float width;

if(vlen(self.beamOrg - CLIENT_vis_org) > PARTICLE_HAZ_DISTANCE){
return;
}

if(self.beamActive == FALSE){
return;
}
segCount = 6;
width = self.beamWidth;
segment = rint(vlen(self.beamEnd - self.beamOrg) / segCount);
segOrg = self.beamOrg;

bAngl = vectoangles(self.beamEnd - self.beamOrg);
bAngl_x = bAngl_x * -1;
makevectors(bAngl);

nexOrg = self.beamOrg + (v_forward * segment) + (v_right * crandom() * 4) + (v_up * crandom() * 6);
Draw_CylindricLine(self.beamOrg, nexOrg, width, "particles/electro_beam", 0.1, time * 0.1, '0.17 0.33 1.0', 1.0, DRAWFLAG_NORMAL | DRAWFLAG_MIPMAP, CLIENT_vis_org);
segOrg = nexOrg;
segCount = segCount - 1;

for( itr = segCount; itr < (segment-2); itr = itr + 1){
nexOrg = self.beamOrg + (v_forward * segment * itr) + (v_right * crandom() * 2) + (v_up * crandom() * 4);

Draw_CylindricLine(segOrg, nexOrg, width, "particles/electro_beam", 0.1, time * 0.1, '0.17 0.33 1.0', 1.0, DRAWFLAG_NORMAL | DRAWFLAG_MIPMAP, CLIENT_vis_org);

width = max(1, width - 1);

segOrg = nexOrg;
}
Draw_CylindricLine(segOrg, self.beamEnd, width, "particles/electro_beam", 0.1, time * 0.1, '0.17 0.33 1.0', 1.0, DRAWFLAG_NORMAL | DRAWFLAG_MIPMAP, CLIENT_vis_org);

};



//float beamType, vector particleOrg, vector particleEnd, float width, float aspect, float shift, vector colr, float alph
void(float beamType, vector particleOrg, vector particleEnd, float width) particle_spawn_beam={

local entity ent;

ent = spawn();
if(!ent){
return;
}
if(beamType == 0){
ent.predraw = particle_beam_las_draw;
ent.nextthink = time + 0.2;
}
else{
ent.predraw = particle_beam_lightning_draw;
ent.nextthink = time + 0.075;
}
ent.drawmask = MASK_NORMAL;
ent.origin = particleOrg;
ent.solid = SOLID_NOT;
ent.movetype = MOVETYPE_NONE;
setsize(ent, '-1 -1 -1', '1 1 1');
setorigin(ent, ent.origin);
ent.beamOrg = particleOrg;
ent.beamEnd = particleEnd;
ent.beamWidth = width;
ent.beamActive = TRUE;
ent.think = particle_beam_th;

};

//maybe at some point someone can figure out MOVETYPE_BOUNCE for csqc.
/*
Expand Down
19 changes: 9 additions & 10 deletions main/client_utils.qc
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,6 @@ void() spawnpoint_Random={
self.fixangle = TRUE;
};

void() legacy_PlayerDie={
//self.items = self.items - (self.items & (IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
//self.invisible_finished = 0;
//self.invincible_finished = 0;
//self.super_damage_finished = 0;
//self.radsuit_finished = 0;
};

float(float hpCurrent, float hpTotal) csqc_updateCompStat={
local float perc;
perc = 0;
Expand All @@ -770,22 +762,29 @@ void( float particleEffectId, vector particleOrg, vector particleVel, float part
WriteCoord(MSG_BROADCAST, particleOrg_x);
WriteCoord(MSG_BROADCAST, particleOrg_y);
WriteCoord(MSG_BROADCAST, particleOrg_z);

WriteCoord(MSG_BROADCAST, particleVel_x);
WriteCoord(MSG_BROADCAST, particleVel_y);
WriteCoord(MSG_BROADCAST, particleVel_z);

WriteShort(MSG_BROADCAST, particleCount);
};

void( float entityId, float particleEffectId, vector particleOrg, vector particleEnd ) client_send_particle_rail={
//void( float entityId, float particleEffectId, vector particleOrg, vector particleEnd ) client_send_particle_rail={
void(float beamType, vector particleOrg, vector particleEnd, float width) client_send_particle_rail={
WriteByte( MSG_BROADCAST, SVC_TEMPENTITY );
WriteByte( MSG_BROADCAST, TE_VFX_RAIL );
WriteShort( MSG_BROADCAST, particleEffectId );
WriteByte( MSG_BROADCAST, beamType );

WriteCoord(MSG_BROADCAST, particleOrg_x);
WriteCoord(MSG_BROADCAST, particleOrg_y);
WriteCoord(MSG_BROADCAST, particleOrg_z);

WriteCoord(MSG_BROADCAST, particleEnd_x);
WriteCoord(MSG_BROADCAST, particleEnd_y);
WriteCoord(MSG_BROADCAST, particleEnd_z);

WriteFloat(MSG_BROADCAST, width);
};

/*
Expand Down
4 changes: 1 addition & 3 deletions main/headers/client_utils.qh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ void() DecodeLevelParms;
entity() SelectSpawnPoint;
//==========================
float(float hpCurrent, float hpTotal) csqc_updateCompStat;
//legacy wrappers
void() legacy_PlayerDie;

//spawn spot wrappers
void() sv_select_info_start;
Expand Down Expand Up @@ -54,4 +52,4 @@ void() client_update_faction;
void() client_update_losses;

void( float particleEffectId, vector particleOrg, vector particleVel, float particleCount ) client_send_particle;
void( float entityId, float particleEffectId, vector particleOrg, vector particleEnd ) client_send_particle_rail;
void(float beamType, vector particleOrg, vector particleEnd, float width) client_send_particle_rail;
9 changes: 4 additions & 5 deletions main/map/map_damage_zone.qc
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ void() map_damage_zone_crs_think={

t_damage_shield(unit, self, world, self.damageValue, unit.origin, TRUE);

org = self.view_ofs + randompos(self.maxs, self.mins);
hit = unit.origin + randompos(unit.maxs, unit.mins);

trailparticles( unit, particleeffectnum("TE_CRYS_RAIL"), org, hit );
pointparticles(particleeffectnum("TE_CRYS_MUZZLE"), org, normalize(hit - org) * 10, 2);
org = self.view_ofs + (randompos(self.maxs, self.mins) * 0.5);
hit = unit.origin + (randompos(unit.maxs, unit.mins) * 0.85);
traceline(org, hit, MOVE_NORMAL, self);
client_send_particle_rail( 1, org, trace_endpos, 4 );

if( (unit.flags & FL_CLIENT) ){
self.SendFlags = self.SendFlags | SENDFLAG_CRIT;
Expand Down
4 changes: 2 additions & 2 deletions main/map/map_particles_debug.qc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ void() map_particle_debug_th={
vdir = self.origin + (v_up * self.dest1_y) + (v_forward * self.dest1_z)+ (v_right * self.dest1_x);
pvel = normalize( vdir - self.origin) * self.count4;
if( self.count3 ){
client_send_particle_rail( num_for_edict(self), particleeffectnum(self.vec_name), self.origin + (v_up * self.compOffset_y) + (v_forward * self.compOffset_z) + (v_right * self.compOffset_x), pvel);
//client_send_particle_rail( num_for_edict(self), particleeffectnum(self.vec_name), self.origin + (v_up * self.compOffset_y) + (v_forward * self.compOffset_z) + (v_right * self.compOffset_x), pvel);
}
else{
client_send_particle( particleeffectnum(self.vec_name), self.origin, pvel, self.count);
//client_send_particle( particleeffectnum(self.vec_name), self.origin, pvel, self.count);
}

self.think = map_particle_debug_th;
Expand Down

0 comments on commit 0b63a43

Please sign in to comment.