![]() |
naev 0.10.4
|
Handles all the weapons in game. More...
#include "weapon.h"#include "array.h"#include "ai.h"#include "camera.h"#include "collision.h"#include "explosion.h"#include "gui.h"#include "log.h"#include "nstring.h"#include "nlua_pilot.h"#include "nlua_vec2.h"#include "opengl.h"#include "pilot.h"#include "player.h"#include "rng.h"#include "spfx.h"Go to the source code of this file.
Data Structures | |
| struct | Weapon |
| In-game representation of a weapon. More... | |
Macros | |
| #define | weapon_isSmart(w) (w->think != NULL) |
| #define | WEAPON_FLAG_DESTROYED 1 |
| #define | weapon_isFlag(w, f) ((w)->flags & (f)) |
| #define | weapon_setFlag(w, f) ((w)->flags |= (f)) |
| #define | weapon_rmFlag(w, f) ((w)->flags &= ~(f)) |
Enumerations | |
| enum | WeaponStatus { WEAPON_STATUS_LOCKING , WEAPON_STATUS_OK , WEAPON_STATUS_UNJAMMED , WEAPON_STATUS_JAMMED , WEAPON_STATUS_JAMMED_SLOWED } |
Functions | |
| static double | weapon_aimTurret (const Outfit *outfit, const Pilot *parent, const Pilot *pilot_target, const vec2 *pos, const vec2 *vel, double dir, double swivel, double time) |
| Gets the aim position of a turret weapon. More... | |
| static void | weapon_createBolt (Weapon *w, const Outfit *outfit, double T, const double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, double time, int aim) |
| Creates the bolt specific properties of a weapon. More... | |
| static void | weapon_createAmmo (Weapon *w, const Outfit *outfit, double T, const double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, double time, int aim) |
| Creates the ammo specific properties of a weapon. More... | |
| static Weapon * | weapon_create (PilotOutfitSlot *po, double T, const double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, const unsigned int target, double time, int aim) |
| Creates a new weapon. More... | |
| static double | weapon_computeTimes (double rdir, double rx, double ry, double dvx, double dvy, double pxv, double vmin, double acc, double *tt) |
| Computes precisely interception times for propelled weapons (rockets). More... | |
| static void | weapon_render (Weapon *w, const double dt) |
| Renders an individual weapon. More... | |
| static void | weapons_updateLayer (const double dt, const WeaponLayer layer) |
| Updates all the weapons in the layer. More... | |
| static void | weapon_update (Weapon *w, const double dt, WeaponLayer layer) |
| Updates an individual weapon. More... | |
| static void | weapon_sample_trail (Weapon *w) |
| Updates the animated trail for a weapon. More... | |
| static void | weapon_destroy (Weapon *w) |
| Destroys a weapon. More... | |
| static void | weapon_free (Weapon *w) |
| Frees the weapon. More... | |
| static void | weapon_explodeLayer (WeaponLayer layer, double x, double y, double radius, const Pilot *parent, int mode) |
| Explodes all the things on a layer. More... | |
| static void | weapons_purgeLayer (Weapon **layer) |
| Purges weapons marked for deletion. More... | |
| static int | weapon_checkCanHit (const Weapon *w, const Pilot *p) |
| Checks to see if the weapon can hit the pilot. More... | |
| static void | weapon_hit (Weapon *w, Pilot *p, vec2 *pos) |
| Weapon hit the pilot. More... | |
| static void | weapon_miss (Weapon *w) |
| Weapon missed and is due to be destroyed. More... | |
| static void | weapon_hitAst (Weapon *w, Asteroid *a, WeaponLayer layer, vec2 *pos) |
| Weapon hit an asteroid. More... | |
| static void | weapon_hitBeam (Weapon *w, Pilot *p, WeaponLayer layer, vec2 pos[2], const double dt) |
| Weapon hit the pilot. More... | |
| static void | weapon_hitAstBeam (Weapon *w, Asteroid *a, WeaponLayer layer, vec2 pos[2], const double dt) |
| Weapon hit an asteroid. More... | |
| static void | think_seeker (Weapon *w, const double dt) |
| The AI of seeker missiles. More... | |
| static void | think_beam (Weapon *w, const double dt) |
| The pseudo-ai of the beam weapons. More... | |
| void | weapon_minimap (const double res, const double w, const double h, const RadarShape shape, double alpha) |
| Draws the minimap weapons (used in player.c). More... | |
| static void | weapon_setThrust (Weapon *w, double thrust) |
| Sets the weapon's thrust. More... | |
| static void | weapon_setTurn (Weapon *w, double turn) |
| Sets the weapon's turn. More... | |
| void | weapon_init (void) |
| Initializes the weapon stuff. More... | |
| void | weapons_update (const double dt) |
| Updates all the weapon layers. More... | |
| void | weapons_render (const WeaponLayer layer, const double dt) |
| Renders all the weapons in a layer. More... | |
| static void | weapon_renderBeam (Weapon *w, const double dt) |
| void | weapon_hitAI (Pilot *p, const Pilot *shooter, double dmg) |
| Informs the AI if needed that it's been hit. More... | |
| void | weapon_add (PilotOutfitSlot *po, const double T, const double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, unsigned int target, double time, int aim) |
| Creates a new weapon. More... | |
| unsigned int | beam_start (PilotOutfitSlot *po, const double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, const unsigned int target, int aim) |
| Starts a beam weapon. More... | |
| void | beam_end (const unsigned int parent, unsigned int beam) |
| Ends a beam weapon. More... | |
| void | weapon_clear (void) |
| Clears all the weapons, does NOT free the layers. More... | |
| void | weapon_exit (void) |
| Destroys all the weapons and frees it all. More... | |
| void | weapon_explode (double x, double y, double radius, int dtype, double damage, const Pilot *parent, int mode) |
| Clears possible exploded weapons. More... | |
Variables | |
| static Weapon ** | wbackLayer = NULL |
| static Weapon ** | wfrontLayer = NULL |
| static gl_vbo * | weapon_vbo = NULL |
| static GLfloat * | weapon_vboData = NULL |
| static size_t | weapon_vboSize = 0 |
| static unsigned int | beam_idgen = 0 |
Handles all the weapons in game.
Weapons are what gets created when a pilot shoots. They are based on the outfit that created them.
Definition in file weapon.c.
| #define weapon_isSmart | ( | w | ) | (w->think != NULL) |
| enum WeaponStatus |
| void beam_end | ( | const unsigned int | parent, |
| unsigned int | beam | ||
| ) |
| unsigned int beam_start | ( | PilotOutfitSlot * | po, |
| const double | dir, | ||
| const vec2 * | pos, | ||
| const vec2 * | vel, | ||
| const Pilot * | parent, | ||
| const unsigned int | target, | ||
| int | aim | ||
| ) |
Starts a beam weapon.
| po | Outfit slot which spawns the weapon. |
| dir | Direction of the shooter. |
| pos | Position of the slot (absolute). |
| vel | Velocity of the slot (absolute). |
| parent | Pilot shooter. |
| target | Target ID that is getting shot. |
| aim | Whether or not to aim. |
|
static |
|
static |
| void weapon_add | ( | PilotOutfitSlot * | po, |
| const double | T, | ||
| const double | dir, | ||
| const vec2 * | pos, | ||
| const vec2 * | vel, | ||
| const Pilot * | parent, | ||
| unsigned int | target, | ||
| double | time, | ||
| int | aim | ||
| ) |
Creates a new weapon.
| po | Outfit slot which spawns the weapon. |
| T | Temperature of the shooter. |
| dir | Direction of the shooter. |
| pos | Position of the slot (absolute). |
| vel | Velocity of the slot (absolute). |
| parent | Pilot ID of the shooter. |
| target | Target ID that is getting shot. |
| time | Expected flight time. |
| aim | Whether or not to aim. |
|
static |
Gets the aim position of a turret weapon.
| outfit | Weapon outfit. |
| parent | Parent of the weapon. |
| pilot_target | Target of the weapon. |
| pos | Position of the turret. |
| vel | Velocity of the turret. |
| dir | Direction facing parent ship and turret. |
| time | Expected flight time. |
| swivel | Maximum angle between weapon and straight ahead. |
| void weapon_clear | ( | void | ) |
|
static |
Computes precisely interception times for propelled weapons (rockets).
| rdir | tried shooting angle. | |
| rx | Relative position x. | |
| ry | Relative position y. | |
| dvx | Relative velocity x. | |
| dvy | Relative velocity y. | |
| pxv | Cross product between relative position and relative velocity | |
| vmin | min ammo velocity. | |
| acc | ammo acceleration. | |
| [out] | tt | Time for the target to reach the interception point. |
|
static |
Creates a new weapon.
| po | Outfit slot which spawned the weapon. |
| T | temperature of the shooter. |
| dir | Direction the shooter is facing. |
| pos | Position of the slot (absolute). |
| vel | Velocity of the slot (absolute). |
| parent | Shooter. |
| target | Target ID of the shooter. |
| time | Expected flight time. |
| aim | Whether or not to aim. |
< Needs a mass.
|
static |
Creates the ammo specific properties of a weapon.
| w | Weapon to create ammo specific properties of. |
| outfit | Outfit which spawned the weapon. |
| T | temperature of the shooter. |
| dir | Direction the shooter is facing. |
| pos | Position of the slot (absolute). |
| vel | Velocity of the slot (absolute). |
| parent | Shooter. |
| time | Expected flight time. |
| aim | Whether or not to aim. |
|
static |
Creates the bolt specific properties of a weapon.
| w | Weapon to create bolt specific properties of. |
| outfit | Outfit which spawned the weapon. |
| T | temperature of the shooter. |
| dir | Direction the shooter is facing. |
| pos | Position of the slot (absolute). |
| vel | Velocity of the slot (absolute). |
| parent | Shooter. |
| time | Expected flight time. |
| aim | Whether or not to aim. |
|
static |
| void weapon_exit | ( | void | ) |
| void weapon_explode | ( | double | x, |
| double | y, | ||
| double | radius, | ||
| int | dtype, | ||
| double | damage, | ||
| const Pilot * | parent, | ||
| int | mode | ||
| ) |
|
static |
|
static |
| void weapon_minimap | ( | const double | res, |
| const double | w, | ||
| const double | h, | ||
| const RadarShape | shape, | ||
| double | alpha | ||
| ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void weapons_render | ( | const WeaponLayer | layer, |
| const double | dt | ||
| ) |
| void weapons_update | ( | const double | dt | ) |
|
static |
|
static |