2018-10-20 01:59 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0002447FSSCPAIpublic2012-12-18 11:54
ReporterSDM 
Assigned ToValathil 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.12 
Target VersionFixed in Version 
Summary0002447: When telling Friendly to disarm Target, Friendly will not fire Secondaries
DescriptionTried 3.6.12, Antipodes 8 7108, and 3.6.13 7211. Friendly will not fire Stilleto IIs or any secondaries (tried Tempests and Hornets as well) at a cruiser with turrets. Ransom's Windmills campaign depends on this feature, so it must've worked at one point.
TagsNo tags attached.
Attached Files
  • ? file icon disarm order.fs2 (5,765 bytes) 2012-12-15 14:45
  • patch file icon 2447.patch (6,735 bytes) 2012-12-16 17:42 -
    Index: code/ai/aibig.cpp
    ===================================================================
    --- code/ai/aibig.cpp	(revision 9440)
    +++ code/ai/aibig.cpp	(working copy)
    @@ -20,6 +20,7 @@
     #include "mission/missionparse.h"
     #include "iff_defs/iff_defs.h"
     #include "math/staticrand.h"
    +#include "ai/aigoals.h"
     
     
     
    @@ -721,71 +722,75 @@
     					if (En_objp->phys_info.speed * dist_to_enemy < 5000.0f)		//	Don't select a bomb if enemy moving fast relative to distance
     						priority1 = WIF_BOMB;
     
    -				if (!(En_objp->flags & OF_PROTECTED)) {
    +				if (!(En_objp->flags & OF_PROTECTED) || (aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP))) {
     					//ai_select_secondary_weapon(Pl_objp, tswp, priority1, priority2);	//	Note, need to select to get weapon speed and lifetime
    -
    +					if(aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) {
    +						priority1 = WIF_PUNCTURE;
    +					}
     					ai_choose_secondary_weapon(Pl_objp, aip, En_objp);
     					int current_bank = tswp->current_secondary_bank;
     					weapon_info	*swip = &Weapon_info[tswp->secondary_bank_weapons[current_bank]];
     
    -					//	If ship is protected and very low on hits, don't fire missiles.
    -					if ((current_bank > -1) &&  (!(En_objp->flags & OF_PROTECTED) || (En_objp->hull_strength > 10*swip->damage))) {
    -						if (aip->ai_flags & AIF_UNLOAD_SECONDARIES) {
    -							if (timestamp_until(swp->next_secondary_fire_stamp[current_bank]) > swip->fire_wait*1000.0f) {
    -								swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (swip->fire_wait*1000.0f));
    +					if(!(En_objp->flags & OF_PROTECTED) || ((aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) && swip->wi_flags & WIF_PUNCTURE )) { //override lockdown on protected ships when using anti subsystem weapons - Valathil
    +						//	If ship is protected and very low on hits, don't fire missiles.
    +						if ((current_bank > -1) &&  (!(En_objp->flags & OF_PROTECTED) || (En_objp->hull_strength > 10*swip->damage))) {
    +							if (aip->ai_flags & AIF_UNLOAD_SECONDARIES) {
    +								if (timestamp_until(swp->next_secondary_fire_stamp[current_bank]) > swip->fire_wait*1000.0f) {
    +									swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (swip->fire_wait*1000.0f));
    +								}
     							}
    -						}
     
    -						if (timestamp_elapsed(swp->next_secondary_fire_stamp[current_bank])) {
    -							float firing_range;
    -							if (swip->wi_flags2 & WIF2_LOCAL_SSM)
    -								firing_range=swip->lssm_lock_range;
    -							else
    -								firing_range = MIN((swip->max_speed * swip->lifetime), swip->weapon_range);
    -							// reduce firing range of secondaries in nebula
    -							extern int Nebula_sec_range;
    -							if ((The_mission.flags & MISSION_FLAG_FULLNEB) && Nebula_sec_range) {
    -								firing_range *= 0.8f;
    -							}
    +							if (timestamp_elapsed(swp->next_secondary_fire_stamp[current_bank])) {
    +								float firing_range;
    +								if (swip->wi_flags2 & WIF2_LOCAL_SSM)
    +									firing_range=swip->lssm_lock_range;
    +								else
    +									firing_range = MIN((swip->max_speed * swip->lifetime), swip->weapon_range);
    +								// reduce firing range of secondaries in nebula
    +								extern int Nebula_sec_range;
    +								if ((The_mission.flags & MISSION_FLAG_FULLNEB) && Nebula_sec_range) {
    +									firing_range *= 0.8f;
    +								}
     
    -							float t = 0.25f;	//	default delay in seconds until next fire.
    +								float t = 0.25f;	//	default delay in seconds until next fire.
     
    -							if (dist_to_enemy < firing_range*1.0f) {
    +								if (dist_to_enemy < firing_range*1.0f) {
     
     
    -								//vm_vec_scale_add(&future_enemy_pos, enemy_pos, enemy_vel, dist_to_enemy/swip->max_speed);
    -								//if (vm_vec_dist_quick(&future_enemy_pos, firing_pos) < firing_range * 0.8f) {
    -									if (ai_fire_secondary_weapon(Pl_objp)) {
    -										if ((aip->ai_flags & AIF_UNLOAD_SECONDARIES) || (swip->burst_flags & WBF_FAST_FIRING)) {
    -											if (swip->burst_shots > swp->burst_counter[current_bank]) {
    -												t = swip->burst_delay;
    -												swp->burst_counter[current_bank]++;
    -											} else {
    -												t = swip->fire_wait;
    -												if ((swip->burst_shots > 0) && (swip->burst_flags & WBF_RANDOM_LENGTH)) {
    -													swp->burst_counter[current_bank] = myrand() % swip->burst_shots;
    +									//vm_vec_scale_add(&future_enemy_pos, enemy_pos, enemy_vel, dist_to_enemy/swip->max_speed);
    +									//if (vm_vec_dist_quick(&future_enemy_pos, firing_pos) < firing_range * 0.8f) {
    +										if (ai_fire_secondary_weapon(Pl_objp)) {
    +											if ((aip->ai_flags & AIF_UNLOAD_SECONDARIES) || (swip->burst_flags & WBF_FAST_FIRING)) {
    +												if (swip->burst_shots > swp->burst_counter[current_bank]) {
    +													t = swip->burst_delay;
    +													swp->burst_counter[current_bank]++;
     												} else {
    - 													swp->burst_counter[current_bank] = 0;
    +													t = swip->fire_wait;
    +													if ((swip->burst_shots > 0) && (swip->burst_flags & WBF_RANDOM_LENGTH)) {
    +														swp->burst_counter[current_bank] = myrand() % swip->burst_shots;
    +													} else {
    + 														swp->burst_counter[current_bank] = 0;
    +													}
     												}
    -											}
    -										} else {
    -											if (swip->burst_shots > swp->burst_counter[current_bank]) {
    -												t = set_secondary_fire_delay(aip, temp_shipp, swip, true);
    -												swp->burst_counter[current_bank]++;
     											} else {
    -												t = set_secondary_fire_delay(aip, temp_shipp, swip, false);
    -												if ((swip->burst_shots > 0) && (swip->burst_flags & WBF_RANDOM_LENGTH)) {
    -													swp->burst_counter[current_bank] = myrand() % swip->burst_shots;
    +												if (swip->burst_shots > swp->burst_counter[current_bank]) {
    +													t = set_secondary_fire_delay(aip, temp_shipp, swip, true);
    +													swp->burst_counter[current_bank]++;
     												} else {
    -													swp->burst_counter[current_bank] = 0;
    +													t = set_secondary_fire_delay(aip, temp_shipp, swip, false);
    +													if ((swip->burst_shots > 0) && (swip->burst_flags & WBF_RANDOM_LENGTH)) {
    +														swp->burst_counter[current_bank] = myrand() % swip->burst_shots;
    +													} else {
    +														swp->burst_counter[current_bank] = 0;
    +													}
     												}
     											}
    +											swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (t*1000.0f));
     										}
    -										swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (t*1000.0f));
    -									}
    -								//}
    +									//}
    +								}
    +								swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (t*1000.0f));
     							}
    -							swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (t*1000.0f));
     						}
     					}
     				}
    
    patch file icon 2447.patch (6,735 bytes) 2012-12-16 17:42 +

-Relationships
+Relationships

-Notes

~0012696

SDM (reporter)

Added test mission

~0014474

MjnMixael (manager)

Uploaded fixed mission that works on current builds. This is still a problem. Alpha 2 in this mission has no primary weapons and has a bank of Stillettos which it should be firing after you order it to disarm the Mentu.

~0014486

Valathil (developer)

Last edited: 2012-12-16 14:58

View 4 revisions

This happens because $Protected on cripple: ships instantly get protected if you order your guys to attack a subsystem, disable or disarm them and fighters don't shoot missiles on protected ships. This was previously an ai_profile flag that was removed in commit 5961 march 2010. This is what killed the Windmills campaign. 3 ways to "fix": 1) change the auto protection behaviour which kinda seems weird anyway (Retail compat?) 2) override the missile lockdown if its antisubsystem missiles 3) people need to remove the cripple flag no code change.

EDIT: ok 1) is out because if you only order a part of your forces to disable the rest would still try to destroy the target.
3) is also wobbly because its an objecttypes.tbl flag and would change the whole shipclass

