diff options
Diffstat (limited to 'src/baseq2/p_weapon.c')
-rw-r--r-- | src/baseq2/p_weapon.c | 797 |
1 files changed, 334 insertions, 463 deletions
diff --git a/src/baseq2/p_weapon.c b/src/baseq2/p_weapon.c index ea75737..ab107b9 100644 --- a/src/baseq2/p_weapon.c +++ b/src/baseq2/p_weapon.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -27,19 +27,19 @@ static qboolean is_quad; static byte is_silenced; -void weapon_grenade_fire (edict_t *ent, qboolean held); +void weapon_grenade_fire(edict_t *ent, qboolean held); -static void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result) +static void P_ProjectSource(gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result) { vec3_t _distance; - VectorCopy (distance, _distance); + VectorCopy(distance, _distance); if (client->pers.hand == LEFT_HANDED) _distance[1] *= -1; else if (client->pers.hand == CENTER_HANDED) _distance[1] = 0; - G_ProjectSource (point, _distance, forward, right, result); + G_ProjectSource(point, _distance, forward, right, result); } @@ -59,10 +59,8 @@ void PlayerNoise(edict_t *who, vec3_t where, int type) { edict_t *noise; - if (type == PNOISE_WEAPON) - { - if (who->client->silencer_shots) - { + if (type == PNOISE_WEAPON) { + if (who->client->silencer_shots) { who->client->silencer_shots--; return; } @@ -75,88 +73,80 @@ void PlayerNoise(edict_t *who, vec3_t where, int type) return; - if (!who->mynoise) - { + if (!who->mynoise) { noise = G_Spawn(); noise->classname = "player_noise"; - VectorSet (noise->mins, -8, -8, -8); - VectorSet (noise->maxs, 8, 8, 8); + VectorSet(noise->mins, -8, -8, -8); + VectorSet(noise->maxs, 8, 8, 8); noise->owner = who; noise->svflags = SVF_NOCLIENT; who->mynoise = noise; noise = G_Spawn(); noise->classname = "player_noise"; - VectorSet (noise->mins, -8, -8, -8); - VectorSet (noise->maxs, 8, 8, 8); + VectorSet(noise->mins, -8, -8, -8); + VectorSet(noise->maxs, 8, 8, 8); noise->owner = who; noise->svflags = SVF_NOCLIENT; who->mynoise2 = noise; } - if (type == PNOISE_SELF || type == PNOISE_WEAPON) - { + if (type == PNOISE_SELF || type == PNOISE_WEAPON) { noise = who->mynoise; level.sound_entity = noise; level.sound_entity_framenum = level.framenum; - } - else // type == PNOISE_IMPACT - { + } else { // type == PNOISE_IMPACT noise = who->mynoise2; level.sound2_entity = noise; level.sound2_entity_framenum = level.framenum; } - VectorCopy (where, noise->s.origin); - VectorSubtract (where, noise->maxs, noise->absmin); - VectorAdd (where, noise->maxs, noise->absmax); + VectorCopy(where, noise->s.origin); + VectorSubtract(where, noise->maxs, noise->absmin); + VectorAdd(where, noise->maxs, noise->absmax); noise->teleport_time = level.time; - gi.linkentity (noise); + gi.linkentity(noise); } -qboolean Pickup_Weapon (edict_t *ent, edict_t *other) +qboolean Pickup_Weapon(edict_t *ent, edict_t *other) { int index; gitem_t *ammo; index = ITEM_INDEX(ent->item); - if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) - && other->client->pers.inventory[index]) - { - if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) + if ((((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) + && other->client->pers.inventory[index]) { + if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM))) return qfalse; // leave the weapon for others to pickup } other->client->pers.inventory[index]++; - if (!(ent->spawnflags & DROPPED_ITEM) ) - { + if (!(ent->spawnflags & DROPPED_ITEM)) { // give them some ammo with it - ammo = FindItem (ent->item->ammo); - if ( (int)dmflags->value & DF_INFINITE_AMMO ) - Add_Ammo (other, ammo, 1000); + ammo = FindItem(ent->item->ammo); + if ((int)dmflags->value & DF_INFINITE_AMMO) + Add_Ammo(other, ammo, 1000); else - Add_Ammo (other, ammo, ammo->quantity); + Add_Ammo(other, ammo, ammo->quantity); - if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) - { - if (deathmatch->value) - { + if (!(ent->spawnflags & DROPPED_PLAYER_ITEM)) { + if (deathmatch->value) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else - SetRespawn (ent, 30); + SetRespawn(ent, 30); } if (coop->value) ent->flags |= FL_RESPAWN; } } - if (other->client->pers.weapon != ent->item && + if (other->client->pers.weapon != ent->item && (other->client->pers.inventory[index] == 1) && - ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) + (!deathmatch->value || other->client->pers.weapon == FindItem("blaster"))) other->client->newweapon = ent->item; return qtrue; @@ -171,15 +161,14 @@ The old weapon has been dropped all the way, so make the new one current =============== */ -void ChangeWeapon (edict_t *ent) +void ChangeWeapon(edict_t *ent) { int i; - if (ent->client->grenade_time) - { + if (ent->client->grenade_time) { ent->client->grenade_time = level.time; ent->client->weapon_sound = 0; - weapon_grenade_fire (ent, qfalse); + weapon_grenade_fire(ent, qfalse); ent->client->grenade_time = 0; } @@ -202,8 +191,8 @@ void ChangeWeapon (edict_t *ent) else ent->client->ammo_index = 0; - if (!ent->client->pers.weapon) - { // dead + if (!ent->client->pers.weapon) { + // dead ent->client->ps.gunindex = 0; return; } @@ -213,16 +202,13 @@ void ChangeWeapon (edict_t *ent) ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model); ent->client->anim_priority = ANIM_PAIN; - if(ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { - ent->s.frame = FRAME_crpain1; - ent->client->anim_end = FRAME_crpain4; - } - else - { - ent->s.frame = FRAME_pain301; - ent->client->anim_end = FRAME_pain304; - + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { + ent->s.frame = FRAME_crpain1; + ent->client->anim_end = FRAME_crpain4; + } else { + ent->s.frame = FRAME_pain301; + ent->client->anim_end = FRAME_pain304; + } } @@ -231,45 +217,39 @@ void ChangeWeapon (edict_t *ent) NoAmmoWeaponChange ================= */ -void NoAmmoWeaponChange (edict_t *ent) +void NoAmmoWeaponChange(edict_t *ent) { - if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("slugs"))] - && ent->client->pers.inventory[ITEM_INDEX(FindItem("railgun"))] ) - { - ent->client->newweapon = FindItem ("railgun"); + if (ent->client->pers.inventory[ITEM_INDEX(FindItem("slugs"))] + && ent->client->pers.inventory[ITEM_INDEX(FindItem("railgun"))]) { + ent->client->newweapon = FindItem("railgun"); return; } - if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("cells"))] - && ent->client->pers.inventory[ITEM_INDEX(FindItem("hyperblaster"))] ) - { - ent->client->newweapon = FindItem ("hyperblaster"); + if (ent->client->pers.inventory[ITEM_INDEX(FindItem("cells"))] + && ent->client->pers.inventory[ITEM_INDEX(FindItem("hyperblaster"))]) { + ent->client->newweapon = FindItem("hyperblaster"); return; } - if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))] - && ent->client->pers.inventory[ITEM_INDEX(FindItem("chaingun"))] ) - { - ent->client->newweapon = FindItem ("chaingun"); + if (ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))] + && ent->client->pers.inventory[ITEM_INDEX(FindItem("chaingun"))]) { + ent->client->newweapon = FindItem("chaingun"); return; } - if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))] - && ent->client->pers.inventory[ITEM_INDEX(FindItem("machinegun"))] ) - { - ent->client->newweapon = FindItem ("machinegun"); + if (ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))] + && ent->client->pers.inventory[ITEM_INDEX(FindItem("machinegun"))]) { + ent->client->newweapon = FindItem("machinegun"); return; } - if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))] > 1 - && ent->client->pers.inventory[ITEM_INDEX(FindItem("super shotgun"))] ) - { - ent->client->newweapon = FindItem ("super shotgun"); + if (ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))] > 1 + && ent->client->pers.inventory[ITEM_INDEX(FindItem("super shotgun"))]) { + ent->client->newweapon = FindItem("super shotgun"); return; } - if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))] - && ent->client->pers.inventory[ITEM_INDEX(FindItem("shotgun"))] ) - { - ent->client->newweapon = FindItem ("shotgun"); + if (ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))] + && ent->client->pers.inventory[ITEM_INDEX(FindItem("shotgun"))]) { + ent->client->newweapon = FindItem("shotgun"); return; } - ent->client->newweapon = FindItem ("blaster"); + ent->client->newweapon = FindItem("blaster"); } /* @@ -279,24 +259,22 @@ Think_Weapon Called by ClientBeginServerFrame and ClientThink ================= */ -void Think_Weapon (edict_t *ent) +void Think_Weapon(edict_t *ent) { // if just died, put the weapon away - if (ent->health < 1) - { + if (ent->health < 1) { ent->client->newweapon = NULL; - ChangeWeapon (ent); + ChangeWeapon(ent); } // call active weapon think routine - if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink) - { + if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink) { is_quad = (ent->client->quad_framenum > level.framenum); if (ent->client->silencer_shots) is_silenced = MZ_SILENCED; else is_silenced = 0; - ent->client->pers.weapon->weaponthink (ent); + ent->client->pers.weapon->weaponthink(ent); } } @@ -308,7 +286,7 @@ Use_Weapon Make the weapon ready if there is ammo ================ */ -void Use_Weapon (edict_t *ent, gitem_t *item) +void Use_Weapon(edict_t *ent, gitem_t *item) { int ammo_index; gitem_t *ammo_item; @@ -317,20 +295,17 @@ void Use_Weapon (edict_t *ent, gitem_t *item) if (item == ent->client->pers.weapon) return; - if (item->ammo && !g_select_empty->value && !(item->flags & IT_AMMO)) - { + if (item->ammo && !g_select_empty->value && !(item->flags & IT_AMMO)) { ammo_item = FindItem(item->ammo); ammo_index = ITEM_INDEX(ammo_item); - if (!ent->client->pers.inventory[ammo_index]) - { - gi.cprintf (ent, PRINT_HIGH, "No %s for %s.\n", ammo_item->pickup_name, item->pickup_name); + if (!ent->client->pers.inventory[ammo_index]) { + gi.cprintf(ent, PRINT_HIGH, "No %s for %s.\n", ammo_item->pickup_name, item->pickup_name); return; } - if (ent->client->pers.inventory[ammo_index] < item->quantity) - { - gi.cprintf (ent, PRINT_HIGH, "Not enough %s for %s.\n", ammo_item->pickup_name, item->pickup_name); + if (ent->client->pers.inventory[ammo_index] < item->quantity) { + gi.cprintf(ent, PRINT_HIGH, "Not enough %s for %s.\n", ammo_item->pickup_name, item->pickup_name); return; } } @@ -346,7 +321,7 @@ void Use_Weapon (edict_t *ent, gitem_t *item) Drop_Weapon ================ */ -void Drop_Weapon (edict_t *ent, gitem_t *item) +void Drop_Weapon(edict_t *ent, gitem_t *item) { int index; @@ -355,13 +330,12 @@ void Drop_Weapon (edict_t *ent, gitem_t *item) index = ITEM_INDEX(item); // see if we're already using it - if ( ((item == ent->client->pers.weapon) || (item == ent->client->newweapon))&& (ent->client->pers.inventory[index] == 1) ) - { - gi.cprintf (ent, PRINT_HIGH, "Can't drop current weapon\n"); + if (((item == ent->client->pers.weapon) || (item == ent->client->newweapon)) && (ent->client->pers.inventory[index] == 1)) { + gi.cprintf(ent, PRINT_HIGH, "Can't drop current weapon\n"); return; } - Drop_Item (ent, item); + Drop_Item(ent, item); ent->client->pers.inventory[index]--; } @@ -377,35 +351,27 @@ A generic function to handle the basics of weapon thinking #define FRAME_IDLE_FIRST (FRAME_FIRE_LAST + 1) #define FRAME_DEACTIVATE_FIRST (FRAME_IDLE_LAST + 1) -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)) +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)) { int n; - if(ent->deadflag || ent->s.modelindex != 255) // VWep animations screw up corpses - { + if (ent->deadflag || ent->s.modelindex != 255) { // VWep animations screw up corpses return; } - if (ent->client->weaponstate == WEAPON_DROPPING) - { - if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST) - { - ChangeWeapon (ent); + if (ent->client->weaponstate == WEAPON_DROPPING) { + if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST) { + ChangeWeapon(ent); return; - } - else if ((FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe) == 4) - { + } else if ((FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe) == 4) { ent->client->anim_priority = ANIM_REVERSE; - if(ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { - ent->s.frame = FRAME_crpain4+1; + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { + ent->s.frame = FRAME_crpain4 + 1; ent->client->anim_end = FRAME_crpain1; - } - else - { - ent->s.frame = FRAME_pain304+1; + } else { + ent->s.frame = FRAME_pain304 + 1; ent->client->anim_end = FRAME_pain301; - + } } @@ -413,10 +379,8 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, return; } - if (ent->client->weaponstate == WEAPON_ACTIVATING) - { - if (ent->client->ps.gunframe == FRAME_ACTIVATE_LAST) - { + if (ent->client->weaponstate == WEAPON_ACTIVATING) { + if (ent->client->ps.gunframe == FRAME_ACTIVATE_LAST) { ent->client->weaponstate = WEAPON_READY; ent->client->ps.gunframe = FRAME_IDLE_FIRST; return; @@ -426,78 +390,58 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, return; } - if ((ent->client->newweapon) && (ent->client->weaponstate != WEAPON_FIRING)) - { + if ((ent->client->newweapon) && (ent->client->weaponstate != WEAPON_FIRING)) { ent->client->weaponstate = WEAPON_DROPPING; ent->client->ps.gunframe = FRAME_DEACTIVATE_FIRST; - if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4) - { + if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4) { ent->client->anim_priority = ANIM_REVERSE; - if(ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { - ent->s.frame = FRAME_crpain4+1; + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { + ent->s.frame = FRAME_crpain4 + 1; ent->client->anim_end = FRAME_crpain1; - } - else - { - ent->s.frame = FRAME_pain304+1; + } else { + ent->s.frame = FRAME_pain304 + 1; ent->client->anim_end = FRAME_pain301; - + } } return; } - if (ent->client->weaponstate == WEAPON_READY) - { - if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) ) - { + if (ent->client->weaponstate == WEAPON_READY) { + if (((ent->client->latched_buttons | ent->client->buttons) & BUTTON_ATTACK)) { ent->client->latched_buttons &= ~BUTTON_ATTACK; - if ((!ent->client->ammo_index) || - ( ent->client->pers.inventory[ent->client->ammo_index] >= ent->client->pers.weapon->quantity)) - { + if ((!ent->client->ammo_index) || + (ent->client->pers.inventory[ent->client->ammo_index] >= ent->client->pers.weapon->quantity)) { ent->client->ps.gunframe = FRAME_FIRE_FIRST; ent->client->weaponstate = WEAPON_FIRING; // start the animation ent->client->anim_priority = ANIM_ATTACK; - if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { - ent->s.frame = FRAME_crattak1-1; + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { + ent->s.frame = FRAME_crattak1 - 1; ent->client->anim_end = FRAME_crattak9; - } - else - { - ent->s.frame = FRAME_attack1-1; + } else { + ent->s.frame = FRAME_attack1 - 1; ent->client->anim_end = FRAME_attack8; } - } - else - { - if (level.time >= ent->pain_debounce_time) - { + } else { + if (level.time >= ent->pain_debounce_time) { gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0); ent->pain_debounce_time = level.time + 1; } - NoAmmoWeaponChange (ent); + NoAmmoWeaponChange(ent); } - } - else - { - if (ent->client->ps.gunframe == FRAME_IDLE_LAST) - { + } else { + if (ent->client->ps.gunframe == FRAME_IDLE_LAST) { ent->client->ps.gunframe = FRAME_IDLE_FIRST; return; } - if (pause_frames) - { - for (n = 0; pause_frames[n]; n++) - { - if (ent->client->ps.gunframe == pause_frames[n]) - { - if (rand()&15) + if (pause_frames) { + for (n = 0; pause_frames[n]; n++) { + if (ent->client->ps.gunframe == pause_frames[n]) { + if (rand() & 15) return; } } @@ -508,16 +452,13 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, } } - if (ent->client->weaponstate == WEAPON_FIRING) - { - for (n = 0; fire_frames[n]; n++) - { - if (ent->client->ps.gunframe == fire_frames[n]) - { + if (ent->client->weaponstate == WEAPON_FIRING) { + for (n = 0; fire_frames[n]; n++) { + if (ent->client->ps.gunframe == fire_frames[n]) { if (ent->client->quad_framenum > level.framenum) gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage3.wav"), 1, ATTN_NORM, 0); - fire (ent); + fire(ent); break; } } @@ -525,7 +466,7 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, if (!fire_frames[n]) ent->client->ps.gunframe++; - if (ent->client->ps.gunframe == FRAME_IDLE_FIRST+1) + if (ent->client->ps.gunframe == FRAME_IDLE_FIRST + 1) ent->client->weaponstate = WEAPON_READY; } } @@ -543,7 +484,7 @@ GRENADE #define GRENADE_MINSPEED 400 #define GRENADE_MAXSPEED 800 -void weapon_grenade_fire (edict_t *ent, qboolean held) +void weapon_grenade_fire(edict_t *ent, qboolean held) { vec3_t offset; vec3_t forward, right; @@ -553,86 +494,73 @@ void weapon_grenade_fire (edict_t *ent, qboolean held) int speed; float radius; - radius = damage+40; + radius = damage + 40; if (is_quad) damage *= 4; - VectorSet(offset, 8, 8, ent->viewheight-8); - AngleVectors (ent->client->v_angle, forward, right, NULL); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + VectorSet(offset, 8, 8, ent->viewheight - 8); + AngleVectors(ent->client->v_angle, forward, right, NULL); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); timer = ent->client->grenade_time - level.time; speed = GRENADE_MINSPEED + (GRENADE_TIMER - timer) * ((GRENADE_MAXSPEED - GRENADE_MINSPEED) / GRENADE_TIMER); - fire_grenade2 (ent, start, forward, damage, speed, timer, radius, held); + fire_grenade2(ent, start, forward, damage, speed, timer, radius, held); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; ent->client->grenade_time = level.time + 1.0; - if(ent->deadflag || ent->s.modelindex != 255) // VWep animations screw up corpses - { + if (ent->deadflag || ent->s.modelindex != 255) { // VWep animations screw up corpses return; } if (ent->health <= 0) return; - if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { ent->client->anim_priority = ANIM_ATTACK; - ent->s.frame = FRAME_crattak1-1; + ent->s.frame = FRAME_crattak1 - 1; ent->client->anim_end = FRAME_crattak3; - } - else - { + } else { ent->client->anim_priority = ANIM_REVERSE; ent->s.frame = FRAME_wave08; ent->client->anim_end = FRAME_wave01; } } -void Weapon_Grenade (edict_t *ent) +void Weapon_Grenade(edict_t *ent) { - if ((ent->client->newweapon) && (ent->client->weaponstate == WEAPON_READY)) - { - ChangeWeapon (ent); + if ((ent->client->newweapon) && (ent->client->weaponstate == WEAPON_READY)) { + ChangeWeapon(ent); return; } - if (ent->client->weaponstate == WEAPON_ACTIVATING) - { + if (ent->client->weaponstate == WEAPON_ACTIVATING) { ent->client->weaponstate = WEAPON_READY; ent->client->ps.gunframe = 16; return; } - if (ent->client->weaponstate == WEAPON_READY) - { - if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) ) - { + if (ent->client->weaponstate == WEAPON_READY) { + if (((ent->client->latched_buttons | ent->client->buttons) & BUTTON_ATTACK)) { ent->client->latched_buttons &= ~BUTTON_ATTACK; - if (ent->client->pers.inventory[ent->client->ammo_index]) - { + if (ent->client->pers.inventory[ent->client->ammo_index]) { ent->client->ps.gunframe = 1; ent->client->weaponstate = WEAPON_FIRING; ent->client->grenade_time = 0; - } - else - { - if (level.time >= ent->pain_debounce_time) - { + } else { + if (level.time >= ent->pain_debounce_time) { gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0); ent->pain_debounce_time = level.time + 1; } - NoAmmoWeaponChange (ent); + NoAmmoWeaponChange(ent); } return; } - if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48)) - { - if (rand()&15) + if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48)) { + if (rand() & 15) return; } @@ -641,48 +569,39 @@ void Weapon_Grenade (edict_t *ent) return; } - if (ent->client->weaponstate == WEAPON_FIRING) - { + if (ent->client->weaponstate == WEAPON_FIRING) { if (ent->client->ps.gunframe == 5) gi.sound(ent, CHAN_WEAPON, gi.soundindex("weapons/hgrena1b.wav"), 1, ATTN_NORM, 0); - if (ent->client->ps.gunframe == 11) - { - if (!ent->client->grenade_time) - { + if (ent->client->ps.gunframe == 11) { + if (!ent->client->grenade_time) { ent->client->grenade_time = level.time + GRENADE_TIMER + 0.2; ent->client->weapon_sound = gi.soundindex("weapons/hgrenc1b.wav"); } // they waited too long, detonate it in their hand - if (!ent->client->grenade_blew_up && level.time >= ent->client->grenade_time) - { + if (!ent->client->grenade_blew_up && level.time >= ent->client->grenade_time) { ent->client->weapon_sound = 0; - weapon_grenade_fire (ent, qtrue); + weapon_grenade_fire(ent, qtrue); ent->client->grenade_blew_up = qtrue; } if (ent->client->buttons & BUTTON_ATTACK) return; - if (ent->client->grenade_blew_up) - { - if (level.time >= ent->client->grenade_time) - { + if (ent->client->grenade_blew_up) { + if (level.time >= ent->client->grenade_time) { ent->client->ps.gunframe = 15; ent->client->grenade_blew_up = qfalse; - } - else - { + } else { return; } } } - if (ent->client->ps.gunframe == 12) - { + if (ent->client->ps.gunframe == 12) { ent->client->weapon_sound = 0; - weapon_grenade_fire (ent, qfalse); + weapon_grenade_fire(ent, qfalse); } if ((ent->client->ps.gunframe == 15) && (level.time < ent->client->grenade_time)) @@ -690,8 +609,7 @@ void Weapon_Grenade (edict_t *ent) ent->client->ps.gunframe++; - if (ent->client->ps.gunframe == 16) - { + if (ent->client->ps.gunframe == 16) { ent->client->grenade_time = 0; ent->client->weaponstate = WEAPON_READY; } @@ -706,7 +624,7 @@ GRENADE LAUNCHER ====================================================================== */ -void weapon_grenadelauncher_fire (edict_t *ent) +void weapon_grenadelauncher_fire(edict_t *ent) { vec3_t offset; vec3_t forward, right; @@ -714,38 +632,38 @@ void weapon_grenadelauncher_fire (edict_t *ent) int damage = 120; float radius; - radius = damage+40; + radius = damage + 40; if (is_quad) damage *= 4; - VectorSet(offset, 8, 8, ent->viewheight-8); - AngleVectors (ent->client->v_angle, forward, right, NULL); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + VectorSet(offset, 8, 8, ent->viewheight - 8); + AngleVectors(ent->client->v_angle, forward, right, NULL); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); - VectorScale (forward, -2, ent->client->kick_origin); + VectorScale(forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -1; - fire_grenade (ent, start, forward, damage, 600, 2.5, radius); + fire_grenade(ent, start, forward, damage, 600, 2.5, radius); - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_GRENADE | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_GRENADE | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; } -void Weapon_GrenadeLauncher (edict_t *ent) +void Weapon_GrenadeLauncher(edict_t *ent) { static int pause_frames[] = {34, 51, 59, 0}; static int fire_frames[] = {6, 0}; - Weapon_Generic (ent, 5, 16, 59, 64, pause_frames, fire_frames, weapon_grenadelauncher_fire); + Weapon_Generic(ent, 5, 16, 59, 64, pause_frames, fire_frames, weapon_grenadelauncher_fire); } /* @@ -756,7 +674,7 @@ ROCKET ====================================================================== */ -void Weapon_RocketLauncher_Fire (edict_t *ent) +void Weapon_RocketLauncher_Fire(edict_t *ent) { vec3_t offset, start; vec3_t forward, right; @@ -767,41 +685,40 @@ void Weapon_RocketLauncher_Fire (edict_t *ent) damage = 100 + (int)(random() * 20.0); radius_damage = 120; damage_radius = 120; - if (is_quad) - { + if (is_quad) { damage *= 4; radius_damage *= 4; } - AngleVectors (ent->client->v_angle, forward, right, NULL); + AngleVectors(ent->client->v_angle, forward, right, NULL); - VectorScale (forward, -2, ent->client->kick_origin); + VectorScale(forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -1; - VectorSet(offset, 8, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); - fire_rocket (ent, start, forward, damage, 650, damage_radius, radius_damage); + VectorSet(offset, 8, 8, ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); + fire_rocket(ent, start, forward, damage, 650, damage_radius, radius_damage); // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_ROCKET | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_ROCKET | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; } -void Weapon_RocketLauncher (edict_t *ent) +void Weapon_RocketLauncher(edict_t *ent) { static int pause_frames[] = {25, 33, 42, 50, 0}; static int fire_frames[] = {5, 0}; - Weapon_Generic (ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_RocketLauncher_Fire); + Weapon_Generic(ent, 4, 12, 50, 54, pause_frames, fire_frames, Weapon_RocketLauncher_Fire); } @@ -813,7 +730,7 @@ BLASTER / HYPERBLASTER ====================================================================== */ -void Blaster_Fire (edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, int effect) +void Blaster_Fire(edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, int effect) { vec3_t forward, right; vec3_t start; @@ -821,30 +738,30 @@ void Blaster_Fire (edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, in if (is_quad) damage *= 4; - AngleVectors (ent->client->v_angle, forward, right, NULL); - VectorSet(offset, 24, 8, ent->viewheight-8); - VectorAdd (offset, g_offset, offset); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + AngleVectors(ent->client->v_angle, forward, right, NULL); + VectorSet(offset, 24, 8, ent->viewheight - 8); + VectorAdd(offset, g_offset, offset); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); - VectorScale (forward, -2, ent->client->kick_origin); + VectorScale(forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -1; - fire_blaster (ent, start, forward, damage, 1000, effect, hyper); + fire_blaster(ent, start, forward, damage, 1000, effect, hyper); // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); if (hyper) - gi.WriteByte (MZ_HYPERBLASTER | is_silenced); + gi.WriteByte(MZ_HYPERBLASTER | is_silenced); else - gi.WriteByte (MZ_BLASTER | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(MZ_BLASTER | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); PlayerNoise(ent, start, PNOISE_WEAPON); } -void Weapon_Blaster_Fire (edict_t *ent) +void Weapon_Blaster_Fire(edict_t *ent) { int damage; @@ -852,20 +769,20 @@ void Weapon_Blaster_Fire (edict_t *ent) damage = 15; else damage = 10; - Blaster_Fire (ent, vec3_origin, damage, qfalse, EF_BLASTER); + Blaster_Fire(ent, vec3_origin, damage, qfalse, EF_BLASTER); ent->client->ps.gunframe++; } -void Weapon_Blaster (edict_t *ent) +void Weapon_Blaster(edict_t *ent) { static int pause_frames[] = {19, 32, 0}; static int fire_frames[] = {5, 0}; - Weapon_Generic (ent, 4, 8, 52, 55, pause_frames, fire_frames, Weapon_Blaster_Fire); + Weapon_Generic(ent, 4, 8, 52, 55, pause_frames, fire_frames, Weapon_Blaster_Fire); } -void Weapon_HyperBlaster_Fire (edict_t *ent) +void Weapon_HyperBlaster_Fire(edict_t *ent) { float rotation; vec3_t offset; @@ -874,24 +791,17 @@ void Weapon_HyperBlaster_Fire (edict_t *ent) ent->client->weapon_sound = gi.soundindex("weapons/hyprbl1a.wav"); - if (!(ent->client->buttons & BUTTON_ATTACK)) - { + if (!(ent->client->buttons & BUTTON_ATTACK)) { ent->client->ps.gunframe++; - } - else - { - if (! ent->client->pers.inventory[ent->client->ammo_index] ) - { - if (level.time >= ent->pain_debounce_time) - { + } else { + if (! ent->client->pers.inventory[ent->client->ammo_index]) { + if (level.time >= ent->pain_debounce_time) { gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0); ent->pain_debounce_time = level.time + 1; } - NoAmmoWeaponChange (ent); - } - else - { - rotation = (ent->client->ps.gunframe - 5) * 2*M_PI/6; + NoAmmoWeaponChange(ent); + } else { + rotation = (ent->client->ps.gunframe - 5) * 2 * M_PI / 6; offset[0] = -4 * sin(rotation); offset[1] = 0; offset[2] = 4 * cos(rotation); @@ -904,18 +814,15 @@ void Weapon_HyperBlaster_Fire (edict_t *ent) damage = 15; else damage = 20; - Blaster_Fire (ent, offset, damage, qtrue, effect); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + Blaster_Fire(ent, offset, damage, qtrue, effect); + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; ent->client->anim_priority = ANIM_ATTACK; - if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { ent->s.frame = FRAME_crattak1 - 1; ent->client->anim_end = FRAME_crattak9; - } - else - { + } else { ent->s.frame = FRAME_attack1 - 1; ent->client->anim_end = FRAME_attack8; } @@ -926,20 +833,19 @@ void Weapon_HyperBlaster_Fire (edict_t *ent) ent->client->ps.gunframe = 6; } - if (ent->client->ps.gunframe == 12) - { + if (ent->client->ps.gunframe == 12) { gi.sound(ent, CHAN_AUTO, gi.soundindex("weapons/hyprbd1a.wav"), 1, ATTN_NORM, 0); ent->client->weapon_sound = 0; } } -void Weapon_HyperBlaster (edict_t *ent) +void Weapon_HyperBlaster(edict_t *ent) { static int pause_frames[] = {0}; static int fire_frames[] = {6, 7, 8, 9, 10, 11, 0}; - Weapon_Generic (ent, 5, 20, 49, 53, pause_frames, fire_frames, Weapon_HyperBlaster_Fire); + Weapon_Generic(ent, 5, 20, 49, 53, pause_frames, fire_frames, Weapon_HyperBlaster_Fire); } /* @@ -950,7 +856,7 @@ MACHINEGUN / CHAINGUN ====================================================================== */ -void Machinegun_Fire (edict_t *ent) +void Machinegun_Fire(edict_t *ent) { int i; vec3_t start; @@ -960,8 +866,7 @@ void Machinegun_Fire (edict_t *ent) int kick = 2; vec3_t offset; - if (!(ent->client->buttons & BUTTON_ATTACK)) - { + if (!(ent->client->buttons & BUTTON_ATTACK)) { ent->client->machinegun_shots = 0; ent->client->ps.gunframe++; return; @@ -972,26 +877,22 @@ void Machinegun_Fire (edict_t *ent) else ent->client->ps.gunframe = 5; - if (ent->client->pers.inventory[ent->client->ammo_index] < 1) - { + if (ent->client->pers.inventory[ent->client->ammo_index] < 1) { ent->client->ps.gunframe = 6; - if (level.time >= ent->pain_debounce_time) - { + if (level.time >= ent->pain_debounce_time) { gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0); ent->pain_debounce_time = level.time + 1; } - NoAmmoWeaponChange (ent); + NoAmmoWeaponChange(ent); return; } - if (is_quad) - { + if (is_quad) { damage *= 4; kick *= 4; } - for (i=1 ; i<3 ; i++) - { + for (i = 1 ; i < 3 ; i++) { ent->client->kick_origin[i] = crandom() * 0.35; ent->client->kick_angles[i] = crandom() * 0.7; } @@ -999,52 +900,48 @@ void Machinegun_Fire (edict_t *ent) ent->client->kick_angles[0] = ent->client->machinegun_shots * -1.5; // raise the gun as it is firing - if (!deathmatch->value) - { + if (!deathmatch->value) { ent->client->machinegun_shots++; if (ent->client->machinegun_shots > 9) ent->client->machinegun_shots = 9; } // get start / end positions - VectorAdd (ent->client->v_angle, ent->client->kick_angles, angles); - AngleVectors (angles, forward, right, NULL); - VectorSet(offset, 0, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); - fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN); + VectorAdd(ent->client->v_angle, ent->client->kick_angles, angles); + AngleVectors(angles, forward, right, NULL); + VectorSet(offset, 0, 8, ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); + fire_bullet(ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN); - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_MACHINEGUN | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_MACHINEGUN | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; ent->client->anim_priority = ANIM_ATTACK; - if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { - ent->s.frame = FRAME_crattak1 - (int) (random()+0.25); + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { + ent->s.frame = FRAME_crattak1 - (int)(random() + 0.25); ent->client->anim_end = FRAME_crattak9; - } - else - { - ent->s.frame = FRAME_attack1 - (int) (random()+0.25); + } else { + ent->s.frame = FRAME_attack1 - (int)(random() + 0.25); ent->client->anim_end = FRAME_attack8; } } -void Weapon_Machinegun (edict_t *ent) +void Weapon_Machinegun(edict_t *ent) { static int pause_frames[] = {23, 45, 0}; static int fire_frames[] = {4, 5, 0}; - Weapon_Generic (ent, 3, 5, 45, 49, pause_frames, fire_frames, Machinegun_Fire); + Weapon_Generic(ent, 3, 5, 45, 49, pause_frames, fire_frames, Machinegun_Fire); } -void Chaingun_Fire (edict_t *ent) +void Chaingun_Fire(edict_t *ent) { int i; int shots; @@ -1063,113 +960,95 @@ void Chaingun_Fire (edict_t *ent) if (ent->client->ps.gunframe == 5) gi.sound(ent, CHAN_AUTO, gi.soundindex("weapons/chngnu1a.wav"), 1, ATTN_IDLE, 0); - if ((ent->client->ps.gunframe == 14) && !(ent->client->buttons & BUTTON_ATTACK)) - { + if ((ent->client->ps.gunframe == 14) && !(ent->client->buttons & BUTTON_ATTACK)) { ent->client->ps.gunframe = 32; ent->client->weapon_sound = 0; return; - } - else if ((ent->client->ps.gunframe == 21) && (ent->client->buttons & BUTTON_ATTACK) - && ent->client->pers.inventory[ent->client->ammo_index]) - { + } else if ((ent->client->ps.gunframe == 21) && (ent->client->buttons & BUTTON_ATTACK) + && ent->client->pers.inventory[ent->client->ammo_index]) { ent->client->ps.gunframe = 15; - } - else - { + } else { ent->client->ps.gunframe++; } - if (ent->client->ps.gunframe == 22) - { + if (ent->client->ps.gunframe == 22) { ent->client->weapon_sound = 0; gi.sound(ent, CHAN_AUTO, gi.soundindex("weapons/chngnd1a.wav"), 1, ATTN_IDLE, 0); - } - else - { + } else { ent->client->weapon_sound = gi.soundindex("weapons/chngnl1a.wav"); } ent->client->anim_priority = ANIM_ATTACK; - if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) - { + if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) { ent->s.frame = FRAME_crattak1 - (ent->client->ps.gunframe & 1); ent->client->anim_end = FRAME_crattak9; - } - else - { + } else { ent->s.frame = FRAME_attack1 - (ent->client->ps.gunframe & 1); ent->client->anim_end = FRAME_attack8; } if (ent->client->ps.gunframe <= 9) shots = 1; - else if (ent->client->ps.gunframe <= 14) - { + else if (ent->client->ps.gunframe <= 14) { if (ent->client->buttons & BUTTON_ATTACK) shots = 2; else shots = 1; - } - else + } else shots = 3; if (ent->client->pers.inventory[ent->client->ammo_index] < shots) shots = ent->client->pers.inventory[ent->client->ammo_index]; - if (!shots) - { - if (level.time >= ent->pain_debounce_time) - { + if (!shots) { + if (level.time >= ent->pain_debounce_time) { gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0); ent->pain_debounce_time = level.time + 1; } - NoAmmoWeaponChange (ent); + NoAmmoWeaponChange(ent); return; } - if (is_quad) - { + if (is_quad) { damage *= 4; kick *= 4; } - for (i=0 ; i<3 ; i++) - { + for (i = 0 ; i < 3 ; i++) { ent->client->kick_origin[i] = crandom() * 0.35; ent->client->kick_angles[i] = crandom() * 0.7; } - for (i=0 ; i<shots ; i++) - { + for (i = 0 ; i < shots ; i++) { // get start / end positions - AngleVectors (ent->client->v_angle, forward, right, up); - r = 7 + crandom()*4; - u = crandom()*4; - VectorSet(offset, 0, r, u + ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + AngleVectors(ent->client->v_angle, forward, right, up); + r = 7 + crandom() * 4; + u = crandom() * 4; + VectorSet(offset, 0, r, u + ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); - fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_CHAINGUN); + fire_bullet(ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_CHAINGUN); } // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte ((MZ_CHAINGUN1 + shots - 1) | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte((MZ_CHAINGUN1 + shots - 1) | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index] -= shots; } -void Weapon_Chaingun (edict_t *ent) +void Weapon_Chaingun(edict_t *ent) { static int pause_frames[] = {38, 43, 51, 61, 0}; static int fire_frames[] = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0}; - Weapon_Generic (ent, 4, 31, 61, 64, pause_frames, fire_frames, Chaingun_Fire); + Weapon_Generic(ent, 4, 31, 61, 64, pause_frames, fire_frames, Chaingun_Fire); } @@ -1181,7 +1060,7 @@ SHOTGUN / SUPERSHOTGUN ====================================================================== */ -void weapon_shotgun_fire (edict_t *ent) +void weapon_shotgun_fire(edict_t *ent) { vec3_t start; vec3_t forward, right; @@ -1189,54 +1068,52 @@ void weapon_shotgun_fire (edict_t *ent) int damage = 4; int kick = 8; - if (ent->client->ps.gunframe == 9) - { + if (ent->client->ps.gunframe == 9) { ent->client->ps.gunframe++; return; } - AngleVectors (ent->client->v_angle, forward, right, NULL); + AngleVectors(ent->client->v_angle, forward, right, NULL); - VectorScale (forward, -2, ent->client->kick_origin); + VectorScale(forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -2; - VectorSet(offset, 0, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + VectorSet(offset, 0, 8, ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); - if (is_quad) - { + if (is_quad) { damage *= 4; kick *= 4; } if (deathmatch->value) - fire_shotgun (ent, start, forward, damage, kick, 500, 500, DEFAULT_DEATHMATCH_SHOTGUN_COUNT, MOD_SHOTGUN); + fire_shotgun(ent, start, forward, damage, kick, 500, 500, DEFAULT_DEATHMATCH_SHOTGUN_COUNT, MOD_SHOTGUN); else - fire_shotgun (ent, start, forward, damage, kick, 500, 500, DEFAULT_SHOTGUN_COUNT, MOD_SHOTGUN); + fire_shotgun(ent, start, forward, damage, kick, 500, 500, DEFAULT_SHOTGUN_COUNT, MOD_SHOTGUN); // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_SHOTGUN | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_SHOTGUN | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; } -void Weapon_Shotgun (edict_t *ent) +void Weapon_Shotgun(edict_t *ent) { static int pause_frames[] = {22, 28, 34, 0}; static int fire_frames[] = {8, 9, 0}; - Weapon_Generic (ent, 7, 18, 36, 39, pause_frames, fire_frames, weapon_shotgun_fire); + Weapon_Generic(ent, 7, 18, 36, 39, pause_frames, fire_frames, weapon_shotgun_fire); } -void weapon_supershotgun_fire (edict_t *ent) +void weapon_supershotgun_fire(edict_t *ent) { vec3_t start; vec3_t forward, right; @@ -1245,16 +1122,15 @@ void weapon_supershotgun_fire (edict_t *ent) int damage = 6; int kick = 12; - AngleVectors (ent->client->v_angle, forward, right, NULL); + AngleVectors(ent->client->v_angle, forward, right, NULL); - VectorScale (forward, -2, ent->client->kick_origin); + VectorScale(forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -2; - VectorSet(offset, 0, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + VectorSet(offset, 0, 8, ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); - if (is_quad) - { + if (is_quad) { damage *= 4; kick *= 4; } @@ -1262,31 +1138,31 @@ void weapon_supershotgun_fire (edict_t *ent) v[PITCH] = ent->client->v_angle[PITCH]; v[YAW] = ent->client->v_angle[YAW] - 5; v[ROLL] = ent->client->v_angle[ROLL]; - AngleVectors (v, forward, NULL, NULL); - fire_shotgun (ent, start, forward, damage, kick, DEFAULT_SHOTGUN_HSPREAD, DEFAULT_SHOTGUN_VSPREAD, DEFAULT_SSHOTGUN_COUNT/2, MOD_SSHOTGUN); + AngleVectors(v, forward, NULL, NULL); + fire_shotgun(ent, start, forward, damage, kick, DEFAULT_SHOTGUN_HSPREAD, DEFAULT_SHOTGUN_VSPREAD, DEFAULT_SSHOTGUN_COUNT / 2, MOD_SSHOTGUN); v[YAW] = ent->client->v_angle[YAW] + 5; - AngleVectors (v, forward, NULL, NULL); - fire_shotgun (ent, start, forward, damage, kick, DEFAULT_SHOTGUN_HSPREAD, DEFAULT_SHOTGUN_VSPREAD, DEFAULT_SSHOTGUN_COUNT/2, MOD_SSHOTGUN); + AngleVectors(v, forward, NULL, NULL); + fire_shotgun(ent, start, forward, damage, kick, DEFAULT_SHOTGUN_HSPREAD, DEFAULT_SHOTGUN_VSPREAD, DEFAULT_SSHOTGUN_COUNT / 2, MOD_SSHOTGUN); // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_SSHOTGUN | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_SSHOTGUN | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index] -= 2; } -void Weapon_SuperShotgun (edict_t *ent) +void Weapon_SuperShotgun(edict_t *ent) { static int pause_frames[] = {29, 42, 57, 0}; static int fire_frames[] = {7, 0}; - Weapon_Generic (ent, 6, 17, 57, 61, pause_frames, fire_frames, weapon_supershotgun_fire); + Weapon_Generic(ent, 6, 17, 57, 61, pause_frames, fire_frames, weapon_supershotgun_fire); } @@ -1299,7 +1175,7 @@ RAILGUN ====================================================================== */ -void weapon_railgun_fire (edict_t *ent) +void weapon_railgun_fire(edict_t *ent) { vec3_t start; vec3_t forward, right; @@ -1307,52 +1183,49 @@ void weapon_railgun_fire (edict_t *ent) int damage; int kick; - if (deathmatch->value) - { // normal damage is too extreme in dm + if (deathmatch->value) { + // normal damage is too extreme in dm damage = 100; kick = 200; - } - else - { + } else { damage = 150; kick = 250; } - if (is_quad) - { + if (is_quad) { damage *= 4; kick *= 4; } - AngleVectors (ent->client->v_angle, forward, right, NULL); + AngleVectors(ent->client->v_angle, forward, right, NULL); - VectorScale (forward, -3, ent->client->kick_origin); + VectorScale(forward, -3, ent->client->kick_origin); ent->client->kick_angles[0] = -3; - VectorSet(offset, 0, 7, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); - fire_rail (ent, start, forward, damage, kick); + VectorSet(offset, 0, 7, ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); + fire_rail(ent, start, forward, damage, kick); // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_RAILGUN | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_RAILGUN | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index]--; } -void Weapon_Railgun (edict_t *ent) +void Weapon_Railgun(edict_t *ent) { static int pause_frames[] = {56, 0}; static int fire_frames[] = {4, 0}; - Weapon_Generic (ent, 3, 18, 56, 61, pause_frames, fire_frames, weapon_railgun_fire); + Weapon_Generic(ent, 3, 18, 56, 61, pause_frames, fire_frames, weapon_railgun_fire); } @@ -1364,7 +1237,7 @@ BFG10K ====================================================================== */ -void weapon_bfg_fire (edict_t *ent) +void weapon_bfg_fire(edict_t *ent) { vec3_t offset, start; vec3_t forward, right; @@ -1376,13 +1249,12 @@ void weapon_bfg_fire (edict_t *ent) else damage = 500; - if (ent->client->ps.gunframe == 9) - { + if (ent->client->ps.gunframe == 9) { // send muzzle flash - gi.WriteByte (svc_muzzleflash); - gi.WriteShort (ent-g_edicts); - gi.WriteByte (MZ_BFG | is_silenced); - gi.multicast (ent->s.origin, MULTICAST_PVS); + gi.WriteByte(svc_muzzleflash); + gi.WriteShort(ent - g_edicts); + gi.WriteByte(MZ_BFG | is_silenced); + gi.multicast(ent->s.origin, MULTICAST_PVS); ent->client->ps.gunframe++; @@ -1392,8 +1264,7 @@ void weapon_bfg_fire (edict_t *ent) // cells can go down during windup (from power armor hits), so // check again and abort firing if we don't have enough now - if (ent->client->pers.inventory[ent->client->ammo_index] < 50) - { + if (ent->client->pers.inventory[ent->client->ammo_index] < 50) { ent->client->ps.gunframe++; return; } @@ -1401,33 +1272,33 @@ void weapon_bfg_fire (edict_t *ent) if (is_quad) damage *= 4; - AngleVectors (ent->client->v_angle, forward, right, NULL); + AngleVectors(ent->client->v_angle, forward, right, NULL); - VectorScale (forward, -2, ent->client->kick_origin); + VectorScale(forward, -2, ent->client->kick_origin); // make a big pitch kick with an inverse fall ent->client->v_dmg_pitch = -40; - ent->client->v_dmg_roll = crandom()*8; + ent->client->v_dmg_roll = crandom() * 8; ent->client->v_dmg_time = level.time + DAMAGE_TIME; - VectorSet(offset, 8, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); - fire_bfg (ent, start, forward, damage, 400, damage_radius); + VectorSet(offset, 8, 8, ent->viewheight - 8); + P_ProjectSource(ent->client, ent->s.origin, offset, forward, right, start); + fire_bfg(ent, start, forward, damage, 400, damage_radius); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); - if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) + if (!((int)dmflags->value & DF_INFINITE_AMMO)) ent->client->pers.inventory[ent->client->ammo_index] -= 50; } -void Weapon_BFG (edict_t *ent) +void Weapon_BFG(edict_t *ent) { static int pause_frames[] = {39, 45, 50, 55, 0}; static int fire_frames[] = {9, 17, 0}; - Weapon_Generic (ent, 8, 32, 55, 58, pause_frames, fire_frames, weapon_bfg_fire); + Weapon_Generic(ent, 8, 32, 55, 58, pause_frames, fire_frames, weapon_bfg_fire); } |