13#include "pilot_cargo.h"
23 int quantity,
unsigned int id );
96 WARN( _(
"Unable to copy cargo over from pilot '%s' to '%s'. Leaving "
114 int quantity,
unsigned int id )
123 WARN(
"Trying to add mission cargo with negative quantity! (q=%d)", q );
188 if ( freespace < quantity ) {
189 quantity = freespace;
190 if ( ( quantity == 0 ) && (
id == 0 ) )
206 for (
int i = 0; i <
array_size( p->commodities ); i++ )
207 q += p->commodities[i].quantity;
220 for (
int i = 0; i <
array_size( p->commodities ); i++ ) {
252 unsigned int id = pilot_genMissionCargoID( pilot );
258unsigned int pilot_genMissionCargoID(
Pilot *pilot )
260 unsigned int id, max_id;
433 double px, py, bvx, bvy;
438 n =
MAX( 1, RNG( (
int)( quantity / 10 ), (
int)( quantity / 5 ) ) );
441 bvx = p->solid.vel.x;
442 bvy = p->solid.vel.y;
443 for (
int i = 0; i < n; i++ ) {
447 double r = RNGF() * 25. - 12.5;
448 double a = 2. * M_PI * RNGF();
449 double vx = bvx + r * cos( a );
450 double vy = bvy + r * sin( a );
453 spfx_add( effect, px, py, vx, vy, SPFX_LAYER_BACK );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void gui_setGeneric(const Pilot *pilot)
Calls trigger functions depending on who the pilot is.
Header file with generic functions and naev-specifics.
int pilot_cargoRmAll(Pilot *pilot, int cleanup)
Gets rid of all cargo from pilot. Can remove mission cargo.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoMove(Pilot *dest, Pilot *src)
Moves cargo from one pilot to another.
int pilot_cargoMoveRaw(Pilot *dest, Pilot *src)
Moves cargo from one pilot to another without any checks.
unsigned int pilot_addMissionCargo(Pilot *pilot, const Commodity *cargo, int quantity)
Adds special mission cargo, can't sell it and such.
int pilot_cargoRm(Pilot *pilot, const Commodity *cargo, int quantity)
Tries to get rid of quantity cargo from pilot.
static int pilot_cargoAddInternal(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Adds cargo to the pilot's "commodities" array only.
int pilot_cargoRmRaw(Pilot *pilot, const Commodity *cargo, int quantity, int cleanup)
Tries to get rid of quantity cargo from pilot. Can remove mission cargo.
int pilot_cargoOwned(const Pilot *pilot, const Commodity *cargo)
Gets how many of the commodity a pilot has.
int pilot_cargoJet(Pilot *p, const Commodity *cargo, int quantity, int simulate)
Tries to get rid of quantity cargo from pilot, jetting it into space.
int pilot_cargoUsedMission(const Pilot *p)
Gets how much mission cargo ship has on board.
int pilot_rmMissionCargo(Pilot *pilot, unsigned int cargo_id, int jettison)
Removes special mission cargo based on id.
static unsigned int mission_cargo_id
int pilot_cargoAdd(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Tries to add quantity of cargo to pilot.
int pilot_cargoUsed(const Pilot *p)
Gets how much cargo ship has on board.
int pilot_cargoAddRaw(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Adds cargo without checking the pilot's free space.
void pilot_cargoCalc(Pilot *pilot)
Calculates how much cargo ship has left and such.
void pilot_updateMass(Pilot *pilot)
Updates the pilot stats after mass change.
int spfx_get(const char *name)
Gets the id of an spfx based on name.
void spfx_add(int effect, const double px, const double py, const double vx, const double vy, int layer)
Creates a new special effect.
Stores a pilot commodity.
const Commodity * commodity
The representation of an in-game pilot.
PilotCommodity * commodities