/*
===============
FireWeapon
===============
*/
void FireWeapon( gentity_t *ent )
{
  if( ent->client )
  {
    // set aiming directions
    AngleVectors( ent->client->ps.viewangles, forward, right, up );
    CalcMuzzlePoint( ent, forward, right, up, muzzle );
  }
  else
  {
    AngleVectors( ent->turretAim, forward, right, up );
    VectorCopy( ent->s.pos.trBase, muzzle );
  }

  // fire the specific weapon
  switch( ent->s.weapon )
  {
    case WP_ALEVEL1:
    case WP_ALEVEL1_UPG:
      meleeAttack( ent, LEVEL1_CLAW_RANGE, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_DMG, MOD_LEVEL1_CLAW );
      break;
    case WP_ALEVEL3:
    case WP_ALEVEL3_UPG:
      meleeAttack( ent, LEVEL3_CLAW_RANGE, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_DMG, MOD_LEVEL3_CLAW );
      break;
    case WP_ALEVEL2:
      meleeAttack( ent, LEVEL2_CLAW_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW );
      break;
    case WP_ALEVEL2_UPG:
      meleeAttack( ent, LEVEL2_CLAW_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW );
      break;
    case WP_ALEVEL4:
      meleeAttack( ent, LEVEL4_CLAW_RANGE, LEVEL4_CLAW_WIDTH, LEVEL4_CLAW_DMG, MOD_LEVEL4_CLAW );
      break;

    case WP_BLASTER:
      blasterFire( ent );
      break;
    case WP_MACHINEGUN:
      bulletFire( ent, RIFLE_SPREAD, RIFLE_DMG, MOD_MACHINEGUN );
      break;
    case WP_SHOTGUN:
      shotgunFire( ent );
      break;
    case WP_CHAINGUN:
      bulletFire( ent, CHAINGUN_SPREAD, CHAINGUN_DMG, MOD_CHAINGUN );
      break;
    case WP_FLAMER:
      flamerFire( ent );
      break;
    case WP_PULSE_RIFLE:
      pulseRifleFire( ent );
      break;
    case WP_MASS_DRIVER:
      massDriverFire( ent );
      break;
    case WP_LUCIFER_CANNON:
      LCChargeFire( ent, qfalse );
      break;
    case WP_LAS_GUN:
      lasGunFire( ent );
      break;
    case WP_PAIN_SAW:
      painSawFire( ent );
      break;
    case WP_GRENADE:
			if(ent->client->pers.grenades >= 4)
			{
				ent->client->ps.persistant[ PERS_CREDIT ] += GRENADE_PRICE;
				trap_SendServerCommand( ent-g_entities, va(
        "print \"^1You have dropped 4 grenades allready, please detonate(Right click Blaster) them in order to drop more.\n\"" ) );
			}
			else
			{
				ent->client->pers.grenades += 1;
				throwGrenade( ent );
			}
      break;

    case WP_LOCKBLOB_LAUNCHER:
      lockBlobLauncherFire( ent );
      break;
    case WP_HIVE:
      hiveFire( ent );
      break;
    case WP_TESLAGEN:
      teslaFire( ent );
      break;
    case WP_MGTURRET:
      bulletFire( ent, MGTURRET_SPREAD, MGTURRET_DMG, MOD_MGTURRET );
      break;

    case WP_ABUILD:
    case WP_ABUILD2:
      buildFire( ent, MN_A_BUILD );
      break;
    case WP_HBUILD:
    case WP_HBUILD2:
      buildFire( ent, MN_H_BUILD );
      break;
    default:
      break;
  }
}
Example #2
0
/*
===============
FireWeapon
===============
*/
void FireWeapon( gentity_t *ent )
{
	if ( ent->client )
	{
		// set aiming directions
		AngleVectors( ent->client->ps.viewangles, forward, right, up );
		CalcMuzzlePoint( ent, forward, right, up, muzzle );
	}
	else
	{
		AngleVectors( ent->turretAim, forward, right, up );
		VectorCopy( ent->s.pos.trBase, muzzle );
	}

	// fire the specific weapon
	switch ( ent->s.weapon )
	{
		case WP_ALEVEL1:
			meleeAttack( ent, LEVEL1_CLAW_RANGE, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_WIDTH,
			             LEVEL1_CLAW_DMG, MOD_LEVEL1_CLAW );
			break;

		case WP_ALEVEL1_UPG:
			meleeAttack( ent, LEVEL1_CLAW_U_RANGE, LEVEL1_CLAW_WIDTH, LEVEL1_CLAW_WIDTH,
			             LEVEL1_CLAW_DMG, MOD_LEVEL1_CLAW );
			break;

		case WP_ALEVEL3:
			meleeAttack( ent, LEVEL3_CLAW_RANGE, LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_WIDTH,
			             LEVEL3_CLAW_DMG, MOD_LEVEL3_CLAW );
			break;

		case WP_ALEVEL3_UPG:
			meleeAttack( ent, LEVEL3_CLAW_UPG_RANGE, LEVEL3_CLAW_WIDTH,
			             LEVEL3_CLAW_WIDTH, LEVEL3_CLAW_DMG, MOD_LEVEL3_CLAW );
			break;

		case WP_ALEVEL2:
			meleeAttack( ent, LEVEL2_CLAW_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_WIDTH,
			             LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW );
			break;

		case WP_ALEVEL2_UPG:
			meleeAttack( ent, LEVEL2_CLAW_U_RANGE, LEVEL2_CLAW_WIDTH, LEVEL2_CLAW_WIDTH,
			             LEVEL2_CLAW_DMG, MOD_LEVEL2_CLAW );
			break;

		case WP_ALEVEL4:
			meleeAttack( ent, LEVEL4_CLAW_RANGE, LEVEL4_CLAW_WIDTH,
			             LEVEL4_CLAW_HEIGHT, LEVEL4_CLAW_DMG, MOD_LEVEL4_CLAW );
			break;

		case WP_BLASTER:
			blasterFire( ent );
			break;

		case WP_MACHINEGUN:
			bulletFire( ent, RIFLE_SPREAD, RIFLE_DMG, MOD_MACHINEGUN );
			break;

		case WP_SHOTGUN:
			shotgunFire( ent );
			break;

		case WP_CHAINGUN:
			bulletFire( ent, CHAINGUN_SPREAD, CHAINGUN_DMG, MOD_CHAINGUN );
			break;

		case WP_FLAMER:
			flamerFire( ent );
			break;

		case WP_PULSE_RIFLE:
			pulseRifleFire( ent );
			break;

		case WP_MASS_DRIVER:
			massDriverFire( ent );
			break;

		case WP_LUCIFER_CANNON:
			LCChargeFire( ent, qfalse );
			break;

		case WP_LAS_GUN:
			lasGunFire( ent );
			break;

		case WP_PAIN_SAW:
			painSawFire( ent );
			break;

		case WP_GRENADE:
			throwGrenade( ent );
			break;

		case WP_LOCKBLOB_LAUNCHER:
			lockBlobLauncherFire( ent );
			break;

		case WP_HIVE:
			hiveFire( ent );
			break;

		case WP_TESLAGEN:
			teslaFire( ent );
			break;

		case WP_MGTURRET:
			bulletFire( ent, MGTURRET_SPREAD, MGTURRET_DMG, MOD_MGTURRET );
			break;

		case WP_ABUILD:
		case WP_ABUILD2:
			buildFire( ent, MN_A_BUILD );
			break;

		case WP_HBUILD:
			buildFire( ent, MN_H_BUILD );
			break;

		default:
			break;
	}
}
Example #3
0
/*
===============
FireWeapon2
===============
*/
void FireWeapon2( gentity_t *ent )
{
  if( ent->client )
  {
    // set aiming directions
    AngleVectors( ent->client->ps.viewangles, forward, right, up );
    CalcMuzzlePoint( ent, forward, right, up, muzzle );
  }
  else
  {
    AngleVectors( ent->s.angles2, forward, right, up );
    VectorCopy( ent->s.pos.trBase, muzzle );
  }

  // fire the specific weapon
  switch( ent->s.weapon )
  {

    case WP_ALEVEL0:
      meleeAttack( ent, LEVEL0_SCRATCH_RANGE, 2, LEVEL0_SCRATCH_DMG, MOD_LEVEL0_BITE );
      break;
    case WP_ALEVEL1_UPG:
      poisonCloud( ent );
      break;
    case WP_ALEVEL2_UPG:
      areaZapFire( ent );
      break;

    case WP_LUCIFER_CANNON:
      LCChargeFire( ent, qtrue );
      break;

//standard weapons w/o secondary just use melee
//dictionary:
//meleeAttack( ent, [range], [width], [damage], MOD_[means of death] );
//note: keep width 20 for humans otherwise it will not hit the target in vents.
    case WP_BLASTER:
      meleeAttack( ent, BLASTER_MELEE_RANGE, 20, BLASTER_MELEE, MOD_BLASTER );
      break;
    case WP_SHOTGUN:
      meleeAttack( ent, SHOTGUN_BLAST_RANGE, 20, SHOTGUN_BLAST, MOD_SHOTGUN ); //acts like a forward explosion
      break;
    case WP_PULSE_RIFLE:
      lasGunFire( ent, LASGUN_SPREAD*2 );
      break;

    case WP_CHAINGUN:
      bulletFire( ent, CHAINGUN_SPREAD, CHAINGUN_DMG, MOD_CHAINGUN );
      break;

    case WP_LOCKBLOB_LAUNCHER:
      throwGrenade( ent );
      break;

    case WP_MGTURRET:
      shotgunFire( ent );
      shotgunFire( ent );
      shotgunFire( ent );
      break;

    case WP_ABUILD:
    case WP_ABUILD2:
    case WP_HBUILD:
    case WP_HBUILD2:
      cancelBuildFire( ent );
      break;
    default:
      break;
  }
}