diff --git a/code/hud/hudtarget.cpp b/code/hud/hudtarget.cpp index 41b708ca1a..ba29beb915 100644 --- a/code/hud/hudtarget.cpp +++ b/code/hud/hudtarget.cpp @@ -5828,7 +5828,7 @@ void HudGaugeWeapons::render(float frametime) } // indicate if this is linked or currently armed - if ( (sw->current_primary_bank == i) || (Player_ship->flags & SF_PRIMARY_LINKED) ) { + if ( (sw->current_primary_bank == i && !(Player_ship->flags & SF_PRIMARY_LINKED)) || ((Player_ship->flags & SF_PRIMARY_LINKED) && !(Weapon_info[sw->primary_bank_weapons[i]].wi_flags3 & WIF3_NOLINK))) { renderPrintf(position[0] + Weapon_plink_offset_x, name_y, EG_NULL, "%c", Lcl_special_chars + 2); } diff --git a/code/parse/scripting.cpp b/code/parse/scripting.cpp index e8eba5ed8a..8f2f07e3a2 100644 --- a/code/parse/scripting.cpp +++ b/code/parse/scripting.cpp @@ -301,6 +301,9 @@ bool ConditionedHook::ConditionsValid(int action, object *objp) if (!(primary || secondary)) return false; + + if (shipp->flags & SF_PRIMARY_LINKED && primary && Weapon_info[shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank]].wi_flags3 & WIF3_NOLINK) + return false; break; case CHA_ONWPDESELECTED: @@ -309,6 +312,9 @@ bool ConditionedHook::ConditionsValid(int action, object *objp) secondary = stricmp(Weapon_info[shipp->weapons.secondary_bank_weapons[shipp->weapons.current_secondary_bank]].name, scp->data.name) == 0; prev_secondary = stricmp(Weapon_info[shipp->weapons.secondary_bank_weapons[shipp->weapons.previous_secondary_bank]].name, scp->data.name) == 0; + if (prev_primary && shipp->flags & SF_PRIMARY_LINKED && (Weapon_info[shipp->weapons.primary_bank_weapons[shipp->weapons.previous_primary_bank]].wi_flags3 & WIF3_NOLINK)) + return true; + if ( !prev_secondary && ! secondary && !prev_primary && !primary ) return false; @@ -356,8 +362,8 @@ bool ConditionedHook::ConditionsValid(int action, object *objp) primary = stricmp(Weapon_info[shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank]].name, scp->data.name) == 0; secondary = stricmp(Weapon_info[shipp->weapons.secondary_bank_weapons[shipp->weapons.current_secondary_bank]].name, scp->data.name) == 0; - // if (shipp->flags & SF_PRIMARY_LINKED && primary && Weapon_info[shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank]].wi_flags3 & WIF3_NOLINK) - // return false; + if (shipp->flags & SF_PRIMARY_LINKED && primary && Weapon_info[shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank]].wi_flags3 & WIF3_NOLINK) + return false; if (!(primary || secondary)) return false; diff --git a/code/parse/sexp.cpp b/code/parse/sexp.cpp index 3836c758e6..8b7511057d 100644 --- a/code/parse/sexp.cpp +++ b/code/parse/sexp.cpp @@ -18256,7 +18256,7 @@ int sexp_is_secondary_selected(int node) } // is this the bank currently selected - if(bank == shipp->weapons.current_secondary_bank){ + if( (bank == shipp->weapons.current_primary_bank) || ((shipp->flags & SF_PRIMARY_LINKED) && !(Weapon_info[shipp->weapons.primary_bank_weapons[bank]].wi_flags3 & WIF3_NOLINK)) ){ return SEXP_TRUE; } diff --git a/code/weapon/weapon.h b/code/weapon/weapon.h index c069f22c11..0bc4873afc 100644 --- a/code/weapon/weapon.h +++ b/code/weapon/weapon.h @@ -39,6 +39,7 @@ extern int Num_weapon_subtypes; #define WIF_DEFAULT_VALUE 0 #define WIF2_DEFAULT_VALUE 0 +#define WIF3_DEFAULT_VALUE 0 #define WIF_HOMING_HEAT (1 << 0) // if set, this weapon homes via seeking heat #define WIF_HOMING_ASPECT (1 << 1) // if set, this weapon homes via chasing aspect @@ -112,6 +113,8 @@ extern int Num_weapon_subtypes; #define WIF2_CIWS (1 << 30) // This weapons' burst and shockwave damage can damage bombs (Basically, a reverse for TAKES_BLAST/SHOCKWAVE_DAMAGE #define WIF2_ANTISUBSYSBEAM (1 << 31) // This beam can target subsystems as per normal +#define WIF3_NOLINK (1 << 0) // This weapon can not be linked with others + #define WIF_HOMING (WIF_HOMING_HEAT | WIF_HOMING_ASPECT | WIF_HOMING_JAVELIN) #define WIF_LOCKED_HOMING (WIF_HOMING_ASPECT | WIF_HOMING_JAVELIN) @@ -349,6 +352,7 @@ typedef struct weapon_info { float energy_consumed; // Energy used up when weapon is fired int wi_flags; // bit flags defining behavior, see WIF_xxxx int wi_flags2; // stupid int wi_flags, only 32 bits... argh - Goober5000 + int wi_flags3; // stupid int wi_flags2, only 32 bits... argh - The E float turn_time; float cargo_size; // cargo space taken up by individual weapon (missiles only) float rearm_rate; // rate per second at which secondary weapons are loaded during rearming diff --git a/code/weapon/weapons.cpp b/code/weapon/weapons.cpp index 4c8e4b1c6c..b9e1d1bfc8 100644 --- a/code/weapon/weapons.cpp +++ b/code/weapon/weapons.cpp @@ -467,7 +467,7 @@ int weapon_info_lookup(const char *name) #define DEFAULT_WEAPON_SPAWN_COUNT 10 // Parse the weapon flags. -void parse_wi_flags(weapon_info *weaponp, int wi_flags, int wi_flags2) +void parse_wi_flags(weapon_info *weaponp, int wi_flags, int wi_flags2, int wi_flags3) { const char *spawn_str = NOX("Spawn"); const size_t spawn_str_len = strlen(spawn_str); @@ -485,6 +485,7 @@ void parse_wi_flags(weapon_info *weaponp, int wi_flags, int wi_flags2) // reseting the flag values if set to override the existing flags weaponp->wi_flags = wi_flags; weaponp->wi_flags2 = wi_flags2; + weaponp->wi_flags3 = wi_flags3; } bool set_pierce = false; @@ -644,6 +645,8 @@ void parse_wi_flags(weapon_info *weaponp, int wi_flags, int wi_flags2) weaponp->wi_flags2 |= WIF2_CIWS; else if (!stricmp(NOX("anti-subsystem beam"), weapon_strings[i])) weaponp->wi_flags2 |= WIF2_ANTISUBSYSBEAM; + else if (!stricmp(NOX("no primary linking"), weapon_strings[i])) + weaponp->wi_flags3 |= WIF3_NOLINK; else Warning(LOCATION, "Bogus string in weapon flags: %s\n", weapon_strings[i]); } @@ -1068,6 +1071,7 @@ int parse_weapon(int subtype, bool replace) bool create_if_not_found = true; int wi_flags = WIF_DEFAULT_VALUE; int wi_flags2 = WIF2_DEFAULT_VALUE; + int wi_flags3 = WIF3_DEFAULT_VALUE; required_string("$Name:"); stuff_string(fname, F_NAME, NAME_LENGTH); @@ -1728,7 +1732,7 @@ int parse_weapon(int subtype, bool replace) } - parse_wi_flags(wip, wi_flags, wi_flags2); + parse_wi_flags(wip, wi_flags, wi_flags2, wi_flags3); // be friendly; make sure ballistic flags are synchronized - Goober5000 // primary