FS2_Open
Open source remastering of the Freespace 2 engine
shipfx.cpp File Reference
#include "asteroid/asteroid.h"
#include "bmpman/bmpman.h"
#include "cmdline/cmdline.h"
#include "debris/debris.h"
#include "debugconsole/console.h"
#include "fireball/fireballs.h"
#include "gamesequence/gamesequence.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/linklist.h"
#include "hud/hudmessage.h"
#include "io/timer.h"
#include "lighting/lighting.h"
#include "math/fvi.h"
#include "model/model.h"
#include "network/multi.h"
#include "network/multimsgs.h"
#include "network/multiutil.h"
#include "object/object.h"
#include "object/objectdock.h"
#include "object/objectsnd.h"
#include "parse/parselo.h"
#include "parse/scripting.h"
#include "particle/particle.h"
#include "playerman/player.h"
#include "render/3d.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#include "ship/shiphit.h"
#include "weapon/muzzleflash.h"
#include "weapon/shockwave.h"
#include "weapon/weapon.h"

Go to the source code of this file.

Classes

struct  ship_flash
 
struct  clip_ship
 
struct  split_ship
 
class  CombinedVariable
 

Macros

#define SHIP_CANNON_BITMAP   "argh"
 
#define SHIPFX_WARP_DELAY   (2.0f)
 
#define LARGEST_RAD   1390.0f
 
#define LARGEST_RAD_TIME   7.0f
 
#define SMALLEST_RAD   15.0f
 
#define SMALLEST_RAD_TIME   1.5f
 
#define w(p)   (*((int *) (p)))
 
#define MAX_FLASHES   128
 
#define FLASH_LIFE_PRIMARY   0.25f
 
#define FLASH_LIFE_SECONDARY   0.50f
 
#define DEBRIS_NONE   0
 
#define DEBRIS_DRAW   1
 
#define DEBRIS_FREE   2
 
#define ENGINE_WASH_CHECK_INTERVAL   250
 
#define WV_ANIMATION   0
 
#define WV_RADIUS   1
 
#define WV_SPEED   2
 
#define WV_TIME   3
 

Typedefs

typedef struct ship_flash ship_flash
 
typedef struct clip_ship clip_ship
 
typedef struct split_ship split_ship
 

Functions

void shipfx_remove_submodel_ship_sparks (ship *shipp, int submodel_num)
 
void model_get_rotating_submodel_axis (vec3d *model_axis, vec3d *world_axis, int model_instance_num, int submodel_num, matrix *objorient)
 
void shipfx_subsystem_maybe_create_live_debris (object *ship_objp, ship *ship_p, ship_subsys *subsys, vec3d *exp_center, float exp_mag)
 
void set_ship_submodel_as_blown_off (ship *shipp, char *name)
 
void shipfx_maybe_create_live_debris_at_ship_death (object *ship_objp)
 
void shipfx_blow_off_subsystem (object *ship_objp, ship *ship_p, ship_subsys *subsys, vec3d *exp_center, bool no_explosion)
 
void shipfx_blow_up_hull (object *obj, int model, vec3d *exp_center)
 
void shipfx_blow_up_model (object *obj, int model, int submodel, int ndebris, vec3d *exp_center)
 
float shipfx_calculate_warp_time (object *objp, int warp_dir)
 
float shipfx_calculate_warp_dist (object *objp)
 
void shipfx_actually_warpin (ship *shipp, object *objp)
 
int shipfx_special_warp_objnum_valid (int objnum)
 
void shipfx_warpin_start (object *objp)
 
void shipfx_warpin_frame (object *objp, float frametime)
 
void shipfx_actually_warpout (int shipnum)
 
int compute_special_warpout_stuff (object *objp, float *speed, float *warp_time, vec3d *warp_pos)
 
void compute_warpout_stuff (object *objp, float *speed, float *warp_time, vec3d *warp_pos)
 
void shipfx_warpout_start (object *objp)
 
void shipfx_warpout_frame (object *objp, float frametime)
 
