View Issue Details

IDProjectCategoryView StatusLast Update
0001002FSSCPgameplaypublic2006-08-19 04:42
ReporterARSPR Assigned Totaylor  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformP4 2.8 HT - 1.5GB - 7800GSOSWindows XPOS VersionSP2
Product Version3.6.9 
Summary0001002: Computer controled shields do not recharge but unload
DescriptionComputer controled ships (at least friendly ones) suffer this bug. Sometimes they do not recharge their damaged shields but empty them.
Steps To ReproduceA good mission to test is Derelict "Striking The Line" (DL4-04.fs2).

Use simulator, and then when mission starts order all ships to cover you so they just don't engage the Shivans.

Then select one of your mates and fire at him. You will see how about 50% of times the selected ship shiels don't recharge but empty themselves.

(If the bug doesn't happen with the first ship select any other and repeat the process, time compression is handy too ;) ).
Additional InformationSome kind of bug with smartshields?

I've tested with medium difficulty and vp 3.6.8. zeta.
TagsNo tags attached.

Activities

taylor

2006-07-21 20:18

administrator   ~0006279

Last edited: 2006-07-21 20:23

Does Derelict use smart shields (remember than it's an ai_profiles.tbl flag now)?

Looking over the code, and thinking it's not using smart shields, it would appear to just do what retail does. I haven't actually verified that yet, but the code looks to be the same. Basically it's getting recharged normally, but then it will try the balance the shields and so the low quad gets emptied.

Technically I think that this is a :V: bug, but I'm hesitant to change it unless at least Goober agrees with me on that. I have a code fix for this already, but since it does affect retail balance (even if it's very minor), we need a consensus on whether to fix this or not. :)

(EDIT: Attaching the diff of my changes, just in case I overwrite them or something.)

edited on: 07-21-06 16:23

2006-07-21 20:23

 

shield_fix.diff (2,449 bytes)   
Index: code/object/object.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/object/object.cpp,v
retrieving revision 2.63.2.2
diff -u -r2.63.2.2 object.cpp
--- code/object/object.cpp	5 Jul 2006 23:36:56 -0000	2.63.2.2
+++ code/object/object.cpp	21 Jul 2006 20:55:18 -0000
@@ -953,6 +953,10 @@
 
 	if (!(The_mission.ai_profile->flags & AIPF_SMART_SHIELD_MANAGEMENT))
 	{
+		// if we aren't going to change anything anyway then just bail
+		if (delta == 0.0f)
+			return;
+
 		for (i=0; i<MAX_SHIELD_SECTIONS; i++) {
 			objp->shield_quadrant[i] += delta/MAX_SHIELD_SECTIONS;
 			if (objp->shield_quadrant[i] > section_max)
Index: code/ai/aicode.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/ai/aicode.cpp,v
retrieving revision 1.72.2.6
diff -u -r1.72.2.6 aicode.cpp
--- code/ai/aicode.cpp	5 Jul 2006 23:47:59 -0000	1.72.2.6
+++ code/ai/aicode.cpp	21 Jul 2006 20:55:20 -0000
@@ -12827,21 +12827,37 @@
 	float	shield_strength_avg;
 	float	delta;
 
+	// if we are already at the max shield strength for all quads then just bail now
+	if ( Ships[objp->instance].ship_max_shield_strength == get_shield_strength(objp) )
+		return;
+
 
 	shield_strength_avg = get_shield_strength(objp)/MAX_SHIELD_SECTIONS;
 
 	delta = SHIELD_BALANCE_RATE * shield_strength_avg;
 
-	for (i=0; i<MAX_SHIELD_SECTIONS; i++)
+	for (i=0; i<MAX_SHIELD_SECTIONS; i++) {
 		if (objp->shield_quadrant[i] < shield_strength_avg) {
-			add_shield_strength(objp, delta);
+			// only do it the retail way if using smart shields (since that's a bigger thing) - taylor
+			if (The_mission.ai_profile->flags & AIPF_SMART_SHIELD_MANAGEMENT)
+				add_shield_strength(objp, delta);
+			else
+				objp->shield_quadrant[i] += delta/MAX_SHIELD_SECTIONS;
+
 			if (objp->shield_quadrant[i] > shield_strength_avg)
 				objp->shield_quadrant[i] = shield_strength_avg;
+
 		} else {
-			add_shield_strength(objp, -delta);
+			// only do it the retail way if using smart shields (since that's a bigger thing) - taylor
+			if (The_mission.ai_profile->flags & AIPF_SMART_SHIELD_MANAGEMENT)
+				add_shield_strength(objp, -delta);
+			else
+				objp->shield_quadrant[i] -= delta/MAX_SHIELD_SECTIONS;
+
 			if (objp->shield_quadrant[i] < shield_strength_avg)
 				objp->shield_quadrant[i] = shield_strength_avg;
 		}
+	}
 }
 
 //	Manage the shield for this ship.
shield_fix.diff (2,449 bytes)   

taylor

2006-07-22 12:41

administrator   ~0006282

The following build has the proposed fix in it if you want to test it out yourself: http://icculus.org/~taylor/fso/testing/light_test.rar

ARSPR

2006-07-22 14:13

reporter   ~0006283

I'm running on a 56Kb Internet connection lately so I cannot download big things :(

I'll have to wait till my DSL connection is up again.

Goober5000

2006-07-22 18:57

administrator   ~0006287

Okay, I think we may have to rename "smart shields". The way it is currently, smart shields only recharge the quadrant that needs to be recharged, which is more or less an engine bug. Taylors change fixes an AI bug. I would recommend changing the old flag to something like "don't waste shield recharge energy" and letting Taylor's new fix keep the "smart shields" flag.

taylor

2006-07-22 19:31

administrator   ~0006293

Little lost... so you want to keep the original :v: bug, let my fix be the "smart shields" flag and change the current smart shields to a new flag?

Goober5000

2006-07-22 19:49

administrator   ~0006294

Um...

1) The default shield recharging behavior should be as it was in retail.
2) The "selective recharge" should be called something more appropriate, not "smart shields" as it currently is.
3) Taylor's fix should be committed under the "smart shields" flag (or another name, if you have something better).

