52 #define SHIP_CANNON_BITMAP "argh"
61 Assert(submodel_num != -1);
68 for (
int spark_num=0; spark_num<shipp->
num_hits; spark_num++) {
91 object *live_debris_obj;
92 int i, num_live_debris, live_debris_submodel;
102 angles zero_angs = {0.0f, 0.0f, 0.0f};
105 vec3d model_axis, world_axis, rotvel, world_axis_pt;
128 for (i=0; i<num_live_debris; i++) {
130 vec3d start_world_pos, start_model_pos, end_world_pos;
147 if(fireball_type < 0) {
154 live_debris_obj =
debris_create(ship_objp, pm->
id, live_debris_submodel, &end_world_pos, exp_center, 1, exp_mag);
157 if (live_debris_obj) {
159 vec3d delta_x, radial_vel;
160 vm_vec_sub(&delta_x, &end_world_pos, &world_axis_pt);
165 vec3d rand_vec, vec_to_center;
186 if (rotvel_mag > 0.1) {
187 float scale = (1.2f + 0.2f *
frand()) * vel_mag / rotvel_mag;
254 int live_debris_submodel = -1;
316 if(fireball_type < 0) {
344 bool try_live_debris =
true;
351 if ( try_live_debris ) {
354 try_live_debris =
false;
386 if ( submodel == 0 ) {
390 for (i=0; i<ndebris; i++ ) {
418 static float shipfx_calculate_effect_radius(
object *
objp,
int warp_dir )
460 #define SHIPFX_WARP_DELAY (2.0f) // time for warp effect to ramp up before ship moves into it.
468 #define LARGEST_RAD 1390.0f
469 #define LARGEST_RAD_TIME 7.0f
471 #define SMALLEST_RAD 15.0f
472 #define SMALLEST_RAD_TIME 1.5f
503 CLAMP(rad_percent, 0.0
f, 1.0
f);
516 length = 2.0f * objp->
radius;
538 object *special_objp;
628 object *sp_objp = NULL;
630 int valid_reference_ship =
FALSE, ref_objnum;
631 vec3d facing_normal, vec_to_knossos, center_pos;
636 mprintf((
"special warpout only for single player\n"));
641 valid_reference_ship =
FALSE;
642 ref_objnum = Ships[objp->
instance].special_warpout_objnum;
645 if ((ref_objnum >= 0) && (ref_objnum <
MAX_OBJECTS)) {
646 sp_objp = &
Objects[ref_objnum];
649 valid_reference_ship =
TRUE;
654 if (!valid_reference_ship) {
655 mprintf((
"Special warpout reference ship is not a Knossos\n"));
667 facing_normal = sp_objp->
orient.
vec.fvec;
676 dist_to_plane += pm->
mins.
xyz.z;
679 if (dist_to_plane < 0) {
680 mprintf((
"warpout started too late\n"));
685 float max_warpout_angle = 0.707f;
687 max_warpout_angle = 0.866f;
692 mprintf((
"special warpout angle exceeded\n"));
703 *warp_time += dist_to_plane / *speed;
720 mprintf((
"Invalid special warp\n"));
724 float ship_move_dist, warp_dist;
769 if ( ship_move_dist < radius*1.5
f ) {
770 ship_move_dist = radius*1.5f;
776 *warp_time += ship_move_dist / *speed;
778 warp_dist = ship_move_dist;
800 mprintf((
"Ship is already departing!\n" ));
893 for(idx=0; idx<n_lights; idx++){
942 for(idx=0; idx<n_lights; idx++){
950 if ( src_obj != objp ) {
973 #define w(p) (*((int *) (p)))
1003 if ( src_obj != objp ) {
1077 int tmap_num =
w(mc.
t_poly+40);
1122 int tmap_num =
w(mc.
t_poly+40);
1196 #define MAX_FLASHES 128 // How many flashes total
1197 #define FLASH_LIFE_PRIMARY 0.25f // How long flash lives
1198 #define FLASH_LIFE_SECONDARY 0.50f // How long flash lives
1223 Ship_flash_highest = -1;
1224 Ship_flash_inited = 1;
1236 Assert(Ship_flash_inited);
1239 int closest_light = -1;
1240 float d, closest_dist = 0.0f;
1257 if ( (closest_light==-1) || (d<closest_dist) ) {
1264 if ( closest_light == -1 )
return;
1266 int first_slot = -1;
1269 if ( (first_slot==-1) && (Ship_flash[i].objnum < 0) ) {
1273 if ( (Ship_flash[i].objnum == objnum) && (Ship_flash[i].obj_signature==objp->
signature) ) {
1274 if ( Ship_flash[i].light_num == closest_light ) {
1276 Ship_flash[
i].
life = 0.0f;
1287 if ( first_slot == -1 ) {
1289 Ship_flash_highest++;
1296 Assert( Ship_flash[first_slot].objnum == -1 );
1298 Ship_flash[first_slot].
objnum = objnum;
1300 Ship_flash[first_slot].
life = 0.0f;
1306 Ship_flash[first_slot].
light_num = closest_light;
1320 if ( (Ship_flash[i].objnum == objnum) && (Ship_flash[i].obj_signature==objp->
signature) ) {
1321 float v = (Ship_flash[
i].
max_life - Ship_flash[
i].
life)/Ship_flash[i].max_life;
1342 sf->
life += frametime;
1347 if ( i == Ship_flash_highest ) {
1348 while( (Ship_flash_highest>0) && (Ship_flash[Ship_flash_highest].objnum == -1) ) {
1349 Ship_flash_highest--;
1359 DCF(particle_width,
"Sets multiplier for angular width of the particle spew ( 0 - 5)")
1364 dc_printf(
"Particle_width : %f\n", Particle_width);
1370 CLAMP(value, 0.0, 5.0);
1371 Particle_width =
value;
1373 dc_printf(
"Particle_width set to %f\n", Particle_width);
1377 DCF(particle_num,
"Sets multiplier for the number of particles created")
1383 dc_printf(
"Particle_number : %f\n", Particle_number);
1389 CLAMP(value, 0.0, 5.0);
1390 Particle_number =
value;
1392 dc_printf(
"Particle_number set to %f\n", Particle_number);
1396 DCF(particle_life,
"Multiplier for the lifetime of particles created")
1401 dc_printf(
"Particle_life : %f\n", Particle_life);
1407 CLAMP(value, 0.0, 5.0);
1408 Particle_life =
value;
1410 dc_printf(
"Particle_life set to %f\n", Particle_life);
1419 int create_spark = 1;
1423 float ship_radius, spark_scale_factor;
1429 if(sn < 0 && sip->damage_spew.n_high <= 0)
1439 if (ship_radius > 40) {
1440 spark_scale_factor = 1.0f;
1441 }
else if (ship_radius > 20) {
1442 spark_scale_factor = (ship_radius - 20.0f) / 20.0
f;
1444 spark_scale_factor = 0.0f;
1447 float spark_time_scale = 1.0f + spark_scale_factor * (Particle_life - 1.0f);
1448 float spark_width_scale = 1.0f + spark_scale_factor * (Particle_width - 1.0f);
1449 float spark_num_scale = 1.0f + spark_scale_factor * (Particle_number - 1.0f);
1454 if (hull_percent < 0.001) {
1455 hull_percent = 0.001f;
1457 float fraction = 0.1f * obj->radius / hull_percent;
1458 if (fraction > 1.0
f) {
1493 vec3d warp_pnt, tmp;
1511 if ( create_spark ) {
1536 vec3d tmp_norm, tmp_vel;
1540 tmp_vel = obj->phys_info.vel;
1562 if (hull_percent > 0.6
f) {
1564 float spark_duration = (
float)pow(2.0
f, -5.0
f*(hull_percent-1.3
f)) * (1.0
f + 0.6
f*(
frand()-0.5
f));
1597 pe.
min_life = 0.7f * spark_time_scale;
1598 pe.
max_life = 1.5f * spark_time_scale;
1618 DCF_BOOL(bs_exp_fire_low, Bs_exp_fire_low)
1624 dc_printf(
"Bs_exp_fire_time_mult : %f\n", Bs_exp_fire_time_mult);
1631 Bs_exp_fire_time_mult =
value;
1632 dc_printf(
"Bs_exp_fire_time_mult set to %f\n", Bs_exp_fire_time_mult);
1636 #define DEBRIS_NONE 0
1637 #define DEBRIS_DRAW 1
1638 #define DEBRIS_FREE 2
1666 static int get_split_ship()
1672 int max_size = (
int)Split_ships.size();
1673 for (i = 0; i < max_size; i++) {
1674 if (!Split_ships[i].used)
1681 Split_ships.push_back(addition);
1683 return (Split_ships.size() - 1);
1686 static void maybe_fireball_wipe(
clip_ship* half_ship,
int* sound_handle);
1713 float init_clip_plane_dist;
1741 if (tmp.
xyz.z > init_clip_plane_dist) {
1763 float ship_length = front_length + back_length;
1767 float expl_length_scale = (ship_length - 200.0f) / 2000.0
f;
1769 float speed_reduction_factor = (1.0f + 0.001f*parent_ship_obj->
radius);
1770 float explosion_time = (3.0f + expl_length_scale + (
frand()-0.5f)) * speed_reduction_factor;
1771 float long_length =
MAX(front_length, back_length);
1772 float expl_vel = long_length / explosion_time;
1776 float rel_vel = (0.6f + 0.2f*
frand()) * expl_vel * speed_reduction_factor;
1777 float front_vel = rel_vel * back_length / ship_length;
1778 float back_vel = -rel_vel * front_length / ship_length;
1783 rotvel.
xyz.z = 0.0f;
1794 temp_rotvel.
xyz.z = 0.0f;
1795 vec3d vel_from_rotvel;
1812 static void half_ship_render_ship_and_debris(
clip_ship* half_ship,
ship *shipp)
1817 vec3d orig_ship_world_center, clip_plane_norm, model_clip_plane_pt, debris_clip_plane_pt;
1833 vec3d temp_pos = orig_ship_world_center;
1840 int create_debris = 0;
1854 if ( !is_live_debris ) {
1860 if ( create_debris ) {
1862 vec3d center_to_debris, debris_vel, radial_vel;
1864 int debris_count = 0;
1872 if ( !is_live_debris ) {
1884 float radial_mag = 10.0f + 30.0f*
frand();
1898 vm_vec_add2(&model_clip_plane_pt, &orig_ship_world_center);
1908 vec3d orig_ship_world_center, clip_plane_norm, model_clip_plane_pt, debris_clip_plane_pt;
1927 vec3d temp_pos = orig_ship_world_center;
1934 int create_debris = 0;
1948 if ( !is_live_debris ) {
1952 render_info.
set_clip_plane(debris_clip_plane_pt, clip_plane_norm);
1960 if ( create_debris ) {
1962 vec3d center_to_debris, debris_vel, radial_vel;
1964 int debris_count = 0;
1972 if ( !is_live_debris ) {
1984 float radial_mag = 10.0f + 30.0f*
frand();
1998 vm_vec_add2(&model_clip_plane_pt, &orig_ship_world_center);
2003 render_info.
set_clip_plane(model_clip_plane_pt, clip_plane_norm);
2011 Split_ships.clear();
2023 i = get_split_ship();
2025 Split_ships[
i].used = 1;
2028 split_ship_init(shipp, &Split_ships[i] );
2033 if(db == NULL || shipp == NULL)
2044 if(fabs(curspeed) >= 0.001f)
2046 float scale = debris_speed / curspeed;
2056 if(curspeed < sip->debris_min_speed)
2058 if(fabs(curspeed) >= 0.001
f)
2073 if(fabs(curspeed) >= 0.001
f)
2090 if(fabs(currotvel) >= 0.001f)
2092 float scale = debris_rotspeed / currotvel;
2102 if(curspeed < sip->debris_min_rotspeed)
2104 if(fabs(currotvel) >= 0.001
f)
2120 if(fabs(currotvel) >= 0.001
f)
2154 float index, increment;
2156 index = (z - pm->
xc[0].
z) / increment;
2160 }
else if (index > (pm->
num_xc - 1.0f - 0.5f)) {
2163 int floor_index = (
int)floor(index);
2164 int ceil_index = (
int)ceil(index);
2181 return (duration - time_left);
2192 int sound_index, handle;
2194 float sound_range = 1.0f + 0.0043f*radius;
2199 handle = sound_handle[handle_index];
2208 snd_stop(sound_handle[handle_index]);
2219 static void maybe_fireball_wipe(
clip_ship* half_ship,
int* sound_handle)
2228 vec3d model_clip_plane_pt, orig_ship_world_center,
temp;
2235 vm_vec_add2(&model_clip_plane_pt, &orig_ship_world_center);
2256 if(fireball_type < 0) {
2260 fireball_create(&model_clip_plane_pt, fireball_type,
FIREBALL_LARGE_EXPLOSION,
OBJ_INDEX(half_ship->
parent_obj), rad, 0, &half_ship->
parent_obj->
phys_info.
vel, 0.0f, -1, NULL, low_res_fireballs);
2263 int time_low, time_high;
2264 time_low =
int(650 * Bs_exp_fire_time_mult);
2265 time_high =
int(900 * Bs_exp_fire_time_mult);
2277 pe.
pos = model_clip_plane_pt;
2331 Assert( the_split_ship->used );
2337 if ( !the_split_ship->explosion_flash_started ) {
2341 float intensity = 1.0f - 0.1f*excess_dist / objp->
radius;
2343 if (intensity > 1) {
2351 the_split_ship->explosion_flash_started = 1;
2355 physics_sim(&the_split_ship->front_ship.local_pivot, &the_split_ship->front_ship.orient, &the_split_ship->front_ship.phys_info, frametime);
2356 physics_sim(&the_split_ship->back_ship.local_pivot, &the_split_ship->back_ship.orient, &the_split_ship->back_ship.phys_info, frametime);
2357 the_split_ship->front_ship.length_left -= the_split_ship->front_ship.explosion_vel*frametime;
2358 the_split_ship->back_ship.length_left += the_split_ship->back_ship.explosion_vel *frametime;
2359 the_split_ship->front_ship.cur_clip_plane_pt += the_split_ship->front_ship.explosion_vel*frametime;
2360 the_split_ship->back_ship.cur_clip_plane_pt += the_split_ship->back_ship.explosion_vel *frametime;
2362 float length_left =
MAX( the_split_ship->front_ship.length_left, the_split_ship->back_ship.length_left );
2364 if ( length_left < 0 ) {
2365 the_split_ship->used = 0;
2369 maybe_fireball_wipe(&the_split_ship->front_ship, (
int*)&the_split_ship->sound_handle);
2370 maybe_fireball_wipe(&the_split_ship->back_ship, (
int*)&the_split_ship->sound_handle);
2380 Assert( the_split_ship->used );
2382 if (the_split_ship->front_ship.length_left > 0) {
2383 half_ship_render_ship_and_debris(&the_split_ship->front_ship,shipp);
2386 if (the_split_ship->back_ship.length_left > 0) {
2387 half_ship_render_ship_and_debris(&the_split_ship->back_ship,shipp);
2399 Assert( the_split_ship->used );
2401 if (the_split_ship->front_ship.length_left > 0) {
2405 if (the_split_ship->back_ship.length_left > 0) {
2425 int disrupted_arc=0;
2434 if ( damage > 0.30
f ) {
2474 freq =
fl2i(MAX_EMP_ARC_TIMESTAMP);
2478 freq =
fl2i((damage+0.1
f)*5000.0
f);
2489 int n, n_arcs = ((rand()>>5) % 3)+1;
2501 if ( obj->
radius > 200.0f ) {
2510 if ( d > max_dist ) {
2517 if ( d > max_dist ) {
2525 if ( d > max_dist ) {
2534 int a = (
int) (factor*100.0
f);
2535 int b = (
int) (factor*1000.0f);
2536 int lifetime = (
myrand()%((
b)-(a)+1))+(
a);
2581 if ( lifetime > 750 ) {
2584 }
else if ( lifetime > 500 ) {
2587 }
else if ( lifetime > 250 ) {
2590 }
else if ( lifetime > 100 ) {
2606 if ( mr < RAND_MAX/5 ) {
2623 if ( obj->
radius > 200.0f ) {
2632 if ( d > max_dist ) {
2866 #define ENGINE_WASH_CHECK_INTERVAL 250 // (4x sec)
2876 object *
objp, *max_ship_intensity_objp;
2888 float dist_sqr, inset_depth, dot_to_ship, max_ship_intensity;
2891 float max_wash_dist, half_angle, radius_mult;
2900 if (time_to_next_hit < 0) {
2902 time_to_next_hit = 0;
2911 max_ship_intensity_objp = NULL;
2912 max_ship_intensity = 0;
2941 float ship_intensity = 0;
2956 vec3d submodel_static_offset;
2957 bool submodel_rotation =
false;
2969 nprintf((
"wash",
"Adding default engine wash to ship %s", wash_sip->
name));
2976 half_angle = ewp->
angle;
2989 submodel_rotation =
true;
2993 vec3d world_thruster_pos, world_thruster_norm, apex, thruster_to_ship, apex_to_ship,
temp;
2997 if ( submodel_rotation ) {
3013 vm_vec_sub(&thruster_to_ship, &objp->
pos, &world_thruster_pos);
3016 dot_to_ship =
vm_vec_dot(&thruster_to_ship, &world_thruster_norm);
3017 if (dot_to_ship > 0) {
3024 if (dist_sqr < max_wash_dist*max_wash_dist) {
3028 vm_vec_cross(&temp, &world_thruster_norm, &thruster_to_ship);
3030 ship_intensity += (1.0f - dist_sqr / (max_wash_dist*max_wash_dist));
3032 if (dist_sqr < 0.25 * max_wash_dist * max_wash_dist) {
3039 vm_vec_scale_add(&apex, &world_thruster_pos, &world_thruster_norm, -inset_depth);
3044 if (
vm_vec_dot(&apex_to_ship, &world_thruster_norm) > cosf(half_angle)) {
3045 vm_vec_cross(&temp, &world_thruster_norm, &thruster_to_ship);
3047 ship_intensity += (1.0f - dist_sqr / (max_wash_dist*max_wash_dist));
3049 if (dist_sqr < 0.25 * max_wash_dist * max_wash_dist) {
3062 if (ship_intensity > max_ship_intensity) {
3063 max_ship_intensity = ship_intensity;
3064 max_ship_intensity_objp = wash_objp;
3070 Assert(max_ship_intensity_objp != NULL);
3084 if(started_with_no_wash){
3166 int getString(
char *output,
size_t output_max);
3189 StorageUnion.su_Float = n_Float;
3195 StorageUnion.su_Int = n_Int;
3203 StorageUnion.su_Image = n_Int;
3208 StorageUnion.su_Sound = n_Int;
3213 StorageUnion.su_Int = n_Int;
3220 StorageUnion.su_String = (
char *)
vm_malloc(strlen(n_String)+1);
3221 strcpy(StorageUnion.su_String, n_String);
3228 vm_free(StorageUnion.su_String);
3236 *output = StorageUnion.su_Float;
3241 *output =
i2fl(StorageUnion.su_Image);
3246 *output =
i2fl(StorageUnion.su_Int);
3251 *output =
i2fl(StorageUnion.su_Sound);
3256 *output = (
float)atof(StorageUnion.su_String);
3283 *output =
fl2i(StorageUnion.su_Float);
3288 *output = StorageUnion.su_Image;
3293 *output = StorageUnion.su_Int;
3298 *output = StorageUnion.su_Sound;
3303 *output = atoi(StorageUnion.su_String);
3318 if(output == NULL || output_max == 0)
3323 snprintf(output, output_max,
"%f", StorageUnion.su_Float);
3329 snprintf(output, output_max,
"%s",
bm_get_filename(StorageUnion.su_Image));
3334 snprintf(output, output_max,
"%i", StorageUnion.su_Int);
3339 Error(
LOCATION,
"Sound CombinedVariables are not supported yet.");
3346 strncpy(output, StorageUnion.su_String, output_max);
3358 if(dest == NULL || src == NULL || num == 0)
3362 buf[
sizeof(
buf)-1] =
'\0';
3366 for(
size_t i = 0; i <
num; i++)
3371 snprintf(buf,
sizeof(buf)-1,
"+%s:", sp->name);
3376 case CombinedVariable::TYPE_FLOAT:
3383 case CombinedVariable::TYPE_INT:
3390 case CombinedVariable::TYPE_IMAGE:
3398 case CombinedVariable::TYPE_SOUND:
3406 case CombinedVariable::TYPE_STRING:
3418 #define WV_ANIMATION 0
3424 {
"Animation",
WV_ANIMATION, CombinedVariable::TYPE_STRING},
3425 {
"Radius",
WV_RADIUS, CombinedVariable::TYPE_FLOAT},
3426 {
"Speed",
WV_SPEED, CombinedVariable::TYPE_FLOAT},
3427 {
"Time",
WV_TIME, CombinedVariable::TYPE_FLOAT},
3530 *output = objp->
pos;
3551 stage_duration[0] = 0;
3577 float warpout_speed = 0.0f;
3578 float warp_time = 0.0f;
3594 radius = shipfx_calculate_effect_radius(objp,
direction);
3596 if(portal_objp != NULL)
3599 radius =
MIN(radius, 0.8
f*portal_objp->
radius);
3602 int warp_objnum = -1;
3609 warp_objnum =
fireball_create(&pos, fireball_type,
FIREBALL_WARP_EFFECT,
OBJ_INDEX(objp), radius, 1, NULL, warp_time, shipp->
ship_info_index, NULL, 0, 0, sip->
warpout_snd_start, sip->
warpout_snd_end);
3617 warp_objnum =
fireball_create(&pos, fireball_type,
FIREBALL_WARP_EFFECT,
OBJ_INDEX(objp), radius, 0, NULL, warp_time, shipp->
ship_info_index, NULL, 0, 0, sip->
warpin_snd_start, sip->
warpin_snd_end);
3626 if (warp_objnum < 0)
3634 stage_time_start = total_time_start =
timestamp();
3639 stage_time_end =
timestamp(stage_duration[1]);
3640 total_time_end = stage_duration[1] + stage_duration[2];
3743 mprintf((
"Hmmm... player ship warpout time elapsed, but he wasn't in warp stage 3.\n" ));
3755 if (delta_ms > 1000.0
f * frametime ) {
3756 nprintf((
"AI",
"Frame %i: Ship %s missed departue cue by %7.3f seconds.\n",
Framecount, shipp->
ship_name, - (
float) delta_ms/1000.0f));
3821 anim_fps = shockwave_fps = 0;
3822 anim_nframes = shockwave_nframes = 0;
3823 anim_total_time = shockwave_total_time = 0;
3834 if(strlen(tmp_name))
3840 anim_total_time =
fl2i(((
float)anim_nframes / (
float)anim_fps) * 1000.0
f);
3850 shockwave_total_time =
fl2i(((
float)shockwave_nframes / (
float)shockwave_fps) * 1000.0
f);
3855 shockwave_radius = 0.0f;
3867 z_offset_max = objp->
radius;
3868 z_offset_min = -objp->
radius;
3870 if(tube_radius <= 0.0
f)
3871 tube_radius = objp->
radius;
3873 if(shockwave_radius <= 0.0
f)
3874 shockwave_radius = objp->
radius;
3879 if(tube_radius <= 0.0
f)
3885 if (shockwave_radius <= 0.0
f)
3886 shockwave_radius = z_offset_max - z_offset_min;
3894 stage_duration[1] =
MAX(anim_total_time - sip->
warpin_time, shockwave_total_time);
3899 stage_duration[1] =
MAX(anim_total_time - sip->
warpout_time, shockwave_total_time);
3901 stage_time_start = stage_time_end = total_time_start = total_time_end =
timestamp();
3907 snd_range_factor = 1.0f;
3908 snd_start = snd_end = -1;
3909 snd_start_gs = snd_end_gs = NULL;
3947 z_offset_min = -z_offset_max;
3948 if(tube_radius <= 0.0
f)
3952 tube_radius =
MAX(x_radius, y_radius);
3955 shockwave_radius = z_offset_max - z_offset_min;
3968 int gs_start_index = -1;
3969 int gs_end_index = -1;
3988 if(gs_start_index > -1)
3990 snd_start_gs = &
Snds[gs_start_index];
3993 if(gs_end_index > -1)
3995 snd_end_gs = &
Snds[gs_end_index];
4000 int total_duration = 0;
4002 total_duration += stage_duration[i];
4005 total_time_end =
timestamp(total_duration);
4007 stage_time_start = total_time_start;
4008 stage_time_end =
timestamp(stage_duration[stage]);
4024 stage_time_end =
timestamp(stage_duration[stage]);
4106 int anim_frame =
fl2i( ((
float)(
timestamp() - total_time_start)/1000.0
f) * (
float)anim_fps);
4108 if ( anim_frame < anim_nframes )
4125 int shockwave_frame =
fl2i( ((
float)(
timestamp() - stage_time_start)/1000.0
f) * (
float)shockwave_fps);
4127 if(shockwave_frame < shockwave_nframes)
4132 memset(&p, 0,
sizeof(p));
4153 if(snd_end_gs != NULL)
4193 stage_time_start = stage_time_end =
timestamp();
4196 stage_duration[0] = 0;
4197 stage_duration[1] = 1000;
4198 stage_duration[2] = 0;
4199 stage_duration[3] = -1;
4200 stage_duration[4] = 0;
4201 stage_duration[5] = 1000;
4205 stage_duration[3] = sip->
warpin_time - (stage_duration[1] + stage_duration[2] + stage_duration[4] + stage_duration[5]);
4207 stage_duration[3] = sip->
warpout_time - (stage_duration[1] + stage_duration[2] + stage_duration[4] + stage_duration[5]);
4208 if(stage_duration[3] <= 0)
4209 stage_duration[3] = 3000;
4226 if(width_full <= 0.0
f)
4230 z_offset_max = pm->
maxs.
xyz.z;
4231 z_offset_min = pm->
mins.
xyz.z;
4236 if(width_full <= 0.0
f)
4238 width_full = 2.0f*objp->
radius;
4240 height_full = width_full;
4241 z_offset_max = objp->
radius;
4242 z_offset_min = -objp->
radius;
4246 snd_range_factor = sqrt(width_full*width_full+height_full*height_full)/141.421356f;
4248 if(width_full <= 0.0
f)
4250 if(height_full <= 0.0
f)
4282 total_time_end += stage_duration[
i];
4284 stage_time_start = total_time_start;
4285 stage_time_end =
timestamp(stage_duration[stage]);
4315 snd_gs = &
Snds[gs_index];
4334 stage_time_end =
timestamp(stage_duration[stage]);
4364 height = height_full * progress;
4374 height = height_full * (1.0f-progress);
4413 frame =
fl2i( (
int)(((
float)(
timestamp() - (
float)total_time_start)/1000.0
f) * (
float)anim_fps) % anim_nframes);
4465 if(total_duration <= 0)
4466 total_duration = 1000;
4468 total_time_start = total_time_end =
timestamp();
4470 scale_factor = 750.0f * objp->
radius;
4472 initial_velocity = 1.0f;
4484 total_time_end =
timestamp(total_duration);
4502 pos_final = objp->
pos;
4514 objp->
pos = pos_final;
4536 scale = scale_factor*(1.0f-pow((1.0
f-progress), decel_exp))-scale_factor;
4541 scale =
MIN(scale, (initial_velocity * (total_duration / 1000) * -(1.0
f - progress)));
4545 scale = scale_factor*pow(progress, accel_exp);
4549 scale += initial_velocity * (total_duration / 1000) * progress;
void mc_info_init(mc_info *mc)
float debris_max_rotspeed
int model_collide(mc_info *mc_info_obj)
#define MOVEMENT_TYPE_ROT
int timestamp(int delta_ms)
struct split_ship split_ship
model_subsystem * system_info
0.75 second spark sound effect
#define SIF2_SHOW_SHIP_MODEL
#define TMAP_FLAG_SOFT_QUAD
void set_ship_submodel_as_blown_off(ship *shipp, char *name)
int Cmdline_old_collision_sys
void model_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_num, int submodel_num, const matrix *objorient, const vec3d *objpos)
#define NUM_SUB_EXPL_HANDLES
float vm_vec_mag_quick(const vec3d *v)
matrix * vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1)
int live_debris[MAX_LIVE_DEBRIS]
#define FLASH_LIFE_SECONDARY
GLfloat GLfloat GLfloat GLfloat h
void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k)
int getWarpPosition(vec3d *output)
void shipfx_flash_do_frame(float frametime)
float frand_range(float min, float max)
Return a floating point number in the range min..max.
#define FLASH_LIFE_PRIMARY
polymodel * model_get(int model_num)
weapon_info Weapon_info[MAX_WEAPON_TYPES]
0.50 second spark sound effect
int batch_add_beam(int texture, int tmap_flags, vec3d *start, vec3d *end, float width, float intensity)
DCF(particle_num,"Sets multiplier for the number of particles created")
void RemHookVar(char *name)
SCP_vector< game_snd > Snds
int debris_objects[MAX_DEBRIS_OBJECTS]
void g3_stop_user_clip_plane()
float vm_vec_mag(const vec3d *v)
submodel_instance_info submodel_info_1
#define FIREBALL_LARGE_EXPLOSION
float warpout_player_speed
virtual int warpShipRender()
#define PLAYER_WARPOUT_SPEED
asteroid Asteroids[MAX_ASTEROIDS]
float ship_get_warpout_speed(object *objp)
virtual int warpShipRender()
ushort multi_get_next_network_signature(int what_kind)
WE_Default(object *n_objp, int n_direction)
WE_BSG(object *n_objp, int n_direction)
void shipfx_do_shockwave_stuff(ship *shipp, shockwave_create_info *sci)
void shipfx_blow_up_hull(object *obj, int model, vec3d *exp_center)
void shipfx_warpin_frame(object *objp, float frametime)
ubyte g3_transfer_vertex(vertex *dest, const vec3d *src)
void mflash_create(vec3d *gun_pos, vec3d *gun_dir, physics_info *pip, int mflash_type, object *local)
#define MAX_MODEL_TEXTURES
float Bs_exp_fire_time_mult
#define SSF_NO_LIVE_DEBRIS
#define SF_ARRIVING_STAGE_2
float side_slip_time_const
virtual int getWarpOrientation(matrix *output)
const float MAX_ARC_LENGTH_PERCENTAGE
int subsystem_stricmp(const char *str1, const char *str2)
int shockwave_create(int parent_objnum, vec3d *pos, shockwave_create_info *sci, int flag, int delay)
const float MAX_EMP_ARC_TIMESTAMP
void obj_snd_delete_type(int objnum, int sndnum, ship_subsys *ss)
void set_flags(uint flags)
int light_get_global_dir(vec3d *pos, int n)
struct vec3d::@225::@227 xyz
#define TMAP_HTL_3D_UNLIT
#define PF_SPECIAL_WARP_IN
int getWarpOrientation(matrix *output)
int gamesnd_get_by_name(const char *name)
int snd_is_playing(int sig)
vec3d * vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m)
#define Assertion(expr, msg,...)
#define END_OF_LIST(head)
#define SHIPFX_WARP_DELAY
bool Rendering_to_shadow_map
virtual int warpShipRender()
void shipfx_engine_wash_level_init()
void vm_vec_scale_add2(vec3d *dest, const vec3d *src, float k)
#define FIREBALL_EXPLOSION_LARGE1
virtual int warpShipClip()
void find_submodel_instance_point_normal(vec3d *outpnt, vec3d *outnorm, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const vec3d *submodel_norm)
GLenum GLenum GLenum GLenum GLenum scale
GLfloat GLfloat GLfloat v2
bsp_collision_leaf * bsp_leaf
void snd_update_3d_pos(int soundnum, game_snd *gs, vec3d *new_pos, float radius, float range_factor)
#define MAX_DEBRIS_PIECES
int special_warpin_objnum
GLenum GLuint GLenum GLsizei const GLchar * buf
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
static const int TYPE_IMAGE
float vm_vec_mag_squared(const vec3d *v)
void particle_emit(particle_emitter *pe, int type, int optional_data, float range)
thruster_bank * thrusters
script_state Script_system("FS2_Open Scripting")
virtual int getWarpOrientation(matrix *output)
void ship_get_eye(vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew, bool from_origin)
void do_sub_expl_sound(float radius, vec3d *sound_pos, int *sound_handle)
void shipfx_do_damaged_arcs_frame(ship *shipp)
void stuff_float(float *f)
#define SHIP_GUARDIAN_THRESHOLD_DEFAULT
void shipfx_stop_engine_wash_sound()
int obj_snd_assign(int objnum, int sndnum, vec3d *pos, int main, int flags, ship_subsys *associated_sub)
void submodel_render_DEPRECATED(int model_num, int submodel_num, matrix *orient, vec3d *pos, uint flags=MR_DEPRECATED_NORMAL, int objnum=-1, int *replacement_textures=NULL, int render=MODEL_RENDER_ALL)
0.10 second spark sound effect
void ship_actually_depart(int shipnum, int method)
void g3_start_user_clip_plane(const vec3d *plane_point, const vec3d *plane_normal)
void shipfx_debris_limit_speed(debris *db, ship *shipp)
int num_initial_asteroids
int bm_is_valid(int handle)
Checks if the bitmap indexed by handle is valid.
int explosion_flash_started
int object_is_docked(object *objp)
void model_find_submodel_offset(vec3d *outpnt, int model_num, int sub_model_num)
void model_render_queue(model_render_params *interp, draw_list *scene, int model_num, matrix *orient, vec3d *pos)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void model_instance_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos)
void shipfx_actually_warpout(int shipnum)
#define FIREBALL_MEDIUM_EXPLOSION
#define WT_DEFAULT_THEN_KNOSSOS
void shipfx_large_blowup_queue_render(draw_list *scene, ship *shipp)
matrix * vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
float ship_get_subsystem_strength(ship *shipp, int type)
void dock_calc_docked_center(vec3d *dest, object *objp)
void vm_vec_add2(vec3d *dest, const vec3d *src)
void shipfx_maybe_create_live_debris_at_ship_death(object *ship_objp)
WarpEffect * warpout_effect
ubyte arc_type[MAX_SHIP_ARCS]
ship_spark sparks[MAX_SHIP_HITS]
void big_explosion_flash(float)
void shipfx_actually_warpin(ship *shipp, object *objp)
struct matrix::@228::@230 vec
virtual int getWarpPosition(vec3d *output)
virtual int warpFrame(float frametime)
WE_Hyperspace(object *n_objp, int n_direction)
float ship_max_hull_strength
void vm_vec_scale(vec3d *dest, float s)
int timestamp_until(int stamp)
#define TMAP_FLAG_GOURAUD
int compute_special_warpout_stuff(object *objp, float *speed, float *warp_time, vec3d *warp_pos)
int gameseq_get_state_idx(char *s)
int explosion_flash_timestamp
int * ship_replacement_textures
GLboolean GLboolean GLboolean GLboolean a
int fireball_ship_explosion_type(ship_info *sip)
int shipfx_large_blowup_do_frame(ship *shipp, float frametime)
int ship_subsys_disrupted(ship_subsys *ss)
float get_hull_pct(object *objp)
void model_clear_instance(int model_num)
virtual int warpShipQueueRender(draw_list *scene)
ship_flash Ship_flash[MAX_FLASHES]
virtual int getWarpPosition(vec3d *output)
int snd_play_3d(game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius, vec3d *source_vel, int looping, float vol_scale, int priority, vec3d *sound_fvec, float range_factor, int force, bool is_ambient)
#define WE_BSG_NUM_STAGES
texture_map maps[MAX_MODEL_TEXTURES]
int sound_handle[NUM_SUB_EXPL_HANDLES]
void stuff_string(char *outstr, int type, int len, char *terminators)
void engine_wash_ship_process(ship *shipp)
virtual int warpFrame(float frametime)
void world_find_model_instance_point(vec3d *out, vec3d *world_pt, const polymodel_instance *pmi, int submodel_num, const matrix *orient, const vec3d *pos)
void vm_set_identity(matrix *m)
void submodel_render_queue(model_render_params *render_info, draw_list *scene, int model_num, int submodel_num, matrix *orient, vec3d *pos)
static const int TYPE_INT
submodel_instance * submodel
const char * bm_get_filename(int handle)
Gets the filename of the bitmap indexed by handle, which must exist.
float dock_calc_max_cross_sectional_radius_perpendicular_to_axis(object *objp, axis_type axis)
void shipfx_warpout_frame(object *objp, float frametime)
int sub_expl_sound_handle[NUM_SUB_EXPL_HANDLES]
ubyte g3_rotate_vertex(vertex *dest, const vec3d *src)
void physics_init(physics_info *pi)
ubyte draw_debris[MAX_DEBRIS_OBJECTS]
virtual int warpShipClip()
int arc_timestamp[MAX_SHIP_ARCS]
float vm_vec_normalized_dir(vec3d *dest, const vec3d *end, const vec3d *start)
float vm_vec_dist(const vec3d *v0, const vec3d *v1)
int optional_string(const char *pstr)
#define PCM_WARPOUT_STAGE2
float fireball_lifeleft(object *obj)
bool dc_optional_string_either(const char *str1, const char *str2)
Searches for an optional string and it's alias.
void shipfx_remove_submodel_ship_sparks(ship *shipp, int submodel_num)
int large_ship_blowup_index
void model_init_submodel_axis_pt(submodel_instance_info *sii, int model_num, int submodel_num)
void SetHookObject(char *name, object *objp)
int getString(char *output, size_t output_max)
void shipfx_blow_off_subsystem(object *ship_objp, ship *ship_p, ship_subsys *subsys, vec3d *exp_center, bool no_explosion)
float vm_vec_normalize_safe(vec3d *v)
dc_printf("Particle_width set to %f\n", Particle_width)
debris Debris[MAX_DEBRIS_PIECES]
#define SF_NO_DEPARTURE_WARP
int model_should_render_engine_glow(int objnum, int bank_obj)
#define SUBSYSTEM_WEAPONS
vec3d * vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m)
float dock_calc_max_semilatus_rectum_parallel_to_axis(object *objp, axis_type axis)
int snd_get_duration(int snd_id)
object Objects[MAX_OBJECTS]
void shipfx_warpin_start(object *objp)
void submodel_get_two_random_points(int model_num, int submodel_num, vec3d *v1, vec3d *v2, vec3d *n1=NULL, vec3d *n2=NULL)
void shipfx_subsystem_maybe_create_live_debris(object *ship_objp, ship *ship_p, ship_subsys *subsys, vec3d *exp_center, float exp_mag)
vec3d model_center_disp_to_orig_center
#define SF_ARRIVING_STAGE_1
void set_replacement_textures(int *textures)
#define SF_NO_ARRIVAL_WARP
char warpin_anim[MAX_FILENAME_LEN]
int warpFrame(float frametime)
#define vm_vec_make(v, _x, _y, _z)
bool shipfx_eye_in_shadow(vec3d *eye_pos, object *src_obj, int sun_n)
int ship_guardian_threshold
int model_get_parent_submodel_for_live_debris(int model_num, int live_debris_model_num)
#define SND_PRIORITY_MUST_PLAY
#define FIREBALL_NUM_LARGE_EXPLOSIONS
void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s)
int getFloat(float *output)
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void compute_warpout_stuff(object *objp, float *speed, float *warp_time, vec3d *warp_pos)
#define TMAP_FLAG_CORRECT
static const int TYPE_SOUND
int special_warpout_objnum
void dc_stuff_float(float *f)
Stuffs a float to the given variable.
void vm_vec_rand_vec_quick(vec3d *rvec)
int is_valid_vec(const vec3d *vec)
void allocate(int quad, int n_tri=0)
void ship_apply_wash_damage(object *ship_objp, object *other_obj, float damage)
float shipfx_calculate_warp_time(object *objp, int warp_dir)
char warpout_anim[MAX_FILENAME_LEN]
int Player_engine_wash_loop
GLuint const GLchar * name
int light_get_global_count()
int RunCondition(int condition, char format='\0', void *data=NULL, class object *objp=NULL, int more_data=0)
#define MAX_DEBRIS_OBJECTS
#define MOVEMENT_TYPE_INTRINSIC_ROTATE
void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1)
#define WE_HOMEWORLD_NUM_STAGES
struct ship_flash ship_flash
float ship_class_get_length(ship_info *sip)
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
GLboolean GLboolean GLboolean b
void send_ship_depart_packet(object *objp, int method)
virtual int warpFrame(float frametime)
void physics_sim(vec3d *position, matrix *orient, physics_info *pi, float sim_time)
void shipfx_do_lightning_frame(ship *shipp)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
#define MR_DEPRECATED_NORMAL
#define DCF_BOOL(function_name, bool_variable)
polymodel_instance * model_get_instance(int model_instance_num)
GLint GLsizei GLsizei height
void model_render_DEPRECATED(int model_num, matrix *orient, vec3d *pos, uint flags=MR_DEPRECATED_NORMAL, int objnum=-1, int lighting_skip=-1, int *replacement_textures=NULL, int render=MODEL_RENDER_ALL, const bool is_skybox=false)
float frand()
Return random value in range 0.0..1.0- (1.0- means the closest number less than 1.0)
#define ENGINE_WASH_CHECK_INTERVAL
bool shipfx_in_shadow(object *src_obj)
int snd_time_remaining(int handle)
void submodel_get_two_random_points_better(int model_num, int submodel_num, vec3d *v1, vec3d *v2)
#define SUBSYSTEM_SENSORS
0.25 second spark sound effect
void bm_page_in_texture(int bitmapnum, int nframes)
Marks a texture as being used for this level.
static const int TYPE_STRING
int batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orient, float rad, float alpha, float depth)
p_object * mission_parse_get_parse_object(ushort net_signature)
void shipfx_flash_light_model(object *objp, int model_num)
int snd_play_looping(game_snd *gs, float pan, int start_loop, int stop_loop, float vol_scale, int scriptingUpdateVolume)
void shipfx_blow_up_model(object *obj, int model, int submodel, int ndebris, vec3d *exp_center)
char subobj_name[MAX_NAME_LEN]
float vm_vec_copy_normalize(vec3d *dest, const vec3d *src)
float model_get_radius(int modelnum)
WE_Homeworld(object *n_objp, int n_direction)
#define MULTIPLAYER_MASTER
static const int TYPE_FLOAT
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
#define SHIP_CANNON_BITMAP
SCP_vector< ship_info > Ship_info
#define SIF_KNOSSOS_DEVICE
vec3d * vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1)
#define TMAP_FLAG_TEXTURED
particle_effect damage_spew
#define SND_PRIORITY_SINGLE_INSTANCE
#define timestamp_elapsed(stamp)
1.00 second spark sound effect
vec3d * get_subsystem_world_pos(object *parent_obj, ship_subsys *subsys, vec3d *world_pos)
void shipfx_warpout_start(object *objp)
virtual int warpFrame(float frametime)
void parse_combined_variable_list(CombinedVariable *dest, flag_def_list *src, size_t num)
GLsizei GLsizei GLuint * obj
void vm_quaternion_rotate(matrix *M, float theta, const vec3d *u)
float get_model_cross_section_at_z(float z, polymodel *pm)
float vm_vec_dot(const vec3d *v0, const vec3d *v1)
GLenum GLuint GLenum GLsizei length
void set_clip_plane(vec3d &pos, vec3d &normal)
#define timestamp_rand(a, b)
void shipfx_large_blowup_level_init()
object * debris_create(object *source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, int hull_flag, float exp_force)
float split_plane[MAX_SPLIT_PLANE]
vec3d arc_pts[MAX_SHIP_ARCS][2]
void shipfx_queue_render_ship_halves_and_debris(draw_list *scene, clip_ship *half_ship, ship *shipp)
int bm_load_either(const char *filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
Loads either animation (bm_load_animation) or still image (bm_load)
WarpEffect * warpin_effect
struct engine_wash_info * wash_info_pointer
void shipfx_large_blowup_render(ship *shipp)
#define PCM_WARPOUT_STAGE3
void model_get_rotating_submodel_axis(vec3d *model_axis, vec3d *world_axis, int model_instance_num, int submodel_num, matrix *objorient)
void multi_set_network_signature(ushort signature, int what_kind)
bool shipfx_point_in_shadow(vec3d *p0, matrix *src_orient, vec3d *src_pos, float radius)
void HUD_printf(const char *format,...)
float fvi_ray_plane(vec3d *new_pnt, const vec3d *plane_pnt, const vec3d *plane_norm, const vec3d *ray_origin, const vec3d *ray_direction, float rad)
int batch_add_polygon(int texture, int tmap_flags, vec3d *pos, matrix *orient, float width, float height, float alpha)
asteroid_field Asteroid_field
int bm_unload(int handle, int clear_render_targets, bool nodebug)
Unloads a bitmap's data, but not the bitmap info.
ushort multi_assign_network_signature(int what_kind)
void shipfx_flash_create(object *objp, int model_num, vec3d *gun_pos, vec3d *gun_dir, int is_primary, int weapon_info_index)
flag_def_list Warp_variables[]
#define FIREBALL_EXPLOSION_MEDIUM
vec3d * vm_vec_cross(vec3d *dest, const vec3d *src0, const vec3d *src1)
#define FIREBALL_WARP_EFFECT
int get_sound_time_played(int snd_id, int handle)
#define SMALLEST_RAD_TIME
int getWarpPosition(vec3d *output)
struct clip_ship clip_ship
int shipfx_special_warp_objnum_valid(int objnum)
virtual int warpShipClip()
bool IsConditionOverride(int action, object *objp=NULL)
SCP_vector< asteroid_info > Asteroid_info
static const int TYPE_NONE
void gameseq_post_event(int event)
particle_effect impact_spew
void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1)
matrix vmd_identity_matrix
#define timestamp_valid(stamp)
SCP_vector< engine_wash_info > Engine_wash_info
float shipfx_calculate_warp_dist(object *objp)
char ship_name[NAME_LENGTH]
SCP_vector< ship_type_info > Ship_types
int getWarpOrientation(matrix *output)
void shipfx_large_blowup_init(ship *shipp)
particle_effect split_particles
GLfloat GLfloat GLfloat GLfloat v3
float vm_vec_normalize(vec3d *v)
int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, int warp_open_sound, int warp_close_sound)
float debris_min_rotspeed
void shipfx_emit_spark(int n, int sn)
#define BSP_LIGHT_TYPE_WEAPON