bool shipfx_point_in_shadow (vec3d *p0, matrix *src_orient, vec3d *src_pos, float radius)
 
bool shipfx_in_shadow (object *src_obj)
 
bool shipfx_eye_in_shadow (vec3d *eye_pos, object *src_obj, int sun_n)
 
void shipfx_flash_init ()
 
void shipfx_flash_create (object *objp, int model_num, vec3d *gun_pos, vec3d *gun_dir, int is_primary, int weapon_info_index)
 
void shipfx_flash_light_model (object *objp, int model_num)
 
void shipfx_flash_do_frame (float frametime)
 
 if (dc_optional_string_either("status","--status")||dc_optional_string_either("?","--?"))
 
 CLAMP (value, 0.0, 5.0)
 
 dc_printf ("Particle_width set to %f\n", Particle_width)
 
 DCF (particle_num,"Sets multiplier for the number of particles created")
 
 DCF (particle_life,"Multiplier for the lifetime of particles created")
 
void shipfx_emit_spark (int n, int sn)
 
 DCF (bs_exp_fire_time_mult,"Sets multiplier time between fireball in big ship explosion")
 
void shipfx_queue_render_ship_halves_and_debris (draw_list *scene, clip_ship *half_ship, ship *shipp)
 
void shipfx_large_blowup_level_init ()
 
void shipfx_large_blowup_init (ship *shipp)
 
void shipfx_debris_limit_speed (debris *db, ship *shipp)
 
float get_model_cross_section_at_z (float z, polymodel *pm)
 
int get_sound_time_played (int snd_id, int handle)
 
void do_sub_expl_sound (float radius, vec3d *sound_pos, int *sound_handle)
 
void big_explosion_flash (float)
 
int shipfx_large_blowup_do_frame (ship *shipp, float frametime)
 
void shipfx_large_blowup_render (ship *shipp)
 
void shipfx_large_blowup_queue_render (draw_list *scene, ship *shipp)
 
void shipfx_do_damaged_arcs_frame (ship *shipp)
 
void shipfx_do_lightning_frame (ship *shipp)
 
void shipfx_do_shockwave_stuff (ship *shipp, shockwave_create_info *sci)
 
int model_should_render_engine_glow (int objnum, int bank_obj)
 
void engine_wash_ship_process (ship *shipp)
 
void shipfx_engine_wash_level_init ()
 
void shipfx_stop_engine_wash_sound ()
 
void parse_combined_variable_list (CombinedVariable *dest, flag_def_list *src, size_t num)
 

Variables

float flFrametime
 
int Framecount
 
int Cmdline_tbp
 
int Ship_cannon_bitmap = -1
 
int Player_engine_wash_loop = -1
 
float splode_level
 
int Ship_flash_inited = 0
 
int Ship_flash_highest = -1
 
ship_flash Ship_flash [MAX_FLASHES]
 
float Particle_width = 1.2f
 
dc_stuff_floatvalue
 
float Particle_number = 1.2f
 
float Particle_life = 1.2f
 
int Bs_exp_fire_low = 1
 
float Bs_exp_fire_time_mult = 1.0f
 
const float MAX_ARC_LENGTH_PERCENTAGE = 0.25f
 
const float MAX_EMP_ARC_TIMESTAMP = 150.0f
 
int l_cruiser_count = 1
 
int l_big_count = 2
 
int l_huge_count = 3
 
float l_max_radius = 3000.0f
 
int Wash_on = 1
 
flag_def_list Warp_variables []
 

Macro Definition Documentation

#define DEBRIS_DRAW   1

Definition at line 1637 of file shipfx.cpp.

#define DEBRIS_FREE   2

Definition at line 1638 of file shipfx.cpp.

#define DEBRIS_NONE   0

Definition at line 1636 of file shipfx.cpp.

#define ENGINE_WASH_CHECK_INTERVAL   250

Definition at line 2866 of file shipfx.cpp.

#define FLASH_LIFE_PRIMARY   0.25f

Definition at line 1197 of file shipfx.cpp.

#define FLASH_LIFE_SECONDARY   0.50f

