Skip to content

Commit 2576515

Browse files
authored
Allow Trigger Radius curve input to work with muzzle effects (scp-fs2open#6706)
The Input of `Trigger Radius` for curves within new particle effects was never hooked up for muzzle flashes, so this PR adds in the necessary lines to get it working. This allows modders to make a muzzle effect that can scale to the weapon radius through curves, and thus modders can simply make one curve scaled muzzle flash and avoid making a many muzzle flashes for each sized weapon that uses the same base effect. Tested and works as expected.
1 parent c2314f6 commit 2576515

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

code/ai/aiturret.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
20192019
//spawn particle effect
20202020
auto particleSource = particle::ParticleManager::get()->createSource(wip->muzzle_effect);
20212021
particleSource->setHost(make_unique<EffectHostTurret>(&Objects[parent_ship->objnum], turret->system_info->turret_gun_sobj, turret->turret_next_fire_pos));
2022+
particleSource->setTriggerRadius(objp->radius);
20222023
particleSource->finishCreation();
20232024
}
20242025
else if (wip->muzzle_flash >= 0) {
@@ -2135,6 +2136,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
21352136
//spawn particle effect
21362137
auto particleSource = particle::ParticleManager::get()->createSource(Weapon_info[tsi->weapon_class].muzzle_effect);
21372138
particleSource->setHost(make_unique<EffectHostTurret>(&Objects[tsi->parent_objnum], tsi->turret->system_info->turret_gun_sobj, tsi->turret->turret_next_fire_pos - 1));
2139+
particleSource->setTriggerRadius(Objects[weapon_objnum].radius);
21382140
particleSource->finishCreation();
21392141
}
21402142
else if (Weapon_info[tsi->weapon_class].muzzle_flash >= 0) {

code/ship/shipfx.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,16 @@ void shipfx_flash_create(object *objp, int model_num, vec3d *gun_pos, vec3d *gun
10661066
auto particleSource = particle::ParticleManager::get()->createSource(Weapon_info[weapon_info_index].muzzle_effect);
10671067
//This should probably end up attached to the subobject, not the object, but it's not that much of a problem since primaries / secondaries rarely move.
10681068
particleSource->setHost(make_unique<EffectHostObject>(objp, *gun_pos, gunOrient, true));
1069+
1070+
// set radius manually following logic in weapon_create function --wookieejedi
1071+
if (Weapon_info[weapon_info_index].collision_radius_override > 0.0f)
1072+
particleSource->setTriggerRadius(Weapon_info[weapon_info_index].collision_radius_override);
1073+
else if (Weapon_info[weapon_info_index].render_type == WRT_POF) {
1074+
particleSource->setTriggerRadius(model_get_radius(Weapon_info[weapon_info_index].model_num));
1075+
} else if (Weapon_info[weapon_info_index].render_type == WRT_LASER) {
1076+
particleSource->setTriggerRadius(Weapon_info[weapon_info_index].laser_head_radius);
1077+
}
1078+
10691079
particleSource->finishCreation();
10701080
// if there's a muzzle flash entry and no muzzle effect entry, we use the mflash
10711081
} else if (Weapon_info[weapon_info_index].muzzle_flash >= 0) {

0 commit comments

Comments
 (0)