View Issue Details

IDProjectCategoryView StatusLast Update
0000945FSSCPdockingpublic2012-07-01 05:59
ReporterThe Trivial Psychic Assigned ToGoober5000  
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformAMD-2600+ 1GB DDR400 ATI9600XTOSWinXP in OGLOS VersionSP2
Target Version3.6.14Fixed in Version3.6.14 
Summary0000945: Non-Leader Docked Craft Attempt Maneuvers
DescriptionIf you dock one or more fighter craft to a larger ship, regardless of the fact that the larger ship is the dock leader, the smaller craft will still attempt to loiter, or engage nearby hostiles, causing the larger craft to spin about. If there are more than one small fighter docked to the large craft, it will also cause a degree of jerkiness to the spinning, since there are multiple fighters trying to maneuver the ship. The only way to avoid this is to give every ship except the dock leader, orders to play dead. If a wing is docked in this manner, the individual fighters in the wing must be given such an order, rather than the wing as a whole.

Unfortunately, this behaviour has been somewhat present since Retail, and I'm certain that one or more campaigns have taken advantage of it for comedic effect. Therefore, the best way I can see to preserve backwards compatibility would be to add a checkbox either in the docking controls or in the ship flags, that causes the ship to be inactive while docked, which includes engines and weapons primarily, though perhaps not turrets. Not sure if this should be engaged by default for any new missions created with a such-enabled FRED, so that when a designer docks 2 or more objects together, any object not deemed as the dock leader, automatically has this checkbox enabled. Missions previously created and loaded either in FRED or in FS, will default to the previous behaviour.
Steps To ReproduceTake a ship with multiple dockpoints, dock several fighters to it, make all hostile, then play in mission and watch the core ship spin around. Then, change the intial orders of the fighters to "play dead, 89", then replay the mission and watch how it behaves as it should.
Additional InformationThis was split from bug 0000530.
TagsNo tags attached.

Relationships

parent of 0002557 closedGoober5000 Jettison-cargo-delay doesn't work 
has duplicate 0001723 closedGoober5000 Fighters/bombers with no orders will keep trying to fly around when docked to another ship 

Activities

The_E

2010-10-22 13:00

administrator   ~0012422

Is this still current?

Goober5000

2010-10-23 20:33

administrator   ~0012433

I believe so.

FUBAR-BDHR

2010-10-23 23:41

developer   ~0012434

Last edited: 2010-10-23 23:45

I second that believe so and know that the speed issue still happens as well. Probably should a relation to that one.

Guess I never filed that report in SCP Mantis because this one was here. It's still open in Diaspora Mantis so the problem still exists in some form.

Goober5000

2012-01-03 08:15

administrator   ~0013020

Okay, here's how I propose to fix this:

If a ship is docked to something, and does not have any active goals or orders, then it should not perform evasive maneuvers.

Note, the decision should not be whether the ship is the "dock leader" or not, because the dock leader only matters as far as warping into the mission. It's not necessarily the ship that has control of the stack at a particular time.

Goober5000

2012-01-03 08:17

administrator   ~0013021

I should also look through the code to see if I made that incorrect assumption anywhere else the dock leader is referenced.

Alan Bolte

2012-01-03 08:51

reporter   ~0013022

I don't understand the relationship to 2548. 2548 is for non-docked cargo containers, nav buoys, and sentry guns. In the patch I attached, all I had to do was give non-flyable 'ships' the same exclusion from shockwave-dodging that big ships have (which is handled separately from normal weapon dodging as far as I can tell). I guess the shockwave-dodging behavior might be feeding into the docking issues, I dunno.

Goober5000

2012-01-03 08:57

administrator   ~0013023

Oh. I assumed 2548 was for docked cargo containers. Reopening then.

niffiwan

2012-06-20 01:08

developer   ~0013680

Would a kind soul be able to FRED up a test mission for this bug?

MjnMixael

2012-06-21 20:26

manager  

MultiDockTest.fs2 (9,481 bytes)

MjnMixael

2012-06-21 20:26

manager   ~0013695

Test mission uploaded for no mods.

niffiwan

2012-06-22 09:23

developer   ~0013700

Thanks MjnMixael!

Goober5000

2012-06-25 10:35

