2018-12-15 13:21 EST


View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001778FSSCPgameplaypublic2008-10-05 18:00
ReporterKeldorKatarn 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.9 
Target VersionFixed in Version3.6.10 
Summary0001778: ai_link_primaries problem
DescriptionThe $AI Always Links Energy Weapons and $AI Maybe Links Energy Weapons AI Profile settings are not interpreted correctly:

if (shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_always[Game_skill_level]) {

comparing the ship's absolute energy level to a percentage doesn't do much good, so this must be:

if (shipp->weapon_energy * 100.0f / sip->max_weapon_reserve > The_mission.ai_profile->link_energy_levels_always[Game_skill_level]) {
Additional InformationFix attached
TagsNo tags attached.
Attached Files
  • patch file icon ai_link_primaries_fix.patch (863 bytes) 2008-09-26 09:28 -
    Index: code/ai/aicode.cpp
    ===================================================================
    --- code/ai/aicode.cpp	(revision 4831)
    +++ code/ai/aicode.cpp	(working copy)
    @@ -6549,9 +6554,9 @@
     	}
     
     	// regular lasers
    -	if (shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_always[Game_skill_level]) {
    +	if (shipp->weapon_energy * 100.0f / sip->max_weapon_reserve > The_mission.ai_profile->link_energy_levels_always[Game_skill_level]) {
     		shipp->flags |= SF_PRIMARY_LINKED;
    -	} else if (shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_maybe[Game_skill_level]) {
    +	} else if (shipp->weapon_energy * 100.0f / sip->max_weapon_reserve > The_mission.ai_profile->link_energy_levels_maybe[Game_skill_level]) {
     		if (objp->hull_strength < shipp->ship_max_hull_strength/3.0f)
     			shipp->flags |= SF_PRIMARY_LINKED;
     	}
    
    patch file icon ai_link_primaries_fix.patch (863 bytes) 2008-09-26 09:28 +
  • patch file icon ai_link_primaries_fix_new.patch (3,133 bytes) 2008-09-27 23:27 -
    Index: code/ai/ai_profiles.cpp
    ===================================================================
    --- code/ai/ai_profiles.cpp	(revision 4835)
    +++ code/ai/ai_profiles.cpp	(working copy)
    @@ -335,6 +335,8 @@
     
     			set_flag(profile, "$smart afterburner management:", AIPF_SMART_AFTERBURNER_MANAGEMENT);
     
    +			set_flag(profile, "$smart linked fire management:", AIPF_SMART_LINKED_FIRE_MANAGEMENT);
    +
     			set_flag(profile, "$allow rapid secondary dumbfire:", AIPF_ALLOW_RAPID_SECONDARY_DUMBFIRE);
     			
     			set_flag(profile, "$huge turret weapons ignore bombs:", AIPF_HUGE_TURRET_WEAPONS_IGNORE_BOMBS);
    Index: code/ai/ai_profiles.h
    ===================================================================
    --- code/ai/ai_profiles.h	(revision 4835)
    +++ code/ai/ai_profiles.h	(working copy)
    @@ -78,6 +78,7 @@
     #define AIPF_ASSIST_SCORING_SCALES_WITH_DAMAGE						(1 << 17)
     #define AIPF_ALLOW_MULTI_EVENT_SCORING								(1 << 18)
     #define AIPF_SMART_AFTERBURNER_MANAGEMENT							(1 << 19)
    +#define AIPF_SMART_LINKED_FIRE_MANAGEMENT							(1 << 20)
     
     
     #define MAX_AI_PROFILES	5
    Index: code/ai/aicode.cpp
    ===================================================================
    --- code/ai/aicode.cpp	(revision 4835)
    +++ code/ai/aicode.cpp	(working copy)
    @@ -6554,9 +6554,11 @@
     	}
     
     	// regular lasers
    -	if (shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_always[Game_skill_level]) {
    +	if (!(The_mission.ai_profile->flags & AIPF_SMART_LINKED_FIRE_MANAGEMENT) && shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_always[Game_skill_level] ||
    +		The_mission.ai_profile->flags & AIPF_SMART_LINKED_FIRE_MANAGEMENT && shipp->weapon_energy * 100.0f / sip->max_weapon_reserve > The_mission.ai_profile->link_energy_levels_always[Game_skill_level]) {
     		shipp->flags |= SF_PRIMARY_LINKED;
    -	} else if (shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_maybe[Game_skill_level]) {
    +	} else if (!(The_mission.ai_profile->flags & AIPF_SMART_LINKED_FIRE_MANAGEMENT) && shipp->weapon_energy > The_mission.ai_profile->link_energy_levels_maybe[Game_skill_level] ||
    +				The_mission.ai_profile->flags & AIPF_SMART_LINKED_FIRE_MANAGEMENT && shipp->weapon_energy * 100.0f / sip->max_weapon_reserve > The_mission.ai_profile->link_energy_levels_maybe[Game_skill_level]) {
     		if (objp->hull_strength < shipp->ship_max_hull_strength/3.0f)
     			shipp->flags |= SF_PRIMARY_LINKED;
     	}
    Index: code/globalincs/def_files.cpp
    ===================================================================
    --- code/globalincs/def_files.cpp	(revision 4835)
    +++ code/globalincs/def_files.cpp	(working copy)
    @@ -816,6 +816,10 @@
     ;; instead of afterburning until fuel is exhausted						\n\
     $smart afterburner management: NO										\n\
     																		\n\
    +;; if set, the AI will properly link primaries according to				\n\
    +;; specified percentages of energy levels instead of retail behavior	\n\
    +$smart linked fire management: NO										\n\
    +																		\n\
     ;; if set, allows an AI ship to switch to rapid fire for dumbfire		\n\
     ;; missiles																\n\
     $allow rapid secondary dumbfire: NO										\n\
    
    patch file icon ai_link_primaries_fix_new.patch (3,133 bytes) 2008-09-27 23:27 +

-Relationships
+Relationships

-Notes

~0009711

Goober5000 (administrator)

Good catch. Add an ai_profiles flag and I can commit this patch.

~0009718

KeldorKatarn (reporter)

I don't understand.. this is not retail. This was added by someone in FS_Open and uses above AI Profile lines to get the values. Why does this need an additional ai_profiles flag? It was a bug, this doesn't add a feature. The original feature was buggy.

~0009724

Goober5000 (administrator)

This *is* a retail feature. Go back and read the code more carefully. Compare it to the original source code release.

The only difference between retail and SCP is that in retail the percentages were defined in the code, and in SCP the percentages are defined in ai_profiles so that they can be edited.

~0009728

KeldorKatarn (reporter)

Last edited: 2008-09-27 23:28

I see, so this bug was already in retail. I will make this a flag then alright.

Edit: New patch attached. Feel free to change the comment line again to something more appropriate if you think that is needed.

~0009740

KeldorKatarn (reporter)

Is this ok now?

~0009752

Goober5000 (administrator)

Mostly. I tweaked it, then committed.

~0009757

KeldorKatarn (reporter)

Last edited: 2008-10-01 11:48

Note withdrawn. Missread

+Notes

-Issue History
Date Modified Username Field Change
2008-09-26 09:28 KeldorKatarn New Issue
2008-09-26 09:28 KeldorKatarn File Added: ai_link_primaries_fix.patch
2008-09-27 01:54 Goober5000 Note Added: 0009711
2008-09-27 01:57 Goober5000 Status new => confirmed
2008-09-27 07:54 KeldorKatarn Note Added: 0009718
2008-09-27 20:28 Goober5000 Note Added: 0009724
2008-09-27 22:59 KeldorKatarn Note Added: 0009728
2008-09-27 23:27 KeldorKatarn File Added: ai_link_primaries_fix_new.patch
2008-09-27 23:28 KeldorKatarn Note Edited: 0009728
2008-09-29 10:38 KeldorKatarn Note Added: 0009740
2008-09-30 20:44 Goober5000 Note Added: 0009752
2008-09-30 20:44 Goober5000 Status confirmed => resolved
2008-09-30 20:44 Goober5000 Resolution open => fixed
2008-09-30 20:44 Goober5000 Fixed in Version => 3.6.10
2008-10-01 11:23 KeldorKatarn Status resolved => feedback
2008-10-01 11:23 KeldorKatarn Resolution fixed => reopened
2008-10-01 11:46 KeldorKatarn Note Added: 0009757
2008-10-01 11:48 KeldorKatarn Note Edited: 0009757
2008-10-05 18:00 Goober5000 Status feedback => resolved
2008-10-05 18:00 Goober5000 Resolution reopened => fixed
+Issue History