35 VectorCopy(distance, _distance);
61 if (who->client->silencer_shots) {
62 who->client->silencer_shots--;
76 noise->classname =
"player_noise";
77 VectorSet(noise->mins, -8, -8, -8);
78 VectorSet(noise->maxs, 8, 8, 8);
80 noise->svflags = SVF_NOCLIENT;
84 noise->classname =
"player_noise";
85 VectorSet(noise->mins, -8, -8, -8);
86 VectorSet(noise->maxs, 8, 8, 8);
88 noise->svflags = SVF_NOCLIENT;
89 who->mynoise2 = noise;
97 noise = who->mynoise2;
102 VectorCopy(where, noise->s.origin);
103 VectorSubtract(where, noise->maxs, noise->absmin);
104 VectorAdd(where, noise->maxs, noise->absmax);
106 gi.linkentity(noise);
117 if ((((
int)(
dmflags->value) & DF_WEAPONS_STAY) ||
coop->value)
118 &&
other->client->pers.inventory[index]) {
123 other->client->pers.inventory[index]++;
128 if ((
int)
dmflags->value & DF_INFINITE_AMMO)
135 if ((
int)(
dmflags->value) & DF_WEAPONS_STAY)
145 if (
other->client->pers.weapon != ent->item &&
146 (
other->client->pers.inventory[index] == 1) &&
148 other->client->newweapon = ent->item;
166 if (ent->client->grenade_time) {
168 ent->client->weapon_sound = 0;
170 ent->client->grenade_time = 0;
173 ent->client->pers.lastweapon = ent->client->pers.weapon;
174 ent->client->pers.weapon = ent->client->newweapon;
175 ent->client->newweapon = NULL;
176 ent->client->machinegun_shots = 0;
179 if (ent->s.modelindex == 255) {
180 if (ent->client->pers.weapon)
181 i = ((ent->client->pers.weapon->weapmodel & 0xff) << 8);
184 ent->s.skinnum = (ent -
g_edicts - 1) | i;
187 if (ent->client->pers.weapon && ent->client->pers.weapon->ammo)
190 ent->client->ammo_index = 0;
192 if (!ent->client->pers.weapon) {
194 ent->client->ps.gunindex = 0;
199 ent->client->ps.gunframe = 0;
200 ent->client->ps.gunindex =
gi.modelindex(ent->client->pers.weapon->view_model);
203 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
222 ent->client->newweapon =
FindItem(
"railgun");
227 ent->client->newweapon =
FindItem(
"hyperblaster");
232 ent->client->newweapon =
FindItem(
"chaingun");
237 ent->client->newweapon =
FindItem(
"machinegun");
242 ent->client->newweapon =
FindItem(
"super shotgun");
247 ent->client->newweapon =
FindItem(
"shotgun");
250 ent->client->newweapon =
FindItem(
"blaster");
263 if (ent->health < 1) {
264 ent->client->newweapon = NULL;
269 if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink) {
271 if (ent->client->silencer_shots)
275 ent->client->pers.weapon->weaponthink(ent);
293 if (item == ent->client->pers.weapon)
300 if (!ent->client->pers.inventory[ammo_index]) {
305 if (ent->client->pers.inventory[ammo_index] < item->
quantity) {
312 ent->client->newweapon = item;
326 if ((
int)(
dmflags->value) & DF_WEAPONS_STAY)
331 if (((item == ent->client->pers.weapon) || (item == ent->client->newweapon)) && (ent->client->pers.inventory[index] == 1)) {
332 gi.cprintf(ent, PRINT_HIGH,
"Can't drop current weapon\n");
337 ent->client->pers.inventory[index]--;
348 #define FRAME_FIRE_FIRST (FRAME_ACTIVATE_LAST + 1)
349 #define FRAME_IDLE_FIRST (FRAME_FIRE_LAST + 1)
350 #define FRAME_DEACTIVATE_FIRST (FRAME_IDLE_LAST + 1)
352 void Weapon_Generic(edict_t *ent,
int FRAME_ACTIVATE_LAST,
int FRAME_FIRE_LAST,
int FRAME_IDLE_LAST,
int FRAME_DEACTIVATE_LAST,
int *pause_frames,
int *fire_frames,
void (*fire)(edict_t *ent))
356 if (ent->deadflag || ent->s.modelindex != 255) {
361 if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST) {
364 }
else if ((FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe) == 4) {
366 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
376 ent->client->ps.gunframe++;
381 if (ent->client->ps.gunframe == FRAME_ACTIVATE_LAST) {
387 ent->client->ps.gunframe++;
391 if ((ent->client->newweapon) && (ent->client->weaponstate !=
WEAPON_FIRING)) {
397 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
410 if (((ent->client->latched_buttons | ent->client->buttons) & BUTTON_ATTACK)) {
411 ent->client->latched_buttons &= ~BUTTON_ATTACK;
412 if ((!ent->client->ammo_index) ||
413 (ent->client->pers.inventory[ent->client->ammo_index] >= ent->client->pers.weapon->quantity)) {
419 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
427 if (
level.
time >= ent->pain_debounce_time) {
428 gi.sound(ent, CHAN_VOICE,
gi.soundindex(
"weapons/noammo.wav"), 1, ATTN_NORM, 0);
429 ent->pain_debounce_time =
level.
time + 1;
434 if (ent->client->ps.gunframe == FRAME_IDLE_LAST) {
440 for (n = 0; pause_frames[n]; n++) {
441 if (ent->client->ps.gunframe == pause_frames[n]) {
448 ent->client->ps.gunframe++;
454 for (n = 0; fire_frames[n]; n++) {
455 if (ent->client->ps.gunframe == fire_frames[n]) {
457 gi.sound(ent, CHAN_ITEM,
gi.soundindex(
"items/damage3.wav"), 1, ATTN_NORM, 0);
465 ent->client->ps.gunframe++;
481 #define GRENADE_TIMER 3.0
482 #define GRENADE_MINSPEED 400
483 #define GRENADE_MAXSPEED 800
495 radius = damage + 40;
499 VectorSet(offset, 8, 8, ent->viewheight - 8);
503 timer = ent->client->grenade_time -
level.
time;
507 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
508 ent->client->pers.inventory[ent->client->ammo_index]--;
510 ent->client->grenade_time =
level.
time + 1.0;
512 if (ent->deadflag || ent->s.modelindex != 255) {
516 if (ent->health <= 0)
519 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
532 if ((ent->client->newweapon) && (ent->client->weaponstate ==
WEAPON_READY)) {
539 ent->client->ps.gunframe = 16;
544 if (((ent->client->latched_buttons | ent->client->buttons) & BUTTON_ATTACK)) {
545 ent->client->latched_buttons &= ~BUTTON_ATTACK;
546 if (ent->client->pers.inventory[ent->client->ammo_index]) {
547 ent->client->ps.gunframe = 1;
549 ent->client->grenade_time = 0;
551 if (
level.
time >= ent->pain_debounce_time) {
552 gi.sound(ent, CHAN_VOICE,
gi.soundindex(
"weapons/noammo.wav"), 1, ATTN_NORM, 0);
553 ent->pain_debounce_time =
level.
time + 1;
560 if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48)) {
565 if (++ent->client->ps.gunframe > 48)
566 ent->client->ps.gunframe = 16;
571 if (ent->client->ps.gunframe == 5)
572 gi.sound(ent, CHAN_WEAPON,
gi.soundindex(
"weapons/hgrena1b.wav"), 1, ATTN_NORM, 0);
574 if (ent->client->ps.gunframe == 11) {
575 if (!ent->client->grenade_time) {
577 ent->client->weapon_sound =
gi.soundindex(
"weapons/hgrenc1b.wav");
581 if (!ent->client->grenade_blew_up &&
level.
time >= ent->client->grenade_time) {
582 ent->client->weapon_sound = 0;
584 ent->client->grenade_blew_up = qtrue;
587 if (ent->client->buttons & BUTTON_ATTACK)
590 if (ent->client->grenade_blew_up) {
591 if (
level.
time >= ent->client->grenade_time) {
592 ent->client->ps.gunframe = 15;
593 ent->client->grenade_blew_up = qfalse;
600 if (ent->client->ps.gunframe == 12) {
601 ent->client->weapon_sound = 0;
605 if ((ent->client->ps.gunframe == 15) && (
level.
time < ent->client->grenade_time))
608 ent->client->ps.gunframe++;
610 if (ent->client->ps.gunframe == 16) {
611 ent->client->grenade_time = 0;
633 radius = damage + 40;
637 VectorSet(offset, 8, 8, ent->viewheight - 8);
641 VectorScale(
forward, -2, ent->client->kick_origin);
642 ent->client->kick_angles[0] = -1;
649 gi.multicast(ent->s.origin, MULTICAST_PVS);
651 ent->client->ps.gunframe++;
655 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
656 ent->client->pers.inventory[ent->client->ammo_index]--;
661 static int pause_frames[] = {34, 51, 59, 0};
662 static int fire_frames[] = {6, 0};
677 vec3_t offset, start;
693 VectorScale(
forward, -2, ent->client->kick_origin);
694 ent->client->kick_angles[0] = -1;
696 VectorSet(offset, 8, 8, ent->viewheight - 8);
704 gi.multicast(ent->s.origin, MULTICAST_PVS);
706 ent->client->ps.gunframe++;
710 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
711 ent->client->pers.inventory[ent->client->ammo_index]--;
716 static int pause_frames[] = {25, 33, 42, 50, 0};
717 static int fire_frames[] = {5, 0};
731 void Blaster_Fire(edict_t *ent, vec3_t g_offset,
int damage, qboolean hyper,
int effect)
740 VectorSet(offset, 24, 8, ent->viewheight - 8);
741 VectorAdd(offset, g_offset, offset);
744 VectorScale(
forward, -2, ent->client->kick_origin);
745 ent->client->kick_angles[0] = -1;
756 gi.multicast(ent->s.origin, MULTICAST_PVS);
771 ent->client->ps.gunframe++;
776 static int pause_frames[] = {19, 32, 0};
777 static int fire_frames[] = {5, 0};
790 ent->client->weapon_sound =
gi.soundindex(
"weapons/hyprbl1a.wav");
792 if (!(ent->client->buttons & BUTTON_ATTACK)) {
793 ent->client->ps.gunframe++;
795 if (! ent->client->pers.inventory[ent->client->ammo_index]) {
796 if (
level.
time >= ent->pain_debounce_time) {
797 gi.sound(ent, CHAN_VOICE,
gi.soundindex(
"weapons/noammo.wav"), 1, ATTN_NORM, 0);
798 ent->pain_debounce_time =
level.
time + 1;
802 rotation = (ent->client->ps.gunframe - 5) * 2 * M_PI / 6;
803 offset[0] = -4 * sin(rotation);
805 offset[2] = 4 * cos(rotation);
807 if ((ent->client->ps.gunframe == 6) || (ent->client->ps.gunframe == 9))
808 effect = EF_HYPERBLASTER;
816 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
817 ent->client->pers.inventory[ent->client->ammo_index]--;
820 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
829 ent->client->ps.gunframe++;
830 if (ent->client->ps.gunframe == 12 && ent->client->pers.inventory[ent->client->ammo_index])
831 ent->client->ps.gunframe = 6;
834 if (ent->client->ps.gunframe == 12) {
835 gi.sound(ent, CHAN_AUTO,
gi.soundindex(
"weapons/hyprbd1a.wav"), 1, ATTN_NORM, 0);
836 ent->client->weapon_sound = 0;
843 static int pause_frames[] = {0};
844 static int fire_frames[] = {6, 7, 8, 9, 10, 11, 0};
867 if (!(ent->client->buttons & BUTTON_ATTACK)) {
868 ent->client->machinegun_shots = 0;
869 ent->client->ps.gunframe++;
873 if (ent->client->ps.gunframe == 5)
874 ent->client->ps.gunframe = 4;
876 ent->client->ps.gunframe = 5;
878 if (ent->client->pers.inventory[ent->client->ammo_index] < 1) {
879 ent->client->ps.gunframe = 6;
880 if (
level.
time >= ent->pain_debounce_time) {
881 gi.sound(ent, CHAN_VOICE,
gi.soundindex(
"weapons/noammo.wav"), 1, ATTN_NORM, 0);
882 ent->pain_debounce_time =
level.
time + 1;
893 for (i = 1 ; i < 3 ; i++) {
894 ent->client->kick_origin[i] =
crandom() * 0.35;
895 ent->client->kick_angles[i] =
crandom() * 0.7;
897 ent->client->kick_origin[0] =
crandom() * 0.35;
898 ent->client->kick_angles[0] = ent->client->machinegun_shots * -1.5;
902 ent->client->machinegun_shots++;
903 if (ent->client->machinegun_shots > 9)
904 ent->client->machinegun_shots = 9;
908 VectorAdd(ent->client->v_angle, ent->client->kick_angles, angles);
910 VectorSet(offset, 0, 8, ent->viewheight - 8);
917 gi.multicast(ent->s.origin, MULTICAST_PVS);
921 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
922 ent->client->pers.inventory[ent->client->ammo_index]--;
925 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
936 static int pause_frames[] = {23, 45, 0};
937 static int fire_frames[] = {4, 5, 0};
958 if (ent->client->ps.gunframe == 5)
959 gi.sound(ent, CHAN_AUTO,
gi.soundindex(
"weapons/chngnu1a.wav"), 1, ATTN_IDLE, 0);
961 if ((ent->client->ps.gunframe == 14) && !(ent->client->buttons & BUTTON_ATTACK)) {
962 ent->client->ps.gunframe = 32;
963 ent->client->weapon_sound = 0;
965 }
else if ((ent->client->ps.gunframe == 21) && (ent->client->buttons & BUTTON_ATTACK)
966 && ent->client->pers.inventory[ent->client->ammo_index]) {
967 ent->client->ps.gunframe = 15;
969 ent->client->ps.gunframe++;
972 if (ent->client->ps.gunframe == 22) {
973 ent->client->weapon_sound = 0;
974 gi.sound(ent, CHAN_AUTO,
gi.soundindex(
"weapons/chngnd1a.wav"), 1, ATTN_IDLE, 0);
976 ent->client->weapon_sound =
gi.soundindex(
"weapons/chngnl1a.wav");
980 if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) {
984 ent->s.frame =
FRAME_attack1 - (ent->client->ps.gunframe & 1);
988 if (ent->client->ps.gunframe <= 9)
990 else if (ent->client->ps.gunframe <= 14) {
991 if (ent->client->buttons & BUTTON_ATTACK)
998 if (ent->client->pers.inventory[ent->client->ammo_index] < shots)
999 shots = ent->client->pers.inventory[ent->client->ammo_index];
1002 if (
level.
time >= ent->pain_debounce_time) {
1003 gi.sound(ent, CHAN_VOICE,
gi.soundindex(
"weapons/noammo.wav"), 1, ATTN_NORM, 0);
1004 ent->pain_debounce_time =
level.
time + 1;
1015 for (i = 0 ; i < 3 ; i++) {
1016 ent->client->kick_origin[i] =
crandom() * 0.35;
1017 ent->client->kick_angles[i] =
crandom() * 0.7;
1020 for (i = 0 ; i < shots ; i++) {
1025 VectorSet(offset, 0, r, u + ent->viewheight - 8);
1035 gi.multicast(ent->s.origin, MULTICAST_PVS);
1039 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
1040 ent->client->pers.inventory[ent->client->ammo_index] -= shots;
1046 static int pause_frames[] = {38, 43, 51, 61, 0};
1047 static int fire_frames[] = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0};
1069 if (ent->client->ps.gunframe == 9) {
1070 ent->client->ps.gunframe++;
1076 VectorScale(
forward, -2, ent->client->kick_origin);
1077 ent->client->kick_angles[0] = -2;
1079 VectorSet(offset, 0, 8, ent->viewheight - 8);
1096 gi.multicast(ent->s.origin, MULTICAST_PVS);
1098 ent->client->ps.gunframe++;
1101 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
1102 ent->client->pers.inventory[ent->client->ammo_index]--;
1107 static int pause_frames[] = {22, 28, 34, 0};
1108 static int fire_frames[] = {8, 9, 0};
1125 VectorScale(
forward, -2, ent->client->kick_origin);
1126 ent->client->kick_angles[0] = -2;
1128 VectorSet(offset, 0, 8, ent->viewheight - 8);
1136 v[PITCH] = ent->client->v_angle[PITCH];
1137 v[YAW] = ent->client->v_angle[YAW] - 5;
1138 v[ROLL] = ent->client->v_angle[ROLL];
1141 v[YAW] = ent->client->v_angle[YAW] + 5;
1149 gi.multicast(ent->s.origin, MULTICAST_PVS);
1151 ent->client->ps.gunframe++;
1154 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
1155 ent->client->pers.inventory[ent->client->ammo_index] -= 2;
1160 static int pause_frames[] = {29, 42, 57, 0};
1161 static int fire_frames[] = {7, 0};
1200 VectorScale(
forward, -3, ent->client->kick_origin);
1201 ent->client->kick_angles[0] = -3;
1203 VectorSet(offset, 0, 7, ent->viewheight - 8);
1211 gi.multicast(ent->s.origin, MULTICAST_PVS);
1213 ent->client->ps.gunframe++;
1216 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
1217 ent->client->pers.inventory[ent->client->ammo_index]--;
1223 static int pause_frames[] = {56, 0};
1224 static int fire_frames[] = {4, 0};
1240 vec3_t offset, start;
1243 float damage_radius = 1000;
1250 if (ent->client->ps.gunframe == 9) {
1255 gi.multicast(ent->s.origin, MULTICAST_PVS);
1257 ent->client->ps.gunframe++;
1265 if (ent->client->pers.inventory[ent->client->ammo_index] < 50) {
1266 ent->client->ps.gunframe++;
1275 VectorScale(
forward, -2, ent->client->kick_origin);
1278 ent->client->v_dmg_pitch = -40;
1279 ent->client->v_dmg_roll =
crandom() * 8;
1282 VectorSet(offset, 8, 8, ent->viewheight - 8);
1286 ent->client->ps.gunframe++;
1290 if (!((
int)
dmflags->value & DF_INFINITE_AMMO))
1291 ent->client->pers.inventory[ent->client->ammo_index] -= 50;
1296 static int pause_frames[] = {39, 45, 50, 55, 0};
1297 static int fire_frames[] = {9, 17, 0};
1309 void fire_flaregun(edict_t *
self, vec3_t start, vec3_t aimdir,
int damage,
1310 int speed,
float timer,
float damage_radius);
1327 VectorSet(offset, 8, 8, ent->viewheight - 8);
1331 VectorScale(
forward, -2, ent->client->kick_origin);
1332 ent->client->kick_angles[0] = -1;
1341 gi.multicast(ent->s.origin, MULTICAST_PVS);
1345 ent->client->ps.gunframe++;
1351 ent->client->pers.inventory[ent->client->ammo_index]--;
1366 static int pause_frames[] = { 39, 45, 50, 53, 0 };
1367 static int fire_frames[] = { 9, 17, 0 };