administrator   ~0013721

Okay, the case demonstrated in the test mission is now fixed. You should also draw up a test case for a fighter that isn't initially docked. (Initially docked ships have a particularly clean AI state that later-docked ships may not have.)

MjnMixael

2012-06-25 13:54

manager  

MultiDockTest2.fs2 (10,171 bytes)

MjnMixael

2012-06-25 13:54

manager   ~0013722

New mission uploaded, is that what you mean?

Also, the Argo's maneuverability in retail is impressive..

Goober5000

2012-06-25 22:52

administrator   ~0013723

Hmm. As I feared, the Argo flips out in the second test mission. More detective work is needed.

Goober5000

2012-06-25 23:27

administrator   ~0013724

I have patched most of the gaps, but the fighters still pulse their engines if shot at. I'll defer this for now, but revisit it later.

Goober5000

2012-06-25 23:29

administrator  

patch2_for_945.patch (3,402 bytes)   
Index: code/ai/aicode.cpp
===================================================================
--- code/ai/aicode.cpp	(revision 8915)
+++ code/ai/aicode.cpp	(working copy)
@@ -10589,9 +10589,8 @@
 	case AIS_DOCK_4A:
 	{
 		if (aigp == NULL) {	//	Can happen for initially docked ships.
-			// Goober5000 - if we just "sit and wait for further orders", then we're not doing any behavior, grrr...
-			// (commenting out a retail bug)
-			//ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] );		// do the default behavior
+			// this now "just sits here" for docked ships
+			ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] );		// do the default behavior
 		} else {
 			mission_log_add_entry(LOG_SHIP_DOCKED, shipp->ship_name, goal_shipp->ship_name);
 
@@ -13585,6 +13584,12 @@
 
 	Assert((aip->mode != AIM_WAYPOINTS) || (aip->active_goal != AI_ACTIVE_GOAL_DYNAMIC));
 
+	if (!stricmp(shipp->ship_name, "GTF Ulysses 2")) {
+		mprintf(("ship 2\n"));
+	} else if (!stricmp(shipp->ship_name, "GTF Ulysses 3")) {
+		mprintf(("ship 3\n"));
+	}
+
 	// Set globals defining the current object and its enemy object.
 	Pl_objp = &Objects[objnum];
 
@@ -14188,42 +14193,42 @@
 
 void ai_do_default_behavior(object *obj)
 {
-	ai_info	*aip;
-	int		ship_flags;
-
 	Assert(obj != NULL);
 	Assert(obj->instance != -1);
 	Assert(Ships[obj->instance].ai_index != -1);
 
-	aip = &Ai_info[Ships[obj->instance].ai_index];
+	ai_info	*aip = &Ai_info[Ships[obj->instance].ai_index];
+	int	ship_flags = Ship_info[Ships[obj->instance].ship_info_index].flags;
 
-	ship_flags = Ship_info[Ships[obj->instance].ship_info_index].flags;
-	if (!is_instructor(obj) && (ship_flags & (SIF_FIGHTER | SIF_BOMBER)))
+	// default behavior in most cases (especially if we're docked) is to just stay put
+	aip->mode = AIM_NONE;
+	aip->submode_start_time = Missiontime;
+	aip->active_goal = AI_GOAL_NONE;
+
+	// if we're not docked, we may modify the behavior a bit
+	if (!object_is_docked(obj))
 	{
-		int enemy_objnum = find_enemy(OBJ_INDEX(obj), 1000.0f, The_mission.ai_profile->max_attackers[Game_skill_level]);
-		set_target_objnum(aip, enemy_objnum);
-		aip->mode = AIM_CHASE;
-		aip->submode = SM_ATTACK;
-		aip->submode_start_time = Missiontime;
+		// fighters automatically chase things
+		if (!is_instructor(obj) && (ship_flags & (SIF_FIGHTER | SIF_BOMBER)))
+		{
+			int enemy_objnum = find_enemy(OBJ_INDEX(obj), 1000.0f, The_mission.ai_profile->max_attackers[Game_skill_level]);
+			set_target_objnum(aip, enemy_objnum);
+			aip->mode = AIM_CHASE;
+			aip->submode = SM_ATTACK;
+		}
+		// support ships automatically keep a safe distance
+		else if (ship_flags & SIF_SUPPORT)
+		{
+			aip->mode = AIM_SAFETY;
+			aip->submode = AISS_1;
+			aip->ai_flags &= ~(AIF_REPAIRING);
+		}
+		// sentry guns... do their thing
+		else if (ship_flags & SIF_SENTRYGUN)
+		{
+			aip->mode = AIM_SENTRYGUN;
+		}
 	}
-	else if (ship_flags & (SIF_SUPPORT))
-	{
-		aip->mode = AIM_SAFETY;
-		aip->submode = AISS_1;
-		aip->submode_start_time = Missiontime;
-		aip->ai_flags &= ~(AIF_REPAIRING);
-	}
-	else if ( ship_flags & SIF_SENTRYGUN )
-	{
-		aip->mode = AIM_SENTRYGUN;
-	}
-	else
-	{
-		aip->mode = AIM_NONE;
-	}
-	
-	aip->submode_start_time = Missiontime;
-	aip->active_goal = AI_GOAL_NONE;
 }
 
 #define	FRIENDLY_DAMAGE_THRESHOLD	50.0f		//	Display a message at this threshold.  Note, this gets scaled by Skill_level
patch2_for_945.patch (3,402 bytes)   

Goober5000

2012-06-25 23:29

administrator   ~0013725

I've uploaded my current patch.

Goober5000

2012-06-25 23:32

administrator  

0MultiDockTest2.fs2 (10,183 bytes)

Goober5000

2012-06-25 23:33

administrator   ~0013726

This new version of MultiDockTest assigns one of the ships to stay-still (the other is still play-dead) and changes the mission name.

niffiwan

2012-06-26 10:08

developer  

patch3_for_945.patch (1,427 bytes)   
Index: fs2_open/code/ai/aicode.cpp
===================================================================
--- fs2_open/code/ai/aicode.cpp    (revision 8915)
+++ fs2_open/code/ai/aicode.cpp    (working copy)
@@ -11999,6 +11999,11 @@ void ai_maybe_evade_locked_missile(object *objp, ai_info *aip)
 		return;
 	}
 
