diff --git a/code/controlconfig/controlsconfig.h b/code/controlconfig/controlsconfig.h index 74a4107c527..14d055f4834 100644 --- a/code/controlconfig/controlsconfig.h +++ b/code/controlconfig/controlsconfig.h @@ -270,6 +270,11 @@ enum IoActionId { //!< ---------------------------- CYCLE_PRIMARY_WEAPON_SEQUENCE =118, //!< cycle num primaries to fire at once + //!< @n + //!< Auto-balance shields + //!< ---------------------- + TOGGLE_AUTO_SHIELD_EQUALIZE =119, //!< toggle automatic shield equalization + /*! * This must always be below the last defined item */ diff --git a/code/controlconfig/controlsconfigcommon.cpp b/code/controlconfig/controlsconfigcommon.cpp index ff011f77671..937d5ece874 100644 --- a/code/controlconfig/controlsconfigcommon.cpp +++ b/code/controlconfig/controlsconfigcommon.cpp @@ -196,6 +196,7 @@ config_item Control_config[CCFG_MAX + 1] = { { KEY_ALTED | KEY_N, -1, COMPUTER_TAB, false, "Cycle Nav Points", CC_TYPE_TRIGGER, -1, -1, 0, false, false }, { KEY_ALTED | KEY_G, -1, SHIP_TAB, false, "Toggle Gliding", CC_TYPE_TRIGGER, -1, -1, 0, false, false }, { KEY_O, -1, WEAPON_TAB, false, "Cycle Primary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0, false, false }, + { KEY_ALTED | KEY_Q, -1, COMPUTER_TAB, false, "Toggle Auto Equalize Shields", CC_TYPE_TRIGGER, -1, -1, 0, true, false }, { -1, -1, -1, false, "", CC_TYPE_TRIGGER, -1, -1, 0, false, false } }; @@ -594,7 +595,6 @@ void control_config_common_load_overrides(); void control_config_common_init() { for (int i=0; iflags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE; + return button_function_critical(n); + + case SHIELD_XFER_TOP: // transfer shield energy to front + case SHIELD_XFER_BOTTOM: // transfer shield energy to rear + case SHIELD_XFER_LEFT: // transfer shield energy to left + case SHIELD_XFER_RIGHT: // transfer shield energy to right + Player->flags |= PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE; + return button_function_critical(n); + } /** @@ -2514,6 +2524,7 @@ int button_function(int n) if (!Sel_NextNav()) gamesnd_play_iface(SND_GENERAL_FAIL); break; + default: keyHasBeenUsed = FALSE; break; @@ -2805,6 +2816,17 @@ int button_function(int n) hud_escort_target_next(); break; + case TOGGLE_AUTO_SHIELD_EQUALIZE: + Players[Player_num].flags ^= PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE; + if (Players[Player_num].flags & PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE) { + Players[Player_num].flags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE; + button_function(SHIELD_EQUALIZE); + HUD_printf(XSTR("Auto shield equalization activated", 1638)); + } else { + HUD_printf(XSTR("Auto shield equalization deactivated", 1639)); + } + break; + default: keyHasBeenUsed = FALSE; break; diff --git a/code/io/keycontrol.h b/code/io/keycontrol.h index 618880099b5..701a721595e 100644 --- a/code/io/keycontrol.h +++ b/code/io/keycontrol.h @@ -39,5 +39,6 @@ void process_set_of_keys(int key, int count, int *list); void game_process_pause_key(); void button_strip_noncritical_keys(button_info *bi); +extern int button_function(int n); #endif diff --git a/code/localization/localize.cpp b/code/localization/localize.cpp index b0eb556510f..c4cabdfd0ef 100644 --- a/code/localization/localize.cpp +++ b/code/localization/localize.cpp @@ -57,7 +57,7 @@ int Lcl_english = 1; // the english version (in the code) to a foreign version (in the table). Thus, if you // add a new string to the code, you must assign it a new index. Use the number below for // that index and increase the number below by one. -#define XSTR_SIZE 1638 +#define XSTR_SIZE 1640 // struct to allow for strings.tbl-determined x offset diff --git a/code/mission/missiontraining.cpp b/code/mission/missiontraining.cpp index a70fba4e24e..bad9505c0d9 100644 --- a/code/mission/missiontraining.cpp +++ b/code/mission/missiontraining.cpp @@ -362,8 +362,11 @@ void training_mission_init() // only clear player flags if this is actually a training mission if ( The_mission.game_type & MISSION_TYPE_TRAINING ) { - Player->flags &= ~(PLAYER_FLAGS_MATCH_TARGET | PLAYER_FLAGS_MSG_MODE | PLAYER_FLAGS_AUTO_TARGETING | PLAYER_FLAGS_AUTO_MATCH_SPEED | PLAYER_FLAGS_LINK_PRIMARY | PLAYER_FLAGS_LINK_SECONDARY ); + Player->flags &= ~(PLAYER_FLAGS_MATCH_TARGET | PLAYER_FLAGS_MSG_MODE | PLAYER_FLAGS_AUTO_TARGETING | PLAYER_FLAGS_AUTO_MATCH_SPEED | PLAYER_FLAGS_LINK_PRIMARY | PLAYER_FLAGS_LINK_SECONDARY | PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE ); } + + // never start with auto shield equalization on but overridden + Player->flags &= ~PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE; } void training_mission_page_in() diff --git a/code/playerman/player.h b/code/playerman/player.h index ba4306526a8..59d631bda43 100644 --- a/code/playerman/player.h +++ b/code/playerman/player.h @@ -52,6 +52,8 @@ struct campaign_info; #define PLAYER_FLAGS_KILLED_SELF_UNKNOWN (1<<16) // player died by his own hand #define PLAYER_FLAGS_KILLED_SELF_MISSILES (1<<17) // player died by his own missile #define PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE (1<<18) // player died by his own shockwave +#define PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE (1<<19) // is auto shield equalization on? +#define PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE (1<<20) // is auto shield equalization overridden by manual control? #define PLAYER_KILLED_SELF ( PLAYER_FLAGS_KILLED_SELF_MISSILES | PLAYER_FLAGS_KILLED_SELF_SHOCKWAVE ) diff --git a/code/playerman/playercontrol.cpp b/code/playerman/playercontrol.cpp index 8b8d8d00a64..817ec91807a 100644 --- a/code/playerman/playercontrol.cpp +++ b/code/playerman/playercontrol.cpp @@ -1293,6 +1293,10 @@ void player_save_target_and_weapon_link_prefs() Player->flags &= ~PLAYER_FLAGS_LINK_SECONDARY; } } + + if ( Player->flags & PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE ) { + Player->save_flags |= PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE; + } } /** diff --git a/code/ship/shiphit.cpp b/code/ship/shiphit.cpp index 0993989ffdd..143823c37ca 100755 --- a/code/ship/shiphit.cpp +++ b/code/ship/shiphit.cpp @@ -25,6 +25,7 @@ #include "hud/hudtarget.h" #include "iff_defs/iff_defs.h" #include "io/joy_ff.h" +#include "io/keycontrol.h" #include "io/timer.h" #include "mission/missionlog.h" #include "mod_table/mod_table.h" @@ -2104,6 +2105,10 @@ static void ship_do_damage(object *ship_objp, object *other_obj, vec3d *hitpos, damage += (piercing_pct * pre_shield); subsystem_damage += (piercing_pct * pre_shield_ss); } + + if (((Player->flags & (PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE | PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE_OVERRIDE)) == PLAYER_FLAGS_AUTO_SHIELD_EQUALIZE) && (ship_objp == Player_obj)) { + button_function(SHIELD_EQUALIZE); + } } // if shield damage was increased, don't carry over leftover damage at scaled level