コード例 #1
0
ファイル: g_weapon.c プロジェクト: bmorel/Unvanquished
/*
===============
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;
	}
}
コード例 #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:
    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;
  }
}