+	// don't evade missiles if you're docked
+	if (object_is_docked(objp)) {
+		return;
+	}
+
 	if (aip->ai_flags & (AIF_NO_DYNAMIC | AIF_KAMIKAZE)) {	//	If not allowed to pursue dynamic objectives, don't evade.  Dumb?  Maybe change. -- MK, 3/15/98
 		return;
 	}
@@ -12097,6 +12102,11 @@ void maybe_evade_dumbfire_weapon(ai_info *aip)
 		return;
 	}
 
+	// don't evade dumbfires if you're docked
+	if (object_is_docked(Pl_objp)) {
+		return;
+	}
+
 	//	Make sure in a mode in which we evade dumbfire weapons.
 	switch (aip->mode) {
 	case AIM_CHASE:
@@ -14635,7 +14645,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_
 		
 		//	Hit by a protected ship, don't attack it.
 		if (objp_hitter->flags & OF_PROTECTED) {
-			if ((Ship_info[shipp->ship_info_index].flags & (SIF_FIGHTER | SIF_BOMBER)) && (aip->target_objnum == -1)) {
+			if (((Ship_info[shipp->ship_info_index].flags & (SIF_FIGHTER | SIF_BOMBER)) && (aip->target_objnum == -1)) || !object_is_docked(objp_ship)) {
 				if (aip->mode == AIM_CHASE) {
 					if (aip->submode != SM_EVADE_WEAPON) {
 						aip->mode = AIM_CHASE;
patch3_for_945.patch (1,427 bytes)   

niffiwan

2012-06-26 10:13

developer   ~0013727

I had a go at stopping the fighters from maneuvering by preventing them from entering AIM_EVADE_WEAPON mode (see patch3) - in testing with the 1st mission this has stopped most of the movement, but not all. There are a few "twitches" which don't appear to be being caused by changes in the AI mode, i.e. the fighters are staying in AIM_NONE the entire time. So I'm not sure what's causing this...

Goober5000

2012-06-27 05:32

administrator   ~0013729

Well done niffiwan. Two out of three of those are solid fixes. The third I'm not sure about; will have to double-check.

Goober5000

2012-07-01 03:25

administrator   ~0013740

All fixed!

Related Changesets

fs2open: trunk r8914

2012-06-25 05:39

Goober5000


Ported: N/A

Details Diff
fix the old Volition bug where a docked ship would execute its default behavior even when the preceding comment explicitly said that it should "just sit here" :-/
also guard against a few edge cases related to this
(all of this is in regards to Mantis 0000945)
Affected Issues
0000945
mod - /trunk/fs2_open/code/ai/aicode.cpp Diff File
mod - /trunk/fs2_open/code/ship/ship.cpp Diff File

fs2open: trunk r8918

2012-06-30 23:24

Goober5000


Ported: N/A

Details Diff
this should fix all of the issues with docked fighters and bombers (Mantis 0000945) Affected Issues
0000945
mod - /trunk/fs2_open/code/ai/aicode.cpp Diff File
mod - /trunk/fs2_open/code/ship/shiphit.cpp Diff File

Issue History

Date Modified Username Field Change
2006-06-11 19:15 The Trivial Psychic New Issue
2006-07-20 01:27 Goober5000 Additional Information Updated
2006-11-24 23:04 Goober5000 Relationship added child of 0000530
2007-10-22 05:41 Goober5000 Relationship deleted child of 0000530
2010-10-22 13:00 The_E Note Added: 0012422
2010-10-23 20:33 Goober5000 Note Added: 0012433
2010-10-23 23:41 FUBAR-BDHR Note Added: 0012434
2010-10-23 23:45 FUBAR-BDHR Note Edited: 0012434
2012-01-03 08:05 Goober5000 Relationship added related to 0002557
2012-01-03 08:08 Goober5000 Relationship added parent of 0002548
2012-01-03 08:09 Goober5000 Relationship replaced has duplicate 0002557
2012-01-03 08:09 Goober5000 Relationship replaced parent of 0002557
2012-01-03 08:10 Goober5000 Priority normal => urgent
2012-01-03 08:10 Goober5000 Severity minor => major
2012-01-03 08:10 Goober5000 Target Version => 3.6.14
2012-01-03 08:15 Goober5000 Note Added: 0013020
2012-01-03 08:17 Goober5000 Note Added: 0013021
2012-01-03 08:51 Alan Bolte Note Added: 0013022
2012-01-03 08:57 Goober5000 Note Added: 0013023
2012-01-03 08:58 Goober5000 Relationship deleted parent of 0002548
2012-06-20 01:08 niffiwan Note Added: 0013680
2012-06-21 20:26 MjnMixael File Added: MultiDockTest.fs2
2012-06-21 20:26 MjnMixael Note Added: 0013695
2012-06-22 09:23 niffiwan Note Added: 0013700
2012-06-25 10:33 Goober5000 Changeset attached => fs2open trunk r8914
2012-06-25 10:35 Goober5000 Note Added: 0013721
2012-06-25 13:54 MjnMixael File Added: MultiDockTest2.fs2
2012-06-25 13:54 MjnMixael Note Added: 0013722
2012-06-25 22:52 Goober5000 Note Added: 0013723
2012-06-25 23:27 Goober5000 Note Added: 0013724
2012-06-25 23:29 Goober5000 File Added: patch2_for_945.patch
2012-06-25 23:29 Goober5000 Note Added: 0013725
2012-06-25 23:32 Goober5000 File Added: 0MultiDockTest2.fs2
2012-06-25 23:33 Goober5000 Note Added: 0013726
2012-06-26 10:08 niffiwan File Added: patch3_for_945.patch
2012-06-26 10:13 niffiwan Note Added: 0013727
2012-06-27 05:32 Goober5000 Note Added: 0013729
2012-07-01 03:24 Goober5000 Changeset attached => fs2open trunk r8918
2012-07-01 03:25 Goober5000 Note Added: 0013740
2012-07-01 03:25 Goober5000 Status assigned => resolved
2012-07-01 03:25 Goober5000 Resolution open => fixed
2012-07-01 03:25 Goober5000 Fixed in Version => 3.6.14
2012-07-01 03:25 Goober5000 Description Updated
2012-07-01 05:59 Goober5000 Relationship added has duplicate 0001723