void weapon_railgun_fire (edict_t *ent) { vec3_t start; vec3_t forward, right; vec3_t offset; int damage; int kick; if (deathmatch->value) { // normal damage is too extreme in dm damage = 100; kick = 200; } else { damage = 150; kick = 250; } if (is_quad) { damage *= 4; kick *= 4; } AngleVectors (ent->client->v_angle, forward, right, NULL); 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); ent->client->ps.gunframe++; if(EMPNukeCheck(ent, start)) { gi.sound (ent, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) ent->client->pers.inventory[ent->client->ammo_index]--; 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); PlayerNoise(ent, start, PNOISE_WEAPON); // play quad damage sound playQuadSound(ent); }
/* ====================================================================== ROCKET ====================================================================== */ void Weapon_RocketLauncher_Fire (edict_t *ent) { vec3_t offset, start; vec3_t forward, right; int damage; float damage_radius; int radius_damage; damage = 100 + (int)(random() * 20.0); radius_damage = 120; damage_radius = 120; if (is_quad) { damage *= 4; radius_damage *= 4; } ent->client->ps.gunframe++; AngleVectors (ent->client->v_angle, forward, right, NULL); 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); if(EMPNukeCheck(ent, start)) { gi.sound (ent, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); } else { if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) ent->client->pers.inventory[ent->client->ammo_index]--; 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); PlayerNoise(ent, start, PNOISE_WEAPON); // play quad damage sound playQuadSound(ent); } }
void monster_fire_bfg (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype) { if(EMPNukeCheck(self, start)) { gi.sound (self, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } ANIM_AIM(self, aimdir); fire_bfg (self, start, aimdir, damage, speed, damage_radius); gi.WriteByte (svc_muzzleflash2); gi.WriteShort (self - g_edicts); gi.WriteByte (flashtype); gi.multicast (start, MULTICAST_PVS); }
void monster_autocannon_fire(edict_t *self) { vec3_t forward, right, start; // fire straight ahead AngleVectors (self->s.angles, forward, right, NULL); if (self->onFloor) VectorNegate(right, right); VectorMA(self->s.origin, 24, forward, start); G_ProjectSource (self->s.origin, fireOffset[self->style], forward, right, start); if(EMPNukeCheck(self, start)) { gi.sound (self, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } // what to fire? switch(self->style) { case 1: default: fire_bullet(self, start, forward, AC_BULLET_DMG, AC_BULLET_KICK, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_AUTOCANNON); gi.WriteByte (svc_muzzleflash); gi.WriteShort (self - g_edicts); gi.WriteByte (MZ_CHAINGUN2); gi.multicast (self->s.origin, MULTICAST_PVS); break; case 2: fire_rocket(self, start, forward, AC_ROCKET_DMG, AC_ROCKET_SPEED, AC_ROCKET_RADIUS_DMG, AC_ROCKET_DMG_RADIUS); gi.WriteByte (svc_muzzleflash); gi.WriteShort (self - g_edicts); gi.WriteByte (MZ_ROCKET); gi.multicast (self->s.origin, MULTICAST_PVS); break; case 3: case 4: fire_blaster (self, start, forward, AC_BLASTER_DMG, AC_BLASTER_SPEED, EF_HYPERBLASTER, true); gi.WriteByte (svc_muzzleflash); gi.WriteShort (self - g_edicts); gi.WriteByte (MZ_HYPERBLASTER); gi.multicast (self->s.origin, MULTICAST_PVS); break; } }
int Blaster_Fire (edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, int effect) { vec3_t forward, right; vec3_t start; vec3_t offset; int ret = 1; 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); VectorScale (forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -1; if(EMPNukeCheck(ent, start)) { gi.sound (ent, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); ret = 0; } else { fire_blaster (ent, start, forward, damage, 1000, effect, hyper); // send muzzle flash gi.WriteByte (svc_muzzleflash); gi.WriteShort (ent-g_edicts); if (hyper) gi.WriteByte (MZ_HYPERBLASTER | is_silenced); else gi.WriteByte (MZ_BLASTER | is_silenced); gi.multicast (ent->s.origin, MULTICAST_PVS); PlayerNoise(ent, start, PNOISE_WEAPON); // play quad damage sound playQuadSound(ent); } return ret; }
void TankMachineGun (edict_t *self) { vec3_t dir; vec3_t vec; vec3_t start; vec3_t forward, right; int flash_number; flash_number = MZ2_TANK_MACHINEGUN_1 + (self->s.frame - FRAME_attak406); AngleVectors (self->s.angles, forward, right, NULL); G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start); if (self->enemy) { VectorCopy (self->enemy->s.origin, vec); vec[2] += self->enemy->viewheight; VectorSubtract (vec, start, vec); vectoangles (vec, vec); dir[0] = vec[0]; } else { dir[0] = 0; } if (self->s.frame <= FRAME_attak415) dir[1] = self->s.angles[1] - 8 * (self->s.frame - FRAME_attak411); else dir[1] = self->s.angles[1] + 8 * (self->s.frame - FRAME_attak419); dir[2] = 0; AngleVectors (dir, forward, NULL, NULL); if(EMPNukeCheck(self, start)) { gi.sound (self, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } monster_fire_bullet (self, start, forward, 20, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flash_number); }
void jorg_firebullet_left (edict_t *self) { vec3_t forward, right, target; vec3_t start; AngleVectors (self->s.angles, forward, right, NULL); G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_JORG_MACHINEGUN_L1], forward, right, start); VectorMA (self->enemy->s.origin, -0.2, self->enemy->velocity, target); target[2] += self->enemy->viewheight; VectorSubtract (target, start, forward); VectorNormalize (forward); if(EMPNukeCheck(self, start)) { gi.sound (self, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } monster_fire_bullet (self, start, forward, 6, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MZ2_JORG_MACHINEGUN_L1); }
void makronBFG (edict_t *self) { vec3_t forward, right; vec3_t start; vec3_t dir; vec3_t vec; AngleVectors (self->s.angles, forward, right, NULL); G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_MAKRON_BFG], forward, right, start); if(EMPNukeCheck(self, start)) { gi.sound (self, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } VectorCopy (self->enemy->s.origin, vec); vec[2] += self->enemy->viewheight; VectorSubtract (vec, start, dir); VectorNormalize (dir); gi.sound (self, CHAN_VOICE, sound_attack_bfg, 1, ATTN_NORM, 0); monster_fire_bfg (self, start, dir, 50, 300, 100, 300, MZ2_MAKRON_BFG); }
void turret_breach_fire (edict_t *self) { vec3_t f, r, u; vec3_t start; int damage; int speed; AngleVectors (self->s.angles, f, r, u); VectorMA (self->s.origin, self->move_origin[0], f, start); VectorMA (start, self->move_origin[1], r, start); VectorMA (start, self->move_origin[2], u, start); if(EMPNukeCheck(self, start)) { gi.sound (self, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } damage = 100 + random() * 50; speed = 550 + 50 * skill->value; fire_rocket (self->teammaster->owner, start, f, damage, speed, 150, damage); gi.positioned_sound (start, self, CHAN_WEAPON, gi.soundindex("weapons/rocklf1a.wav"), 1, ATTN_NORM, 0); }
void weapon_bfg_fire (edict_t *ent) { vec3_t offset, start; vec3_t forward, right; int damage; float damage_radius = 1000; AngleVectors (ent->client->v_angle, forward, right, NULL); VectorScale (forward, -2, ent->client->kick_origin); VectorSet(offset, 8, 8, ent->viewheight-8); P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); if(ent->client->ps.gunframe == 9) { ent->flags &= ~FL_BFGMISSFIRE; } if(!(ent->flags & FL_BFGMISSFIRE) && EMPNukeCheck(ent, start)) { ent->flags |= FL_BFGMISSFIRE; gi.sound (ent, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); } if(ent->flags & FL_BFGMISSFIRE) { ent->client->ps.gunframe++; return; } if (deathmatch->value) damage = 200; else damage = 500; 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); ent->client->ps.gunframe++; PlayerNoise(ent, start, PNOISE_WEAPON); return; } // 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) { ent->client->ps.gunframe++; return; } if (is_quad) damage *= 4; // 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_time = level.time + DAMAGE_TIME; ent->client->ps.gunframe++; if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) ent->client->pers.inventory[ent->client->ammo_index] -= 50; fire_bfg (ent, start, forward, damage, 400, damage_radius); PlayerNoise(ent, start, PNOISE_WEAPON); // play quad damage sound playQuadSound(ent); }
void Chaingun_Fire (edict_t *ent) { int i; int shots; vec3_t start; vec3_t forward, right, up; float r, u; vec3_t offset; int damage; int kick = 2; if (deathmatch->value) damage = 6; else damage = 8; 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)) { 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]) { ent->client->ps.gunframe = 15; } else { ent->client->ps.gunframe++; } 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 { ent->client->weapon_sound = gi.soundindex("weapons/chngnl1a.wav"); } if (ent->client->ps.gunframe <= 9) shots = 1; else if (ent->client->ps.gunframe <= 14) { if (ent->client->buttons & BUTTON_ATTACK) shots = 2; else shots = 1; } 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) { gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0); ent->pain_debounce_time = level.time + 1; } NoAmmoWeaponChange (ent); return; } if (is_quad) { damage *= 4; kick *= 4; } for (i=0 ; i<3 ; i++) { ent->client->kick_origin[i] = crandom() * 0.35; ent->client->kick_angles[i] = crandom() * 0.7; } if(EMPNukeCheck(ent, ent->s.origin)) { gi.sound (ent, CHAN_AUTO, gi.soundindex("items/empnuke/emp_missfire.wav"), 1, ATTN_NORM, 0); return; } if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) ent->client->pers.inventory[ent->client->ammo_index] -= shots; 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); 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); PlayerNoise(ent, start, PNOISE_WEAPON); // play quad damage sound playQuadSound(ent); }