![]() |
naev 0.11.5
|
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 "nlua_outfit.h"#include "opengl.h"#include "pilot.h"#include "player.h"#include "rng.h"#include "spfx.h"#include "intlist.h"Go to the source code of this file.
Data Structures | |
| struct | WeaponCollision |
| Struct useful for generalization of weapno collisions. More... | |
| struct | WeaponHit |
| Represents a weapon hitting something. More... | |
Macros | |
| #define | QUADRATURE(ref, v) |
Functions | |
| static void | weapon_updateVBO (void) |
| Checks to see if we have to update the VBO size. | |
| static double | weapon_aimTurretAngle (const Outfit *outfit, const Pilot *parent, const Target *target, const vec2 *pos, const vec2 *vel, double dir, double time) |
| Gets the aim direction of a turret weapon. | |
| static double | weapon_aimTurret (const Outfit *outfit, const Pilot *parent, const Target *target, const vec2 *pos, const vec2 *vel, double dir, double time) |
| Gets the aim position of a turret weapon. | |
| static double | weapon_aimTurretStatic (const vec2 *target_pos, const vec2 *pos, double dir, double swivel) |
| Gets the aim position of a turret weapon. | |
| static void | weapon_createBolt (Weapon *w, const Outfit *outfit, double T, double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, double time, int aim) |
| Creates the bolt specific properties of a weapon. | |
| static void | weapon_createAmmo (Weapon *w, const Outfit *outfit, double T, double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, double time, int aim) |
| Creates the ammo specific properties of a weapon. | |
| static int | weapon_create (Weapon *w, PilotOutfitSlot *po, const Outfit *ref, double T, double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, const Target *target, double time, int aim) |
| Creates a new weapon. | |
| 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). | |
| static void | weapon_render (Weapon *w, double dt) |
| Renders an individual weapon. | |
| static void | weapon_updateCollide (Weapon *w, double dt) |
| Updates an individual weapon. | |
| static void | weapon_update (Weapon *w, double dt) |
| Updates an individual weapon. | |
| static void | weapon_sample_trail (Weapon *w) |
| Updates the animated trail for a weapon. | |
| static void | weapon_destroy (Weapon *w) |
| Destroys a weapon. | |
| static void | weapon_free (Weapon *w) |
| Frees the weapon. | |
| static int | weapon_checkCanHit (const Weapon *w, const Pilot *p) |
| Checks to see if the weapon can hit the pilot. | |
| static void | weapon_damage (Weapon *w, const Damage *dmg) |
| Applies damage to a weapon. | |
| static void | weapon_hit (Weapon *w, const WeaponHit *hit) |
| A bolt/launcher weapon hit something. | |
| static void | weapon_hitBeam (Weapon *w, const WeaponHit *hit, double dt) |
| A beam weapon hit something. | |
| static void | weapon_miss (Weapon *w) |
| Weapon missed and is due to be destroyed. | |
| static int | weapon_testCollision (const WeaponCollision *wc, const glTexture *ctex, int csx, int csy, const Solid *csol, const CollPoly *cpol, double cradius, vec2 crash[2]) |
| Tests to see if a weapon collides with a ship. | |
| static void | think_seeker (Weapon *w, double dt) |
| The AI of seeker missiles. | |
| static void | think_beam (Weapon *w, double dt) |
| The pseudo-ai of the beam weapons. | |
| void | weapon_minimap (double res, double w, double h, const RadarShape shape, double alpha) |
| Draws the minimap weapons (used in player.c). | |
| static void | weapon_setAccel (Weapon *w, double accel) |
| Sets the weapon's accel. | |
| static void | weapon_setTurn (Weapon *w, double turn) |
| Sets the weapon's turn. | |
| void | weapon_init (void) |
| Initializes the weapon stuff. | |
| Weapon * | weapon_getStack (void) |
| Gets the weapon stack. Do not manipulate directly. | |
| static int | weapon_cmp (const void *ptr1, const void *ptr2) |
| Compare id (for use with bsearch) | |
| Weapon * | weapon_getID (unsigned int id) |
| Gets a weapon by ID. | |
| void | weapon_newSystem (void) |
| Sets up collision stuff for a new system. | |
| void | weapons_updatePurge (void) |
| Purges unnecessary weapons. | |
| void | weapons_updateCollide (double dt) |
| Handles weapon collisions. | |
| void | weapons_update (double dt) |
| Updates all the weapons. | |
| void | weapons_render (const WeaponLayer layer, double dt) |
| Renders all the weapons in a layer. | |
| static void | weapon_renderBeam (Weapon *w, double dt) |
| void | weapon_hitAI (Pilot *p, const Pilot *shooter, double dmg) |
| Informs the AI if needed that it's been hit. | |
| static void | weapon_hitExplode (Weapon *w, const Damage *dmg, double radius) |
| A weapon hit something and decided to explode. | |
| int | weapon_inArc (const Outfit *o, const Pilot *parent, const Target *target, const vec2 *pos, const vec2 *vel, double dir, double time) |
| Gets the aim position of a turret weapon. | |
| Weapon * | weapon_add (PilotOutfitSlot *po, const Outfit *ref, double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, const Target *target, double time, int aim) |
| Creates a new weapon. | |
| double | weapon_targetFlyTime (const Outfit *o, const Pilot *p, const Target *t) |
| Gets the fly time for a weapon target. | |
| unsigned int | beam_start (PilotOutfitSlot *po, double dir, const vec2 *pos, const vec2 *vel, const Pilot *parent, const Target *target, int aim) |
| Starts a beam weapon. | |
| void | beam_end (unsigned int beam) |
| Ends a beam weapon. | |
| void | weapon_clear (void) |
| Clears all the weapons, does NOT free the layers. | |
| void | weapon_exit (void) |
| Destroys all the weapons and frees it all. | |
| const IntList * | weapon_collideQuery (int x1, int y1, int x2, int y2) |
| void | weapon_collideQueryIL (IntList *il, int x1, int y1, int x2, int y2) |
Variables | |
| static Weapon * | weapon_stack = NULL |
| static gl_vbo * | weapon_vbo = NULL |
| static GLfloat * | weapon_vboData = NULL |
| static size_t | weapon_vboSize = 0 |
| static unsigned int | weapon_idgen = 0 |
| static int | qt_init = 0 |
| static Quadtree | weapon_quadtree |
| static IntList | weapon_qtquery |
| static IntList | weapon_qtexp |
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 QUADRATURE | ( | ref, | |
| v ) |
| void beam_end | ( | unsigned int | beam | ) |
| unsigned int beam_start | ( | PilotOutfitSlot * | po, |
| double | dir, | ||
| const vec2 * | pos, | ||
| const vec2 * | vel, | ||
| const Pilot * | parent, | ||
| const Target * | 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 that is getting shot. |
| aim | Whether or not to aim. |
|
static |
|
static |
| Weapon * weapon_add | ( | PilotOutfitSlot * | po, |
| const Outfit * | ref, | ||
| double | dir, | ||
| const vec2 * | pos, | ||
| const vec2 * | vel, | ||
| const Pilot * | parent, | ||
| const Target * | target, | ||
| double | time, | ||
| int | aim ) |
Creates a new weapon.
| po | Outfit slot which spawns the weapon. |
| ref | Reference outfit to use for computing damage and properties. |
| 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 |
| void weapon_clear | ( | void | ) |
|
static |
| const IntList * weapon_collideQuery | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2 ) |
| void weapon_collideQueryIL | ( | IntList * | il, |
| int | x1, | ||
| int | y1, | ||
| int | x2, | ||
| int | y2 ) |
|
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.
| w | Weapon to create. |
| po | Outfit slot which spawned the weapon. |
| ref | Reference outfit to use, does not have to be the outfit in the slot, but will default to it if set to NULL. |
| 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 | ) |
|
static |
| Weapon * weapon_getID | ( | unsigned int | id | ) |
| Weapon * weapon_getStack | ( | void | ) |
| int weapon_inArc | ( | const Outfit * | o, |
| const Pilot * | parent, | ||
| const Target * | target, | ||
| const vec2 * | pos, | ||
| const vec2 * | vel, | ||
| double | dir, | ||
| double | time ) |
| void weapon_minimap | ( | double | res, |
| double | w, | ||
| double | h, | ||
| const RadarShape | shape, | ||
| double | alpha ) |
|
static |
| void weapon_newSystem | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Tests to see if a weapon collides with a ship.
| wc | Weapon collision data. | |
| ctex | Collision target texture. | |
| csx | Collision target texture x sprite. | |
| csy | Collision target texture y sprite. | |
| csol | Collision target solid. | |
| cpol | Collision target collision polygon (NULL if none). | |
| cradius | Collision radius fallback (if no texture and polygon are provided). | |
| [out] | crash | Crash location, which is only set if collision is detected. |
|
static |
|
static |
|
static |
| void weapons_render | ( | const WeaponLayer | layer, |
| double | dt ) |
| void weapons_update | ( | double | dt | ) |
| void weapons_updateCollide | ( | double | dt | ) |
| void weapons_updatePurge | ( | void | ) |
|
static |
|
static |
|
static |
|
static |