View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001948 | FSSCP | --------- | public | 2009-07-02 20:24 | 2009-07-20 04:14 |
Reporter | KeldorKatarn | Assigned To | chief1983 | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | IBM PC | OS | Windows | OS Version | Vista SP1 |
Product Version | 3.6.11 | ||||
Summary | 0001948: "fire down normals" without effect | ||||
Description | I have a model that has a torpedo launcher as a turret. The turret is just a tube that cannot move (rotation speed = 0.0 in ships.tbl). However the torpedoes are all still fired directly towards the target. So someone told me to use the "fire down normals" flag and I did. To my surprise this didn't change a thing. The torp is still fired directly at the target. | ||||
Steps To Reproduce | Look at the source code. | ||||
Additional Information | The function int aifft_rotate_turret(...) in aiturret.cpp has the following ending: // return 0 by default (to preserve retail behavior) but allow for a per-subsystem option // for using the turret normals for firing if (ss->system_info->flags & MSS_FLAG_FIRE_ON_NORMAL) return 1; return 0; This is the only place where MSS_FLAG_FIRE_ON_NORMAL is evaluated. The only caller to aifft_rotate_turret() is void ai_fire_from_turret() in the same file. And that function does this with the return value: int use_angles = aifft_rotate_turret(...); use_angles is passes as a parameter to ship_get_global_turret_gun_info() which does this with it. (gvec seems to be the output direction vector) if (use_angles) model_find_world_dir(gvec, &tp->turret_norm, tp->model_num, tp->turret_gun_sobj, &objp->orient, &objp->pos ); else { //vector gun_pos2; //vm_vec_add(&gun_pos2, gpos, gun_pos); vm_vec_normalized_dir(gvec, targetp, gpos); } That output vector is used in ai_fire_from_turret() later and that's where the bug is, I believe: Here a wrong vector is assigned: // We're ready to fire... now get down to specifics, like where is the // actual gun point and normal, not just the one for whole turret. // moved here as if there are two weapons with indentical fire stamps // they would have shared the fire point. tv2e = v2e; v2e was only calculated to get the dot product: // Fire in the direction the turret is facing, not right at the target regardless of turret dir. vm_vec_sub(&v2e, &predicted_enemy_pos, &gpos); dist_to_enemy = vm_vec_normalize(&v2e); dot = vm_vec_dot(&v2e, &gvec); it was never meant as the firing direction, otherwise the gvec would not have been calculated. This if that is changed to: tv2e = gvec; This should work correctly. Later the correct vector is then used to initialize fire the weapon: turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos); THis is also the only place where tv2e is used except for the line that adds jitter, but I think here also the correct firing vector must be used: if(wip->wi_flags & WIF_FLAK){ flak_jitter_aim(&tv2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS)); } Proposed (1-line) patch attached. Please check in detail and confirm. Please check and confirm. | ||||
Tags | No tags attached. | ||||
2009-07-02 20:24
|
fire-down-normal.patch (505 bytes)
Index: code/ai/aiturret.cpp =================================================================== --- code/ai/aiturret.cpp (revision 5382) +++ code/ai/aiturret.cpp (working copy) @@ -1951,7 +1951,7 @@ // actual gun point and normal, not just the one for whole turret. // moved here as if there are two weapons with indentical fire stamps // they would have shared the fire point. - tv2e = v2e; + tv2e = gvec; // make sure to reset this for current weapon ok_to_fire = false; |
|
This seems to be right. Can someone confirm that the patch works as expected? |
|
KKs patch committed. |
|
I think this is confirmed to work and can be set to resolved. |
|
Closed. |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-07-02 20:24 | KeldorKatarn | New Issue | |
2009-07-02 20:24 | KeldorKatarn | File Added: fire-down-normal.patch | |
2009-07-03 16:29 | portej05 | Note Added: 0011036 | |
2009-07-03 17:13 | portej05 | Status | new => assigned |
2009-07-03 17:13 | portej05 | Assigned To | => chief1983 |
2009-07-03 17:13 | portej05 | Note Added: 0011037 | |
2009-07-03 17:13 | portej05 | Status | assigned => feedback |
2009-07-20 00:47 | KeldorKatarn | Note Added: 0011096 | |
2009-07-20 04:14 | chief1983 | Note Added: 0011097 | |
2009-07-20 04:14 | chief1983 | Status | feedback => resolved |
2009-07-20 04:14 | chief1983 | Resolution | open => fixed |