Definition at line 1198 of file shipfx.cpp.

#define LARGEST_RAD   1390.0f

Definition at line 468 of file shipfx.cpp.

#define LARGEST_RAD_TIME   7.0f

Definition at line 469 of file shipfx.cpp.

#define MAX_FLASHES   128

Definition at line 1196 of file shipfx.cpp.

#define SHIP_CANNON_BITMAP   "argh"

Definition at line 52 of file shipfx.cpp.

#define SHIPFX_WARP_DELAY   (2.0f)

Definition at line 460 of file shipfx.cpp.

#define SMALLEST_RAD   15.0f

Definition at line 471 of file shipfx.cpp.

#define SMALLEST_RAD_TIME   1.5f

Definition at line 472 of file shipfx.cpp.

#define w (   p)    (*((int *) (p)))

Definition at line 973 of file shipfx.cpp.

#define WV_ANIMATION   0

Definition at line 3418 of file shipfx.cpp.

#define WV_RADIUS   1

Definition at line 3419 of file shipfx.cpp.

#define WV_SPEED   2

Definition at line 3420 of file shipfx.cpp.

#define WV_TIME   3

Definition at line 3421 of file shipfx.cpp.

Typedef Documentation

typedef struct clip_ship clip_ship
typedef struct ship_flash ship_flash
typedef struct split_ship split_ship

Function Documentation

void big_explosion_flash ( float  flash)

Adds a flash for Big Ship explosions

Parameters
flashflash intensity. Range capped from 0 to 1.

Definition at line 164 of file fredstubs.cpp.

CLAMP ( value  ,
0.  0,
5.  0 
)
int compute_special_warpout_stuff ( object objp,
float speed,
float warp_time,
vec3d warp_pos 
)

Definition at line 626 of file shipfx.cpp.

void compute_warpout_stuff ( object objp,
float speed,
float warp_time,
vec3d warp_pos 
)

Definition at line 709 of file shipfx.cpp.

dc_printf ( "Particle_width set to %f\n ,
Particle_width   
)
DCF ( particle_num  ,
"Sets multiplier for the number of particles created"   
)

Definition at line 1377 of file shipfx.cpp.

DCF ( particle_life  ,
"Multiplier for the lifetime of particles created"   
)

Definition at line 1396 of file shipfx.cpp.

DCF ( bs_exp_fire_time_mult  ,
"Sets multiplier time between fireball in big ship explosion"   
)

Definition at line 1619 of file shipfx.cpp.

void do_sub_expl_sound ( float  radius,
vec3d sound_pos,
int sound_handle 
)

Sound manager for big ship sub explosions sounds.

Forces playing of sub-explosion sounds. Keeps track of active sounds, plays them for >= 750 ms when sound has played >= 750, sound is stopped and new instance is started

Definition at line 2190 of file shipfx.cpp.

void engine_wash_ship_process ( ship shipp)

Do engine wash effect for ship

Assumes length of engine wash is greater than radius of engine wash hemisphere

Definition at line 2873 of file shipfx.cpp.

float get_model_cross_section_at_z ( float  z,
polymodel pm 
)

Definition at line 2148 of file shipfx.cpp.

int get_sound_time_played ( int  snd_id,
int  handle 
)

Returns how long sound has been playing

Definition at line 2172 of file shipfx.cpp.

if ( dc_optional_string_either("status","--status")||dc_optional_string_either("?","--?")  )

Definition at line 1363 of file shipfx.cpp.

void model_get_rotating_submodel_axis ( vec3d model_axis,
vec3d world_axis,
int  model_instance_num,
int  submodel_num,
matrix objorient 
)

Definition at line 3452 of file modelread.cpp.

int model_should_render_engine_glow ( int  objnum,
int  bank_obj 
)

Definition at line 5084 of file modelinterp.cpp.

void parse_combined_variable_list ( CombinedVariable dest,
flag_def_list src,
size_t  num 
)

Definition at line 3356 of file shipfx.cpp.

void set_ship_submodel_as_blown_off ( ship shipp,
char *  name 
)

