Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cheat tweaks #3492

Merged
merged 4 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/fxdata/terrain.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ WlbType = 0

[slab58]
Name = DOOR_MIDAS
TooltipTextID = 201
TooltipTextID = 1076
BlockFlagsHeight = 4
BlockHealthIndex = 6
BlockFlags = BLOCKING IS_DOOR
Expand All @@ -1054,7 +1054,7 @@ WlbType = 0

[slab59]
Name = DOOR_MIDAS2
TooltipTextID = 201
TooltipTextID = 1076
BlockFlagsHeight = 4
BlockHealthIndex = 6
BlockFlags = BLOCKING IS_DOOR
Expand Down
61 changes: 61 additions & 0 deletions src/front_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,54 @@ void process_cheat_mode_selection_inputs()
}
clear_key_pressed(KC_LSHIFT);
}
else if (is_key_pressed(KC_LCONTROL, KMod_DONTCARE))
{
if (player->work_state == PSt_MkGoodCreatr)
{
new_value = player->cheatselection.chosen_hero_kind;
do
{
if (new_value == 0)
{
new_value = game.conf.crtr_conf.model_count - 1;
}
else
{
new_value--;
if (new_value == 0)
{
break;
}
}
crconf = &game.conf.crtr_conf.model[new_value];
}
while ( ((crconf->model_flags & CMF_IsEvil) != 0) || ((crconf->model_flags & CMF_IsSpectator) != 0) );
set_players_packet_action(player, PckA_CheatSwitchHero, new_value, 0, 0, 0);
}
else if (player->work_state == PSt_MkBadCreatr)
{
new_value = player->cheatselection.chosen_creature_kind;
do
{
if (new_value == 0)
{
new_value = game.conf.crtr_conf.model_count - 1;
}
else
{
new_value--;
if (new_value == 0)
{
break;
}
}
crconf = &game.conf.crtr_conf.model[new_value];
}
while ( ((crconf->model_flags & CMF_IsEvil) == 0) || ((crconf->model_flags & CMF_IsSpectator) != 0) );
set_players_packet_action(player, PckA_CheatSwitchCreature, new_value, 0, 0, 0);
}
clear_key_pressed(KC_LCONTROL);
}
break;
}
case PSt_PlaceTerrain:
Expand Down Expand Up @@ -3149,6 +3197,19 @@ void process_cheat_mode_selection_inputs()
set_players_packet_action(player, PckA_CheatSwitchTerrain, new_value, 0, 0, 0);
clear_key_pressed(KC_LSHIFT);
}
else if (is_key_pressed(KC_LCONTROL, KMod_DONTCARE))
{
if (new_value == SlbT_ROCK)
{
new_value = game.conf.slab_conf.slab_types_count - 1;
}
else
{
new_value--;
}
set_players_packet_action(player, PckA_CheatSwitchTerrain, new_value, 0, 0, 0);
clear_key_pressed(KC_LCONTROL);
}
if ( (player->cheatselection.chosen_terrain_kind >= SlbT_WALLDRAPE) && (player->cheatselection.chosen_terrain_kind <= SlbT_WALLPAIRSHR) )
{
if (is_key_pressed(KC_LALT, KMod_DONTCARE))
Expand Down
10 changes: 10 additions & 0 deletions src/gui_boxmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ long gf_decide_victory(struct GuiBox *gbox, struct GuiBoxOption *goptn, unsigned
long gfa_single_player_mode(struct GuiBox* gbox, struct GuiBoxOption* goptn, long* tag);
long gf_all_doors(struct GuiBox *gbox, struct GuiBoxOption *goptn, unsigned char btn, long *tag);
long gf_all_traps(struct GuiBox *gbox, struct GuiBoxOption *goptn, unsigned char btn, long *tag);
long gf_give_door_trap(struct GuiBox *gbox, struct GuiBoxOption *goptn, unsigned char btn, long *tag);

struct GuiBoxOption gui_main_cheat_list[] = { //gui_main_option_list in beta
{"Null mode", 1, NULL, gf_change_player_state, 0, 0, 0, PSt_None, 0, 0, 0, true},
Expand Down Expand Up @@ -110,6 +111,7 @@ struct GuiBoxOption gui_creature_cheat_option_list[] = {
{"Research all rooms", 1, NULL, gf_research_rooms, 0, 0, 0, 0, 0, 0, 0, 0},
{"All doors manufacturable", 1, NULL, gf_all_doors, 0, 0, 0, 0, 0, 0, 0, 0},
{"All traps manufacturable", 1, NULL, gf_all_traps, 0, 0, 0, 0, 0, 0, 0, 0},
{"Increment doors and traps count", 1, NULL, gf_give_door_trap, 0, 0, 0, 0, 0, 0, 0, 0},
{"Win the level instantly", 1, NULL, gf_decide_victory, 0, 0, 0, 1, 0, 0, 0, 0},
{"Lose the level instantly", 1, NULL, gf_decide_victory, 0, 0, 0, 0, 0, 0, 0, 0},
{"!", 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -289,6 +291,14 @@ long gf_all_traps(struct GuiBox *gbox, struct GuiBoxOption *goptn, unsigned char
return 1;
}

long gf_give_door_trap(struct GuiBox *gbox, struct GuiBoxOption *goptn, unsigned char btn, long *tag)
{
struct PlayerInfo* player = get_my_player();
// if (player->cheat_mode == 0) return false; -- there's no cheat_mode flag yet
set_players_packet_action(player, PckA_CheatGiveDoorTrap, 0, 0, 0, 0);
return 1;
}

void gui_draw_all_boxes(void)
{
SYNCDBG(5,"Starting");
Expand Down
1 change: 1 addition & 0 deletions src/packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ enum TbPacketAction {
PckA_SetNearestTeleport,
PckA_SetRoomspaceDragPaint,
PckA_PlyrQueryCreature,
PckA_CheatGiveDoorTrap,
};

/** Packet flags for non-action player operation. */
Expand Down
21 changes: 21 additions & 0 deletions src/packets_cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "bflib_math.h"
#include "gui_topmsg.h"
#include "gui_msgs.h"
#include "frontmenu_ingame_tabs.h"
#include "post_inc.h"

extern void clear_input(struct Packet* packet);
Expand Down Expand Up @@ -847,6 +848,26 @@ TbBool process_players_global_cheats_packet_action(PlayerNumber plyr_idx, struct
make_available_all_traps(plyr_idx);
return false;
}
case PckA_CheatGiveDoorTrap:
{
long model;
for (model = 1; model < game.conf.trapdoor_conf.door_types_count; model++)
{
if (is_door_buildable(plyr_idx, model))
{
set_door_buildable_and_add_to_amount(plyr_idx, model, 1, 1);
}
}
for (model = 1; model < game.conf.trapdoor_conf.trap_types_count; model++)
{
if (is_trap_buildable(plyr_idx, model))
{
set_trap_buildable_and_add_to_amount(plyr_idx, model, 1, 1);
}
}
update_trap_tab_to_config();
return false;
}
default:
return false;
}
Expand Down