Add back homing weapons cheat for D2

Kreator proposed restoring the Descent 2 cheat that grants homing
capability to all weapons.  This commit implements that proposition,
with some changes to the implementation details.

Based-on-patch-by: Chris Taylor <chris@icculus.org>
Requested-by: Chris Taylor <https://github.com/dxx-rebirth/dxx-rebirth/pull/318>
This commit is contained in:
Kp 2017-01-29 21:02:48 +00:00
parent 32760e8a8f
commit 59bad96d5f
6 changed files with 40 additions and 0 deletions

View file

@ -211,6 +211,9 @@ int attempt_to_steal_item(vobjptridx_t objp, vobjptr_t playerobjp);
#define SMEGA_ID 40
void weapons_homing_all();
void weapons_homing_all_reset();
extern void rock_the_mine_frame(void);
extern void smega_rock_stuff(void);
extern void init_smega_detonates(void);

View file

@ -333,6 +333,7 @@ struct game_cheats : prohibit_void_ptr<game_cheats>
int lamer;
int accessory;
int bouncyfire;
int homingfire;
int killallrobots;
int robotskillrobots;
int monsterdamage;

View file

@ -1149,6 +1149,11 @@ int cheats_enabled()
//turns off all cheats & resets cheater flag
void game_disable_cheats()
{
#if defined(DXX_BUILD_DESCENT_II)
if (cheats.homingfire)
weapons_homing_all_reset();
#endif
cheats = {};
}

View file

@ -1405,6 +1405,7 @@ constexpr cheat_code cheat_codes[] = {
{ "rockrgrl", &game_cheats::fullautomap },
{ "wildfire", &game_cheats::rapidfire },
{ "duddaboo", &game_cheats::bouncyfire },
{ "lpnlizard", &game_cheats::homingfire },
{ "imagespace", &game_cheats::robotfiringsuspended },
{ "spaniard", &game_cheats::killallrobots },
{ "silkwing", &game_cheats::robotskillrobots },
@ -1639,6 +1640,11 @@ static window_event_result FinalCheats()
HUD_init_message(HM_DEFAULT, "Bouncing weapons %s!", cheats.bouncyfire?TXT_ON:TXT_OFF);
}
if (gotcha == &game_cheats::homingfire)
{
HUD_init_message(HM_DEFAULT, "Homing weapons %s!", cheats.homingfire ? (weapons_homing_all(), TXT_ON) : (weapons_homing_all_reset(), TXT_OFF));
}
#endif
if (gotcha == &game_cheats::turbo)

View file

@ -1383,6 +1383,14 @@ static window_event_result AdvanceLevel(int secret_flag)
#if defined(DXX_BUILD_DESCENT_II)
Assert(!secret_flag);
// Loading a level can write over homing_flag.
// So for simplicity, reset the homing weapon cheat here.
if (cheats.homingfire)
{
cheats.homingfire = 0;
weapons_homing_all_reset();
}
#endif
if (Current_level_num != Last_level)
{

View file

@ -1013,6 +1013,23 @@ int pick_up_vulcan_ammo(player_info &player_info, uint_fast32_t ammo_count, cons
}
#if defined(DXX_BUILD_DESCENT_II)
// Homing weapons cheat
void weapons_homing_all()
{
range_for(auto &&objp, vobjptr)
if (objp->type == OBJ_WEAPON)
objp->ctype.laser_info.track_goal = object_none;
range_for (auto &w, Weapon_info)
w.homing_flag |= 2;
}
void weapons_homing_all_reset()
{
range_for (auto &w, Weapon_info)
w.homing_flag &= ~2;
}
#define SMEGA_SHAKE_TIME (F1_0*2)
#define MAX_SMEGA_DETONATES 4
static array<fix64, MAX_SMEGA_DETONATES> Smega_detonate_times;