Definition at line 215 of file shipfx.cpp.

void shipfx_actually_warpin ( ship shipp,
object objp 
)

Definition at line 526 of file shipfx.cpp.

void shipfx_actually_warpout ( int  shipnum)

Definition at line 619 of file shipfx.cpp.

void shipfx_blow_off_subsystem ( object ship_objp,
ship ship_p,
ship_subsys subsys,
vec3d exp_center,
bool  no_explosion 
)

Definition at line 295 of file shipfx.cpp.

void shipfx_blow_up_hull ( object obj,
int  model,
vec3d exp_center 
)

Definition at line 325 of file shipfx.cpp.

void shipfx_blow_up_model ( object obj,
int  model,
int  submodel,
int  ndebris,
vec3d exp_center 
)

Creates "ndebris" pieces of debris on random verts of the the "submodel" in the ship's model.

Definition at line 374 of file shipfx.cpp.

float shipfx_calculate_warp_dist ( object objp)

Definition at line 510 of file shipfx.cpp.

float shipfx_calculate_warp_time ( object objp,
int  warp_dir 
)

Definition at line 474 of file shipfx.cpp.

void shipfx_debris_limit_speed ( debris db,
ship shipp 
)

Definition at line 2031 of file shipfx.cpp.

void shipfx_do_damaged_arcs_frame ( ship shipp)

Definition at line 2417 of file shipfx.cpp.

void shipfx_do_lightning_frame ( ship shipp)

Definition at line 2648 of file shipfx.cpp.

void shipfx_do_shockwave_stuff ( ship shipp,
shockwave_create_info sci 
)

Do all shockwaves for a ship blowing up

Definition at line 2776 of file shipfx.cpp.

void shipfx_emit_spark ( int  n,
int  sn 
)

Definition at line 1417 of file shipfx.cpp.

void shipfx_engine_wash_level_init ( )

Engine wash level init

Definition at line 3106 of file shipfx.cpp.

bool shipfx_eye_in_shadow ( vec3d eye_pos,
object src_obj,
int  sun_n 
)

Given world point see if it is in a shadow.

Definition at line 977 of file shipfx.cpp.

void shipfx_flash_create ( object objp,
int  model_num,
vec3d gun_pos,
vec3d gun_dir,
int  is_primary,
int  weapon_info_index 
)

Given that a ship fired a weapon, light up the model accordingly.

Definition at line 1231 of file shipfx.cpp.

void shipfx_flash_do_frame ( float  frametime)

Does whatever processing needs to be done each frame.

Definition at line 1331 of file shipfx.cpp.

void shipfx_flash_init ( )

Resets the ship flash stuff. Call before each level.

Definition at line 1216 of file shipfx.cpp.

void shipfx_flash_light_model ( object objp,
int  model_num 
)

Sets the flash lights in the model used by this ship to the appropriate values.

There might not be any flashes linked to this ship in which case this function does nothing.

Definition at line 1314 of file shipfx.cpp.

bool shipfx_in_shadow ( object src_obj)

Given an ship see if it is in a shadow.

Definition at line 926 of file shipfx.cpp.

int shipfx_large_blowup_do_frame ( ship shipp,
float  frametime 
)

Returns 1 when explosion is done

Definition at line 2325 of file shipfx.cpp.

void shipfx_large_blowup_init ( ship shipp)

Definition at line 2019 of file shipfx.cpp.

void shipfx_large_blowup_level_init ( )

Definition at line 2009 of file shipfx.cpp.

void shipfx_large_blowup_queue_render ( draw_list scene,
ship shipp 
)

Definition at line 2393 of file shipfx.cpp.

void shipfx_large_blowup_render ( ship shipp)

Definition at line 2374 of file shipfx.cpp.

void shipfx_maybe_create_live_debris_at_ship_death ( object ship_objp)

Create debris for ship submodel which has live debris (at ship death) when ship submodel has not already been blown off (and hence liberated live debris)

Definition at line 240 of file shipfx.cpp.