~0014489

Valathil (developer)

I attached a patch that uses solution 2) as in when a ship is protected, AI with the disable or disarm order are still allowed to fire their subsystem attacking secondaries. But since this an AI bug I'd like for some tests before this goes in if its even the thing we want.

~0014493

karajorma (administrator)

I'm pretty sure the $Protected on cripple flag should only be affecting ships which had the previous always-on system of protection.

I couldn't remove this because of retail compatibility. It is there for a reason though, without it, unless the FREDder takes care of it, the AI will quite happily blow away a ship you've ordered them to disable.

If Windmills used the old AI_Profile flag then that was a large mistake on Ransom's part as that flag was part of a deal between me and the Wing Commander Saga team. Where I'd add the flag as a temporary measure in order to allow them to continue development while I coded up a more permanent solution. It was never meant to be used in releases.

I think the patch would actually break a lot of missions, especially any where subsystem damage is then passed on to the underlying ship. I had planned to one day code in a ship based override but since no one ever seemed to need it, it slid down the priorities table.

~0014494

Valathil (developer)

they will still stop on ships with low health

~0014510

karajorma (administrator)

To be honest, I'm not a fan of this solution. If as a FREDder I want to protect a ship, I should be reasonably certain I can do so without having the player come along and order the ship to continue to be attacked.

