Esempio n. 1
0
/**
 * @brief Have pilot stop shooting his weapon.
 *
 * Only really deals with beam weapons.
 *
 *    @param p Pilot that was shooting.
 *    @param level Level of the shot.
 */
void pilot_shootStop( Pilot* p, int level )
{
   int i;
   PilotWeaponSet *ws;

   /* Get active set. */
   ws = pilot_weapSet( p, p->active_set );

   /* Case no outfits. */
   if (ws->slots == NULL)
      return;

   /* Stop all beams. */
   for (i=0; i<array_size(ws->slots); i++) {

      /* Must have assosciated outfit. */
      if (ws->slots[i].slot->outfit == NULL)
         continue;

      /* Must match level. */
      if ((level != -1) && (ws->slots[i].level != level))
         continue;

      /* Only handle beams. */
      if (!outfit_isBeam(ws->slots[i].slot->outfit))
         continue;
      
      /* Stop beam. */
      if (ws->slots[i].slot->u.beamid > 0) {
         beam_end( p->id, ws->slots[i].slot->u.beamid );
         ws->slots[i].slot->u.beamid = 0;
      }
   }
}
Esempio n. 2
0
void TestMappingUpdate(std::ostream& output)
{
	sensor_msgs::LaserScan test_scan;
	test_scan.angle_min = angles::from_degrees(-90.0);
	test_scan.angle_max = angles::from_degrees(+90.0);
	test_scan.angle_increment = angles::from_degrees(45.0);
	test_scan.range_min = 1.7;
	test_scan.range_max = 5.5;
	for(double angle = test_scan.angle_min; angle <= test_scan.angle_max; angle += test_scan.angle_increment)
	{
		test_scan.ranges.push_back(4.5);
	}
	
	tf::Vector3 loc(-5.0, 0.0, 0.0);
	tf::Quaternion rot;
	rot.setRPY(0.0, 0.0, angles::from_degrees(-90.0));
	tf::Transform robot(rot, loc);
	
	OccupancyGrid test_grid(12, 12, 1.0, 0.0, 0.0);
	_mappingUpdate(test_grid, test_scan, robot);
	
	tf::Vector3 beam_start(0.0, 0.0, 0.0);
	tf::Vector3 beam_end(0.0, 6.0, 0.0);
	_mapUpdateBeamHit(test_grid, beam_start, beam_end);
	
	output << test_grid;
}
Esempio n. 3
0
/**
 * @brief Have pilot stop shooting their weapon.
 *
 * Only really deals with beam weapons.
 *
 *    @param p Pilot that was shooting.
 *    @param level Level of the shot.
 */
void pilot_shootStop( Pilot* p, int level )
{
   int i, recalc;
   PilotWeaponSet *ws;
   PilotOutfitSlot *slot;

   /* Get active set. */
   ws = pilot_weapSet( p, p->active_set );

   /* Case no outfits. */
   if (ws->slots == NULL)
      return;

   /* Stop all beams. */
   recalc = 0;
   for (i=0; i<array_size(ws->slots); i++) {
      slot = ws->slots[i].slot;

      /* Must have associated outfit. */
      if (ws->slots[i].slot->outfit == NULL)
         continue;

      /* Must match level. */
      if ((level != -1) && (ws->slots[i].level != level))
         continue;

      /* Only handle beams. */
      if (!outfit_isBeam(slot->outfit)) {
         /* Turn off the state. */
         if (outfit_isMod( slot->outfit )) {
            slot->state = PILOT_OUTFIT_OFF;
            recalc = 1;
         }
         continue;
      }

      /* Stop beam. */
      if (ws->slots[i].slot->u.beamid > 0) {
         /* Enforce minimum duration if set. */
         if (slot->outfit->u.bem.min_duration > 0.) {

            slot->stimer = slot->outfit->u.bem.min_duration -
                  (slot->outfit->u.bem.duration - slot->timer);

            if (slot->stimer > 0.)
               continue;
         }

         beam_end( p->id, slot->u.beamid );
         pilot_stopBeam(p, slot);
      }
   }

   /* Must recalculate. */
   if (recalc)
      pilot_calcStats( p );
}