bool shipfx_point_in_shadow ( vec3d p0,
matrix src_orient,
vec3d src_pos,
float  radius 
)

Given point p0, in object's frame of reference, find if it can see the sun.

Definition at line 874 of file shipfx.cpp.

void shipfx_queue_render_ship_halves_and_debris ( draw_list scene,
clip_ship half_ship,
ship shipp 
)

Definition at line 1903 of file shipfx.cpp.

void shipfx_remove_submodel_ship_sparks ( ship shipp,
int  submodel_num 
)

Definition at line 59 of file shipfx.cpp.

int shipfx_special_warp_objnum_valid ( int  objnum)

Definition at line 536 of file shipfx.cpp.

void shipfx_stop_engine_wash_sound ( )

Pause engine wash sounds

Definition at line 3114 of file shipfx.cpp.

void shipfx_subsystem_maybe_create_live_debris ( object ship_objp,
ship ship_p,
ship_subsys subsys,
vec3d exp_center,
float  exp_mag 
)

Check if subsystem has live debris and create

DKA: 5/26/99 make velocity of debris scale according to size of debris subobject (at least for large subobjects)

Definition at line 82 of file shipfx.cpp.

void shipfx_warpin_frame ( object objp,
float  frametime 
)

Definition at line 605 of file shipfx.cpp.

void shipfx_warpin_start ( object objp)

Definition at line 565 of file shipfx.cpp.

void shipfx_warpout_frame ( object objp,
float  frametime 
)

Definition at line 848 of file shipfx.cpp.

void shipfx_warpout_start ( object objp)

Definition at line 794 of file shipfx.cpp.

Variable Documentation

int Bs_exp_fire_low = 1

Definition at line 1615 of file shipfx.cpp.

float Bs_exp_fire_time_mult = 1.0f

Definition at line 1616 of file shipfx.cpp.

int Cmdline_tbp
float flFrametime

Definition at line 22 of file fredstubs.cpp.

int Framecount

Definition at line 22 of file systemvars.cpp.

int l_big_count = 2

Definition at line 2645 of file shipfx.cpp.

int l_cruiser_count = 1

Definition at line 2644 of file shipfx.cpp.

int l_huge_count = 3

Definition at line 2646 of file shipfx.cpp.

float l_max_radius = 3000.0f

Definition at line 2647 of file shipfx.cpp.

const float MAX_ARC_LENGTH_PERCENTAGE = 0.25f

Definition at line 2413 of file shipfx.cpp.

const float MAX_EMP_ARC_TIMESTAMP = 150.0f

Definition at line 2415 of file shipfx.cpp.

float Particle_life = 1.2f

Definition at line 1395 of file shipfx.cpp.

float Particle_number = 1.2f

Definition at line 1376 of file shipfx.cpp.

Particle_width = 1.2f

Definition at line 1358 of file shipfx.cpp.

int Player_engine_wash_loop = -1

Definition at line 55 of file shipfx.cpp.

int Ship_cannon_bitmap = -1

Definition at line 53 of file shipfx.cpp.

ship_flash Ship_flash[MAX_FLASHES]

Definition at line 1211 of file shipfx.cpp.

int Ship_flash_highest = -1

Definition at line 1210 of file shipfx.cpp.

int Ship_flash_inited = 0

Definition at line 1209 of file shipfx.cpp.

float splode_level

Definition at line 473 of file modelinterp.cpp.

Definition at line 1368 of file shipfx.cpp.

flag_def_list Warp_variables[]
Initial value:
= {
}
#define WV_RADIUS
Definition: shipfx.cpp:3419
#define WV_TIME
Definition: shipfx.cpp:3421
static const int TYPE_STRING
Definition: shipfx.cpp:3130
static const int TYPE_FLOAT
Definition: shipfx.cpp:3126
#define WV_ANIMATION
Definition: shipfx.cpp:3418
#define WV_SPEED
Definition: shipfx.cpp:3420

Definition at line 3423 of file shipfx.cpp.

int Wash_on = 1

Definition at line 2864 of file shipfx.cpp.