Exemplo n.º 1
0
Arquivo: board.c Projeto: pegue/naev
/**
 * @brief Checks to see if the pilot can steal from it's target.
 *
 *    @param p Pilot stealing from it's target.
 *    @return 0 if successful, 1 if fails, -1 if fails and kills target.
 */
static int board_trySteal( Pilot *p )
{
   Pilot *target;

   /* Get the target. */
   target = pilot_get(p->target);
   if (target == NULL)
      return 1;

   /* See if was successful. */
   if (RNGF() > (0.5 * 
            (10. + (double)target->ship->crew)/(10. + (double)p->ship->crew)))
      return 0;

   /* Triggered self destruct. */
   if (RNGF() < 0.4) {
      /* Don't actually kill. */
      target->armour = 1.;
      /* This will make the boarding ship take the possible faction hit. */
      pilot_hit( target, NULL, p->id, DAMAGE_TYPE_KINETIC, 100. );
      /* Return ship dead. */
      return -1;
   }

   return 1;
}
Exemplo n.º 2
0
Arquivo: weapon.c Projeto: zid/naev
/**
 * @brief Weapon hit the pilot.
 *
 *    @param w Weapon involved in the collision.
 *    @param p Pilot that got hit.
 *    @param layer Layer to which the weapon belongs.
 *    @param pos Position of the hit.
 */
static void weapon_hit( Weapon* w, Pilot* p, WeaponLayer layer, Vector2d* pos )
{
   Pilot *parent;
   int spfx;
   double damage;
   DamageType dtype;
   WeaponLayer spfx_layer;
   int s;

   /* Get general details. */
   parent = pilot_get(w->parent);
   damage = w->strength * outfit_damage(w->outfit);
   dtype  = outfit_damageType(w->outfit);

   /* Play sound if they have it. */
   s = outfit_soundHit(w->outfit);
   if (s != -1)
      w->voice = sound_playPos( s,
            w->solid->pos.x,
            w->solid->pos.y,
            w->solid->vel.x,
            w->solid->vel.y);

   /* Have pilot take damage and get real damage done. */
   damage = pilot_hit( p, w->solid, w->parent, dtype, damage );

   /* Get the layer. */
   spfx_layer = (p==player) ? SPFX_LAYER_FRONT : SPFX_LAYER_BACK;
   /* Choose spfx. */
   if (p->shield > 0.)
      spfx = outfit_spfxShield(w->outfit);
   else
      spfx = outfit_spfxArmour(w->outfit);
   /* Add sprite, layer depends on whether player shot or not. */
   spfx_add( spfx, pos->x, pos->y,
         VX(p->solid->vel), VY(p->solid->vel), spfx_layer );

   /* Inform AI that it's been hit. */
   weapon_hitAI( p, parent, damage );

   /* no need for the weapon particle anymore */
   weapon_destroy(w,layer);
}
Exemplo n.º 3
0
Arquivo: weapon.c Projeto: zid/naev
/**
 * @brief Weapon hit the pilot.
 *
 *    @param w Weapon involved in the collision.
 *    @param p Pilot that got hit.
 *    @param layer Layer to which the weapon belongs.
 *    @param pos Position of the hit.
 *    @param dt Current delta tick.
 */
static void weapon_hitBeam( Weapon* w, Pilot* p, WeaponLayer layer,
      Vector2d pos[2], const double dt )
{
   (void) layer;
   Pilot *parent;
   int spfx;
   double damage;
   DamageType dtype;
   WeaponLayer spfx_layer;

   /* Get general details. */
   parent = pilot_get(w->parent);
   damage = outfit_damage(w->outfit) * dt;
   dtype  = outfit_damageType(w->outfit);

   /* Have pilot take damage and get real damage done. */
   damage = pilot_hit( p, w->solid, w->parent, dtype, damage );

   /* Add sprite, layer depends on whether player shot or not. */
   if (w->lockon == -1.) {
      /* Get the layer. */
      spfx_layer = (p==player) ? SPFX_LAYER_FRONT : SPFX_LAYER_BACK;

      /* Choose spfx. */
      if (p->shield > 0.)
         spfx = outfit_spfxShield(w->outfit);
      else
         spfx = outfit_spfxArmour(w->outfit);

      /* Add graphic. */
      spfx_add( spfx, pos[0].x, pos[0].y,
            VX(p->solid->vel), VY(p->solid->vel), spfx_layer );
      spfx_add( spfx, pos[1].x, pos[1].y,
            VX(p->solid->vel), VY(p->solid->vel), spfx_layer );
         w->lockon = -2;
   }

   /* Inform AI that it's been hit. */
   weapon_hitAI( p, parent, damage );
}