22 #include "refresh/models.h"
86 for (i = 0; i < 4; i++) {
87 Q_snprintf(name,
sizeof(name),
"player/step%i.wav", i + 1);
124 model->sprite_vertical = qtrue;
150 if (e->
type == ex_free) {
151 memset(e, 0,
sizeof(*e));
160 if (e->
start < time) {
165 memset(oldest, 0,
sizeof(*oldest));
176 ex->
ent.flags = RF_FULLBRIGHT;
180 ex->
ent.angles[1] = rand() % 360;
188 ex->
frames = sprite_model->numframes;
215 ex->
ent.flags = RF_TRANSLUCENT | RF_NOSHADOW;
222 ex->
ent.flags = RF_FULLBRIGHT;
228 #define LENGTH(a) ((sizeof (a)) / (sizeof(*(a))))
237 { { 0.4f, 0.2f, 0.02f }, 12.5f, 20.00f },
238 { { 0.351563f, 0.175781f, 0.017578f }, 15.0f, 23.27f },
239 { { 0.30625f, 0.153125f, 0.015312f }, 20.0f, 24.95f },
240 { { 0.264062f, 0.132031f, 0.013203f }, 22.5f, 25.01f },
241 { { 0.225f, 0.1125f, 0.01125f }, 25.0f, 27.53f },
242 { { 0.189063f, 0.094531f, 0.009453f }, 27.5f, 28.55f },
243 { { 0.15625f, 0.078125f, 0.007813f }, 30.0f, 30.80f },
244 { { 0.126563f, 0.063281f, 0.006328f }, 27.5f, 40.43f },
245 { { 0.1f, 0.05f, 0.005f }, 25.0f, 49.02f },
246 { { 0.076563f, 0.038281f, 0.003828f }, 22.5f, 58.15f },
247 { { 0.05625f, 0.028125f, 0.002812f }, 20.0f, 61.03f },
248 { { 0.039063f, 0.019531f, 0.001953f }, 17.5f, 63.59f },
249 { { 0.025f, 0.0125f, 0.00125f }, 15.0f, 66.47f },
250 { { 0.014063f, 0.007031f, 0.000703f }, 12.5f, 71.34f },
251 { { 0.f, 0.f, 0.f }, 10.0f, 72.00f }
255 { { 0.04f, 0.02f, 0.0f }, 5.f, 15.00f },
256 { { 0.2f, 0.15f, 0.01f }, 15.f, 15.00f },
257 { { 0.04f, 0.02f, 0.0f }, 5.f, 15.00f },
279 float timeAlpha = ((float)(curve_size - 1)) * phase;
280 int baseSample = (
int)floorf(timeAlpha);
281 baseSample = max(0, min(curve_size - 2, baseSample));
283 float w1 = timeAlpha - (float)(baseSample);
313 memset(&ent, 0,
sizeof(ent));
316 if (ex->
type == ex_free)
333 if (f >= ex->
frames - 1) {
337 ent->alpha = 1.0 - frac / (ex->
frames - 1);
347 if (f >= ex->
frames - 1) {
352 ent->alpha = ((float)ex->
frames - (
float)f) / (
float)ex->
frames;
353 ent->alpha = max(0.f, min(1.f, ent->alpha));
354 ent->alpha = ent->alpha * ent->alpha * (3.f - 2.f * ent->alpha);
357 ent->skinnum = (f >> 1);
358 if (ent->skinnum < 0)
361 ent->flags |= RF_TRANSLUCENT;
369 if (f >= ex->
frames - 1) {
374 ent->alpha = (5.0 - (float)f) / 5.0;
376 ent->flags |= RF_TRANSLUCENT;
382 if (ex->
type == ex_free)
394 if (ex->
type != ex_light) {
395 VectorCopy(ent->origin, ent->oldorigin);
401 ent->backlerp = 1.0 - (frac - f);
416 #define MAX_LASERS 32
441 memset(l, 0,
sizeof(*l));
457 memset(&ent, 0,
sizeof(ent));
465 if (l->
color == -1) {
466 float f = (float)time / (
float)l->
lifetime;
468 ent.rgba.u8[0] = l->
rgba.u8[0];
469 ent.rgba.u8[1] = l->
rgba.u8[1];
470 ent.rgba.u8[2] = l->
rgba.u8[2];
471 ent.rgba.u8[3] = l->
rgba.u8[3] * f;
477 ent.skinnum = l->
color;
478 ent.flags = RF_TRANSLUCENT | RF_BEAM;
479 VectorCopy(l->
start, ent.origin);
480 VectorCopy(l->
end, ent.oldorigin);
481 ent.frame = l->
width;
498 l->
color = (colors >> ((rand() % 4) * 8)) & 0xff;
617 VectorSubtract(b->
end, org, dist);
618 vectoangles2(dist, angles);
628 steps = ceil(d / model_length);
629 len = (d - model_length) / (steps - 1);
631 memset(&ent, 0,
sizeof(ent));
632 ent.model = b->
model;
638 VectorCopy(b->
end, ent.origin);
639 ent.flags = RF_FULLBRIGHT;
640 ent.angles[0] = angles[0];
641 ent.angles[1] = angles[1];
642 ent.angles[2] = rand() % 360;
648 VectorCopy(org, ent.origin);
650 ent.flags = RF_FULLBRIGHT;
651 ent.angles[0] = -angles[0];
652 ent.angles[1] = angles[1] + 180.0;
653 ent.angles[2] = rand() % 360;
655 ent.angles[0] = angles[0];
656 ent.angles[1] = angles[1];
657 ent.angles[2] = rand() % 360;
662 for (j = 0; j < 3; j++)
663 org[j] += dist[j] * len;
687 float hand_multiplier;
688 player_state_t *ps, *ops;
693 hand_multiplier = -1;
708 for (j = 0; j < 3; j++)
716 VectorMA(org, -1,
cl.
v_up, org);
719 VectorSubtract(b->
end, org, dist);
722 d = VectorLength(dist);
728 VectorMA(org, -1,
cl.
v_up, org);
731 vectoangles2(dist, angles);
738 VectorCopy(b->
start, org);
741 VectorSubtract(b->
end, org, dist);
742 vectoangles2(dist, angles);
749 tmp[1] = angles[1] + 180.0;
753 VectorMA(org, -b->
offset[0] + 1, r, org);
754 VectorMA(org, -b->
offset[1], f, org);
755 VectorMA(org, -b->
offset[2] - 10, u, org);
767 steps = ceil(d / model_length);
768 len = (d - model_length) / (steps - 1);
770 memset(&ent, 0,
sizeof(ent));
771 ent.model = b->
model;
772 ent.frame = framenum;
773 ent.flags = RF_FULLBRIGHT;
774 ent.angles[0] = -angles[0];
775 ent.angles[1] = angles[1] + 180.0;
776 ent.angles[2] =
cl.
time % 360;
779 VectorCopy(org, ent.origin);
783 for (j = 0; j < 3; j++)
784 org[j] += dist[j] * len;
799 #define MAX_SUSTAINS 32
908 Com_WPrintf(
"Invalid value '%s' for '%s'\n", self->string, self->name);
917 Com_WPrintf(
"Invalid value '%s' for '%s'\n", self->string, self->name);
951 VectorCopy(
te.
pos1, move);
955 MakeNormalVectors(vec,
right,
up);
957 for (i = 0; i < len; i++) {
963 VectorClear(p->
accel);
969 VectorScale(
right,
c, dir);
970 VectorMA(dir, s,
up, dir);
977 for (j = 0; j < 3; j++) {
979 p->
vel[j] = dir[j] * 6;
982 VectorAdd(move, vec, move);
989 fcolor[0] = (float)
color.u8[0] / 255.f;
990 fcolor[1] = (
float)
color.u8[1] / 255.f;
991 fcolor[2] = (float)
color.u8[2] / 255.f;
997 VectorCopy(
te.
pos1, move);
1001 float num_segments = ceilf(len / 100.f);
1002 float segment_size = len / num_segments;
1004 for (
float segment = 0; segment < num_segments; segment++)
1006 float offset = (segment + 0.25f) * segment_size;
1008 VectorMA(move, offset, vec, pos);
1010 cdlight_t* dl = CL_AllocDlight(0);
1011 VectorScale(fcolor, 0.25f, dl->color);
1012 VectorCopy(pos, dl->origin);
1015 dl->die =
cl.
time + 1000;
1016 VectorScale(vec, segment_size * 0.5f, dl->velosity);
1051 angles[0] = acos(
te.
dir[2]) / M_PI * 180;
1053 angles[1] = atan2(
te.
dir[1],
te.
dir[0]) / M_PI * 180;
1054 else if (
te.
dir[1] > 0)
1056 else if (
te.
dir[1] < 0)
1067 static const byte splash_color[] = {0x00, 0xe0, 0xb0, 0x50, 0xd0, 0xe0, 0xe8};
1085 case TE_BULLET_SPARKS:
1086 if (
te.
type == TE_GUNSHOT)
1091 if (
te.
type != TE_SPARKS) {
1105 case TE_SCREEN_SPARKS:
1106 case TE_SHIELD_SPARKS:
1107 if (
te.
type == TE_SCREEN_SPARKS)
1127 if (
te.
color == SPLASH_SPARKS) {
1138 case TE_LASER_SPARKS:
1142 case TE_BLUEHYPERBLASTER:
1153 ex->
type = ex_blaster;
1154 ex->
ent.flags = RF_FULLBRIGHT | RF_TRANSLUCENT;
1164 ex->
ent.skinnum = 1;
1169 ex->
ent.skinnum = 2;
1178 ex->
type = ex_flare;
1203 case TE_GRENADE_EXPLOSION:
1204 case TE_GRENADE_EXPLOSION_WATER:
1212 ex->
type = ex_light;
1217 if (
te.
type == TE_GRENADE_EXPLOSION_WATER)
1234 case TE_PLASMA_EXPLOSION:
1240 case TE_ROCKET_EXPLOSION:
1241 case TE_ROCKET_EXPLOSION_WATER:
1244 ex->
type = ex_light;
1249 if (
te.
type == TE_ROCKET_EXPLOSION_WATER)
1261 case TE_EXPLOSION1_NP:
1266 case TE_EXPLOSION1_BIG:
1271 case TE_BFG_EXPLOSION:
1275 ex->
ent.flags = RF_FULLBRIGHT;
1282 ex->
ent.flags |= RF_TRANSLUCENT;
1283 ex->
ent.alpha = 0.80;
1287 case TE_BFG_BIGEXPLOSION:
1295 case TE_BUBBLETRAIL:
1299 case TE_PARASITE_ATTACK:
1300 case TE_MEDIC_CABLE_ATTACK:
1311 case TE_GRAPPLE_CABLE:
1316 case TE_WELDING_SPARKS:
1321 ex->
type = ex_flash;
1324 ex->
ent.flags = RF_BEAM;
1326 ex->
light = 100 + (rand() % 75);
1338 case TE_TUNNEL_SPARKS:
1352 case TE_PLAIN_EXPLOSION:
1371 case TE_MONSTER_HEATBEAM:
1376 case TE_HEATBEAM_SPARKS:
1381 case TE_HEATBEAM_STEAM:
1390 case TE_BUBBLETRAIL2:
1399 case TE_CHAINFIST_SMOKE:
1400 VectorSet(
te.
dir, 0, 0, 1);
1404 case TE_ELECTRIC_SPARKS:
1410 case TE_TRACKER_EXPLOSION:
1412 CL_ColorFlash(
te.
pos1, 0, 150, -1, -1, -1);
1418 case TE_TELEPORT_EFFECT:
1423 case TE_WIDOWBEAMOUT:
1431 case TE_WIDOWSPLASH:
1436 Com_Error(ERR_DROP,
"%s: bad type", __func__);