taylor

2006-07-22 20:19

administrator   ~0006295

My fix isn't to shield recharging though, it's to the ai balancing of shields (ie, "Q" for the player). The :v: bug is that it gets the average shield strength and then goes through each quad and if the quad is lower than the average then it adds a balance ammount (not to full balance though), and if it's higher than the average it removes a balance ammount.

The problem is that it uses the add_shield_strength() function to do this, and that function is for recharging shields. That means that for each quad in the balance function it's doing the add or subtract on every quad. If quad 0 is lower than the average then it would add some to not only that quad but all other quads at the same time. If quad 1 is higher than the average then it will remove some from ALL quads, even though it's already processed quad 0 and found that it should be adding in that case. If the first 3 quads are above the average then it will effectively remove most/all (it removes the balance amount 3 times) of quad 4's energy during the balance, then add just a little more to all 4 quads.

My fix is to just do what (retail) add_shield_strength() does, but just for the one quad at a time in ai_balance_shield(). This makes sure that the balance function doesn't artificially recharge shields faster, and also doesn't keep removing shield strength from quads that are trying to recharge. I wouldn't really consider this "smart", just "not broken". I would rather just not use this fix at all than consider it as "smart shields" since it doesn't really affect general shield recharging. At most it just makes sure that the recharging will try and an stay at a more predictable rate for all quads.


I'll do whatever though, just want to make sure that the problem and fix is understood first.

Goober5000

2006-07-22 22:40

administrator   ~0006297

Oh. I thought your fix had something to do with AI shield management - i.e. when to equalize shields or shift power to a certain quadrant.

It sounds like combining your fix with the existing one is the best fix. Maybe rename it to "fix shield recharging" so it's clear.

taylor

2006-07-22 23:11

administrator   ~0006300

It is AI management of shield balance, I missed a "like" when referrring to "Q" for the player, so it doesn't have anything to do with the player, strickly the AI. But, it doesn't change when to do it (at most 10 seconds since last hit, same as retail), or the amount at which to balance. The fix is just to make sure that that doesn't try to balance each quad 16 times per call giving totally random recharge rates for the whole shield. The overall rate of recharge doesn't change (I didn't make any modifications to that) and it doesn't change the rate or amount at which one quad will get more energy.

It's simply that the act of the AI balancing shields will actually lower shield enery for a quad that it should be increasing enery to. Quads that should have enery reduced during the act of AI balancing can actually increase dramatically (10-15% in some cases) over their original energy level.

If you don't use smart shields and rely only on the retail effect of AI balance then the AI controled fighters can actually have a shield quad which *never* recharges. The simple act of balancing the shields can remove more enery from that quad than the standard recharge is able to give it.

If you have smart shields enabled then this already doesn't happen, since that code is crap and doesn't even allow a shield quad to drop in power through add_shield_strength(). Though, now that I think about it, this same bug does make the act of AI balancing recharge a smart shield quad on an AI ship 0000007:0000004 times faster than it should be.

Goober5000

2006-07-26 17:06

administrator   ~0006345

Okay, I defer to your judgement then. :)

taylor

2006-07-28 02:18

administrator   ~0006359

I think that there have been enough people referring to this as "new" that it warrants a little extra testing/investigation. What I fixed is something that was messed up in retail, but everyone really should have noticed that before now. My fix will deffinitely cover up any new bug so I want to be sure that there isn't really something else, something new, hiding in there before I make any sort of change.

taylor

2006-08-18 21:41

administrator   ~0006480

Ok, I can't find any other bug. People being able to notice it may have just coincided with another bug fix and they may have been looking for it at that point. Either way I don't see any actual new behavior other than the retail code bug mentioned here. I never even noticed it in retail until I actually started looking for it. My fix has also been in with my last 5 or 6 test builds and has been used without complaint. I assume that it's satisfactory then.

Unless you have a complaint about it, Goober, I'll commit the change later tonight. It's small enough that we can easily comment it out, or just revert it, later on if we need to.

taylor

2006-08-19 04:42

administrator   ~0006486

Fixered.

Hopefully without breaking anything else. ;)

Issue History

Date Modified Username Field Change
2006-07-21 18:48 ARSPR New Issue
2006-07-21 20:18 taylor Note Added: 0006279
2006-07-21 20:23 taylor Note Edited: 0006279
2006-07-21 20:23 taylor File Added: shield_fix.diff
2006-07-22 12:41 taylor Note Added: 0006282
2006-07-22 14:13 ARSPR Note Added: 0006283
2006-07-22 18:57 Goober5000 Note Added: 0006287
2006-07-22 19:31 taylor Note Added: 0006293
2006-07-22 19:49 Goober5000 Note Added: 0006294
2006-07-22 20:19 taylor Note Added: 0006295
2006-07-22 22:40 Goober5000 Note Added: 0006297
2006-07-22 23:11 taylor Note Added: 0006300
2006-07-26 17:06 Goober5000 Note Added: 0006345
2006-07-26 17:06 Goober5000 Assigned To => taylor
2006-07-26 17:06 Goober5000 Status new => assigned
2006-07-28 02:18 taylor Note Added: 0006359
2006-08-18 21:41 taylor Note Added: 0006480
2006-08-19 04:42 taylor Status assigned => resolved
2006-08-19 04:42 taylor Resolution open => fixed
2006-08-19 04:42 taylor Note Added: 0006486