More importantly, pretty much every mission built to date has been made with the above assumption. I can see this breaking numerous missions where the player has to disable a ship. Once the ship is disabled the AI would continue to attack it even though the mission designer had set the ship to be protected.


Secondly, there's no off switch for this addition. It will always be on for every mod regardless of what they desired. I think the behaviour in the patch should depend on an objecttypes.tbl flag. This means that once Wanderer's objecttypes code is in trunk not only can the behaviour be switched from the tables but also via FRED.

~0014514

Valathil (developer)

I talked with kara and we came to the conclusion to commit because attacking is allowed on protected ships when disabling/disarming so secondary behaviour should be the same as primary.

~0014515

Valathil (developer)

Fix committed to trunk@9447.
+Notes

+Related Changesets

-Issue History
Date Modified Username Field Change
2011-05-29 22:39 SDM New Issue
2011-05-29 22:39 SDM Status new => assigned
2011-05-29 22:39 SDM Assigned To => Sushi_CW
2011-05-29 23:26 SDM File Added: disarm order.fs2
2011-05-29 23:26 SDM Note Added: 0012696
2012-12-15 14:45 MjnMixael File Deleted: disarm order.fs2
2012-12-15 14:45 MjnMixael File Added: disarm order.fs2
2012-12-15 14:46 MjnMixael Note Added: 0014474
2012-12-15 15:18 Sushi_CW Assigned To Sushi_CW =>
2012-12-16 13:42 Valathil Note Added: 0014486
2012-12-16 13:58 Valathil Note Edited: 0014486 View Revisions
2012-12-16 14:55 Valathil Note Edited: 0014486 View Revisions
2012-12-16 14:58 Valathil Note Edited: 0014486 View Revisions
2012-12-16 17:42 Valathil File Added: 2447.patch
2012-12-16 17:42 Valathil Assigned To => Valathil
2012-12-16 17:45 Valathil Note Added: 0014489
2012-12-16 17:45 Valathil Status assigned => code review
2012-12-16 19:58 karajorma Note Added: 0014493
2012-12-16 20:03 Valathil Note Added: 0014494
2012-12-18 04:45 karajorma Note Added: 0014510
2012-12-18 11:53 Valathil Note Added: 0014514
2012-12-18 11:54 Valathil Changeset attached => fs2open trunk r9447
2012-12-18 11:54 Valathil Note Added: 0014515
2012-12-18 11:54 Valathil Status code review => resolved
2012-12-18 11:54 Valathil Resolution open => fixed
+Issue History