📄 cg_marks.c
字号:
active_particles = p;
p->time = cg.time;
p->alpha = 1.0;
p->alphavel = 0;
p->roll = 0;
p->pshader = pshader;
p->endtime = cg.time + duration;
if (fleshEntityNum)
p->startfade = cg.time;
else
p->startfade = cg.time + 100;
p->width = 4;
p->height = 4;
p->endheight = 4+rand()%3;
p->endwidth = p->endheight;
p->type = P_SMOKE;
VectorCopy( start, p->org );
p->vel[0] = 0;
p->vel[1] = 0;
p->vel[2] = -20;
VectorClear( p->accel );
p->rotate = qfalse;
p->roll = rand()%179;
p->color = BLOODRED;
p->alpha = 0.75;
}
void CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent)
{
cparticle_t *p;
int time;
int time2;
float ratio;
float duration = 1500;
time = cg.time;
time2 = cg.time + cent->currentState.time;
ratio =(float)1 - ((float)time / (float)time2);
if (!pshader)
CG_Printf ("CG_Particle_OilParticle == ZERO!\n");
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
p->alpha = 1.0;
p->alphavel = 0;
p->roll = 0;
p->pshader = pshader;
p->endtime = cg.time + duration;
p->startfade = p->endtime;
p->width = 1;
p->height = 3;
p->endheight = 3;
p->endwidth = 1;
p->type = P_SMOKE;
VectorCopy(cent->currentState.origin, p->org );
p->vel[0] = (cent->currentState.origin2[0] * (16 * ratio));
p->vel[1] = (cent->currentState.origin2[1] * (16 * ratio));
p->vel[2] = (cent->currentState.origin2[2]);
p->snum = 1.0f;
VectorClear( p->accel );
p->accel[2] = -20;
p->rotate = qfalse;
p->roll = rand()%179;
p->alpha = 0.75;
}
void CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent)
{
cparticle_t *p;
if (!pshader)
CG_Printf ("CG_Particle_OilSlick == ZERO!\n");
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
if (cent->currentState.angles2[2])
p->endtime = cg.time + cent->currentState.angles2[2];
else
p->endtime = cg.time + 60000;
p->startfade = p->endtime;
p->alpha = 1.0;
p->alphavel = 0;
p->roll = 0;
p->pshader = pshader;
if (cent->currentState.angles2[0] || cent->currentState.angles2[1])
{
p->width = cent->currentState.angles2[0];
p->height = cent->currentState.angles2[0];
p->endheight = cent->currentState.angles2[1];
p->endwidth = cent->currentState.angles2[1];
}
else
{
p->width = 8;
p->height = 8;
p->endheight = 16;
p->endwidth = 16;
}
p->type = P_FLAT_SCALEUP;
p->snum = 1.0;
VectorCopy(cent->currentState.origin, p->org );
p->org[2]+= 0.55 + (crandom() * 0.5);
p->vel[0] = 0;
p->vel[1] = 0;
p->vel[2] = 0;
VectorClear( p->accel );
p->rotate = qfalse;
p->roll = rand()%179;
p->alpha = 0.75;
}
void CG_OilSlickRemove (centity_t *cent)
{
cparticle_t *p, *next;
int id;
id = 1.0f;
if (!id)
CG_Printf ("CG_OilSlickRevove NULL id\n");
for (p=active_particles ; p ; p=next)
{
next = p->next;
if (p->type == P_FLAT_SCALEUP)
{
if (p->snum == id)
{
p->endtime = cg.time + 100;
p->startfade = p->endtime;
p->type = P_FLAT_SCALEUP_FADE;
}
}
}
}
qboolean ValidBloodPool (vec3_t start)
{
#define EXTRUDE_DIST 0.5
vec3_t angles;
vec3_t right, up;
vec3_t this_pos, x_pos, center_pos, end_pos;
float x, y;
float fwidth, fheight;
trace_t trace;
vec3_t normal;
fwidth = 16;
fheight = 16;
VectorSet (normal, 0, 0, 1);
vectoangles (normal, angles);
AngleVectors (angles, NULL, right, up);
VectorMA (start, EXTRUDE_DIST, normal, center_pos);
for (x= -fwidth/2; x<fwidth; x+= fwidth)
{
VectorMA (center_pos, x, right, x_pos);
for (y= -fheight/2; y<fheight; y+= fheight)
{
VectorMA (x_pos, y, up, this_pos);
VectorMA (this_pos, -EXTRUDE_DIST*2, normal, end_pos);
CG_Trace (&trace, this_pos, NULL, NULL, end_pos, -1, CONTENTS_SOLID);
if (trace.entityNum < (MAX_ENTITIES - 1)) // may only land on world
return qfalse;
if (!(!trace.startsolid && trace.fraction < 1))
return qfalse;
}
}
return qtrue;
}
void CG_BloodPool (localEntity_t *le, qhandle_t pshader, trace_t *tr)
{
cparticle_t *p;
qboolean legit;
vec3_t start;
float rndSize;
if (!pshader)
CG_Printf ("CG_BloodPool pshader == ZERO!\n");
if (!free_particles)
return;
VectorCopy (tr->endpos, start);
legit = ValidBloodPool (start);
if (!legit)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
p->endtime = cg.time + 3000;
p->startfade = p->endtime;
p->alpha = 1.0;
p->alphavel = 0;
p->roll = 0;
p->pshader = pshader;
rndSize = 0.4 + random()*0.6;
p->width = 8*rndSize;
p->height = 8*rndSize;
p->endheight = 16*rndSize;
p->endwidth = 16*rndSize;
p->type = P_FLAT_SCALEUP;
VectorCopy(start, p->org );
p->vel[0] = 0;
p->vel[1] = 0;
p->vel[2] = 0;
VectorClear( p->accel );
p->rotate = qfalse;
p->roll = rand()%179;
p->alpha = 0.75;
p->color = BLOODRED;
}
#define NORMALSIZE 16
#define LARGESIZE 32
void CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir)
{
float length;
float dist;
float crittersize;
vec3_t angles, forward;
vec3_t point;
cparticle_t *p;
int i;
dist = 0;
length = VectorLength (dir);
vectoangles (dir, angles);
AngleVectors (angles, forward, NULL, NULL);
crittersize = LARGESIZE;
if (length)
dist = length / crittersize;
if (dist < 1)
dist = 1;
VectorCopy (origin, point);
for (i=0; i<dist; i++)
{
VectorMA (point, crittersize, forward, point);
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
p->alpha = 1.0;
p->alphavel = 0;
p->roll = 0;
p->pshader = cgs.media.smokePuffShader;
p->endtime = cg.time + 350 + (crandom() * 100);
p->startfade = cg.time;
p->width = LARGESIZE;
p->height = LARGESIZE;
p->endheight = LARGESIZE;
p->endwidth = LARGESIZE;
p->type = P_SMOKE;
VectorCopy( origin, p->org );
p->vel[0] = 0;
p->vel[1] = 0;
p->vel[2] = -1;
VectorClear( p->accel );
p->rotate = qfalse;
p->roll = rand()%179;
p->color = BLOODRED;
p->alpha = 0.75;
}
}
void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed)
{
cparticle_t *p;
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
p->endtime = cg.time + duration;
p->startfade = cg.time + duration/2;
p->color = EMISIVEFADE;
p->alpha = 0.4f;
p->alphavel = 0;
p->height = 0.5;
p->width = 0.5;
p->endheight = 0.5;
p->endwidth = 0.5;
p->pshader = cgs.media.tracerShader;
p->type = P_SMOKE;
VectorCopy(org, p->org);
p->org[0] += (crandom() * x);
p->org[1] += (crandom() * y);
p->vel[0] = vel[0];
p->vel[1] = vel[1];
p->vel[2] = vel[2];
p->accel[0] = p->accel[1] = p->accel[2] = 0;
p->vel[0] += (crandom() * 4);
p->vel[1] += (crandom() * 4);
p->vel[2] += (20 + (crandom() * 10)) * speed;
p->accel[0] = crandom () * 4;
p->accel[1] = crandom () * 4;
}
void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir)
{
float length;
float dist;
float crittersize;
vec3_t angles, forward;
vec3_t point;
cparticle_t *p;
int i;
dist = 0;
VectorNegate (dir, dir);
length = VectorLength (dir);
vectoangles (dir, angles);
AngleVectors (angles, forward, NULL, NULL);
crittersize = LARGESIZE;
if (length)
dist = length / crittersize;
if (dist < 1)
dist = 1;
VectorCopy (origin, point);
for (i=0; i<dist; i++)
{
VectorMA (point, crittersize, forward, point);
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
p->alpha = 5.0;
p->alphavel = 0;
p->roll = 0;
p->pshader = cgs.media.smokePuffShader;
// RF, stay around for long enough to expand and dissipate naturally
if (length)
p->endtime = cg.time + 4500 + (crandom() * 3500);
else
p->endtime = cg.time + 750 + (crandom() * 500);
p->startfade = cg.time;
p->width = LARGESIZE;
p->height = LARGESIZE;
// RF, expand while falling
p->endheight = LARGESIZE*3.0;
p->endwidth = LARGESIZE*3.0;
if (!length)
{
p->width *= 0.2f;
p->height *= 0.2f;
p->endheight = NORMALSIZE;
p->endwidth = NORMALSIZE;
}
p->type = P_SMOKE;
VectorCopy( point, p->org );
p->vel[0] = crandom()*6;
p->vel[1] = crandom()*6;
p->vel[2] = random()*20;
// RF, add some gravity/randomness
p->accel[0] = crandom()*3;
p->accel[1] = crandom()*3;
p->accel[2] = -PARTICLE_GRAVITY*0.4;
VectorClear( p->accel );
p->rotate = qfalse;
p->roll = rand()%179;
p->alpha = 0.75;
}
}
void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha)
{
cparticle_t *p;
if (!pshader)
CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n");
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->time = cg.time;
p->alpha = 1.0;
p->alphavel = 0;
p->roll = rand()%179;
p->pshader = pshader;
if (duration > 0)
p->endtime = cg.time + duration;
else
p->endtime = duration;
p->startfade = cg.time;
p->width = size;
p->height = size;
p->endheight = size;
p->endwidth = size;
p->type = P_SPRITE;
VectorCopy( origin, p->org );
p->rotate = qfalse;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -