diff --git a/code/parse/lua.cpp b/code/parse/lua.cpp index 7d69edfc4d..91355fd5d1 100644 --- a/code/parse/lua.cpp +++ b/code/parse/lua.cpp @@ -4181,6 +4181,7 @@ ADE_FUNC(checkRayCollision, l_Object, "vector Start Point, vector End Point, [bo obj = objh->objp; int flags = 0; int submodel = -1; + bool model_started = false; switch(obj->type) { case OBJ_SHIP: @@ -4208,6 +4209,11 @@ ADE_FUNC(checkRayCollision, l_Object, "vector Start Point, vector End Point, [bo if (model_num < 0) return ADE_RETURN_NIL; + if (obj->type == OBJ_SHIP) { + ship_model_start(obj); + model_started = true; + } + mc_info hull_check; hull_check.model_num = model_num; @@ -4219,8 +4225,13 @@ ADE_FUNC(checkRayCollision, l_Object, "vector Start Point, vector End Point, [bo hull_check.flags = flags; if ( !model_collide(&hull_check) ) { + if (model_started) + ship_model_stop(obj); return ADE_RETURN_NIL; } + + if (model_started) + ship_model_stop(obj); if (local) return ade_set_args(L, "o", l_Vector.Set(hull_check.hit_point)); diff --git a/code/parse/sexp.cpp b/code/parse/sexp.cpp index d0bfb464df..56e5fa2915 100644 --- a/code/parse/sexp.cpp +++ b/code/parse/sexp.cpp @@ -8893,7 +8893,7 @@ void sexp_update_sound_environment(int node) //From sexp help: //{ OP_ADJUST_AUDIO_VOLUME, "adjust-audio-volume\r\n" // "Adjusts the relative volume of one sound type. Takes 2 or 3 arguments....\r\n" - // "\t1:\tSound Type to adjust, either Master, Music, Voice or Effects\r\n" + // "\t1:\tSound Type to adjust, either Music, Voice or Effects\r\n" // "\t2:\tPercentage of the users' settings to adjust to, 0 will be silence, 100 means the maximum volume as set by the user\r\n" // "\t3:\tFade time (optional), time in milliseconds to adjust the volume"}, @@ -8921,20 +8921,22 @@ void sexp_adjust_audio_volume(int node) if (n > 0) { int option = audio_volume_option_lookup(CTEXT(n)); - n = CDR(n); - - float target_volume = 1.0f; - if (n >= 0) { - target_volume = (float)eval_num(n) / 100; - CLAMP(target_volume, 0.0f, 1.0f); + if (option > 0) { n = CDR(n); + + float target_volume = 1.0f; + if (n >= 0) { + target_volume = (float)eval_num(n) / 100; + CLAMP(target_volume, 0.0f, 1.0f); + n = CDR(n); + } + + int time = 0; + if (n >= 0) + time = eval_num(n); + + snd_adjust_audio_volume(option, target_volume, time); } - - int time = 0; - if (n >= 0) - time = eval_num(n); - - snd_adjust_audio_volume(option, target_volume, time); } } diff --git a/code/sound/sound.cpp b/code/sound/sound.cpp index bbfe0e5d9a..9b23cd23eb 100644 --- a/code/sound/sound.cpp +++ b/code/sound/sound.cpp @@ -1396,34 +1396,38 @@ int snd_get_samples_per_measure(char *filename, float num_measures) void snd_adjust_audio_volume(int type, float percent, int time) { - Assert( type >= 0 && type < 4 ); + Assert( type >= 0 && type < 3 ); - switch (type) { - case AAV_MUSIC: - aav_data[type].start_volume = aav_music_volume; - if (percent < aav_music_volume) - aav_data[type].delta = (aav_music_volume - percent) * -1.0f; - else - aav_data[type].delta = percent - aav_music_volume; - break; - case AAV_VOICE: - aav_data[type].start_volume = aav_voice_volume; - if (percent < aav_voice_volume) - aav_data[type].delta = (aav_voice_volume - percent) * -1.0f; - else - aav_data[type].delta = percent - aav_voice_volume; - break; - case AAV_EFFECTS: - aav_data[type].start_volume = aav_effect_volume; - if (percent < aav_effect_volume) - aav_data[type].delta = (aav_effect_volume - percent) * -1.0f; - else - aav_data[type].delta = percent - aav_effect_volume; - break; - } + if ( type >= 0 && type < 3 ) { + switch (type) { + case AAV_MUSIC: + aav_data[type].start_volume = aav_music_volume; + if (percent < aav_music_volume) + aav_data[type].delta = (aav_music_volume - percent) * -1.0f; + else + aav_data[type].delta = percent - aav_music_volume; + break; + case AAV_VOICE: + aav_data[type].start_volume = aav_voice_volume; + if (percent < aav_voice_volume) + aav_data[type].delta = (aav_voice_volume - percent) * -1.0f; + else + aav_data[type].delta = percent - aav_voice_volume; + break; + case AAV_EFFECTS: + aav_data[type].start_volume = aav_effect_volume; + if (percent < aav_effect_volume) + aav_data[type].delta = (aav_effect_volume - percent) * -1.0f; + else + aav_data[type].delta = percent - aav_effect_volume; + break; + default: + Int3(); + } - aav_data[type].delta_time = time; - aav_data[type].start_time = (f2fl(Missiontime) * 1000); + aav_data[type].delta_time = time; + aav_data[type].start_time = (f2fl(Missiontime) * 1000); + } } void adjust_volume_on_frame(float* volume_now, aav* data) diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index d5543b2ad4..ca3fe976dc 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -2266,6 +2266,8 @@ int beam_collide_ship(obj_pair *pair) int valid_hit_occurred = 0; sip = &Ship_info[shipp->ship_info_index]; bwi = &Weapon_info[b->weapon_info_index]; + + ship_model_start(ship_objp); polymodel *pm = model_get(model_num); // get the widest portion of the beam @@ -2355,6 +2357,7 @@ int beam_collide_ship(obj_pair *pair) valid_hit_occurred = 1; } + ship_model_stop(ship_objp); // if we got a hit if (valid_hit_occurred) {